fix problem with super globals and isset()

This commit is contained in:
monte.ohrt
2009-05-16 23:23:49 +00:00
parent 5220455ae5
commit 2919f9a608
2 changed files with 16 additions and 60 deletions

View File

@@ -570,6 +570,15 @@ class Smarty
{
$this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['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;
}
}
/**#@-*/
}

View File

@@ -2047,39 +2047,27 @@ class Smarty_Compiler extends Smarty {
break;
case 'get':
$_ref_val = substr($indexes[1], 1);
$compiled_ref = "\$this->_get_super('get','$_ref_val')";
array_shift($indexes);
$compiled_ref = "\$this->supers['get']";
break;
case 'post':
$_ref_val = substr($indexes[1], 1);
$compiled_ref = "\$this->_get_super('post','$_ref_val')";
array_shift($indexes);
$compiled_ref = "\$this->supers['post']";
break;
case 'cookies':
$_ref_val = substr($indexes[1], 1);
$compiled_ref = "\$this->_get_super('cookies','$_ref_val')";
array_shift($indexes);
$compiled_ref = "\$this->supers['cookies']";
break;
case 'env':
$_ref_val = substr($indexes[1], 1);
$compiled_ref = "\$this->_get_super('env','$_ref_val')";
array_shift($indexes);
$compiled_ref = "\$this->supers['env']";
break;
case 'server':
$_ref_val = substr($indexes[1], 1);
$compiled_ref = "\$this->_get_super('server','$_ref_val')";
array_shift($indexes);
$compiled_ref = "\$this->supers['server']";
break;
case 'session':
$_ref_val = substr($indexes[1], 1);
$compiled_ref = "\$this->_get_super('session','$_ref_val')";
array_shift($indexes);
$compiled_ref = "\$this->supers['session']";
break;
/*
@@ -2088,7 +2076,7 @@ class Smarty_Compiler extends Smarty {
*/
case 'request':
if ($this->request_use_auto_globals) {
$compiled_ref = '$_REQUEST';
$compiled_ref = "\$this->supers['request']";
break;
} else {
$this->_init_smarty_vars = true;