Dealing w/ register_globals


Last edited by KogAdmin:
draft
Wed, 22 Feb 2006 16:10 PST [diff]

Spending time around osCommerce like I do, I spend some time fixing scripts that use register_globals when they shouldn't. I realized the fastest method to dealing with them is to do some VIM magic, combined with some quick PHP thinking

Step 1: get all the POST keys
foreach ($_POST as $key=>$value)
{
    echo "$key<br>";
}



Step 2: Happy magic super VIM time (with justice)
:%s/^.*$/\$& = $_POST[&];/g


Step 3: hackish hackish Sally
Don't ask... The name Sally came to mind (I don't even know anyone named Sally...).

You throw the newly generated buffer that looks like:
$zarg = $_POST[zarg];
$fnord = $_POST[fnord];


into the appropriate place and bam, you now have a reference to everything w/ register_globals. I'm not sure this is the greatest solution, but when modifying lots of stupid code, feel free to go to town. Sucka.


This page is CategoryHowTo
There are no comments on this page.
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki