Magic Quotes / Register Globals

From: Paul Schmidinger (my.email.is.on_at_my.website.eigelb.at)
Date: 09/28/04


Date: Tue, 28 Sep 2004 09:01:36 +0200

Hi,

I have some software that needs magic quotes and register globals both "on".
I now tried to write a script that simpulates the bevaiour, no matter if
those options are on or off. I would appreciate feedback on the script. I
plan to include the script on all .php-Files of the software.

if (get_magic_quotes_gpc()) $mq=true; else $mq=false;
foreach($_GET as $key=>$value)
  if ($mq) eval("\$".$key."=\$value;");
  else eval("\$".$key."=addslashes(\$value);");
foreach($_POST as $key=>$value)
  if ($mq) eval("\$".$key."=\$value;");
  else eval("\$".$key."=addslashes(\$value);");

It appears to be working. Does anyone see any problems with it or possible
improvements ?

What I do *not* want is to start a discussion about wheater magic quotes and
register globals are evil and stuff. :)

Thanks,
Paul Schmidinger
-- www.eigelb.at



Relevant Pages

  • Re: wife-proof way to launch ppp?
    ... enhanced text field, that doesn't really matter. ... You could settle on having her login shell ... You could even start X with a script from her ... Does that mac support running NetBSD? ...
    (comp.unix.bsd.freebsd.misc)
  • Re: GET adding apostrophes?
    ... > extra apostrophe once it got to the script. ... > I guess the extra apostrophe wasn't added by GET like I thought, ... > I probably shouldn't rely on the magic quotes option as much as I do. ... o_O magic quotes is supposed to add BACKSLASHES not quotes. ...
    (alt.php)
  • Re: The page to order an SP2 update CD is borked...
    ... >>> know what zip code my city is. ... > It doesn't matter WHAT order you enter your street address. ... > script is totally off-the-wall. ... > This script on the site is totally screwed up. ...
    (microsoft.public.windowsxp.general)
  • Re: Does Man Have Free Will?
    ... The script isn't written for you. ... No matter how many times you replay the ... The problem, of course, is that no matter if free will is real or not, ... behave accordingly. ...
    (talk.origins)
  • Re: hosts.deny script
    ... gethostip works much better only gives the ip address given the right option, works no matter the input ... Subject: hosts.deny script ... I sometimes get log entries with the symbolic address instead of the ip. ...
    (Fedora)