diff --git a/NEWS b/NEWS index 1e724cd0..eda4125c 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ + - added config-option "request_use_auto_globals" to make auto-globals be + used as request vars instead of HTTP_*_VARS (messju) - make config vars compile statically (Monte) - added block-methods for registered objects (Bharat Mediratta, messju) - ignore one char resource names like c:foo.tpl (Monte) diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index ddad1c5d..a15452d5 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -92,7 +92,7 @@ class Smarty /** * The directory where config files are located. * - * @var string +reques * @var string */ var $config_dir = 'configs'; @@ -271,6 +271,16 @@ class Smarty */ var $request_vars_order = "EGPCS"; + /** + * Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false) + * are uses as request-vars or $_*[]-vars. note: if + * request_use_auto_globals is true, then $request_vars_order has + * no effect, but the php-ini-value "gpc_order" + * + * @var boolean + */ + var $request_use_auto_globals = false; + /** * Set this if you want different sets of compiled files for the same * templates. This is useful for things like different languages. @@ -1483,7 +1493,9 @@ class Smarty $smarty_compiler->_tpl_vars = &$this->_tpl_vars; $smarty_compiler->default_modifiers = $this->default_modifiers; $smarty_compiler->compile_id = $this->_compile_id; - $smarty_compiler->_config = $this->_config; + $smarty_compiler->_config = $this->_config; + + $smarty_compiler->request_use_auto_globals = $this->request_use_auto_globals; if ($smarty_compiler->_compile_file($tpl_file, $template_source, $template_compiled)) { return true; diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 159a7d0d..1febbb12 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -1766,27 +1766,26 @@ class Smarty_Compiler extends Smarty { break; case 'get': - $compiled_ref = "\$GLOBALS['HTTP_GET_VARS']"; - break; + $compiled_ref = ($this->request_use_auto_globals) ? '$_GET' : "\$GLOBALS['HTTP_GET_VARS']"; case 'post': - $compiled_ref = "\$GLOBALS['HTTP_POST_VARS']"; + $compiled_ref = ($this->request_use_auto_globals) ? '$_POST' : "\$GLOBALS['HTTP_POST_VARS']"; break; case 'cookies': - $compiled_ref = "\$GLOBALS['HTTP_COOKIE_VARS']"; + $compiled_ref = ($this->request_use_auto_globals) ? '$_COOKIE' : "\$GLOBALS['HTTP_COOKIE_VARS']"; break; case 'env': - $compiled_ref = "\$GLOBALS['HTTP_ENV_VARS']"; + $compiled_ref = ($this->request_use_auto_globals) ? '$_ENV' : "\$GLOBALS['HTTP_ENV_VARS']"; break; case 'server': - $compiled_ref = "\$GLOBALS['HTTP_SERVER_VARS']"; + $compiled_ref = ($this->request_use_auto_globals) ? '$_SERVER' : "\$GLOBALS['HTTP_SERVER_VARS']"; break; case 'session': - $compiled_ref = "\$GLOBALS['HTTP_SESSION_VARS']"; + $compiled_ref = ($this->request_use_auto_globals) ? '$_SESSION' : "\$GLOBALS['HTTP_SESSION_VARS']"; break; /* @@ -1794,7 +1793,12 @@ class Smarty_Compiler extends Smarty { * compiler. */ case 'request': - $this->_init_smarty_vars = true; + if ($this->request_use_auto_globals) { + $compiled_ref = '$_REQUEST'; + break; + } else { + $this->_init_smarty_vars = true; + } return null; case 'capture':