3 * importGlobalVariable solves the different global variable names
4 * in different versions of php
5 * original idea by Chris Burkert
7 function importGlobalVariable($variable)
9 switch (strtolower($variable))
11 if (isset($_SERVER)) { return $_SERVER; }
13 { return $GLOBALS['HTTP_SERVER_VARS']; }
16 if (isset($_SESSION)) { return $_SESSION; }
18 { return $GLOBALS['HTTP_SESSION_VARS']; }
21 if (isset($_POST)) { return $_POST; }
23 { return $GLOBALS['HTTP_POST_VARS']; }
26 if (isset($_GET)) { return $_GET; }
28 { return $GLOBALS['HTTP_GET_VARS']; }
31 if (isset($_COOKIE)) { return $_COOKIE; }
33 { return $GLOBALS['HTTP_COOKIE_VARS']; }
41 * This routine will check whether the register_globals of php is on or off.
42 * If it is off, all GET,POST, and COOKIE variables will be explicitely 'globalized' here
43 * Note: this uses the $$ variable which will not work in php3
45 $reg_glob_ini=ini_get('register_globals');
47 if(empty($reg_glob_ini)||
(!$reg_glob_ini))
50 /* Process GET vars */
52 //if(sizeof($HTTP_GET_VARS))
53 if(sizeof($global_vars=&importGlobalVariable('get')))
55 //while(list($x,$v)=each($HTTP_GET_VARS))
56 while(list($x,$v)=each($global_vars))
63 /* Process POST vars */
65 //if(sizeof($HTTP_POST_VARS))
66 if(sizeof($global_vars=&importGlobalVariable('post')))
68 //while(list($x,$v)=each($HTTP_POST_VARS))
69 while(list($x,$v)=each($global_vars))
73 //reset($HTTP_POST_VARS);
77 /* Process COOKIE vars */
79 //if(sizeof($HTTP_COOKIE_VARS))
80 if(sizeof($global_vars=&importGlobalVariable('cookie')))
82 //while(list($x,$v)=each($HTTP_COOKIE_VARS))
83 while(list($x,$v)=each($global_vars))
87 //reset($HTTP_COOKIE_VARS);
91 /* Get cookie vars equivalent */
92 $HTTP_COOKIE_VARS=&importGlobalVariable('cookie');
94 /* Process SERVER vars */
96 //if(sizeof($HTTP_SERVER_VARS))
97 if(sizeof($global_vars=&importGlobalVariable('server')))
99 //while(list($x,$v)=each($HTTP_SERVER_VARS))
100 while(list($x,$v)=each($global_vars))
104 //reset($HTTP_SERVER_VARS);
108 /* Get server vars equivalent */
109 $CARE_SERVER_VARS=&importGlobalVariable('server');
111 /* Process SESSION vars */
112 /* if(sizeof($global_vars=&importGlobalVariable('session')))
114 //while(list($x,$v)=each($HTTP_SERVER_VARS))
115 while(list($x,$v)=each($global_vars))
119 //reset($HTTP_SERVER_VARS);
125 //$HTTP_SESSION_VARS=&importGlobalVariable('session');
129 /*------begin------ This protection code was suggested by Luki R. luki@karet.org ---- */
130 if (eregi('inc_vars_resolve.php',$PHP_SELF))
131 die('<meta http-equiv="refresh" content="0; url=../">');