mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-07 11:54:26 +02:00
fix problem with super globals and isset()
This commit is contained in:
@@ -570,6 +570,15 @@ class Smarty
|
|||||||
{
|
{
|
||||||
$this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME']
|
$this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME']
|
||||||
: @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);
|
: @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);
|
||||||
|
|
||||||
|
$this->supers['get'] = $this->request_use_auto_globals ? $_GET : $GLOBALS['HTTP_GET_VARS'];
|
||||||
|
$this->supers['post'] = $this->request_use_auto_globals ? $_POST : $GLOBALS['HTTP_POST_VARS'];
|
||||||
|
$this->supers['server'] = $this->request_use_auto_globals ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
|
||||||
|
$this->supers['session'] = $this->request_use_auto_globals ? $_SESSION : $GLOBALS['HTTP_SESSION_VARS'];
|
||||||
|
$this->supers['request'] = $this->request_use_auto_globals ? $_REQUEST : $GLOBALS['HTTP_REQUEST_VARS'];
|
||||||
|
$this->supers['cookies'] = $this->request_use_auto_globals ? $_COOKIE : $GLOBALS['HTTP_COOKIE_VARS'];
|
||||||
|
$this->supers['env'] = $this->request_use_auto_globals ? $_ENV : $GLOBALS['HTTP_ENV_VARS'];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1952,47 +1961,6 @@ class Smarty
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* wrapper for super global access
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
function _get_super($type,$name)
|
|
||||||
{
|
|
||||||
// don't display anything if not allowed
|
|
||||||
if($this->security && !$this->security_settings['ALLOW_SUPER_GLOBALS']) {
|
|
||||||
$this->trigger_error('security error: super global access not allowed');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(empty($type)||empty($name))
|
|
||||||
return null;
|
|
||||||
switch($type) {
|
|
||||||
case 'get':
|
|
||||||
return $this->request_use_auto_globals ? $_GET[$name] : $GLOBALS['HTTP_GET_VARS'][$name];
|
|
||||||
break;
|
|
||||||
case 'post':
|
|
||||||
return $this->request_use_auto_globals ? $_POST[$name] : $GLOBALS['HTTP_POST_VARS'][$name];
|
|
||||||
break;
|
|
||||||
case 'server':
|
|
||||||
return $this->request_use_auto_globals ? $_SERVER[$name] : $GLOBALS['HTTP_SERVER_VARS'][$name];
|
|
||||||
break;
|
|
||||||
case 'session':
|
|
||||||
return $this->request_use_auto_globals ? $_SESSION[$name] : $GLOBALS['HTTP_SESSION_VARS'][$name];
|
|
||||||
break;
|
|
||||||
case 'request':
|
|
||||||
return $this->request_use_auto_globals ? $_REQUEST[$name] : $GLOBALS['HTTP_REQUEST_VARS'][$name];
|
|
||||||
break;
|
|
||||||
case 'cookies':
|
|
||||||
return $this->request_use_auto_globals ? $_COOKIE[$name] : $GLOBALS['HTTP_COOKIE_VARS'][$name];
|
|
||||||
break;
|
|
||||||
case 'env':
|
|
||||||
return $this->request_use_auto_globals ? $_ENV[$name] : $GLOBALS['HTTP_ENV_VARS'][$name];
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**#@-*/
|
/**#@-*/
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2047,39 +2047,27 @@ class Smarty_Compiler extends Smarty {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'get':
|
case 'get':
|
||||||
$_ref_val = substr($indexes[1], 1);
|
$compiled_ref = "\$this->supers['get']";
|
||||||
$compiled_ref = "\$this->_get_super('get','$_ref_val')";
|
|
||||||
array_shift($indexes);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'post':
|
case 'post':
|
||||||
$_ref_val = substr($indexes[1], 1);
|
$compiled_ref = "\$this->supers['post']";
|
||||||
$compiled_ref = "\$this->_get_super('post','$_ref_val')";
|
|
||||||
array_shift($indexes);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'cookies':
|
case 'cookies':
|
||||||
$_ref_val = substr($indexes[1], 1);
|
$compiled_ref = "\$this->supers['cookies']";
|
||||||
$compiled_ref = "\$this->_get_super('cookies','$_ref_val')";
|
|
||||||
array_shift($indexes);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'env':
|
case 'env':
|
||||||
$_ref_val = substr($indexes[1], 1);
|
$compiled_ref = "\$this->supers['env']";
|
||||||
$compiled_ref = "\$this->_get_super('env','$_ref_val')";
|
|
||||||
array_shift($indexes);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'server':
|
case 'server':
|
||||||
$_ref_val = substr($indexes[1], 1);
|
$compiled_ref = "\$this->supers['server']";
|
||||||
$compiled_ref = "\$this->_get_super('server','$_ref_val')";
|
|
||||||
array_shift($indexes);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'session':
|
case 'session':
|
||||||
$_ref_val = substr($indexes[1], 1);
|
$compiled_ref = "\$this->supers['session']";
|
||||||
$compiled_ref = "\$this->_get_super('session','$_ref_val')";
|
|
||||||
array_shift($indexes);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2088,7 +2076,7 @@ class Smarty_Compiler extends Smarty {
|
|||||||
*/
|
*/
|
||||||
case 'request':
|
case 'request':
|
||||||
if ($this->request_use_auto_globals) {
|
if ($this->request_use_auto_globals) {
|
||||||
$compiled_ref = '$_REQUEST';
|
$compiled_ref = "\$this->supers['request']";
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
$this->_init_smarty_vars = true;
|
$this->_init_smarty_vars = true;
|
||||||
|
Reference in New Issue
Block a user