From 2919f9a6080148dfc85f3bd14ce04394f76a1020 Mon Sep 17 00:00:00 2001 From: "monte.ohrt" Date: Sat, 16 May 2009 23:23:49 +0000 Subject: [PATCH] fix problem with super globals and isset() --- libs/Smarty.class.php | 50 ++++++---------------------------- libs/Smarty_Compiler.class.php | 26 +++++------------- 2 files changed, 16 insertions(+), 60 deletions(-) diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 7e8844df..8b7bcbc7 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -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; - } - } - /**#@-*/ } diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 46e84c25..57e4f779 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -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;