Documentation TYPO3 par Ameos |
00001 <?php 00002 /* $Id: grab_globals.lib.php,v 2.12.2.2 2005/10/21 02:40:39 lem9 Exp $ */ 00003 // vim: expandtab sw=4 ts=4 sts=4: 00004 00014 // protect against older PHP versions' bug about GLOBALS overwrite 00015 // (no need to translate this one :) ) 00016 if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])) { 00017 die("GLOBALS overwrite attempt"); 00018 } 00019 00020 function PMA_gpc_extract($array, &$target, $sanitize = TRUE) { 00021 if (!is_array($array)) { 00022 return FALSE; 00023 } 00024 $is_magic_quotes = get_magic_quotes_gpc(); 00025 foreach ($array AS $key => $value) { 00035 if ($sanitize && is_string($key) && ( 00036 $key == 'cfg' 00037 || $key == 'GLOBALS' 00038 || substr($key, 0, 3) == 'str' 00039 || $key{0} == '_')) { 00040 continue; 00041 } 00042 00043 if (is_array($value)) { 00044 // there could be a variable coming from a cookie of 00045 // another application, with the same name as this array 00046 unset($target[$key]); 00047 00048 PMA_gpc_extract($value, $target[$key], FALSE); 00049 } else if ($is_magic_quotes) { 00050 $target[$key] = stripslashes($value); 00051 } else { 00052 $target[$key] = $value; 00053 } 00054 } 00055 return TRUE; 00056 } 00057 00058 // check if a subform is submitted 00059 $__redirect = NULL; 00060 if ( isset( $_POST['usesubform'] ) ) { 00061 // if a subform is present and should be used 00062 // the rest of the form is deprecated 00063 $subform_id = key( $_POST['usesubform'] ); 00064 $subform = $_POST['subform'][$subform_id]; 00065 $_POST = $subform; 00066 if ( isset( $_POST['redirect'] ) 00067 && $_POST['redirect'] != basename( $_SERVER['PHP_SELF'] ) ) { 00068 $__redirect = $_POST['redirect']; 00069 unset( $_POST['redirect'] ); 00070 } // end if ( isset( $_POST['redirect'] ) ) 00071 } // end if ( isset( $_POST['usesubform'] ) ) 00072 // end check if a subform is submitted 00073 00074 if (!empty($_GET)) { 00075 PMA_gpc_extract($_GET, $GLOBALS); 00076 } // end if 00077 00078 if (!empty($_POST)) { 00079 PMA_gpc_extract($_POST, $GLOBALS); 00080 } // end if (!empty($_POST)) 00081 00082 if (!empty($_FILES)) { 00083 foreach ($_FILES AS $name => $value) { 00084 $$name = $value['tmp_name']; 00085 ${$name . '_name'} = $value['name']; 00086 } 00087 } // end if 00088 00089 if (!empty($_SERVER)) { 00090 $server_vars = array('PHP_SELF', 'HTTP_ACCEPT_LANGUAGE', 'HTTP_AUTHORIZATION'); 00091 foreach ($server_vars as $current) { 00092 if (isset($_SERVER[$current])) { 00093 $$current = $_SERVER[$current]; 00094 } elseif (!isset($$current)) { 00095 $$current = ''; 00096 } 00097 } 00098 unset($server_vars, $current); 00099 } // end if 00100 00101 // Security fix: disallow accessing serious server files via "?goto=" 00102 if (isset($goto) && strpos(' ' . $goto, '/') > 0 && substr($goto, 0, 2) != './') { 00103 unset($goto); 00104 } // end if 00105 00106 if ( ! empty( $__redirect ) ) { 00107 // TODO: ensure that PMA_securePath() is defined and available 00108 // for this script. Meanwhile we duplicate what this function does: 00109 require('./' . preg_replace('@\.\.*@','.',$__redirect)); 00110 exit(); 00111 } // end if ( ! empty( $__redirect ) ) 00112 ?>