3 // vim: expandtab sw=4 ts=4 sts=4:
7 * This library grabs the names and values of the variables sent or posted to a
8 * script in the $_* arrays and sets simple globals variables from them. It does
9 * the same work for the $PHP_SELF, $HTTP_ACCEPT_LANGUAGE and
10 * $HTTP_AUTHORIZATION variables.
12 * loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
15 function PMA_gpc_extract($array, &$target) {
16 if (!is_array($array)) {
19 $is_magic_quotes = get_magic_quotes_gpc();
20 foreach($array AS $key => $value) {
21 if (is_array($value)) {
22 // there could be a variable coming from a cookie of
23 // another application, with the same name as this array
26 PMA_gpc_extract($value, $target[$key]);
27 } else if ($is_magic_quotes) {
28 $target[$key] = stripslashes($value);
30 $target[$key] = $value;
37 PMA_gpc_extract($_GET, $GLOBALS);
41 PMA_gpc_extract($_POST, $GLOBALS);
44 if (!empty($_FILES)) {
45 foreach($_FILES AS $name => $value) {
46 $
$name = $value['tmp_name'];
47 $
{$name . '_name'} = $value['name'];
51 if (!empty($_SERVER)) {
52 $server_vars = array('PHP_SELF', 'HTTP_ACCEPT_LANGUAGE', 'HTTP_AUTHORIZATION');
53 foreach ($server_vars as $current) {
54 if (isset($_SERVER[$current])) {
55 $
$current = $_SERVER[$current];
56 } elseif (!isset($
$current)) {
60 unset($server_vars, $current);
63 // Security fix: disallow accessing serious server files via "?goto="
64 if (isset($goto) && strpos(' ' . $goto, '/') > 0 && substr($goto, 0, 2) != './') {