function PMA_gpc_extract($array, &$target, $sanitize = TRUE) { if (!is_array($array)) { return FALSE; } $is_magic_quotes = get_magic_quotes_gpc(); foreach ($array as $key => $value) { /** * 2005-02-22, rabus: * * This is just an ugly hotfix to avoid changing internal config * parameters. * * Currently, the following variable names are rejected when found in * $_GET or $_POST: cfg, GLOBALS, str* and _* */ if ($sanitize && is_string($key) && ($key == 'cfg' || $key == 'GLOBALS' || substr($key, 0, 3) == 'str' || $key[0] == '_')) { continue; } if (is_array($value)) { // there could be a variable coming from a cookie of // another application, with the same name as this array unset($target[$key]); PMA_gpc_extract($value, $target[$key], FALSE); } else { if ($is_magic_quotes) { $target[$key] = stripslashes($value); } else { $target[$key] = $value; } } } return TRUE; }
/** * copy values from one array to another, usally from a superglobal into $GLOBALS * * @uses $GLOBALS['_import_blacklist'] * @uses preg_replace() * @uses array_keys() * @uses array_unique() * @uses stripslashes() * @param array $array values from * @param array $target values to * @param boolean $sanitize prevent importing key names in $_import_blacklist */ function PMA_gpc_extract($array, &$target, $sanitize = true) { if (!is_array($array)) { return false; } if ($sanitize) { $valid_variables = preg_replace($GLOBALS['_import_blacklist'], '', array_keys($array)); $valid_variables = array_unique($valid_variables); } else { $valid_variables = array_keys($array); } foreach ($valid_variables as $key) { if (strlen($key) === 0) { continue; } if (is_array($array[$key])) { // there could be a variable coming from a cookie of // another application, with the same name as this array unset($target[$key]); PMA_gpc_extract($array[$key], $target[$key], false); } else { $target[$key] = $array[$key]; } } return true; }
/** * copy values from one array to another, usally from a superglobal into $GLOBALS * * @uses $GLOBALS['_import_blacklist'] * @uses preg_replace() * @uses array_keys() * @uses array_unique() * @uses get_magic_quotes_gpc() to check wether stripslashes or not * @uses stripslashes() * @param array $array values from * @param array $target values to * @param boolean $sanitize prevent importing key names in $_import_blacklist */ function PMA_gpc_extract($array, &$target, $sanitize = TRUE) { if (!is_array($array)) { return FALSE; } if ($sanitize) { $valid_variables = preg_replace($GLOBALS['_import_blacklist'], '', array_keys($array)); $valid_variables = array_unique($valid_variables); } else { $valid_variables = array_keys($array); } $is_magic_quotes = get_magic_quotes_gpc(); foreach ($valid_variables as $key) { if (strlen($key) === 0) { continue; } if (is_array($array[$key])) { // there could be a variable coming from a cookie of // another application, with the same name as this array unset($target[$key]); PMA_gpc_extract($array[$key], $target[$key], FALSE); } elseif ($is_magic_quotes) { $target[$key] = stripslashes($array[$key]); } else { $target[$key] = $array[$key]; } } return TRUE; }
function PMA_gpc_extract($array, &$target) { if (!is_array($array)) { return FALSE; } $is_magic_quotes = get_magic_quotes_gpc(); reset($array); while (list($key, $value) = each($array)) { if (is_array($value)) { PMA_gpc_extract($value, $target[$key]); } else { if ($is_magic_quotes) { $target[$key] = stripslashes($value); } else { $target[$key] = $value; } } } reset($array); return TRUE; }
/** * This library grabs the names and values of the variables sent or posted to a * script in the $_* arrays and sets simple globals variables from them. It does * the same work for the $PHP_SELF, $HTTP_ACCEPT_LANGUAGE and * $HTTP_AUTHORIZATION variables. * * loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+ */ function PMA_gpc_extract($array, &$target) { if (!is_array($array)) { return FALSE; } $is_magic_quotes = get_magic_quotes_gpc(); foreach ($array as $key => $value) { if (is_array($value)) { // there could be a variable coming from a cookie of // another application, with the same name as this array unset($target[$key]); PMA_gpc_extract($value, $target[$key]); } else { if ($is_magic_quotes) { $target[$key] = stripslashes($value); } else { $target[$key] = $value; } } } return TRUE; }