Re: magic quotes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Phil Princely wrote:
thanks for all the help.

My code was wrong in the first post, I just copied it straight from
the web. This one works:

if (get_magic_quotes_gpc()) {
    stripslashes_array($_GET);
    stripslashes_array($_POST);
    stripslashes_array($_REQUEST);
    stripslashes_array($_COOKIE);
}
set_magic_quotes_runtime(0);

set_magic_quotes_runtime() has no effect on magic_quotes_gpc.
function stripslashes_array(&$arr) {
    foreach (array_keys($arr) as $k) {
        $arr[$k] = stripslashes($arr[$k]);
    }
}

This function breaks arrays, ignores keys, and takes into account none of PHP's inconsistencies with magic_quotes_gpc.
As I said before, if you need to do it at runtime, use the PHP_Compat code.

Here's the two relevant files, if you can't use the PEAR installer:
http://cvs.php.net/viewvc.cgi/pear/PHP_Compat/Compat/Environment/_magic_quotes_inputs.php?revision=1.3&view=markup
http://cvs.php.net/viewvc.cgi/pear/PHP_Compat/Compat/Environment/magic_quotes_gpc_off.php?revision=1.7&view=markup
I tried searching for setini, but came up with nothing, except this:
setIni('magic_quotes_gpc', 'Off', $inifile); // didn't work: unknown function

ini_set() is probably what you're thinking of, but magic_quotes_gpc is applied before your script is executed so it will have no effect.
That's why the only option at runtime is to reverse it.

Arpad

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux