- bugfix smarty.class and internal.security_handler

- added compile_check configuration 
- added all setter/getter methodes
This commit is contained in:
Uwe.Tews
2009-03-31 14:20:10 +00:00
parent c9bbd7e834
commit 25e4ef7fb9
13 changed files with 231 additions and 13 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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();

View File

@@ -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;
}
}

View File

@@ -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()):'';

View File

@@ -0,0 +1,25 @@
<?php
/**
* Smarty method disableCompileCheck
*
* Disable compile checking
*
* @package Smarty
* @subpackage SmartyMethod
* @author Uwe Tews
*/
/**
* Smarty class disableCompileCheck
*
* Disable compile checking
*/
class Smarty_Method_DisableCompileCheck extends Smarty_Internal_Base {
public function execute()
{
return $this->smarty->compile_check = false;
}
}
?>

View File

@@ -0,0 +1,25 @@
<?php
/**
* Smarty method disableDebugging
*
* Disable debugging
*
* @package Smarty
* @subpackage SmartyMethod
* @author Uwe Tews
*/
/**
* Smarty class disableDebugging
*
* Disable debugging
*/
class Smarty_Method_DisableDebugging extends Smarty_Internal_Base {
public function execute()
{
return $this->smarty->debugging = false;
}
}
?>

View File

@@ -0,0 +1,25 @@
<?php
/**
* Smarty method disableDebuggingUrlCtrl
*
* Disable possibility to Disable debugging by SMARTY_DEBUG attribute
*
* @package Smarty
* @subpackage SmartyMethod
* @author Uwe Tews
*/
/**
* Smarty class disableDebuggingUrlCtrl
*
* Disable possibility to Disable debugging by SMARTY_DEBUG attribute
*/
class Smarty_Method_disableDebuggingUrlCtrl extends Smarty_Internal_Base {
public function execute()
{
return $this->smarty->debugging_ctrl = 'none';
}
}
?>

View File

@@ -0,0 +1,25 @@
<?php
/**
* Smarty method enableCompileCheck
*
* Enable compile checking
*
* @package Smarty
* @subpackage SmartyMethod
* @author Uwe Tews
*/
/**
* Smarty class enableCompileCheck
*
* Enable compile checking
*/
class Smarty_Method_EnableCompileCheck extends Smarty_Internal_Base {
public function execute()
{
return $this->smarty->compile_check = true;
}
}
?>

View File

@@ -0,0 +1,25 @@
<?php
/**
* Smarty method enableDebugging
*
* Enable debugging
*
* @package Smarty
* @subpackage SmartyMethod
* @author Uwe Tews
*/
/**
* Smarty class enableDebugging
*
* Enable debugging
*/
class Smarty_Method_EnableDebugging extends Smarty_Internal_Base {
public function execute()
{
return $this->smarty->debugging = true;
}
}
?>

View File

@@ -0,0 +1,25 @@
<?php
/**
* Smarty method enableDebuggingUrlCtrl
*
* Enable possibility to enable debugging by SMARTY_DEBUG attribute
*
* @package Smarty
* @subpackage SmartyMethod
* @author Uwe Tews
*/
/**
* Smarty class enableDebuggingUrlCtrl
*
* Enable possibility to enable debugging by SMARTY_DEBUG attribute
*/
class Smarty_Method_EnableDebuggingUrlCtrl extends Smarty_Internal_Base {
public function execute()
{
return $this->smarty->debugging_ctrl = 'URL';
}
}
?>

View File

@@ -0,0 +1,31 @@
<?php
/**
* Smarty method getDebugTemplate
*
* Returns debug template filepath
*
* @package Smarty
* @subpackage SmartyMethod
* @author Uwe Tews
*/
/**
* Smarty class getDebugTemplate
*
* Returns debug template filepath
*/
class Smarty_Method_GetDebugTemplate extends Smarty_Internal_Base {
/**
* Returns directory of cache files
*
* @return string debug template filepath
*/
public function execute()
{
return $this->smarty->debug_tpl;
}
}
?>

View File

@@ -0,0 +1,32 @@
<?php
/**
* Smarty method setDebugTemplate
*
* Sets debug template filepath
*
* @package Smarty
* @subpackage SmartyMethod
* @author Uwe Tews
*/
/**
* Smarty class setDebugTemplate
*
* Sets debug template filepath
*/
class Smarty_Method_SetDebugTemplate extends Smarty_Internal_Base {
/**
* Sets debug template filepath
*
* @param string $ array debug template filepath
*/
public function execute($debug_tpl)
{
$this->smarty->debug_tpl = $debug_tpl;
return;
}
}
?>