From ae3c3fce48449fa9a75991a7390607935f0ecf1d Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Sun, 14 Jun 2009 11:07:26 +0000 Subject: [PATCH] - fixed array access on super globals - changed internal access to smarty object --- change_log.txt | 3 +++ libs/sysplugins/internal.compile_extend.php | 4 +-- libs/sysplugins/internal.compile_function.php | 2 +- .../internal.compile_functionclose.php | 4 +-- .../internal.compile_internal_smarty_var.php | 25 +++++++++++-------- libs/sysplugins/internal.compilebase.php | 1 - 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/change_log.txt b/change_log.txt index aca4f579..21760cc0 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +06/14/2009 +- fixed array access on super globals + 06/13/2009 - bugfix at extend resource: create unique files for compiled template and cache for each combination of template files - update extend resource to handle appen and prepend block attributes diff --git a/libs/sysplugins/internal.compile_extend.php b/libs/sysplugins/internal.compile_extend.php index 6de630dd..33d23add 100644 --- a/libs/sysplugins/internal.compile_extend.php +++ b/libs/sysplugins/internal.compile_extend.php @@ -35,7 +35,7 @@ class Smarty_Internal_Compile_Extend extends Smarty_Internal_CompileBase { $compiler->template->properties['file_dependency'][] = array($_template->getTemplateFilepath(), $_template->getTemplateTimestamp()); // $_old_source = preg_replace ('/' . $this->smarty->left_delimiter . 'extend\s+(?:file=)?\s*(\S+?|(["\']).+?\2)' . $this->smarty->right_delimiter . '/i', '' , $compiler->template->template_source, 1); $_old_source = $compiler->template->template_source; - $_old_source = preg_replace_callback('/(' . $this->smarty->left_delimiter . 'block(.+?)' . $this->smarty->right_delimiter . ')((?:\r?\n?)(.*?)(?:\r?\n?))(' . $this->smarty->left_delimiter . '\/block(.*?)' . $this->smarty->right_delimiter . ')/is', array($this, 'saveBlockData'), $_old_source); + $_old_source = preg_replace_callback('/(' . $this->compiler->smarty->left_delimiter . 'block(.+?)' . $this->compiler->smarty->right_delimiter . ')((?:\r?\n?)(.*?)(?:\r?\n?))(' . $this->compiler->smarty->left_delimiter . '\/block(.*?)' . $this->compiler->smarty->right_delimiter . ')/is', array($this, 'saveBlockData'), $_old_source); $compiler->template->template_source = $_template->getTemplateSource(); $compiler->abort_and_recompile = true; return ' '; @@ -47,7 +47,7 @@ class Smarty_Internal_Compile_Extend extends Smarty_Internal_CompileBase { $this->compiler->trigger_template_error("\"" . $matches[0] . "\" missing name attribute"); } else { // compile block content - $_tpl = $this->smarty->createTemplate('string:' . $matches[3]); + $_tpl = $this->compiler->smarty->createTemplate('string:' . $matches[3]); $_tpl->suppressHeader = true; $_compiled_content = $_tpl->getCompiledTemplate(); unset($_tpl); diff --git a/libs/sysplugins/internal.compile_function.php b/libs/sysplugins/internal.compile_function.php index 2946395b..33c23e13 100644 --- a/libs/sysplugins/internal.compile_function.php +++ b/libs/sysplugins/internal.compile_function.php @@ -33,7 +33,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase { $compiler->template->properties['function'][$_name]['parameter'][$_key] = $_data; } // make function known for recursive calls - $this->smarty->template_functions[$_name]['compiled'] = ''; + $this->compiler->smarty->template_functions[$_name]['compiled'] = ''; $compiler->template->extract_code = true; $compiler->template->extracted_compiled_code = ''; $compiler->template->has_code = false; diff --git a/libs/sysplugins/internal.compile_functionclose.php b/libs/sysplugins/internal.compile_functionclose.php index 80c6ca1a..2c614249 100644 --- a/libs/sysplugins/internal.compile_functionclose.php +++ b/libs/sysplugins/internal.compile_functionclose.php @@ -35,8 +35,8 @@ class Smarty_Internal_Compile_FunctionClose extends Smarty_Internal_CompileBase } $_name = trim($saved_data[0]['name'], "'"); $compiler->template->properties['function'][$_name]['compiled'] = str_replace("\n",'_%n',$compiler->template->extracted_compiled_code); - $this->smarty->template_functions[$_name]['compiled'] = $compiler->template->extracted_compiled_code; - $this->smarty->template_functions[$_name]['parameter'] = $compiler->template->properties['function'][$_name]['parameter']; + $this->compiler->smarty->template_functions[$_name]['compiled'] = $compiler->template->extracted_compiled_code; + $this->compiler->smarty->template_functions[$_name]['parameter'] = $compiler->template->properties['function'][$_name]['parameter']; $compiler->template->extracted_compiled_code = $saved_data[1]; $compiler->template->extract_code = $saved_data[2]; return true; diff --git a/libs/sysplugins/internal.compile_internal_smarty_var.php b/libs/sysplugins/internal.compile_internal_smarty_var.php index 2fb64706..d8c510d6 100644 --- a/libs/sysplugins/internal.compile_internal_smarty_var.php +++ b/libs/sysplugins/internal.compile_internal_smarty_var.php @@ -34,31 +34,31 @@ class Smarty_Internal_Compile_Internal_Smarty_Var extends Smarty_Internal_Compil return 'time()'; case 'get': - $compiled_ref = ($this->smarty->request_use_auto_globals) ? "\$_GET" : "\$GLOBALS['HTTP_GET_VARS']"; + $compiled_ref = ($compiler->smarty->request_use_auto_globals) ? "\$_GET" : "\$GLOBALS['HTTP_GET_VARS']"; break; case 'post': - $compiled_ref = ($this->smarty->request_use_auto_globals) ? "\$_POST" : "\$GLOBALS['HTTP_POST_VARS']"; + $compiled_ref = ($compiler->smarty->request_use_auto_globals) ? "\$_POST" : "\$GLOBALS['HTTP_POST_VARS']"; break; case 'cookies': - $compiled_ref = ($this->smarty->request_use_auto_globals) ? "\$_COOKIE" : "\$GLOBALS['HTTP_COOKIE_VARS']"; + $compiled_ref = ($compiler->smarty->request_use_auto_globals) ? "\$_COOKIE" : "\$GLOBALS['HTTP_COOKIE_VARS']"; break; case 'env': - $compiled_ref = ($this->smarty->request_use_auto_globals) ? "\$_ENV" : "\$GLOBALS['HTTP_ENV_VARS']"; + $compiled_ref = ($compiler->smarty->request_use_auto_globals) ? "\$_ENV" : "\$GLOBALS['HTTP_ENV_VARS']"; break; case 'server': - $compiled_ref = ($this->smarty->request_use_auto_globals) ? "\$_SERVER" : "\$GLOBALS['HTTP_SERVER_VARS']"; + $compiled_ref = ($compiler->smarty->request_use_auto_globals) ? "\$_SERVER" : "\$GLOBALS['HTTP_SERVER_VARS']"; break; case 'session': - $compiled_ref = ($this->smarty->request_use_auto_globals) ? "\$_SESSION" : "\$GLOBALS['HTTP_SESSION_VARS']"; + $compiled_ref = ($compiler->smarty->request_use_auto_globals) ? "\$_SESSION" : "\$GLOBALS['HTTP_SESSION_VARS']"; break; case 'request': - if ($this->smarty->request_use_auto_globals) { + if ($compiler->smarty->request_use_auto_globals) { $compiled_ref = "\$_REQUEST"; break; } @@ -72,7 +72,7 @@ class Smarty_Internal_Compile_Internal_Smarty_Var extends Smarty_Internal_Compil return "'$_version'"; case 'const': - if ($this->smarty->security && !$this->smarty->security_policy->allow_constants) { + if ($compiler->smarty->security && !$compiler->smarty->security_policy->allow_constants) { $compiler->trigger_template_error("(secure mode) constants not permitted"); break; } @@ -87,11 +87,11 @@ class Smarty_Internal_Compile_Internal_Smarty_Var extends Smarty_Internal_Compil return "''"; } case 'ldelim': - $_ldelim = $this->smarty->left_delimiter; + $_ldelim = $compiler->smarty->left_delimiter; return "'$_ldelim'"; case 'rdelim': - $_rdelim = $this->smarty->right_delimiter; + $_rdelim = $compiler->smarty->right_delimiter; return "'$_rdelim'"; default: @@ -99,7 +99,10 @@ class Smarty_Internal_Compile_Internal_Smarty_Var extends Smarty_Internal_Compil break; } if (isset($_index[1])) { - $compiled_ref = $compiled_ref . "[$_index[1]]"; + array_shift($_index); + foreach ($_index as $_ind) { + $compiled_ref = $compiled_ref . "[$_ind]"; + } } return $compiled_ref; } diff --git a/libs/sysplugins/internal.compilebase.php b/libs/sysplugins/internal.compilebase.php index 4bb1e51f..f6cea7bf 100644 --- a/libs/sysplugins/internal.compilebase.php +++ b/libs/sysplugins/internal.compilebase.php @@ -25,7 +25,6 @@ abstract class Smarty_Internal_CompileBase */ function __construct() { - $this->smarty = Smarty::instance(); // initialize valid attributes $this->required_attributes = array(); $this->optional_attributes = array();