Update smarty from 3.0.5 to 3.0.7

See http://smarty-php.googlecode.com/svn/trunk/distribution/change_log.txt
for a list of all changes.

New files:
libs/sysplugins/smarty_internal_get_include_path.php
libs/plugins/shared.mb_str_replace.php

Deleted files (no longer shipped with smarty):
libs/plugins/function.popup.php
libs/plugins/function.popup_init.php


git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@972 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 14 years ago
parent 476035efd1
commit 82778dba1e

@ -3,7 +3,7 @@
/**
* Project: Smarty: the PHP compiling template engine
* File: Smarty.class.php
* SVN: $Id: Smarty.class.php 3794 2010-11-15 22:54:59Z uwe.tews@googlemail.com $
* SVN: $Id: Smarty.class.php 3895 2010-12-31 13:47:12Z uwe.tews@googlemail.com $
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -28,7 +28,7 @@
* @author Monte Ohrt <monte at ohrt dot com>
* @author Uwe Tews
* @package Smarty
* @version 3.0.5
* @version 3.0.7
*/
/**
@ -87,7 +87,7 @@ class Smarty extends Smarty_Internal_Data {
* constant definitions
*/
// smarty version
const SMARTY_VERSION = 'Smarty-3.0.5';
const SMARTY_VERSION = 'Smarty-3.0.7';
//define variable scopes
const SCOPE_LOCAL = 0;
const SCOPE_PARENT = 1;
@ -167,7 +167,7 @@ class Smarty extends Smarty_Internal_Data {
public $security_class = 'Smarty_Security';
public $security_policy = null;
public $php_handling = self::PHP_PASSTHRU;
public $allow_php_tag = true;
public $allow_php_tag = false;
public $allow_php_templates = false;
public $direct_access_security = true;
public $trusted_dir = array();
@ -181,7 +181,7 @@ class Smarty extends Smarty_Internal_Data {
// 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 = false; //Controls whether hidden config sections/vars are read from the file.
// config vars
public $config_vars = array();
// assigned tpl vars
@ -238,6 +238,8 @@ class Smarty extends Smarty_Internal_Data {
public $deprecation_notices = true;
// Smarty 2 BC
public $_version = self::SMARTY_VERSION;
// self pointer to Smarty object
public $smarty;
/**
* Class constructor, initializes basic smarty properties
@ -257,31 +259,6 @@ class Smarty extends Smarty_Internal_Data {
$this->cache_dir = '.' . DS . 'cache' . DS;
$this->config_dir = '.' . DS . 'configs' . DS;
$this->debug_tpl = SMARTY_DIR . 'debug.tpl';
if (!$this->debugging && $this->debugging_ctrl == 'URL') {
if (isset($_SERVER['QUERY_STRING'])) {
$_query_string = $_SERVER['QUERY_STRING'];
} else {
$_query_string = '';
}
if (false !== strpos($_query_string, $this->smarty_debug_id)) {
if (false !== strpos($_query_string, $this->smarty_debug_id . '=on')) {
// enable debugging for this browser session
setcookie('SMARTY_DEBUG', true);
$this->debugging = true;
} elseif (false !== strpos($_query_string, $this->smarty_debug_id . '=off')) {
// disable debugging for this browser session
setcookie('SMARTY_DEBUG', false);
$this->debugging = false;
} else {
// enable debugging for this page
$this->debugging = true;
}
} else {
if (isset($_COOKIE['SMARTY_DEBUG'])) {
$this->debugging = true;
}
}
}
if (isset($_SERVER['SCRIPT_NAME'])) {
$this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
}
@ -315,10 +292,36 @@ class Smarty extends Smarty_Internal_Data {
}
// create template object if necessary
($template instanceof $this->template_class)? $_template = $template :
$_template = $this->createTemplate ($template, $cache_id, $compile_id, $parent);
$_template = $this->createTemplate ($template, $cache_id, $compile_id, $parent, false);
if (isset($this->error_reporting)) {
$_smarty_old_error_level = error_reporting($this->error_reporting);
}
// check URL debugging control
if (!$this->debugging && $this->debugging_ctrl == 'URL') {
if (isset($_SERVER['QUERY_STRING'])) {
$_query_string = $_SERVER['QUERY_STRING'];
} else {
$_query_string = '';
}
if (false !== strpos($_query_string, $this->smarty_debug_id)) {
if (false !== strpos($_query_string, $this->smarty_debug_id . '=on')) {
// enable debugging for this browser session
setcookie('SMARTY_DEBUG', true);
$this->debugging = true;
} elseif (false !== strpos($_query_string, $this->smarty_debug_id . '=off')) {
// disable debugging for this browser session
setcookie('SMARTY_DEBUG', false);
$this->debugging = false;
} else {
// enable debugging for this page
$this->debugging = true;
}
} else {
if (isset($_COOKIE['SMARTY_DEBUG'])) {
$this->debugging = true;
}
}
}
// obtain data for cache modified check
if ($this->cache_modified_check && $this->caching && $display) {
$_isCached = $_template->isCached() && !$_template->has_nocache_code;
@ -328,8 +331,8 @@ class Smarty extends Smarty_Internal_Data {
$_gmt_mtime = '';
}
}
// return redered template
if (isset($this->autoload_filters['output']) || isset($this->registered_filters['output'])) {
// return rendered template
if ((!$this->caching || $_template->resource_object->isEvaluated) && (isset($this->autoload_filters['output']) || isset($this->registered_filters['output']))) {
$_output = Smarty_Internal_Filter_Handler::runFilter('output', $_template->getRenderedTemplate(), $_template);
} else {
$_output = $_template->getRenderedTemplate();
@ -394,7 +397,7 @@ class Smarty extends Smarty_Internal_Data {
$parent = $this;
}
if (!($template instanceof $this->template_class)) {
$template = $this->createTemplate ($template, $cache_id, $compile_id, $parent);
$template = $this->createTemplate ($template, $cache_id, $compile_id, $parent, false);
}
// return cache status of template
return $template->isCached();
@ -415,12 +418,13 @@ class Smarty extends Smarty_Internal_Data {
* creates a template object
*
* @param string $template the resource handle of the template file
* @param object $parent next higher level of Smarty variables
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
* @param object $parent next higher level of Smarty variables
* @param boolean $do_clone flag is Smarty object shall be cloned
* @returns object template object
*/
public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null)
public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true)
{
if (!empty($cache_id) && (is_object($cache_id) || is_array($cache_id))) {
$parent = $cache_id;
@ -441,7 +445,11 @@ class Smarty extends Smarty_Internal_Data {
$tpl = $this->template_objects[$_templateId];
} else {
// create new template object
if ($do_clone) {
$tpl = new $this->template_class($template, clone $this, $parent, $cache_id, $compile_id);
} else {
$tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id);
}
}
} else {
// just return a copy of template class

@ -86,8 +86,9 @@ td {
</head>
<body>
<h1>Smarty Debug Console - Total Time {$execution_time|string_format:"%.5f"}</h1>
<h1>Smarty Debug Console - {if isset($template_name)}{$template_name|debug_print_var}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}</h1>
{if !empty($template_data)}
<h2>included templates &amp; config files (load time in seconds)</h2>
<div>
@ -99,6 +100,7 @@ td {
<br>
{/foreach}
</div>
{/if}
<h2>assigned template variables</h2>
@ -124,13 +126,8 @@ td {
</html>
{/capture}
<script type="text/javascript">
{literal} if ( self.name == '' ) {
var title = 'Console';
}
else {
var title = 'Console_' + self.name;
}{/literal}
_smarty_console = window.open("",title.value,"width=680,height=600,resizable,scrollbars=yes");
{$id = $template_name|default:''|md5}
_smarty_console = window.open("","console{$id}","width=680,height=600,resizable,scrollbars=yes");
_smarty_console.document.write("{$debug_output|escape:'javascript'}");
_smarty_console.document.close();
</script>

@ -37,12 +37,17 @@ function smarty_function_html_options($params, $template)
$options = null;
$selected = array();
$output = null;
$id = null;
$class = null;
$extra = '';
$options_extra = '';
foreach($params as $_key => $_val) {
switch ($_key) {
case 'name':
case 'class':
case 'id':
$$_key = (string)$_val;
break;
@ -74,43 +79,52 @@ function smarty_function_html_options($params, $template)
/* raise error here? */
$_html_result = '';
$_idx = 0;
if (isset($options)) {
foreach ($options as $_key => $_val)
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
foreach ($options as $_key => $_val) {
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx);
}
} else {
foreach ($values as $_i => $_key) {
$_val = isset($output[$_i]) ? $output[$_i] : '';
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx);
}
}
if (!empty($name)) {
$_html_result = '<select name="' . $name . '"' . $extra . '>' . "\n" . $_html_result . '</select>' . "\n";
$_html_class = !empty($class) ? ' class="'.$class.'"' : '';
$_html_id = !empty($id) ? ' id="'.$id.'"' : '';
$_html_result = '<select name="' . $name . '"' . $_html_class . $_html_id . $extra . '>' . "\n" . $_html_result . '</select>' . "\n";
}
return $_html_result;
}
function smarty_function_html_options_optoutput($key, $value, $selected)
function smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, &$idx)
{
if (!is_array($value)) {
$_html_result = '<option value="' .
smarty_function_escape_special_chars($key) . '"';
if (in_array((string)$key, $selected))
$_html_result .= ' selected="selected"';
$_html_result .= '>' . smarty_function_escape_special_chars($value) . '</option>' . "\n";
$_html_class = !empty($class) ? ' class="'.$class.' option"' : '';
$_html_id = !empty($id) ? ' id="'.$id.'-'.$idx.'"' : '';
$_html_result .= $_html_class . $_html_id . '>' . smarty_function_escape_special_chars($value) . '</option>' . "\n";
$idx++;
} else {
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected);
$_idx = 0;
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected, $id.'-'.$idx, $class, $_idx);
$idx++;
}
return $_html_result;
}
function smarty_function_html_options_optgroup($key, $values, $selected)
function smarty_function_html_options_optgroup($key, $values, $selected, $id, $class, &$idx)
{
$optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n";
foreach ($values as $key => $value) {
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected);
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, $idx);
}
$optgroup_html .= "</optgroup>\n";
return $optgroup_html;

