Making PHP4 depreciate work on PHP5 (register globals and sessions)

Posted under » PHP on 1 November 2009

The older PHP version 4 uses register globals directive set to "on". It is better that you avoid those and use superglobals. Some look like these

Avoid those that look like

These functions has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Here is what I'll do.

// 	if (session_is_registered($oldvar)) { change to 
		if (isset($_SESSION[$oldvar]) ) {

Using Register Globals
This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0.

As of pre PHP 5.4 days, you can get around it by enabling register globals to on in your PHP.ini. If you use Apache, you are in luck because with .htaccess you can decide which directory have register globals turned on. Create a .htaccess on the said folder eg.

php_flag register_globals on
Order allow,deny
Allow from all

This still won't work if your apache is not configured to allow this. So you have to add this permission on your apache config to allow .htaccess to work on the folder. "www/oldshit"

‹Directory /www/oldshit/›
    AllowOverride All

Post 5.4 it won't work anymore. You have to use superglobals.  

For uploading, $HTTP_POST_FILES has been depreciated. Now we use $_FILES.

web security linux ubuntu python django git Raspberry apache mysql php drupal cake javascript css AWS