Hi All,
I originally posted this on 2004-02-09, to alt.comp.lang.php, alt.php, and
comp.lang.php, with the followup-to header set to comp.lang.php. Nobody had
any thoughts, so I thought I would post here, just in case.
I want to turn off magic quotes. I realize in retrospect that using a
.htaccess file to turn magic quotes would probably be better than this code,
and I am going to switch to that solution, but I am still trying
to figure out what is causing my current problem:
I am using the following code to automatically strip out any slashes that
were added automagically by gpc_magic_quotes:
$_POST = array_stripslashes($_POST);
// Takes the passed array, and strips and escaping slashes out of
any strings in the array.
// This is a recursive function capable of handling multidimensional
arrays
function array_stripslashes($data)
{
do{
$pair = each($data); // Get the next key-value
pair from the array
if($pair === false)
break;
$key = $pair[0]; // This is just for
readability
$val = $pair[1];
if(is_array($val))
$val = Utility::array_stripslashes($val);
elseif(is_string($val))
$val = stripslashes($val);
$data[$key] = $val;
}while(true);
return $data;
}
Now, I test it several times and it appears to be working fine. But, I just
got an error report from a user, with agent "Mozilla/4.0 (compatible; MSIE
5.0; CS 2000 6.0; Windows 98; DigExt)", and when they clicked on a submit
button, all the POST data was lost. Interestingly enough,
$GLOBALS['HTTP_RAW_POST_DATA'] was populated with all the form fields I
would have expected to be in $_POST (although raw, of course, not parsed
into variables).
Is my code broken? Or is this a bug in PHP? Or what?
Sincerely,
-Josh
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php