@ -1,118 +0,0 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {popup} function plugin
*
* Type: function<br>
* Name: popup<br>
* Purpose: make text pop up in windows via overlib
* @link http://smarty.php.net/manual/en/language.function.popup.php {popup}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param array $params parameters
* @param object $template template object
* @return string
*/
function smarty_function_popup($params, $template)
{
$append = '';
foreach ($params as $_key=>$_value) {
switch ($_key) {
case 'text':
case 'trigger':
case 'function':
case 'inarray':
$$_key = (string)$_value;
if ($_key == 'function' || $_key == 'inarray')
$append .= ',' . strtoupper($_key) . ",'$_value'";
break;
case 'caption':
case 'closetext':
case 'status':
$append .= ',' . strtoupper($_key) . ",'" . str_replace("'","\'",$_value) . "'";
break;
case 'fgcolor':
case 'bgcolor':
case 'textcolor':
case 'capcolor':
case 'closecolor':
case 'textfont':
case 'captionfont':
case 'closefont':
case 'fgbackground':
case 'bgbackground':
case 'caparray':
case 'capicon':
case 'background':
case 'frame':
$append .= ',' . strtoupper($_key) . ",'$_value'";
break;
case 'textsize':
case 'captionsize':
case 'closesize':
case 'width':
case 'height':
case 'border':
case 'offsetx':
case 'offsety':
case 'snapx':
case 'snapy':
case 'fixx':
case 'fixy':
case 'padx':
case 'pady':
case 'timeout':
case 'delay':
$append .= ',' . strtoupper($_key) . ",$_value";
break;
case 'sticky':
case 'left':
case 'right':
case 'center':
case 'above':
case 'below':
case 'noclose':
case 'autostatus':
case 'autostatuscap':
case 'fullhtml':
case 'hauto':
case 'vauto':
case 'mouseoff':
case 'followmouse':
case 'closeclick':
case 'wrap':
if ($_value) $append .= ',' . strtoupper($_key);
break;
default:
trigger_error("[popup] unknown parameter $_key", E_USER_WARNING);
}
}
if (empty($text) && !isset($inarray) && empty($function)) {
trigger_error("overlib: attribute 'text' or 'inarray' or 'function' required",E_USER_WARNING);
return false;
}
if (empty($trigger)) { $trigger = "onmouseover"; }
$retval = $trigger . '="return overlib(\''.preg_replace(array("!'!",'!"!',"![\r\n]!"),array("\'","\'",'\r'),$text).'\'';
$retval .= $append . ');"';
if ($trigger == 'onmouseover')
$retval .= ' onmouseout="nd();"';
return $retval;
}
?>

@ -1,39 +0,0 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {popup_init} function plugin
*
* Type: function<br>
* Name: popup_init<br>
* Purpose: initialize overlib
* @link http://smarty.php.net/manual/en/language.function.popup.init.php {popup_init}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param array $params parameters
* @param object $template template object
* @return string
*/
function smarty_function_popup_init($params, $template)
{
$zindex = 1000;
if (!empty($params['zindex'])) {
$zindex = $params['zindex'];
}
if (!empty($params['src'])) {
return '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:'.$zindex.';"></div>' . "\n"
. '<script type="text/javascript" language="JavaScript" src="'.$params['src'].'"></script>' . "\n";
} else {
trigger_error("popup_init: missing src parameter",E_USER_WARNING);
}
}
?>

@ -22,25 +22,6 @@
*/
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = SMARTY_RESOURCE_CHAR_SET)
{
if (!function_exists('mb_str_replace')) {
// simulate the missing PHP mb_str_replace function
function mb_str_replace($needles, $replacements, $haystack)
{
$rep = (array)$replacements;
foreach ((array)$needles as $key => $needle) {
$replacement = $rep[$key];
$needle_len = mb_strlen($needle);
$replacement_len = mb_strlen($replacement);
$pos = mb_strpos($haystack, $needle, 0);
while ($pos !== false) {
$haystack = mb_substr($haystack, 0, $pos) . $replacement
. mb_substr($haystack, $pos + $needle_len);
$pos = mb_strpos($haystack, $needle, $pos + $replacement_len);
}
}
return $haystack;
}
}
switch ($esc_type) {
case 'html':
return htmlspecialchars($string, ENT_QUOTES, $char_set);
@ -85,12 +66,8 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = SMARTY_
return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\/'));
case 'mail':
// safe way to display e-mail address on a web page
if (function_exists('mb_substr')) {
return mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
} else {
return str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
}
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
case 'nonstd':
// escape non-standard chars, such as ms document quotes

@ -22,30 +22,8 @@
*/
function smarty_modifier_replace($string, $search, $replace)
{
if (!function_exists('mb_str_replace')) {
// simulate the missing PHP mb_str_replace function
function mb_str_replace($needles, $replacements, $haystack)
{
$rep = (array)$replacements;
foreach ((array)$needles as $key => $needle) {
$replacement = $rep[$key];
$needle_len = mb_strlen($needle);
$replacement_len = mb_strlen($replacement);
$pos = mb_strpos($haystack, $needle, 0);
while ($pos !== false) {
$haystack = mb_substr($haystack, 0, $pos) . $replacement
. mb_substr($haystack, $pos + $needle_len);
$pos = mb_strpos($haystack, $needle, $pos + $replacement_len);
}
}
return $haystack;
}
}
if (function_exists('mb_substr')) {
return mb_str_replace($search, $replace, $string);
} else {
return str_replace($search, $replace, $string);
}
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
return smarty_mb_str_replace($search, $replace, $string);
}
?>

@ -22,7 +22,7 @@ function smarty_make_timestamp($string)
return time();
} elseif ($string instanceof DateTime) {
return $string->getTimestamp();
} elseif (preg_match('/^\d{14}$/', $string)) {
} elseif (strlen($string)==14 && ctype_digit($string)) {
// it is mysql timestamp format of YYYYMMDDHHMMSS?
return mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2),
substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4));

@ -0,0 +1,38 @@
<?php
if(!function_exists('smarty_mb_str_replace')) {
function smarty_mb_str_replace($search, $replace, $subject, &$count=0) {
if (!is_array($search) && is_array($replace)) {
return false;
}
if (is_array($subject)) {
// call mb_replace for each single string in $subject
foreach ($subject as &$string) {
$string = &smarty_mb_str_replace($search, $replace, $string, $c);
$count += $c;
}
} elseif (is_array($search)) {
if (!is_array($replace)) {
foreach ($search as &$string) {
$subject = smarty_mb_str_replace($string, $replace, $subject, $c);
$count += $c;
}
} else {
$n = max(count($search), count($replace));
while ($n--) {
$subject = smarty_mb_str_replace(current($search), current($replace), $subject, $c);
$count += $c;
next($search);
next($replace);
}
}
} else {
$parts = mb_split(preg_quote($search), $subject);
$count = count($parts)-1;
$subject = implode($replace, $parts);
}
return $subject;
}
}
?>

