From 25e4ef7fb9db592c686fdef2a3d5184c0104c8c5 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Tue, 31 Mar 2009 14:20:10 +0000 Subject: [PATCH] - bugfix smarty.class and internal.security_handler - added compile_check configuration - added all setter/getter methodes --- change_log.txt | 5 +++ libs/Smarty.class.php | 16 ++++++---- libs/sysplugins/internal.debug.php | 4 --- libs/sysplugins/internal.security_handler.php | 4 +-- libs/sysplugins/internal.template.php | 2 +- .../sysplugins/method.disablecompilecheck.php | 25 +++++++++++++++ libs/sysplugins/method.disabledebugging.php | 25 +++++++++++++++ .../method.disabledebuggingurlctrl.php | 25 +++++++++++++++ libs/sysplugins/method.enablecompilecheck.php | 25 +++++++++++++++ libs/sysplugins/method.enabledebugging.php | 25 +++++++++++++++ .../method.enabledebuggingurlctrl.php | 25 +++++++++++++++ libs/sysplugins/method.getdebugtemplate.php | 31 ++++++++++++++++++ libs/sysplugins/method.setdebugtemplate.php | 32 +++++++++++++++++++ 13 files changed, 231 insertions(+), 13 deletions(-) create mode 100644 libs/sysplugins/method.disablecompilecheck.php create mode 100644 libs/sysplugins/method.disabledebugging.php create mode 100644 libs/sysplugins/method.disabledebuggingurlctrl.php create mode 100644 libs/sysplugins/method.enablecompilecheck.php create mode 100644 libs/sysplugins/method.enabledebugging.php create mode 100644 libs/sysplugins/method.enabledebuggingurlctrl.php create mode 100644 libs/sysplugins/method.getdebugtemplate.php create mode 100644 libs/sysplugins/method.setdebugtemplate.php diff --git a/change_log.txt b/change_log.txt index a4fd1604..e114ed86 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,8 @@ +03/31/2009 +- bugfix smarty.class and internal.security_handler +- added compile_check configuration +- added all setter/getter methodes + 03/30/2009 - added all major setter/getter methodes diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 9c5bae5d..27f49aa1 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -67,6 +67,8 @@ class Smarty extends Smarty_Internal_TemplateBase { public $config_dir = null; // force template compiling? public $force_compile = false; + // check template for modifications? + public $compile_check = true; // use sub dirs for compiled/cached files? public $use_sub_dirs = false; // php file extention @@ -93,14 +95,14 @@ class Smarty extends Smarty_Internal_TemplateBase { public $debugging = false; public $debugging_ctrl = 'URL'; public $smarty_debug_id = 'SMARTY_DEBUG'; - public $request_use_auto_globals = true; - public $debug_tpl = null; + public $debug_tpl = null; + public $request_use_auto_globals = true; // When set, smarty does uses this value as error_reporting-level. public $error_reporting = null; // config var settings public $config_overwrite = true; //Controls whether variables with the same name overwrite each other. public $config_booleanize = true; //Controls whether config values of on/true/yes and off/false/no get converted to boolean - public $config_read_hidden = true; //Controls whether hidden config sections/vars are read from the file. + public $config_read_hidden = true; //Controls whether hidden config sections/vars are read from the file. // config vars public $config_vars = array(); // assigned tpl vars @@ -168,7 +170,8 @@ class Smarty extends Smarty_Internal_TemplateBase { $this->plugins_dir = array(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR); $this->cache_dir = '.' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR; $this->config_dir = '.' . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR; - $this->sysplugins_dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'sysplugins' . DIRECTORY_SEPARATOR; + $this->sysplugins_dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'sysplugins' . DIRECTORY_SEPARATOR; + $this->debug_tpl = SMARTY_DIR . 'debug.tpl'; // set instance object self::instance($this); // load base plugins @@ -307,7 +310,7 @@ class Smarty extends Smarty_Internal_TemplateBase { $this->security_handler = new Smarty_Internal_Security_Handler(); $this->security = true; } else { - throw new Exception("Security policy {$security_definition} not found"); + throw new Exception("Security policy {$security_policy} not found"); } } @@ -324,7 +327,7 @@ class Smarty extends Smarty_Internal_TemplateBase { /** * Adds template directory(s) to existing ones * - * @param string|array $template_dir folder(s) of template sources + * @param string $ |array $template_dir folder(s) of template sources */ public function addTemplateDir($template_dir) { @@ -362,6 +365,7 @@ class Smarty extends Smarty_Internal_TemplateBase { } /** * Set caching life time + * * @param integer $lifetime lifetime of cached file in seconds */ public function setCachingLifetime($lifetime) diff --git a/libs/sysplugins/internal.debug.php b/libs/sysplugins/internal.debug.php index 76658eba..9ec38c99 100644 --- a/libs/sysplugins/internal.debug.php +++ b/libs/sysplugins/internal.debug.php @@ -20,10 +20,6 @@ class Smarty_Internal_Debug extends Smarty_Internal_TemplateBase { { $this->smarty = Smarty::instance(); - if (empty($this->smarty->debug_tpl)) { - // set path to debug template from SMARTY_DIR - $this->smarty->debug_tpl = SMARTY_DIR . 'debug.tpl'; - } // get template names $i = 0; $_template_data = array(); diff --git a/libs/sysplugins/internal.security_handler.php b/libs/sysplugins/internal.security_handler.php index 31140422..f8556117 100644 --- a/libs/sysplugins/internal.security_handler.php +++ b/libs/sysplugins/internal.security_handler.php @@ -59,7 +59,7 @@ class Smarty_Internal_Security_Handler extends Smarty_Internal_Base { foreach ((array)$this->smarty->template_dir as $curr_dir) { if (($_cd = realpath($curr_dir)) !== false && strncmp($_rp, $_cd, strlen($_cd)) == 0 && - substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR) { + (strlen($_rp) == strlen($_cd) || substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR)) { return true; } } @@ -70,7 +70,7 @@ class Smarty_Internal_Security_Handler extends Smarty_Internal_Base { if ($_cd == $_rp) { return true; } elseif (strncmp($_rp, $_cd, strlen($_cd)) == 0 && - substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR) { + (strlen($_rp) == strlen($_cd) || substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR)) { return true; } } diff --git a/libs/sysplugins/internal.template.php b/libs/sysplugins/internal.template.php index ac79ed0f..a5da15ad 100644 --- a/libs/sysplugins/internal.template.php +++ b/libs/sysplugins/internal.template.php @@ -199,7 +199,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { public function mustCompile () { if ($this->mustCompile === null) { - $this->mustCompile = ($this->usesCompiler() && ($this->force_compile || $this->isEvaluated() || $this->getCompiledTimestamp () !== $this->getTemplateTimestamp ())); + $this->mustCompile = ($this->usesCompiler() && ($this->force_compile || $this->isEvaluated() || ($this->smarty->compile_check && $this->getCompiledTimestamp () !== $this->getTemplateTimestamp ()))); // read compiled template if ($this->compiled_template !== true && file_exists($this->getCompiledFilepath())) { $this->compiled_template = !$this->isEvaluated() ? file_get_contents($this->getCompiledFilepath()):''; diff --git a/libs/sysplugins/method.disablecompilecheck.php b/libs/sysplugins/method.disablecompilecheck.php new file mode 100644 index 00000000..80c6f5f4 --- /dev/null +++ b/libs/sysplugins/method.disablecompilecheck.php @@ -0,0 +1,25 @@ +smarty->compile_check = false; + } +} + +?> diff --git a/libs/sysplugins/method.disabledebugging.php b/libs/sysplugins/method.disabledebugging.php new file mode 100644 index 00000000..984eb81d --- /dev/null +++ b/libs/sysplugins/method.disabledebugging.php @@ -0,0 +1,25 @@ +smarty->debugging = false; + } +} + +?> diff --git a/libs/sysplugins/method.disabledebuggingurlctrl.php b/libs/sysplugins/method.disabledebuggingurlctrl.php new file mode 100644 index 00000000..51bb47d8 --- /dev/null +++ b/libs/sysplugins/method.disabledebuggingurlctrl.php @@ -0,0 +1,25 @@ +smarty->debugging_ctrl = 'none'; + } +} + +?> diff --git a/libs/sysplugins/method.enablecompilecheck.php b/libs/sysplugins/method.enablecompilecheck.php new file mode 100644 index 00000000..ad98db48 --- /dev/null +++ b/libs/sysplugins/method.enablecompilecheck.php @@ -0,0 +1,25 @@ +smarty->compile_check = true; + } +} + +?> diff --git a/libs/sysplugins/method.enabledebugging.php b/libs/sysplugins/method.enabledebugging.php new file mode 100644 index 00000000..46d459da --- /dev/null +++ b/libs/sysplugins/method.enabledebugging.php @@ -0,0 +1,25 @@ +smarty->debugging = true; + } +} + +?> diff --git a/libs/sysplugins/method.enabledebuggingurlctrl.php b/libs/sysplugins/method.enabledebuggingurlctrl.php new file mode 100644 index 00000000..c47a666f --- /dev/null +++ b/libs/sysplugins/method.enabledebuggingurlctrl.php @@ -0,0 +1,25 @@ +smarty->debugging_ctrl = 'URL'; + } +} + +?> diff --git a/libs/sysplugins/method.getdebugtemplate.php b/libs/sysplugins/method.getdebugtemplate.php new file mode 100644 index 00000000..1f43febf --- /dev/null +++ b/libs/sysplugins/method.getdebugtemplate.php @@ -0,0 +1,31 @@ +smarty->debug_tpl; + } +} + +?> diff --git a/libs/sysplugins/method.setdebugtemplate.php b/libs/sysplugins/method.setdebugtemplate.php new file mode 100644 index 00000000..b9e9ab8a --- /dev/null +++ b/libs/sysplugins/method.setdebugtemplate.php @@ -0,0 +1,32 @@ +smarty->debug_tpl = $debug_tpl; + return; + } +} + +?>