moved stuff from grab_globals into common.inc.php (preprare removal of grab_globals)
check/init global required variables like: $lang, $server, $db, $table, $convcharset, $goto introduced $goto-whitelist PEAR coding standard
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -12,26 +12,6 @@
|
||||
* loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
|
||||
*/
|
||||
|
||||
/**
|
||||
* check if a subform is submitted
|
||||
*/
|
||||
$__redirect = NULL;
|
||||
if ( isset( $_POST['usesubform'] ) ) {
|
||||
// if a subform is present and should be used
|
||||
// the rest of the form is deprecated
|
||||
$subform_id = key( $_POST['usesubform'] );
|
||||
$subform = $_POST['subform'][$subform_id];
|
||||
$_POST = $subform;
|
||||
if ( isset( $_POST['redirect'] )
|
||||
&& $_POST['redirect'] != basename( $_SERVER['PHP_SELF'] ) ) {
|
||||
$__redirect = $_POST['redirect'];
|
||||
unset( $_POST['redirect'] );
|
||||
} // end if ( isset( $_POST['redirect'] ) )
|
||||
unset( $subform_id, $subform );
|
||||
} // end if ( isset( $_POST['usesubform'] ) )
|
||||
// end check if a subform is submitted
|
||||
|
||||
if ( $__redirect || ! defined( 'PMA_NO_VARIABLES_IMPORT' ) ) {
|
||||
/**
|
||||
* copy values from one array to another, usally from a superglobal into $GLOBALS
|
||||
*
|
||||
@@ -45,9 +25,10 @@ if ( $__redirect || ! defined( 'PMA_NO_VARIABLES_IMPORT' ) ) {
|
||||
* @param array $target values to
|
||||
* @param boolean $sanitize prevent importing key names in $_import_blacklist
|
||||
*/
|
||||
function PMA_gpc_extract($array, &$target, $sanitize = TRUE) {
|
||||
function PMA_gpc_extract($array, &$target, $sanitize = true)
|
||||
{
|
||||
if ( ! is_array($array) ) {
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $sanitize ) {
|
||||
@@ -71,14 +52,14 @@ if ( $__redirect || ! defined( 'PMA_NO_VARIABLES_IMPORT' ) ) {
|
||||
// another application, with the same name as this array
|
||||
unset( $target[$key] );
|
||||
|
||||
PMA_gpc_extract($array[$key], $target[$key], FALSE);
|
||||
PMA_gpc_extract($array[$key], $target[$key], false);
|
||||
} elseif ( $is_magic_quotes ) {
|
||||
$target[$key] = stripslashes($array[$key]);
|
||||
} else {
|
||||
$target[$key] = $array[$key];
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,8 +69,16 @@ if ( $__redirect || ! defined( 'PMA_NO_VARIABLES_IMPORT' ) ) {
|
||||
*/
|
||||
$_import_blacklist = array(
|
||||
'/^cfg$/i', // PMA configuration
|
||||
'/^db$/i', // page to display
|
||||
'/^table$/i', // page to display
|
||||
'/^goto$/i', // page to display
|
||||
'/^lang$/i', // selected language
|
||||
'/^server$/i', // selected server
|
||||
'/^convcharset$/i', // PMA convert charset
|
||||
'/^collation_connection$/i', //
|
||||
'/^set_theme$/i', //
|
||||
'/^GLOBALS$/i', // the global scope
|
||||
'/^str.*$/i', // PMA strings
|
||||
'/^str.*$/i', // PMA localized strings
|
||||
'/^_.*$/i', // PMA does not use variables starting with _ from extern
|
||||
'/^.*\s+.*$/i', // no whitespaces anywhere
|
||||
'/^[0-9]+.*$/i', // numeric variable names
|
||||
@@ -98,11 +87,11 @@ if ( $__redirect || ! defined( 'PMA_NO_VARIABLES_IMPORT' ) ) {
|
||||
|
||||
if ( ! empty( $_GET ) ) {
|
||||
PMA_gpc_extract($_GET, $GLOBALS);
|
||||
} // end if
|
||||
}
|
||||
|
||||
if ( ! empty( $_POST ) ) {
|
||||
PMA_gpc_extract($_POST, $GLOBALS);
|
||||
} // end if (!empty($_POST))
|
||||
}
|
||||
|
||||
if ( ! empty( $_FILES ) ) {
|
||||
foreach ( $_FILES AS $name => $value ) {
|
||||
@@ -110,7 +99,7 @@ if ( $__redirect || ! defined( 'PMA_NO_VARIABLES_IMPORT' ) ) {
|
||||
${$name . '_name'} = $value['name'];
|
||||
}
|
||||
unset( $name, $value );
|
||||
} // end if
|
||||
}
|
||||
|
||||
if ( ! empty( $_SERVER ) ) {
|
||||
$server_vars = array('PHP_SELF', 'HTTP_ACCEPT_LANGUAGE', 'HTTP_AUTHORIZATION');
|
||||
@@ -129,45 +118,6 @@ if ( $__redirect || ! defined( 'PMA_NO_VARIABLES_IMPORT' ) ) {
|
||||
unset( $server_vars, $current );
|
||||
} // end if
|
||||
|
||||
// Security fix: disallow accessing serious server files via "?goto="
|
||||
if (isset($goto) && strpos(' ' . $goto, '/') > 0 && substr($goto, 0, 2) != './') {
|
||||
unset($goto);
|
||||
} // end if
|
||||
|
||||
unset( $_import_blacklist );
|
||||
|
||||
if ( ! empty( $__redirect ) ) {
|
||||
// TODO: ensure that PMA_securePath() is defined and available
|
||||
// for this script. Meanwhile we duplicate what this function does:
|
||||
require('./' . preg_replace('@\.\.*@','.',$__redirect));
|
||||
exit();
|
||||
} // end if ( ! empty( $__redirect ) )
|
||||
|
||||
} else {
|
||||
|
||||
// Security fix: disallow accessing serious server files via "?goto="
|
||||
if ( isset( $_REQUEST['goto'] )
|
||||
&& strpos( $_REQUEST['goto'], '\\' ) !== false
|
||||
&& strpos( $_REQUEST['goto'], '/' ) !== false ) {
|
||||
unset( $_REQUEST['goto'], $_GET['goto'], $_POST['goto'],
|
||||
$_COOKIE['goto'] );
|
||||
} // end if
|
||||
|
||||
/**
|
||||
* Recursive wrapper around strip_tags to process also arrays.
|
||||
*
|
||||
* @param mixed array or string to strip tags
|
||||
*/
|
||||
function array_strip_tags(&$item) {
|
||||
if (is_array($item)) {
|
||||
array_walk($item, 'array_strip_tags');
|
||||
} else {
|
||||
strip_tags($item);
|
||||
}
|
||||
}
|
||||
|
||||
array_walk( $_SERVER, 'array_strip_tags' );
|
||||
array_walk( $_ENV, 'array_strip_tags' );
|
||||
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user