@ -13,10 +13,6 @@
* Smarty Internal Plugin Compile Append Class
*/
class Smarty_Internal_Compile_Append extends Smarty_Internal_Compile_Assign {
// attribute definitions
public $required_attributes = array('var', 'value');
public $shorttag_order = array('var', 'value');
public $optional_attributes = array('scope', 'index');
/**
* Compiles code for the {append} tag
@ -29,6 +25,10 @@ class Smarty_Internal_Compile_Append extends Smarty_Internal_Compile_Assign {
public function compile($args, $compiler, $parameter)
{
$this->compiler = $compiler;
// the following must be assigned at runtime because it will be overwritten in parent class
$this->required_attributes = array('var', 'value');
$this->shorttag_order = array('var', 'value');
$this->optional_attributes = array('scope','index');
// check and get attributes
$_attr = $this->_get_attributes($args);
// map to compile assign attributes

@ -25,6 +25,7 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase {
public function compile($args, $compiler, $parameter)
{
$this->compiler = $compiler;
// the following must be assigned at runtime because it will be overwritten in Smarty_Internal_Compile_Append
$this->required_attributes = array('var', 'value');
$this->shorttag_order = array('var', 'value');
$this->optional_attributes = array('scope');

@ -96,10 +96,12 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
$stack_count = count($compiler->_tag_stack);
while (--$stack_count >= 0) {
if ($compiler->_tag_stack[$stack_count][0] == 'block') {
$_name = trim($compiler->_tag_stack[$stack_count][1][0]['name'] ,"'");
$_name = trim($compiler->_tag_stack[$stack_count][1][0]['name'] ,"'\"");
break;
}
}
// flag that child is already compile by {$smarty.block.child} inclusion
$compiler->template->block_data[$_name]['compiled'] = true;
}
if ($_name == null) {
$compiler->trigger_template_error('{$smarty.block.child} used out of context', $this->compiler->lex->taglineno);
@ -141,7 +143,6 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase {
}
}
unset($_tpl);
$compiler->template->block_data[$_name]['compiled'] = true;
return $_output;
}

@ -40,6 +40,9 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase {
$_smarty_tpl = $compiler->template;
$include_file = null;
if (strpos($_attr['file'],'$_tmp') !== false) {
$this->compiler->trigger_template_error('illegal value for file attribute', $this->compiler->lex->taglineno);
}
eval('$include_file = ' . $_attr['file'] . ';');
// create template object
$_template = new $compiler->smarty->template_class($include_file, $this->smarty, $compiler->template);

@ -42,8 +42,10 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase {
$_name = trim($_attr['name'], "'\"");
unset($_attr['name']);
$compiler->template->properties['function'][$_name]['parameter'] = array();
$_smarty_tpl = $compiler->template;
foreach ($_attr as $_key => $_data) {
$compiler->template->properties['function'][$_name]['parameter'][$_key] = $_data;
eval ('$tmp='.$_data.';');
$compiler->template->properties['function'][$_name]['parameter'][$_key] = $tmp;
}
$compiler->smarty->template_functions[$_name]['parameter'] = $compiler->template->properties['function'][$_name]['parameter'];
if ($compiler->template->caching) {
@ -52,7 +54,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase {
$output = "<?php if (!function_exists('smarty_template_function_{$_name}')) {
function smarty_template_function_{$_name}(\$_smarty_tpl,\$params) {
\$saved_tpl_vars = \$_smarty_tpl->tpl_vars;
foreach (\$_smarty_tpl->template_functions['{$_name}']['parameter'] as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(trim(\$value,'\''));};
foreach (\$_smarty_tpl->template_functions['{$_name}']['parameter'] as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);};
foreach (\$params as \$key => \$value) {\$_smarty_tpl->tpl_vars[\$key] = new Smarty_variable(\$value);}?>";
}
// Init temporay context

@ -31,14 +31,23 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase {
$this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache;
if (is_array($parameter['if condition'])) {
if ($this->compiler->nocache) {
$_nocache = '(null,true)';
$_nocache = ',true';
// create nocache var to make it know for further compiling
if (is_array($parameter['if condition']['var'])) {
$this->compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_variable(null, true);
} else {
$this->compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_variable(null, true);
}
} else {
$_nocache = '';
}
$_output = "<?php \$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."] = new Smarty_Variable{$_nocache};";
if (is_array($parameter['if condition']['var'])) {
$_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]) || !is_array(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value)) \$_smarty_tpl->createLocalArrayVariable(".$parameter['if condition']['var']['var']."$_nocache);\n";
$_output .= "if (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value".$parameter['if condition']['var']['smarty_internal_index']." = ".$parameter['if condition']['value']."){?>";
} else {
$_output = "<?php \$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."] = new Smarty_Variable(\$_smarty_tpl->getVariable(".$parameter['if condition']['var'].",null,true,false)->value{$_nocache});";
$_output .= "if (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."]->value = ".$parameter['if condition']['value']."){?>";
}
return $_output;
} else {
return "<?php if ({$parameter['if condition']}){?>";
@ -91,9 +100,13 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {
if (is_array($parameter['if condition'])) {
$condition_by_assign = true;
if ($this->compiler->nocache) {
$_nocache = '(null,true)';
$_nocache = ',true';
// create nocache var to make it know for further compiling
if (is_array($parameter['if condition']['var'])) {
$this->compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_variable(null, true);
} else {
$this->compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_variable(null, true);
}
} else {
$_nocache = '';
}
@ -104,8 +117,13 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {
if (empty($this->compiler->prefix_code)) {
if ($condition_by_assign) {
$this->_open_tag('elseif', array($nesting + 1, $compiler->tag_nocache));
$_output = "<?php }else{ \$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."] = new Smarty_Variable{$_nocache};";
if (is_array($parameter['if condition']['var'])) {
$_output = "<?php }else{ if (!isset(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]) || !is_array(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value)) \$_smarty_tpl->createLocalArrayVariable(".$parameter['if condition']['var']['var']."$_nocache);\n";
$_output .= "if (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value".$parameter['if condition']['var']['smarty_internal_index']." = ".$parameter['if condition']['value']."){?>";
} else {
$_output = "<?php }else{ \$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."] = new Smarty_Variable(\$_smarty_tpl->getVariable(".$parameter['if condition']['var'].",null,true,false)->value{$_nocache});";
$_output .= "if (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."]->value = ".$parameter['if condition']['value']."){?>";
}
return $_output;
} else {
$this->_open_tag('elseif', array($nesting, $compiler->tag_nocache));
@ -117,8 +135,13 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {
$this->compiler->prefix_code = array();
$this->_open_tag('elseif', array($nesting + 1, $compiler->tag_nocache));
if ($condition_by_assign) {
$_output = "<?php }else{?>{$tmp}<?php \$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."] = new Smarty_Variable{$_nocache};";
if (is_array($parameter['if condition']['var'])) {
$_output = "<?php }else{?>{$tmp}<?php if (!isset(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]) || !is_array(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value)) \$_smarty_tpl->createLocalArrayVariable(".$parameter['if condition']['var']['var']."$_nocache);\n";
$_output .= "if (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value".$parameter['if condition']['var']['smarty_internal_index']." = ".$parameter['if condition']['value']."){?>";
} else {
$_output = "<?php }else{?>{$tmp}<?php \$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."] = new Smarty_Variable(\$_smarty_tpl->getVariable(".$parameter['if condition']['var'].",null,true,false)->value{$_nocache});";
$_output .= "if (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."]->value = ".$parameter['if condition']['value']."){?>";
}
return $_output;
} else {
return "<?php }else{?>{$tmp}<?php if ({$parameter['if condition']}){?>";

@ -163,9 +163,11 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
$_output .= "<?php \$_smarty_tpl = array_pop(\$_tpl_stack);?>";
} else {
$_output .= " echo \$_template->getRenderedTemplate();?>";
if ($_parent_scope != Smarty::SCOPE_LOCAL) {
$_output .= "<?php \$_template->updateParentVariables($_parent_scope);?>";
}
}
}
$_output .= "<?php unset(\$_template);?>";
return $_output;
}

@ -41,6 +41,9 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
foreach ($_attr as $_key => $_value) {
if (is_int($_key)) {
$_paramsArray[] = "$_key=>$_value";
} elseif ($this->compiler->template->caching && in_array($_key,$compiler->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$tag][2])) {
$_value = str_replace("'","^#^",$_value);
$_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^";
} else {
$_paramsArray[] = "'$_key'=>$_value";
}

@ -43,6 +43,9 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
foreach ($_attr as $_key => $_value) {
if (is_int($_key)) {
$_paramsArray[] = "$_key=>$_value";
} elseif ($this->compiler->template->caching && in_array($_key,$compiler->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag][2])) {
$_value = str_replace("'","^#^",$_value);
$_paramsArray[] = "'$_key'=>^#^.var_export($_value,true).^#^";
} else {
$_paramsArray[] = "'$_key'=>$_value";
}

@ -56,22 +56,10 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
break;
case 'template':
if ($compiler->smarty->inheritance) {
$ptr = $compiler->template->parent;
} else {
$ptr = $compiler->template;
}
$_template_name = $ptr->template_resource;
return "'$_template_name'";
return 'basename($_smarty_tpl->getTemplateFilepath())';
case 'current_dir':
if ($compiler->smarty->inheritance) {
$ptr = $compiler->template->parent;
} else {
$ptr = $compiler->template;
}
$_template_dir_name = dirname($ptr->getTemplateFilepath());
return "'$_template_dir_name'";
return 'dirname($_smarty_tpl->getTemplateFilepath())';
case 'version':
$_version = Smarty::SMARTY_VERSION;

@ -30,14 +30,28 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase {
// maybe nocache because of nocache variables
$this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache;
if (is_array($parameter['if condition'])) {
$_output = " <?php if (!isset(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."])) \$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."] = new Smarty_Variable;\n";
$_output .= " while (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."]->value = ".$parameter['if condition']['value'].") {\n ?>";
if ($this->compiler->nocache) {
$_nocache = ',true';
// create nocache var to make it know for further compiling
if (is_array($parameter['if condition']['var'])) {
$this->compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_variable(null, true);
} else {
$this->compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_variable(null, true);
}
} else {
$_nocache = '';
}
if (is_array($parameter['if condition']['var'])) {
$_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]) || !is_array(\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value)) \$_smarty_tpl->createLocalArrayVariable(".$parameter['if condition']['var']['var']."$_nocache);\n";
$_output .= "while (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value".$parameter['if condition']['var']['smarty_internal_index']." = ".$parameter['if condition']['value']."){?>";
} else {
$_output = "<?php \$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."] = new Smarty_Variable(\$_smarty_tpl->getVariable(".$parameter['if condition']['var'].",null,true,false)->value{$_nocache});";
$_output .= "while (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."]->value = ".$parameter['if condition']['value']."){?>";
}
return $_output;
} else {
return '<?php while (' . $parameter['if condition'] . ') { ?>';
return "<?php while ({$parameter['if condition']}){?>";
}
}
}

@ -71,7 +71,8 @@ class Smarty_Internal_CompileBase {
}
// must be named attribute
} else {
$_indexed_attr = array_merge($_indexed_attr, $mixed);
reset($mixed);
$_indexed_attr[key($mixed)] = $mixed[key($mixed)];
}
}
}

@ -7,7 +7,6 @@
* @subpackage Config
* @author Uwe Tews
*/
/**
* Smarty Internal Plugin Configfilelexer
*/
@ -85,7 +84,7 @@ class Smarty_Internal_Configfilelexer
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
$yy_global_pattern = "/^(#)|^(\\[)|^(\\])|^(=)|^([ \t\r]+)|^(\n)|^([0-9]*[a-zA-Z_]\\w*)/";
$yy_global_pattern = "/^(#)|^(\\[)|^(\\])|^(=)|^([ \t\r]+)|^(\n)|^([0-9]*[a-zA-Z_]\\w*)/iS";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
@ -192,7 +191,7 @@ class Smarty_Internal_Configfilelexer
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
$yy_global_pattern = "/^([ \t\r]+)|^(\\d+\\.\\d+(?=[ \t\r]*[\n#]))|^(\\d+(?=[ \t\r]*[\n#]))|^('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#]))|^(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#]))|^(\"\"\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"\"\"(?=[ \t\r]*[\n#]))|^([a-zA-Z]+(?=[ \t\r]*[\n#]))|^([^\n]+?(?=[ \t\r]*\n))|^(\n)/";
$yy_global_pattern = "/^([ \t\r]+)|^(\\d+\\.\\d+(?=[ \t\r]*[\n#]))|^(\\d+(?=[ \t\r]*[\n#]))|^('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#]))|^(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#]))|^(\"\"\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"\"\"(?=[ \t\r]*[\n#]))|^([a-zA-Z]+(?=[ \t\r]*[\n#]))|^([^\n]+?(?=[ \t\r]*\n))|^(\n)/iS";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
@ -313,7 +312,7 @@ class Smarty_Internal_Configfilelexer
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
$yy_global_pattern = "/^([^\n]+?(?=[ \t\r]*\n))/";
$yy_global_pattern = "/^([^\n]+?(?=[ \t\r]*\n))/iS";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
@ -382,7 +381,7 @@ class Smarty_Internal_Configfilelexer
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
$yy_global_pattern = "/^([ \t\r]+)|^([^\n]+?(?=[ \t\r]*\n))|^(\n)/";
$yy_global_pattern = "/^([ \t\r]+)|^([^\n]+?(?=[ \t\r]*\n))|^(\n)/iS";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
@ -460,7 +459,7 @@ class Smarty_Internal_Configfilelexer
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
$yy_global_pattern = "/^(\\.)|^(.*?(?=[\.=[\]\r\n]))/";
$yy_global_pattern = "/^(\\.)|^(.*?(?=[\.=[\]\r\n]))/iS";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
@ -522,6 +521,6 @@ class Smarty_Internal_Configfilelexer
$this->yypopstate();
}
}
}
?>

