Tag Archive: disable


As any decent developer knows, register_globals was a terrible idea, a security risk, and turned ON by default in old versions of PHP!

Thankfully it was removed in PHP 5.4. However, if you are stuck developing on a site that used register_globals, you may find yourself in a situation where seemingly you can’t upgrade beyond PHP 5.3.

However, it’s not all bad news, we can put a piece of code in place which emulates register_globals. This will let us turn it off. It still means your code is less than secure, but of course that’ll be fixed in time as you upgrade and refactor the site, right?

To emulate register_globals, just add the following code to one of your initialisation/bootstrap scripts:

// Emulate register_globals on
if (!ini_get('register_globals')) {
    $superglobals = array($_SERVER, $_ENV,
        $_FILES, $_COOKIE, $_POST, $_GET);
    if (isset($_SESSION)) {
        array_unshift($superglobals, $_SESSION);
    }
    foreach ($superglobals as $superglobal) {
        extract($superglobal, EXTR_SKIP);
    }
}

Now you can turn it off in php.ini. Why is it so bad though? Well, have a look at this:

code

Looks like nothing should happen on that page, right? nothing has been defined.

WRONG! try adding ?loggedIn=anything to the end of the URL:

loggedin

Just a quick one! We all know and love Firebug, but you might get annoyed when you right click to inspect element, only to find you clicked on ‘Inspect Element (Q)’ instead of ‘Inspect Element with Firebug’. So lets get rid of the one we don’t use!

inspect

It’s real easy. Browse to about:config, and proceed past the warning.

config

Set extensions.firebug.hideDefaultInspector to true.
Set devtools.inspector.enabled to false.
Problem solved!

inspect

If you use and love Firebug like me, you may also have been driven mad accidentally clicking the wrong Inspect Element!

Thankfully, it’s real easy to sort. Browse to about:config, search for the setting extensions.firebug.hideDefaultInspector, and change it to true!

No more irritating wasted seconds!