update
[phpmyadmin/crack.git] / libraries / grab_globals.lib.php3
blobac38b90f72bd18f65844ef09b389b4dcab200c52
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
7 * This library grabs the names and values of the variables sent or posted to a
8 * script in the '$HTTP_*_VARS' arrays and sets simple globals variables from
9 * them. It does the same work for the $PHP_SELF variable.
11 * loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
13 if (!defined('PMA_GRAB_GLOBALS_INCLUDED')) {
14 define('PMA_GRAB_GLOBALS_INCLUDED', 1);
16 if (!empty($_GET)) {
17 extract($_GET, EXTR_OVERWRITE);
18 } else if (!empty($HTTP_GET_VARS)) {
19 extract($HTTP_GET_VARS, EXTR_OVERWRITE);
20 } // end if
22 if (!empty($_POST)) {
23 extract($_POST, EXTR_OVERWRITE);
24 } else if (!empty($HTTP_POST_VARS)) {
25 extract($HTTP_POST_VARS, EXTR_OVERWRITE);
26 } // end if
28 if (!empty($_FILES)) {
29 while (list($name, $value) = each($_FILES)) {
30 $$name = $value['tmp_name'];
32 } else if (!empty($HTTP_POST_FILES)) {
33 while (list($name, $value) = each($HTTP_POST_FILES)) {
34 $$name = $value['tmp_name'];
36 } // end if
38 if (!empty($_SERVER) && isset($_SERVER['PHP_SELF'])) {
39 $PHP_SELF = $_SERVER['PHP_SELF'];
40 } else if (!empty($HTTP_SERVER_VARS) && isset($HTTP_SERVER_VARS['PHP_SELF'])) {
41 $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
42 } // end if
44 // Securety fix: disallow accessing serious server files via "?goto="
45 if (isset($goto) && strpos(' ' . $goto, '/') > 0 && substr($goto, 0, 2) != './') {
46 unset($goto);
47 } // end if
49 // Strip slahes from $db / $table values
50 if (get_magic_quotes_gpc()) {
51 if (isset($db)) {
52 $db = stripslashes($db);
54 if (isset($table)) {
55 $table = stripslashes($table);
59 } // $__PMA_GRAB_GLOBALS_LIB__