@ -113,7 +113,6 @@ class Smarty_Internal_Configfileparser#line 79 "smarty_internal_configfileparser
if (in_array(strtolower($str) ,array('on','yes','true'))) {
$res = true;
} else {
assert(in_array(strtolower($str), array('off','no','false')));
$res = false;
}
return $res;
@ -179,7 +178,7 @@ class Smarty_Internal_Configfileparser#line 79 "smarty_internal_configfileparser
$this->set_var($var, $this->compiler->config_data['sections'][$section_name]);
}
}
#line 175 "smarty_internal_configfileparser.php"
#line 174 "smarty_internal_configfileparser.php"
const TPC_OPENB = 1;
const TPC_SECTION = 2;
@ -583,11 +582,11 @@ static public $yy_action = array(
while ($this->yyidx >= 0) {
$this->yy_pop_parser_stack();
}
#line 127 "smarty_internal_configfileparser.y"
#line 126 "smarty_internal_configfileparser.y"
$this->internalError = true;
$this->compiler->trigger_config_file_error("Stack overflow in configfile parser");
#line 586 "smarty_internal_configfileparser.php"
#line 585 "smarty_internal_configfileparser.php"
return;
}
$yytos = new TPC_yyStackEntry;
@ -652,51 +651,51 @@ static public $yy_action = array(
15 => 15,
16 => 16,
);
#line 133 "smarty_internal_configfileparser.y"
#line 132 "smarty_internal_configfileparser.y"
function yy_r0(){ $this->_retvalue = null; }
#line 653 "smarty_internal_configfileparser.php"
#line 136 "smarty_internal_configfileparser.y"
#line 652 "smarty_internal_configfileparser.php"
#line 135 "smarty_internal_configfileparser.y"
function yy_r1(){ $this->add_global_vars($this->yystack[$this->yyidx + 0]->minor); $this->_retvalue = null; }
#line 656 "smarty_internal_configfileparser.php"
#line 142 "smarty_internal_configfileparser.y"
#line 655 "smarty_internal_configfileparser.php"
#line 141 "smarty_internal_configfileparser.y"
function yy_r4(){ $this->add_section_vars($this->yystack[$this->yyidx + -3]->minor, $this->yystack[$this->yyidx + 0]->minor); $this->_retvalue = null; }
#line 659 "smarty_internal_configfileparser.php"
#line 143 "smarty_internal_configfileparser.y"
#line 658 "smarty_internal_configfileparser.php"
#line 142 "smarty_internal_configfileparser.y"
function yy_r5(){ if ($this->smarty->config_read_hidden) { $this->add_section_vars($this->yystack[$this->yyidx + -3]->minor, $this->yystack[$this->yyidx + 0]->minor); } $this->_retvalue = null; }
#line 662 "smarty_internal_configfileparser.php"
#line 146 "smarty_internal_configfileparser.y"
#line 661 "smarty_internal_configfileparser.php"
#line 145 "smarty_internal_configfileparser.y"
function yy_r6(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; }
#line 665 "smarty_internal_configfileparser.php"
#line 147 "smarty_internal_configfileparser.y"
#line 664 "smarty_internal_configfileparser.php"
#line 146 "smarty_internal_configfileparser.y"
function yy_r7(){ $this->_retvalue = array_merge($this->yystack[$this->yyidx + -1]->minor, Array($this->yystack[$this->yyidx + 0]->minor)); }
#line 668 "smarty_internal_configfileparser.php"
#line 148 "smarty_internal_configfileparser.y"
#line 667 "smarty_internal_configfileparser.php"
#line 147 "smarty_internal_configfileparser.y"
function yy_r8(){ $this->_retvalue = Array(); }
#line 671 "smarty_internal_configfileparser.php"
#line 152 "smarty_internal_configfileparser.y"
#line 670 "smarty_internal_configfileparser.php"
#line 151 "smarty_internal_configfileparser.y"
function yy_r9(){ $this->_retvalue = Array("key" => $this->yystack[$this->yyidx + -2]->minor, "value" => $this->yystack[$this->yyidx + 0]->minor); }
#line 674 "smarty_internal_configfileparser.php"
#line 154 "smarty_internal_configfileparser.y"
#line 673 "smarty_internal_configfileparser.php"
#line 153 "smarty_internal_configfileparser.y"
function yy_r10(){ $this->_retvalue = (float) $this->yystack[$this->yyidx + 0]->minor; }
#line 677 "smarty_internal_configfileparser.php"
#line 155 "smarty_internal_configfileparser.y"
#line 676 "smarty_internal_configfileparser.php"
#line 154 "smarty_internal_configfileparser.y"
function yy_r11(){ $this->_retvalue = (int) $this->yystack[$this->yyidx + 0]->minor; }
#line 680 "smarty_internal_configfileparser.php"
#line 156 "smarty_internal_configfileparser.y"
#line 679 "smarty_internal_configfileparser.php"
#line 155 "smarty_internal_configfileparser.y"
function yy_r12(){ $this->_retvalue = $this->parse_bool($this->yystack[$this->yyidx + 0]->minor); }
#line 683 "smarty_internal_configfileparser.php"
#line 157 "smarty_internal_configfileparser.y"
#line 682 "smarty_internal_configfileparser.php"
#line 156 "smarty_internal_configfileparser.y"
function yy_r13(){ $this->_retvalue = self::parse_single_quoted_string($this->yystack[$this->yyidx + 0]->minor); }
#line 686 "smarty_internal_configfileparser.php"
#line 158 "smarty_internal_configfileparser.y"
#line 685 "smarty_internal_configfileparser.php"
#line 157 "smarty_internal_configfileparser.y"
function yy_r14(){ $this->_retvalue = self::parse_double_quoted_string($this->yystack[$this->yyidx + 0]->minor); }
#line 689 "smarty_internal_configfileparser.php"
#line 159 "smarty_internal_configfileparser.y"
#line 688 "smarty_internal_configfileparser.php"
#line 158 "smarty_internal_configfileparser.y"
function yy_r15(){ $this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[$this->yyidx + 0]->minor); }
#line 692 "smarty_internal_configfileparser.php"
#line 160 "smarty_internal_configfileparser.y"
#line 691 "smarty_internal_configfileparser.php"
#line 159 "smarty_internal_configfileparser.y"
function yy_r16(){ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; }
#line 695 "smarty_internal_configfileparser.php"
#line 694 "smarty_internal_configfileparser.php"
private $_retvalue;
@ -753,12 +752,12 @@ static public $yy_action = array(
function yy_syntax_error($yymajor, $TOKEN)
{
#line 120 "smarty_internal_configfileparser.y"
#line 119 "smarty_internal_configfileparser.y"
$this->internalError = true;
$this->yymajor = $yymajor;
$this->compiler->trigger_config_file_error();
#line 758 "smarty_internal_configfileparser.php"
#line 757 "smarty_internal_configfileparser.php"
}
function yy_accept()
@ -769,13 +768,13 @@ static public $yy_action = array(
while ($this->yyidx >= 0) {
$stack = $this->yy_pop_parser_stack();
}
#line 112 "smarty_internal_configfileparser.y"
#line 111 "smarty_internal_configfileparser.y"
$this->successful = !$this->internalError;
$this->internalError = false;
$this->retvalue = $this->_retvalue;
//echo $this->retvalue."\n\n";
#line 776 "smarty_internal_configfileparser.php"
#line 775 "smarty_internal_configfileparser.php"
}
function doParse($yymajor, $yytokenvalue)
@ -868,5 +867,4 @@ static public $yy_action = array(
} while ($yymajor != self::YYNOCODE && $this->yyidx >= 0);
}
}
?>

@ -184,7 +184,7 @@ class Smarty_Internal_Data {
function getTemplateVars($varname = null, $_ptr = null, $search_parents = true)
{
if (isset($varname)) {
$_var = $this->getVariable($varname, $_ptr, $search_parents);
$_var = $this->getVariable($varname, $_ptr, $search_parents, false);
if (is_object($_var)) {
return $_var->value;
} else {
@ -196,8 +196,10 @@ class Smarty_Internal_Data {
$_ptr = $this;
} while ($_ptr !== null) {
foreach ($_ptr->tpl_vars AS $key => $var) {
if (!array_key_exists($key, $_result)) {
$_result[$key] = $var->value;
}
}
// not found, try at parent
if ($search_parents) {
$_ptr = $_ptr->parent;
@ -207,9 +209,11 @@ class Smarty_Internal_Data {
}
if ($search_parents && isset(Smarty::$global_tpl_vars)) {
foreach (Smarty::$global_tpl_vars AS $key => $var) {
if (!array_key_exists($key, $_result)) {
$_result[$key] = $var->value;
}
}
}
return $_result;
}
}

@ -76,10 +76,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data {
public static function display_debug($obj)
{
// prepare information of assigned variables
$ptr = $obj;
while (isset($ptr->parent)) {
$ptr = $ptr->parent;
}
$ptr = self::get_debug_vars($obj);
if ($obj instanceof Smarty) {
$smarty = $obj;
} else {
@ -99,14 +96,54 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data {
$_template->disableSecurity();
$_template->cache_id = null;
$_template->compile_id = null;
if ($obj instanceof Smarty_Internal_Template) {
$_template->assign('template_name',$obj->resource_type.':'.$obj->resource_name);
}
if ($obj instanceof Smarty) {
$_template->assign('template_data', self::$template_data);
} else {
$_template->assign('template_data', null);
}
$_template->assign('assigned_vars', $_assigned_vars);
$_template->assign('config_vars', $_config_vars);
$_template->assign('execution_time', microtime(true) - $smarty->start_time);
echo $smarty->fetch($_template);
echo $_template->getRenderedTemplate();
$smarty->left_delimiter = $ldelim;
$smarty->right_delimiter = $rdelim;
}
/*
* Recursively gets variables from all template/data scopes
*/
public static function get_debug_vars($obj)
{
$config_vars = $obj->config_vars;
$tpl_vars = array();
foreach ($obj->tpl_vars as $key => $var) {
$tpl_vars[$key] = clone $var;
if ($obj instanceof Smarty_Internal_Template) {
$tpl_vars[$key]->scope = $obj->resource_type.':'.$obj->resource_name;
} elseif ($obj instanceof Smarty_Data) {
$tpl_vars[$key]->scope = 'Data object';
} else {
$tpl_vars[$key]->scope = 'Smarty root';
}
}
if (isset($obj->parent)) {
$parent = self::get_debug_vars($obj->parent);
$tpl_vars = array_merge($parent->tpl_vars, $tpl_vars);
$config_vars = array_merge($parent->config_vars, $config_vars);
} else {
foreach (Smarty::$global_tpl_vars as $name => $var) {
if (!array_key_exists($name, $tpl_vars)) {
$clone = clone $var;
$clone->scope = 'Global';
$tpl_vars[$name] = $clone;
}
}
}
return (object) array('tpl_vars' => $tpl_vars, 'config_vars' => $config_vars);
}
/**
* get_key

@ -0,0 +1,44 @@
<?php
/**
* Smarty read include path plugin
*
* @package Smarty
* @subpackage PluginsInternal
* @author Monte Ohrt
*/
/**
* Smarty Internal Read Include Path Class
*/
class Smarty_Internal_Get_Include_Path {
/**
* Return full file path from PHP include_path
*
* @param string $filepath filepath
* @return mixed full filepath or false
*/
public static function getIncludePath($filepath)
{
static $_path_array = null;
if(!isset($_path_array)) {
$_ini_include_path = ini_get('include_path');
if(strstr($_ini_include_path,';')) {
// windows pathnames
$_path_array = explode(';',$_ini_include_path);
} else {
$_path_array = explode(':',$_ini_include_path);
}
}
foreach ($_path_array as $_include_path) {
if (file_exists($_include_path . DS . $filepath)) {
return $_include_path . DS . $filepath;
}
}
return false;
}
}
?>

@ -35,10 +35,7 @@ class Smarty_Internal_Register {
} elseif (!is_callable($callback)) {
throw new Exception("Plugin \"{$tag}\" not callable");
} else {
$this->smarty->registered_plugins[$type][$tag] = array($callback, (bool) $cacheable);
if (isset($cache_attr)&&in_array($type, array(Smarty::PLUGIN_BLOCK, Smarty::PLUGIN_FUNCTION))) {
$this->smarty->registered_plugins[$type][$tag][] = (array) $cache_attr;
}
$this->smarty->registered_plugins[$type][$tag] = array($callback, (bool) $cacheable, (array) $cache_attr);
}
}

@ -274,6 +274,15 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
if ($this->smarty->debugging) {
Smarty_Internal_Debug::end_compile($this);
}
// release objects to free memory
Smarty_Internal_TemplateCompilerBase::$_tag_objects = array();
unset($this->compiler_object->parser->root_buffer,
$this->compiler_object->parser->current_buffer,
$this->compiler_object->parser,
$this->compiler_object->lex,
$this->compiler_object->template,
$this->compiler_object
);
}
/**
@ -500,6 +509,9 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
$output .= preg_replace("!/\*/?%%SmartyNocache:{$this->properties['nocache_hash']}%%\*/!", '', $cache_parts[0][$curr_idx]);
}
}
if (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output'])) {
$output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $this);
}
// rendering (must be done before writing cache file because of {function} nocache handling)
$_smarty_tpl = $this;
ob_start();
@ -591,15 +603,25 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
if ($file == null) {
$file = $this->resource_name;
}
// relative file name?
if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $file)) {
foreach((array)$this->smarty->template_dir as $_template_dir) {
if (strpos('/\\', substr($_template_dir, -1)) === false) {
$_template_dir .= DS;
}
$_filepath = $_template_dir . $file;
if (file_exists($_filepath))
if (file_exists($_filepath)) {
return $_filepath;
}
if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_template_dir)) {
// try PHP include_path
if (($_filepath = Smarty_Internal_Get_Include_Path::getIncludePath($_filepath)) !== false) {
return $_filepath;
}
}
}
}
// try absolute filepath
if (file_exists($file)) return $file;
// no tpl file found
if (!empty($this->smarty->default_template_handler_func)) {
@ -810,7 +832,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
}
/**
* creates a loacal Smarty variable for array assignments
* creates a local Smarty variable for array assignments
*/
public function createLocalArrayVariable($tpl_var, $nocache = false, $scope = Smarty::SCOPE_LOCAL)
{
@ -839,14 +861,10 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
{
if (is_array($value) === true || $value instanceof Countable) {
return count($value);
} elseif ($value instanceof ArrayAccess) {
if ($value->offsetExists(0)) {
return 1;
}
} elseif ($value instanceof Iterator) {
$value->rewind();
if ($value->valid()) {
return 1;
return iterator_count($value);
}
} elseif ($value instanceof PDOStatement) {
return $value->rowCount();

@ -33,7 +33,7 @@ class Smarty_Internal_TemplateCompilerBase {
{
$this->nocache_hash = str_replace('.', '-', uniqid(rand(), true));
}
// abstract function doCompile($_content);
/**
* Methode to compile a Smarty template
*
@ -67,7 +67,7 @@ class Smarty_Internal_TemplateCompilerBase {
$_content = $template->getTemplateSource();
// run prefilter if required
if (isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])) {
$_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $template);
$template->template_source = $_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $template);
}
// on empty template just return header
if ($_content == '') {
@ -196,7 +196,12 @@ class Smarty_Internal_TemplateCompilerBase {
if ($plugin_type == Smarty::PLUGIN_BLOCK && $this->smarty->loadPlugin('smarty_compiler_' . $tag)) {
$plugin = 'smarty_compiler_' . $tag;
if (is_callable($plugin)) {
return $plugin($args, $this->smarty);
// convert arguments format for old compiler plugins
$new_args = array();
foreach ($args as $mixed) {
$new_args = array_merge($new_args, $mixed);
}
return $plugin($new_args, $this->smarty);
}
if (class_exists($plugin, false)) {
$plugin_object = new $plugin;
@ -364,6 +369,7 @@ class Smarty_Internal_TemplateCompilerBase {
($this->nocache || $this->tag_nocache || $this->template->forceNocache == 2)) {
$this->template->has_nocache_code = true;
$_output = str_replace("'", "\'", $content);
$_output = str_replace("^#^", "'", $_output);
$_output = "<?php echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/" . $_output . "/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>";
// make sure we include modifer plugins for nocache code
if (isset($this->template->saved_modifier)) {
@ -401,12 +407,14 @@ class Smarty_Internal_TemplateCompilerBase {
$line = $this->lex->line;
}
$match = preg_split("/\n/", $this->lex->data);
$error_text = 'Syntax Error in template "' . $this->template->getTemplateFilepath() . '" on line ' . $line . ' "' . htmlspecialchars($match[$line-1]) . '" ';
$error_text = 'Syntax Error in template "' . $this->template->getTemplateFilepath() . '" on line ' . $line . ' "' . htmlspecialchars(trim(preg_replace('![\t\r\n]+!',' ',$match[$line-1]))) . '" ';
if (isset($args)) {
// individual error message
$error_text .= $args;
} else {
// expected token from parser
$error_text .= ' - Unexpected "' . $this->lex->value.'"';
if (count($this->parser->yy_get_expected_tokens($this->parser->yymajor)) <= 4 ) {
foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) {
$exp_token = $this->parser->yyTokenName[$token];
if (isset($this->lex->smarty_token_names[$exp_token])) {
@ -417,8 +425,8 @@ class Smarty_Internal_TemplateCompilerBase {
$expect[] = $this->parser->yyTokenName[$token];
}
}
// output parser error message
$error_text .= ' - Unexpected "' . $this->lex->value . '", expected one of: ' . implode(' , ', $expect);
$error_text .= ', expected one of: ' . implode(' , ', $expect);
}
}
throw new SmartyCompilerException($error_text);
}

@ -79,8 +79,6 @@ class Smarty_Internal_Templatelexer
function __construct($data,$compiler)
{
// set instance object
self::instance($this);
// $this->data = preg_replace("/(\r\n|\r|\n)/", "\n", $data);
$this->data = $data;
$this->counter = 0;
@ -93,14 +91,6 @@ class Smarty_Internal_Templatelexer
$this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
$this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter;
}
public static function &instance($new_instance = null)
{
static $instance = null;
if (isset($new_instance) && is_object($new_instance))
$instance = $new_instance;
return $instance;
}
private $_yy_state = 1;
@ -154,11 +144,12 @@ class Smarty_Internal_Templatelexer
22 => 0,
23 => 2,
26 => 0,
27 => 0,
);
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
$yy_global_pattern = "/^(".$this->ldel."[$]smarty\\.block\\.child".$this->rdel.")|^(\\{\\})|^(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|^([\t ]*[\r\n]+[\t ]*)|^(".$this->ldel."strip".$this->rdel.")|^(".$this->ldel."\\s{1,}strip\\s{1,}".$this->rdel.")|^(".$this->ldel."\/strip".$this->rdel.")|^(".$this->ldel."\\s{1,}\/strip\\s{1,}".$this->rdel.")|^(".$this->ldel."\\s*literal\\s*".$this->rdel.")|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s*(if|elseif|else if|while)(?![^\s]))|^(".$this->ldel."\\s*for(?![^\s]))|^(".$this->ldel."\\s*foreach(?![^\s]))|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^(<%)|^(%>)|^(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."|<\\?|\\?>|<%|%>)))|^([\S\s]+)/";
$yy_global_pattern = "/^(".$this->ldel."[$]smarty\\.block\\.child".$this->rdel.")|^(\\{\\})|^(".$this->ldel."\\*([\S\s]*?)\\*".$this->rdel.")|^([\t ]*[\r\n]+[\t ]*)|^(".$this->ldel."strip".$this->rdel.")|^(".$this->ldel."\\s{1,}strip\\s{1,}".$this->rdel.")|^(".$this->ldel."\/strip".$this->rdel.")|^(".$this->ldel."\\s{1,}\/strip\\s{1,}".$this->rdel.")|^(".$this->ldel."\\s*literal\\s*".$this->rdel.")|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s*(if|elseif|else if|while)(?![^\s]))|^(".$this->ldel."\\s*for(?![^\s]))|^(".$this->ldel."\\s*foreach(?![^\s]))|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^(<%)|^(%>)|^(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."|<\\?|\\?>|<%|%>)))|^([\S\s]+)|^(.)/iS";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
@ -374,6 +365,11 @@ class Smarty_Internal_Templatelexer
function yy_r1_26($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
}
function yy_r1_27($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
}
@ -392,26 +388,34 @@ class Smarty_Internal_Templatelexer
10 => 0,
11 => 0,
12 => 0,
13 => 1,
15 => 1,
17 => 1,
13 => 0,
14 => 0,
15 => 0,
16 => 0,
17 => 0,
18 => 0,
19 => 0,
20 => 0,
21 => 0,
20 => 1,
22 => 1,
24 => 1,
26 => 1,
28 => 1,
30 => 1,
32 => 1,
34 => 1,
36 => 1,
38 => 1,
40 => 1,
42 => 1,
44 => 0,
45 => 0,
46 => 0,
26 => 0,
27 => 0,
28 => 0,
29 => 0,
30 => 0,
31 => 0,
32 => 0,
33 => 0,
34 => 0,
35 => 0,
36 => 0,
37 => 0,
38 => 0,
39 => 0,
40 => 0,
41 => 0,
42 => 0,
43 => 3,
47 => 0,
48 => 0,
49 => 0,
@ -419,8 +423,9 @@ class Smarty_Internal_Templatelexer
51 => 0,
52 => 0,
53 => 0,
54 => 3,
58 => 0,
54 => 0,
55 => 1,
57 => 1,
59 => 0,
60 => 0,
61 => 0,
@ -428,8 +433,10 @@ class Smarty_Internal_Templatelexer
63 => 0,
64 => 0,
65 => 0,
66 => 1,
68 => 1,
66 => 0,
67 => 0,
68 => 0,
69 => 0,
70 => 0,
71 => 0,
72 => 0,
@ -437,22 +444,11 @@ class Smarty_Internal_Templatelexer
74 => 0,
75 => 0,
76 => 0,
77 => 0,
78 => 0,
79 => 0,
80 => 0,
81 => 0,
82 => 0,
83 => 0,
84 => 0,
85 => 0,
86 => 0,
87 => 0,
);
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
$yy_global_pattern = "/^('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s*(if|elseif|else if|while)(?![^\s]))|^(".$this->ldel."\\s*for(?![^\s]))|^(".$this->ldel."\\s*foreach(?![^\s]))|^(".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(".$this->ldel."\/)|^(".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+(AS|as)\\s+)|^(\\s+(to)\\s+)|^(\\s+(step)\\s+)|^(\\s+instanceof\\s+)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+(EQ|eq)\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(NE|NEQ|ne|neq)\\s+)|^(\\s*>=\\s*|\\s+(GE|GTE|ge|gte)\\s+)|^(\\s*<=\\s*|\\s+(LE|LTE|le|lte)\\s+)|^(\\s*>\\s*|\\s+(GT|gt)\\s+)|^(\\s*<\\s*|\\s+(LT|lt)\\s+)|^(\\s+(MOD|mod)\\s+)|^(!\\s*|(NOT|not)\\s+)|^(\\s*&&\\s*|\\s*(AND|and)\\s+)|^(\\s*\\|\\|\\s*|\\s*(OR|or)\\s+)|^(\\s*(XOR|xor)\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\\)\\s*)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\+\\+|--)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;)|^(::)|^(\\s*:\\s*)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(\\s*\\?\\s*)|^(0[xX][0-9a-fA-F]+)|^([0-9]*[a-zA-Z_]\\w*)|^(\\d+)|^(\\s+)|^(.)/";
$yy_global_pattern = "/^('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s*(if|elseif|else if|while)(?![^\s]))|^(".$this->ldel."\\s*for(?![^\s]))|^(".$this->ldel."\\s*foreach(?![^\s]))|^(".$this->ldel."\\s{1,})|^(\\s{1,}".$this->rdel.")|^(".$this->ldel."\/)|^(".$this->ldel.")|^(".$this->rdel.")|^(\\s+is\\s+in\\s+)|^(\\s+as\\s+)|^(\\s+to\\s+)|^(\\s+step\\s+)|^(\\s+instanceof\\s+)|^(\\s*===\\s*)|^(\\s*!==\\s*)|^(\\s*==\\s*|\\s+eq\\s+)|^(\\s*!=\\s*|\\s*<>\\s*|\\s+(ne|neq)\\s+)|^(\\s*>=\\s*|\\s+(ge|gte)\\s+)|^(\\s*<=\\s*|\\s+(le|lte)\\s+)|^(\\s*>\\s*|\\s+gt\\s+)|^(\\s*<\\s*|\\s+lt\\s+)|^(\\s+mod\\s+)|^(!\\s*|not\\s+)|^(\\s*&&\\s*|\\s*and\\s+)|^(\\s*\\|\\|\\s*|\\s*or\\s+)|^(\\s*xor\\s+)|^(\\s+is\\s+odd\\s+by\\s+)|^(\\s+is\\s+not\\s+odd\\s+by\\s+)|^(\\s+is\\s+odd)|^(\\s+is\\s+not\\s+odd)|^(\\s+is\\s+even\\s+by\\s+)|^(\\s+is\\s+not\\s+even\\s+by\\s+)|^(\\s+is\\s+even)|^(\\s+is\\s+not\\s+even)|^(\\s+is\\s+div\\s+by\\s+)|^(\\s+is\\s+not\\s+div\\s+by\\s+)|^(\\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\\)\\s*)|^(\\(\\s*)|^(\\s*\\))|^(\\[\\s*)|^(\\s*\\])|^(\\s*->\\s*)|^(\\s*=>\\s*)|^(\\s*=\\s*)|^(\\+\\+|--)|^(\\s*(\\+|-)\\s*)|^(\\s*(\\*|\/|%)\\s*)|^(\\$)|^(\\s*;)|^(::)|^(\\s*:\\s*)|^(@)|^(#)|^(\")|^(`)|^(\\|)|^(\\.)|^(\\s*,\\s*)|^(\\s*&\\s*)|^(\\s*\\?\\s*)|^(0[xX][0-9a-fA-F]+)|^([0-9]*[a-zA-Z_]\\w*)|^(\\d+)|^(\\s+)|^(.)/iS";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
@ -602,279 +598,279 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_AS;
}
function yy_r2_15($yy_subpatterns)
function yy_r2_14($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_TO;
}
function yy_r2_17($yy_subpatterns)
function yy_r2_15($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_STEP;
}
function yy_r2_19($yy_subpatterns)
function yy_r2_16($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
}
function yy_r2_20($yy_subpatterns)
function yy_r2_17($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_IDENTITY;
}
function yy_r2_21($yy_subpatterns)
function yy_r2_18($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_NONEIDENTITY;
}
function yy_r2_22($yy_subpatterns)
function yy_r2_19($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_EQUALS;
}
function yy_r2_24($yy_subpatterns)
function yy_r2_20($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_NOTEQUALS;
}
function yy_r2_26($yy_subpatterns)
function yy_r2_22($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_GREATEREQUAL;
}
function yy_r2_28($yy_subpatterns)
function yy_r2_24($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_LESSEQUAL;
}
function yy_r2_30($yy_subpatterns)
function yy_r2_26($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_GREATERTHAN;
}
function yy_r2_32($yy_subpatterns)
function yy_r2_27($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_LESSTHAN;
}
function yy_r2_34($yy_subpatterns)
function yy_r2_28($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_MOD;
}
function yy_r2_36($yy_subpatterns)
function yy_r2_29($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_NOT;
}
function yy_r2_38($yy_subpatterns)
function yy_r2_30($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_LAND;
}
function yy_r2_40($yy_subpatterns)
function yy_r2_31($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_LOR;
}
function yy_r2_42($yy_subpatterns)
function yy_r2_32($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_LXOR;
}
function yy_r2_44($yy_subpatterns)
function yy_r2_33($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISODDBY;
}
function yy_r2_45($yy_subpatterns)
function yy_r2_34($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISNOTODDBY;
}
function yy_r2_46($yy_subpatterns)
function yy_r2_35($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISODD;
}
function yy_r2_47($yy_subpatterns)
function yy_r2_36($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISNOTODD;
}
function yy_r2_48($yy_subpatterns)
function yy_r2_37($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISEVENBY;
}
function yy_r2_49($yy_subpatterns)
function yy_r2_38($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISNOTEVENBY;
}
function yy_r2_50($yy_subpatterns)
function yy_r2_39($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISEVEN;
}
function yy_r2_51($yy_subpatterns)
function yy_r2_40($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISNOTEVEN;
}
function yy_r2_52($yy_subpatterns)
function yy_r2_41($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISDIVBY;
}
function yy_r2_53($yy_subpatterns)
function yy_r2_42($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ISNOTDIVBY;
}
function yy_r2_54($yy_subpatterns)
function yy_r2_43($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
}
function yy_r2_58($yy_subpatterns)
function yy_r2_47($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_OPENP;
}
function yy_r2_59($yy_subpatterns)
function yy_r2_48($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
}
function yy_r2_60($yy_subpatterns)
function yy_r2_49($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_OPENB;
}
function yy_r2_61($yy_subpatterns)
function yy_r2_50($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
}
function yy_r2_62($yy_subpatterns)
function yy_r2_51($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_PTR;
}
function yy_r2_63($yy_subpatterns)
function yy_r2_52($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_APTR;
}
function yy_r2_64($yy_subpatterns)
function yy_r2_53($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_EQUAL;
}
function yy_r2_65($yy_subpatterns)
function yy_r2_54($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_INCDEC;
}
function yy_r2_66($yy_subpatterns)
function yy_r2_55($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
}
function yy_r2_68($yy_subpatterns)
function yy_r2_57($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_MATH;
}
function yy_r2_70($yy_subpatterns)
function yy_r2_59($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
}
function yy_r2_71($yy_subpatterns)
function yy_r2_60($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
}
function yy_r2_72($yy_subpatterns)
function yy_r2_61($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
}
function yy_r2_73($yy_subpatterns)
function yy_r2_62($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_COLON;
}
function yy_r2_74($yy_subpatterns)
function yy_r2_63($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_AT;
}
function yy_r2_75($yy_subpatterns)
function yy_r2_64($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_HATCH;
}
function yy_r2_76($yy_subpatterns)
function yy_r2_65($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypushstate(self::DOUBLEQUOTEDSTRING);
}
function yy_r2_77($yy_subpatterns)
function yy_r2_66($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
$this->yypopstate();
}
function yy_r2_78($yy_subpatterns)
function yy_r2_67($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_VERT;
}
function yy_r2_79($yy_subpatterns)
function yy_r2_68($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_DOT;
}
function yy_r2_80($yy_subpatterns)
function yy_r2_69($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_COMMA;
}
function yy_r2_81($yy_subpatterns)
function yy_r2_70($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ANDSYM;
}
function yy_r2_82($yy_subpatterns)
function yy_r2_71($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_QMARK;
}
function yy_r2_83($yy_subpatterns)
function yy_r2_72($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_HEX;
}
function yy_r2_84($yy_subpatterns)
function yy_r2_73($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_ID;
}
function yy_r2_85($yy_subpatterns)
function yy_r2_74($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_INTEGER;
}
function yy_r2_86($yy_subpatterns)
function yy_r2_75($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
}
function yy_r2_87($yy_subpatterns)
function yy_r2_76($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
@ -898,7 +894,7 @@ class Smarty_Internal_Templatelexer
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
$yy_global_pattern = "/^(".$this->ldel."\\s*literal\\s*".$this->rdel.")|^(".$this->ldel."\\s*\/literal\\s*".$this->rdel.")|^([\t ]*[\r\n]+[\t ]*)|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^(<%)|^(%>)|^(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."\/?literal".$this->rdel."|<\\?|<%)))|^([\S\s]+)/";
$yy_global_pattern = "/^(".$this->ldel."\\s*literal\\s*".$this->rdel.")|^(".$this->ldel."\\s*\/literal\\s*".$this->rdel.")|^([\t ]*[\r\n]+[\t ]*)|^(<\\?(?:php\\w+|=|[a-zA-Z]+)?)|^(\\?>)|^(<%)|^(%>)|^(([\S\s]*?)(?=([\t ]*[\r\n]+[\t ]*|".$this->ldel."\/?literal".$this->rdel."|<\\?|<%)))|^(.)/iS";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
@ -1018,11 +1014,12 @@ class Smarty_Internal_Templatelexer
12 => 0,
13 => 3,
17 => 0,
18 => 0,
);
if ($this->counter >= strlen($this->data)) {
return false; // end of input
}
$yy_global_pattern = "/^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s*(if|elseif|else if|while)(?![^\s]))|^(".$this->ldel."\\s*for(?![^\s]))|^(".$this->ldel."\\s*foreach(?![^\s]))|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(\")|^(`\\$)|^(\\$[0-9]*[a-zA-Z_]\\w*)|^(\\$)|^(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(".$this->ldel."|\\$|`\\$|\")))|^([\S\s]+)/";
$yy_global_pattern = "/^(".$this->ldel."\\s{1,}\/)|^(".$this->ldel."\\s*(if|elseif|else if|while)(?![^\s]))|^(".$this->ldel."\\s*for(?![^\s]))|^(".$this->ldel."\\s*foreach(?![^\s]))|^(".$this->ldel."\\s{1,})|^(".$this->ldel."\/)|^(".$this->ldel.")|^(\")|^(`\\$)|^(\\$[0-9]*[a-zA-Z_]\\w*)|^(\\$)|^(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(".$this->ldel."|\\$|`\\$|\")))|^([\S\s]+)|^(.)/iS";
do {
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
@ -1173,6 +1170,11 @@ class Smarty_Internal_Templatelexer
function yy_r4_17($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
}
function yy_r4_18($yy_subpatterns)
{
$this->token = Smarty_Internal_Templateparser::TP_OTHER;
}

File diff suppressed because it is too large Load Diff

@ -78,7 +78,7 @@ class Smarty_Internal_Utility {
flush();
$_start_time = microtime(true);
try {
$_tpl = $this->smarty->createTemplate($_template_file);
$_tpl = $this->smarty->createTemplate($_template_file,null,null,null,false);
if ($_tpl->mustCompile()) {
$_tpl->compileTemplateSource();
echo ' compiled in ', microtime(true) - $_start_time, ' seconds';
@ -92,6 +92,10 @@ class Smarty_Internal_Utility {
echo 'Error: ', $e->getMessage(), "<br><br>";
$_error_count++;
}
// free memory
$this->smarty->template_objects = array();
$_tpl->smarty->template_objects = array();
$_tpl = null;
if ($max_errors !== null && $_error_count == $max_errors) {
echo '<br><br>too many errors';
exit();

@ -30,11 +30,17 @@ class Smarty_Internal_Write_File {
// write to tmp file, then move to overt file lock race condition
$_tmp_file = tempnam($_dirpath, 'wrt');
if (!file_put_contents($_tmp_file, $_contents)) {
umask($old_umask);
if (!($fd = @fopen($_tmp_file, 'wb'))) {
$_tmp_file = $_dirpath . DS . uniqid('wrt');
if (!($fd = @fopen($_tmp_file, 'wb'))) {
throw new SmartyException("unable to write file {$_tmp_file}");
return false;
}
}
fwrite($fd, $_contents);
fclose($fd);
// remove original file
if (file_exists($_filepath))
@unlink($_filepath);

Loading…
Cancel
Save