Wiki source for VIMPHPRegisterGlobalsToSanity
==== Dealing w/ register_globals ====
{{lastedit show="3"}}
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 ==
%%(php)
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:
%%(php)
$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]]
{{lastedit show="3"}}
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 ==
%%(php)
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:
%%(php)
$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]]