I’m getting this notice "Undefined variable: _ in magic_quotes_gpc.php on line 43" from this script:
<?php
$HTTP_VARs = array(
'HTTP_GET_VARS' => '_GET',
'HTTP_POST_VARS' => '_POST',
'HTTP_COOKIE_VARS' => '_COOKIE',
'HTTP_SERVER_VARS' => '!_SERVER',
'HTTP_ENV_VARS' => '!_ENV',
'HTTP_POST_FILES' => '!_FILES'
);
if (!isset($HTTP_GET_VARS) && isset($_GET)) {
foreach ($HTTP_VARs as $HTTP_VAR => $_VAR) {
$_VAR = ($_VAR[0] == '!' ? str_replace('!', '', $_VAR) : $_VAR);
if (isset($$_VAR))
$$HTTP_VAR = $$_VAR;
}
}
function strip_magic_quotes($array)
{
foreach ($array as $key => $value)
$array[$key] = (is_array($value) ? strip_magic_quotes($value) : stripslashes($value));
return $array;
}
foreach ($HTTP_VARs as $HTTP_VAR => $_VAR) {
if ($_VAR[0] != '!') {
if (get_magic_quotes_gpc()) {
if (!empty($$_VAR))
$$_VAR = strip_magic_quotes($$_VAR);
} else {
if (is_array($$_VAR)) {
foreach ($$_VAR as $k => $v) {
if (is_array($$_VAR[$k])) {
foreach ($$_VAR[$k] as $k2 => $v2)
$$_VAR[$k][$k2] = addslashes($v2);
@reset($$_VAR[$k]);
} else
$$_VAR[$k] = addslashes($v);
}
@reset($$_VAR);
}
}
}
}
?>
Line 43 is this: if (is_array($$_VAR[$k]))
I used echo to post all values and not a single 1 is _.
I looked and looked and have no idea where this variable _ is coming from, I’m baffled.
WOA! I don’t know what you’re trying to achieve with that massive chunk of code, but you can deal with magic quotes using the following (much simpler) code: