From 780f4f373eeee9fbe72c3adf50ce006c13b3b510 Mon Sep 17 00:00:00 2001 From: cajus Date: Fri, 2 Jun 2006 14:03:58 +0000 Subject: [PATCH] Updated to smarty 2.6.13 git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3644 594d385d-05f5-0310-b6e9-bd551577e9d8 --- TODO | 11 +-- debian/README.debian | 11 --- debian/control | 1 + include/smarty/Config_File.class.php | 12 +-- include/smarty/Smarty.class.php | 28 ++++--- include/smarty/Smarty_Compiler.class.php | 80 +++++++++++-------- include/smarty/debug.tpl | 4 +- .../internals/core.create_dir_structure.php | 2 +- .../internals/core.display_debug_console.php | 2 +- include/smarty/internals/core.is_secure.php | 15 ++-- include/smarty/internals/core.is_trusted.php | 2 +- .../internals/core.process_cached_inserts.php | 2 +- .../core.process_compiled_include.php | 5 ++ .../smarty/internals/core.read_cache_file.php | 10 --- include/smarty/internals/core.rmdir.php | 1 - .../internals/core.write_compiled_include.php | 4 +- include/smarty/plugins/block.textformat.php | 1 + include/smarty/plugins/compiler.assign.php | 2 + .../plugins/function.assign_debug_info.php | 1 + .../smarty/plugins/function.config_load.php | 2 + include/smarty/plugins/function.counter.php | 1 + include/smarty/plugins/function.eval.php | 1 + include/smarty/plugins/function.fetch.php | 1 + .../smarty/plugins/function.html_image.php | 27 ++++--- .../smarty/plugins/function.html_options.php | 1 + .../smarty/plugins/function.html_radios.php | 20 +++-- .../plugins/function.html_select_date.php | 25 +++--- .../plugins/function.html_select_time.php | 2 + include/smarty/plugins/function.math.php | 3 +- include/smarty/plugins/function.popup.php | 2 + .../smarty/plugins/function.popup_init.php | 1 + .../smarty/plugins/modifier.capitalize.php | 1 + .../plugins/modifier.count_characters.php | 1 + .../plugins/modifier.count_paragraphs.php | 1 + .../plugins/modifier.count_sentences.php | 1 + .../smarty/plugins/modifier.count_words.php | 1 + .../smarty/plugins/modifier.date_format.php | 1 + .../plugins/modifier.debug_print_var.php | 1 + include/smarty/plugins/modifier.default.php | 1 + include/smarty/plugins/modifier.escape.php | 14 ++-- include/smarty/plugins/modifier.indent.php | 1 + include/smarty/plugins/modifier.lower.php | 1 + .../smarty/plugins/modifier.regex_replace.php | 8 +- include/smarty/plugins/modifier.replace.php | 1 + include/smarty/plugins/modifier.spacify.php | 1 + .../smarty/plugins/modifier.string_format.php | 1 + .../smarty/plugins/modifier.strip_tags.php | 1 + include/smarty/plugins/modifier.truncate.php | 19 +++-- include/smarty/plugins/modifier.upper.php | 1 + include/smarty/plugins/modifier.wordwrap.php | 1 + .../plugins/shared.escape_special_chars.php | 1 + .../smarty/plugins/shared.make_timestamp.php | 37 +++++---- 52 files changed, 221 insertions(+), 154 deletions(-) diff --git a/TODO b/TODO index 5c1f3fe14..921155625 100644 --- a/TODO +++ b/TODO @@ -1,19 +1,12 @@ -Target for 2.5: +Target for 2.6: =============== -* Update the french manual ( OpenSides ) - -* Change FAIstate when triggering actions - (install, sysinfo, softupdate) +* Add new smarty gettext plugin * Fix DNS plugin * Zones are not creatable, currently * Error messages are partly wrong - -Target for 2.6: -=============== - * Auto-Resize for subdialogs * Enhance the export xls to export the whole three with a maximum of attributes in each sheet ( OpenSides ) diff --git a/debian/README.debian b/debian/README.debian index 0c5378852..a9a9af2fd 100644 --- a/debian/README.debian +++ b/debian/README.debian @@ -43,16 +43,5 @@ uses the NT/LM attributes to pre-generate samba password hashes - to allow easy switching of account properties without asking for passwords after adding samba accounts. - -* A note to PHP5 errors and smarty - -When using PHP5 and the debian packaged version of smarty, you -may get a set of error messages about call by reference for non -variables. This is no GOsa problem. Please modify your php.ini -to have error reporting set to this: - -error_reporting = E_ALL & ~E_NOTICE & ~E_STRICT - - ---- Cajus Pollmeier Fri 02 Jun 2006 16:23:50 +0200 diff --git a/debian/control b/debian/control index d87bda782..d27ec4c02 100644 --- a/debian/control +++ b/debian/control @@ -8,6 +8,7 @@ Standards-Version: 3.7.2.0 Package: gosa Architecture: all Depends: php4 (>= 4:4.3.10-16) | php5, apache | apache-ssl | apache2-mpm-worker | apache2-mpm-threadpool | apache2-mpm-prefork | apache2-mpm-perchild, exim4 | mail-transport-agent, php4-gd | php5-gd, php4-imap | php5-imap, php4-ldap | php5-ldap, php4-mhash | php5-mhash, php4-mysql | php5-mysql, php4-imagick | php5-imagick | imagemagick (>= 5.4.4.5-1) | graphicsmagick-im-compat, fping, libcrypt-smbhash-perl, smarty, php4-recode | php5-recode, wwwconfig-common +Conflicts: smarty-gettext Suggests: cupsys-server, cyrus21-imapd (>= 2.1.11), postfix-ldap, php4-kadm5, php4-cups, etherwake, slapd, gosa-schema Description: Web Based LDAP Administration Program Provided is access to posix, shadow, samba, proxy, fax, pureftp and diff --git a/include/smarty/Config_File.class.php b/include/smarty/Config_File.class.php index b5fdd2269..622c0e8a0 100644 --- a/include/smarty/Config_File.class.php +++ b/include/smarty/Config_File.class.php @@ -18,14 +18,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @link http://smarty.php.net/ - * @version 2.6.9 + * @version 2.6.14 * @copyright Copyright: 2001-2005 New Digital Group, Inc. * @author Andrei Zmievski * @access public * @package Smarty */ -/* $Id: Config_File.class.php,v 1.78 2005/03/22 08:45:06 messju Exp $ */ +/* $Id: Config_File.class.php,v 1.84 2006/01/18 19:02:52 mohrt Exp $ */ /** * Config file reading class @@ -105,7 +105,7 @@ class Config_File { * @param string $var_name (optional) variable to get info for * @return string|array a value or array of values */ - function &get($file_name, $section_name = NULL, $var_name = NULL) + function get($file_name, $section_name = NULL, $var_name = NULL) { if (empty($file_name)) { $this->_trigger_error_msg('Empty config file name'); @@ -285,9 +285,9 @@ class Config_File { $line = $lines[$i]; if (empty($line)) continue; - if ( $line{0} == '[' && preg_match('!^\[(.*?)\]!', $line, $match) ) { + if ( substr($line, 0, 1) == '[' && preg_match('!^\[(.*?)\]!', $line, $match) ) { /* section found */ - if ($match[1]{0} == '.') { + if (substr($match[1], 0, 1) == '.') { /* hidden section */ if ($this->read_hidden) { $section_name = substr($match[1], 1); @@ -347,7 +347,7 @@ class Config_File { */ function _set_config_var(&$container, $var_name, $var_value, $booleanize) { - if ($var_name{0} == '.') { + if (substr($var_name, 0, 1) == '.') { if (!$this->read_hidden) return; else diff --git a/include/smarty/Smarty.class.php b/include/smarty/Smarty.class.php index bb5129007..47ec24efa 100644 --- a/include/smarty/Smarty.class.php +++ b/include/smarty/Smarty.class.php @@ -27,10 +27,10 @@ * @author Monte Ohrt * @author Andrei Zmievski * @package Smarty - * @version 2.6.9 + * @version 2.6.14 */ -/* $Id: Smarty.class.php,v 1.514 2005/03/22 08:45:06 messju Exp $ */ +/* $Id: Smarty.class.php,v 1.524 2006/01/18 19:02:52 mohrt Exp $ */ /** * DIR_SEP isn't used anymore, but third party apps might @@ -464,7 +464,7 @@ class Smarty * * @var string */ - var $_version = '2.6.9'; + var $_version = '2.6.14'; /** * current template inclusion depth @@ -1055,9 +1055,12 @@ class Smarty { if(!isset($name)) { return $this->_tpl_vars; - } - if(isset($this->_tpl_vars[$name])) { + } elseif(isset($this->_tpl_vars[$name])) { return $this->_tpl_vars[$name]; + } else { + // var non-existant, return valid reference + $_tmp = null; + return $_tmp; } } @@ -1074,6 +1077,10 @@ class Smarty return $this->_config[0]['vars']; } else if(isset($this->_config[0]['vars'][$name])) { return $this->_config[0]['vars'][$name]; + } else { + // var non-existant, return valid reference + $_tmp = null; + return $_tmp; } } @@ -1691,8 +1698,8 @@ class Smarty */ function _dequote($string) { - if (($string{0} == "'" || $string{0} == '"') && - $string{strlen($string)-1} == $string{0}) + if ((substr($string, 0, 1) == "'" || substr($string, 0, 1) == '"') && + substr($string, -1) == substr($string, 0, 1)) return substr($string, 1, -1); else return $string; @@ -1708,7 +1715,10 @@ class Smarty function _read_file($filename) { if ( file_exists($filename) && ($fd = @fopen($filename, 'rb')) ) { - $contents = ($size = filesize($filename)) ? fread($fd, $size) : ''; + $contents = ''; + while (!feof($fd)) { + $contents .= fread($fd, 8192); + } fclose($fd); return $contents; } else { @@ -1889,7 +1899,7 @@ class Smarty if ($this->_cache_including) { /* return next set of cache_attrs */ - $_return =& current($_cache_attrs); + $_return = current($_cache_attrs); next($_cache_attrs); return $_return; diff --git a/include/smarty/Smarty_Compiler.class.php b/include/smarty/Smarty_Compiler.class.php index b444b7245..cbcbddb1b 100644 --- a/include/smarty/Smarty_Compiler.class.php +++ b/include/smarty/Smarty_Compiler.class.php @@ -21,12 +21,12 @@ * @link http://smarty.php.net/ * @author Monte Ohrt * @author Andrei Zmievski - * @version 2.6.9 + * @version 2.6.14 * @copyright 2001-2005 New Digital Group, Inc. * @package Smarty */ -/* $Id: Smarty_Compiler.class.php,v 1.367 2005/03/30 16:48:41 mohrt Exp $ */ +/* $Id: Smarty_Compiler.class.php,v 1.381 2006/05/25 14:46:18 boots Exp $ */ /** * Template compiling class @@ -240,6 +240,9 @@ class Smarty_Compiler extends Smarty { $ldq = preg_quote($this->left_delimiter, '~'); $rdq = preg_quote($this->right_delimiter, '~'); + /* un-hide hidden xml open tags */ + $source_content = preg_replace("~<({$ldq}(.*?){$rdq})[?]~s", '< \\1', $source_content); + // run template source through prefilter functions if (count($this->_plugins['prefilter']) > 0) { foreach ($this->_plugins['prefilter'] as $filter_name => $prefilter) { @@ -361,7 +364,7 @@ class Smarty_Compiler extends Smarty { $compiled_content .= $text_blocks[$i]; // remove \n from the end of the file, if any - if (($_len=strlen($compiled_content)) && ($compiled_content{$_len - 1} == "\n" )) { + if (strlen($compiled_content) && (substr($compiled_content, -1) == "\n") ) { $compiled_content = substr($compiled_content, 0, -1); } @@ -425,7 +428,7 @@ class Smarty_Compiler extends Smarty { function _compile_tag($template_tag) { /* Matched comment. */ - if ($template_tag{0} == '*' && $template_tag{strlen($template_tag) - 1} == '*') + if (substr($template_tag, 0, 1) == '*' && substr($template_tag, -1) == '*') return ''; /* Split tag into two three parts: command, command modifiers and the arguments. */ @@ -529,7 +532,7 @@ class Smarty_Compiler extends Smarty { case 'strip': case '/strip': - if ($tag_command{0}=='/') { + if (substr($tag_command, 0, 1)=='/') { $this->_pop_tag('strip'); if (--$this->_strip_depth==0) { /* outermost closing {/strip} */ $this->_additional_newline = "\n"; @@ -572,9 +575,9 @@ class Smarty_Compiler extends Smarty { default: if ($this->_compile_compiler_tag($tag_command, $tag_args, $output)) { return $output; - } else if (@$this->_compile_block_tag($tag_command, $tag_args, $tag_modifier, $output)) { + } else if ($this->_compile_block_tag($tag_command, $tag_args, $tag_modifier, $output)) { return $output; - } else if (@$this->_compile_custom_tag($tag_command, $tag_args, $tag_modifier, $output)) { + } else if ($this->_compile_custom_tag($tag_command, $tag_args, $tag_modifier, $output)) { return $output; } else { $this->_syntax_error("unrecognized tag '$tag_command'", E_USER_ERROR, __FILE__, __LINE__); @@ -664,7 +667,7 @@ class Smarty_Compiler extends Smarty { */ function _compile_block_tag($tag_command, $tag_args, $tag_modifier, &$output) { - if ($tag_command{0} == '/') { + if (substr($tag_command, 0, 1) == '/') { $start_tag = false; $tag_command = substr($tag_command, 1); } else @@ -726,17 +729,18 @@ class Smarty_Compiler extends Smarty { if ($start_tag) { $output = '_push_cacheable_state('block', $tag_command); $attrs = $this->_parse_attrs($tag_args); - $arg_list = $this->_compile_arg_list('block', $tag_command, $attrs, $_cache_attrs=''); + $_cache_attrs=''; + $arg_list = $this->_compile_arg_list('block', $tag_command, $attrs, $_cache_attrs); $output .= "$_cache_attrs\$this->_tag_stack[] = array('$tag_command', array(".implode(',', $arg_list).')); '; - $output .= $this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat=true);'; + $output .= '$_block_repeat=true;' . $this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);'; $output .= 'while ($_block_repeat) { ob_start(); ?>'; } else { $output = '_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat=false)'; + $_out_tag_text = $this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat)'; if ($tag_modifier != '') { $this->_parse_modifiers($_out_tag_text, $tag_modifier); } - $output .= 'echo '.$_out_tag_text.'; } '; + $output .= '$_block_repeat=false;echo ' . $_out_tag_text . '; } '; $output .= " array_pop(\$this->_tag_stack); " . $this->_pop_cacheable_state('block', $tag_command) . '?>'; } @@ -801,7 +805,8 @@ class Smarty_Compiler extends Smarty { $_cacheable_state = $this->_push_cacheable_state('function', $tag_command); $attrs = $this->_parse_attrs($tag_args); - $arg_list = $this->_compile_arg_list('function', $tag_command, $attrs, $_cache_attrs=''); + $_cache_attrs = ''; + $arg_list = $this->_compile_arg_list('function', $tag_command, $attrs, $_cache_attrs); $output = $this->_compile_plugin_call('function', $tag_command).'(array('.implode(',', $arg_list)."), \$this)"; if($tag_modifier != '') { @@ -826,7 +831,7 @@ class Smarty_Compiler extends Smarty { */ function _compile_registered_object_tag($tag_command, $attrs, $tag_modifier) { - if ($tag_command{0} == '/') { + if (substr($tag_command, 0, 1) == '/') { $start_tag = false; $tag_command = substr($tag_command, 1); } else { @@ -874,13 +879,13 @@ class Smarty_Compiler extends Smarty { // block method if ($start_tag) { $prefix = "\$this->_tag_stack[] = array('$obj_comp', $args); "; - $prefix .= "\$this->_reg_objects['$object'][0]->$obj_comp(\$this->_tag_stack[count(\$this->_tag_stack)-1][1], null, \$this, \$_block_repeat=true); "; + $prefix .= "\$_block_repeat=true; \$this->_reg_objects['$object'][0]->$obj_comp(\$this->_tag_stack[count(\$this->_tag_stack)-1][1], null, \$this, \$_block_repeat); "; $prefix .= "while (\$_block_repeat) { ob_start();"; $return = null; $postfix = ''; - } else { - $prefix = "\$_obj_block_content = ob_get_contents(); ob_end_clean(); "; - $return = "\$this->_reg_objects['$object'][0]->$obj_comp(\$this->_tag_stack[count(\$this->_tag_stack)-1][1], \$_obj_block_content, \$this, \$_block_repeat=false)"; + } else { + $prefix = "\$_obj_block_content = ob_get_contents(); ob_end_clean(); \$_block_repeat=false;"; + $return = "\$this->_reg_objects['$object'][0]->$obj_comp(\$this->_tag_stack[count(\$this->_tag_stack)-1][1], \$_obj_block_content, \$this, \$_block_repeat)"; $postfix = "} array_pop(\$this->_tag_stack);"; } } else { @@ -1250,6 +1255,13 @@ class Smarty_Compiler extends Smarty { $tokens = $match[0]; + if(empty($tokens)) { + $_error_msg = $elseif ? "'elseif'" : "'if'"; + $_error_msg .= ' statement requires arguments'; + $this->_syntax_error($_error_msg, E_USER_ERROR, __FILE__, __LINE__); + } + + // make sure we have balanced parenthesis $token_count = array_count_values($tokens); if(isset($token_count['(']) && $token_count['('] != $token_count[')']) { @@ -1372,7 +1384,7 @@ class Smarty_Compiler extends Smarty { !in_array($token, $this->security_settings['IF_FUNCS'])) { $this->_syntax_error("(secure mode) '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__); } - } elseif(preg_match('~^' . $this->_var_regexp . '$~', $token) && isset($tokens[$i+1]) && $tokens[$i+1] == '(') { + } elseif(preg_match('~^' . $this->_var_regexp . '$~', $token) && (strpos('+-*/^%&|', substr($token, -1)) === false) && isset($tokens[$i+1]) && $tokens[$i+1] == '(') { // variable function call $this->_syntax_error("variable function call '$token' not allowed in if statement", E_USER_ERROR, __FILE__, __LINE__); } elseif(preg_match('~^' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '(?:' . $this->_mod_regexp . '*)$~', $token)) { @@ -1643,7 +1655,7 @@ class Smarty_Compiler extends Smarty { } elseif(!in_array($val, $this->_permitted_tokens) && !is_numeric($val)) { // literal string - return $this->_expand_quoted_text('"' . $val .'"'); + return $this->_expand_quoted_text('"' . strtr($val, array('\\' => '\\\\', '"' => '\\"')) .'"'); } return $val; } @@ -1723,7 +1735,7 @@ class Smarty_Compiler extends Smarty { } // prevent cutting of first digit in the number (we _definitly_ got a number if the first char is a digit) - if(is_numeric($var_expr{0})) + if(is_numeric(substr($var_expr, 0, 1))) $_var_ref = $var_expr; else $_var_ref = substr($var_expr, 1); @@ -1749,7 +1761,7 @@ class Smarty_Compiler extends Smarty { $_var_name = substr(array_shift($_indexes), 1); $_output = "\$this->_smarty_vars['$_var_name']"; } - } elseif(is_numeric($_var_name) && is_numeric($var_expr{0})) { + } elseif(is_numeric($_var_name) && is_numeric(substr($var_expr, 0, 1))) { // because . is the operator for accessing arrays thru inidizes we need to put it together again for floating point numbers if(count($_indexes) > 0) { @@ -1762,11 +1774,11 @@ class Smarty_Compiler extends Smarty { } foreach ($_indexes as $_index) { - if ($_index{0} == '[') { + if (substr($_index, 0, 1) == '[') { $_index = substr($_index, 1, -1); if (is_numeric($_index)) { $_output .= "[$_index]"; - } elseif ($_index{0} == '$') { + } elseif (substr($_index, 0, 1) == '$') { if (strpos($_index, '.') !== false) { $_output .= '[' . $this->_parse_var($_index) . ']'; } else { @@ -1778,8 +1790,8 @@ class Smarty_Compiler extends Smarty { $_var_section_prop = isset($_var_parts[1]) ? $_var_parts[1] : 'index'; $_output .= "[\$this->_sections['$_var_section']['$_var_section_prop']]"; } - } else if ($_index{0} == '.') { - if ($_index{1} == '$') + } else if (substr($_index, 0, 1) == '.') { + if (substr($_index, 1, 1) == '$') $_output .= "[\$this->_tpl_vars['" . substr($_index, 2) . "']]"; else $_output .= "['" . substr($_index, 1) . "']"; @@ -1788,7 +1800,7 @@ class Smarty_Compiler extends Smarty { $this->_syntax_error('call to internal object members is not allowed', E_USER_ERROR, __FILE__, __LINE__); } elseif($this->security && substr($_index, 2, 1) == '_') { $this->_syntax_error('(secure) call to private object member is not allowed', E_USER_ERROR, __FILE__, __LINE__); - } elseif ($_index{2} == '$') { + } elseif (substr($_index, 2, 1) == '$') { if ($this->security) { $this->_syntax_error('(secure) call to dynamic object member is not allowed', E_USER_ERROR, __FILE__, __LINE__); } else { @@ -1797,7 +1809,7 @@ class Smarty_Compiler extends Smarty { } else { $_output .= $_index; } - } elseif ($_index{0} == '(') { + } elseif (substr($_index, 0, 1) == '(') { $_index = $this->_parse_parenth_args($_index); $_output .= $_index; } else { @@ -1894,7 +1906,7 @@ class Smarty_Compiler extends Smarty { preg_match_all('~:(' . $this->_qstr_regexp . '|[^:]+)~', $modifier_arg_strings[$_i], $_match); $_modifier_args = $_match[1]; - if ($_modifier_name{0} == '@') { + if (substr($_modifier_name, 0, 1) == '@') { $_map_array = false; $_modifier_name = substr($_modifier_name, 1); } else { @@ -1916,10 +1928,10 @@ class Smarty_Compiler extends Smarty { if($_modifier_name == 'default') { // supress notifications of default modifier vars and args - if($output{0} == '$') { + if(substr($output, 0, 1) == '$') { $output = '@' . $output; } - if(isset($_modifier_args[0]) && $_modifier_args[0]{0} == '$') { + if(isset($_modifier_args[0]) && substr($_modifier_args[0], 0, 1) == '$') { $_modifier_args[0] = '@' . $_modifier_args[0]; } } @@ -1971,7 +1983,7 @@ class Smarty_Compiler extends Smarty { /* Extract the reference name. */ $_ref = substr($indexes[0], 1); foreach($indexes as $_index_no=>$_index) { - if ($_index{0} != '.' && $_index_no<2 || !preg_match('~^(\.|\[|->)~', $_index)) { + if (substr($_index, 0, 1) != '.' && $_index_no<2 || !preg_match('~^(\.|\[|->)~', $_index)) { $this->_syntax_error('$smarty' . implode('', array_slice($indexes, 0, 2)) . ' is an invalid reference', E_USER_ERROR, __FILE__, __LINE__); } } @@ -2209,7 +2221,7 @@ class Smarty_Compiler extends Smarty { if (!isset($this->_cache_serial)) $this->_cache_serial = md5(uniqid('Smarty')); $_ret = 'if ($this->caching && !$this->_cache_including) { echo \'{nocache:' . $this->_cache_serial . '#' . $this->_nocache_count - . '}\';}'; + . '}\'; };'; return $_ret; } @@ -2226,7 +2238,7 @@ class Smarty_Compiler extends Smarty { || --$this->_cacheable_state>0) return ''; return 'if ($this->caching && !$this->_cache_including) { echo \'{/nocache:' . $this->_cache_serial . '#' . ($this->_nocache_count++) - . '}\';}'; + . '}\'; };'; } diff --git a/include/smarty/debug.tpl b/include/smarty/debug.tpl index 7a52cc5ff..7f1c9d425 100644 --- a/include/smarty/debug.tpl +++ b/include/smarty/debug.tpl @@ -5,7 +5,7 @@ {assign_debug_info} {if isset($_smarty_debug_output) and $_smarty_debug_output eq "html"} - +
{section name=templates loop=$_debug_tpls} @@ -37,7 +37,7 @@ {rdelim} _smarty_console = window.open("",title.value,"width=680,height=600,resizable,scrollbars=yes"); _smarty_console.document.write("Smarty Debug Console_"+self.name+""); - _smarty_console.document.write("
Smarty Debug Console
included templates & config files (load time in seconds):
"); + _smarty_console.document.write("
"); _smarty_console.document.write(""); _smarty_console.document.write(""); {section name=templates loop=$_debug_tpls} diff --git a/include/smarty/internals/core.create_dir_structure.php b/include/smarty/internals/core.create_dir_structure.php index 999cf5930..3eecc4972 100644 --- a/include/smarty/internals/core.create_dir_structure.php +++ b/include/smarty/internals/core.create_dir_structure.php @@ -22,7 +22,7 @@ function smarty_core_create_dir_structure($params, &$smarty) /* unix-style paths */ $_dir = $params['dir']; $_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY); - $_new_dir = ($_dir{0}=='/') ? '/' : getcwd().'/'; + $_new_dir = (substr($_dir, 0, 1)=='/') ? '/' : getcwd().'/'; if($_use_open_basedir = !empty($_open_basedir_ini)) { $_open_basedirs = explode(':', $_open_basedir_ini); } diff --git a/include/smarty/internals/core.display_debug_console.php b/include/smarty/internals/core.display_debug_console.php index a5d72913c..1a80f3909 100644 --- a/include/smarty/internals/core.display_debug_console.php +++ b/include/smarty/internals/core.display_debug_console.php @@ -23,7 +23,7 @@ function smarty_core_display_debug_console($params, &$smarty) // set path to debug template from SMARTY_DIR $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl'; if($smarty->security && is_file($smarty->debug_tpl)) { - $smarty->secure_dir[] = dirname(realpath($smarty->debug_tpl)); + $smarty->secure_dir[] = realpath($smarty->debug_tpl); } $smarty->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl'; } diff --git a/include/smarty/internals/core.is_secure.php b/include/smarty/internals/core.is_secure.php index 342f3aff8..d54abd432 100644 --- a/include/smarty/internals/core.is_secure.php +++ b/include/smarty/internals/core.is_secure.php @@ -27,18 +27,21 @@ function smarty_core_is_secure($params, &$smarty) foreach ((array)$params['resource_base_path'] as $curr_dir) { if ( ($_cd = realpath($curr_dir)) !== false && strncmp($_rp, $_cd, strlen($_cd)) == 0 && - $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) { + substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { return true; } } } if (!empty($smarty->secure_dir)) { foreach ((array)$smarty->secure_dir as $curr_dir) { - if ( ($_cd = realpath($curr_dir)) !== false && - strncmp($_rp, $_cd, strlen($_cd)) == 0 && - $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) { - return true; - } + if ( ($_cd = realpath($curr_dir)) !== false) { + if($_cd == $_rp) { + return true; + } elseif (strncmp($_rp, $_cd, strlen($_cd)) == 0 && + substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR) { + return true; + } + } } } } else { diff --git a/include/smarty/internals/core.is_trusted.php b/include/smarty/internals/core.is_trusted.php index f0bd2fb8c..429973158 100644 --- a/include/smarty/internals/core.is_trusted.php +++ b/include/smarty/internals/core.is_trusted.php @@ -25,7 +25,7 @@ function smarty_core_is_trusted($params, &$smarty) if (!empty($curr_dir) && is_readable ($curr_dir)) { $_cd = realpath($curr_dir); if (strncmp($_rp, $_cd, strlen($_cd)) == 0 - && $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) { + && substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { $_smarty_trusted = true; break; } diff --git a/include/smarty/internals/core.process_cached_inserts.php b/include/smarty/internals/core.process_cached_inserts.php index 29cb007eb..1d78edd93 100644 --- a/include/smarty/internals/core.process_cached_inserts.php +++ b/include/smarty/internals/core.process_cached_inserts.php @@ -52,7 +52,7 @@ function smarty_core_process_cached_inserts($params, &$smarty) $replace = ''; } - $params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']); + $params['results'] = substr_replace($params['results'], $replace, strpos($params['results'], $cached_inserts[$i]), strlen($cached_inserts[$i])); if ($smarty->debugging) { $_params = array(); require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); diff --git a/include/smarty/internals/core.process_compiled_include.php b/include/smarty/internals/core.process_compiled_include.php index 3e1d4c15a..d539423bf 100644 --- a/include/smarty/internals/core.process_compiled_include.php +++ b/include/smarty/internals/core.process_compiled_include.php @@ -20,6 +20,11 @@ function smarty_core_process_compiled_include($params, &$smarty) $smarty->_cache_including = true; $_return = $params['results']; + + foreach ($smarty->_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) { + $smarty->_include($_include_file_path, true); + } + foreach ($smarty->_cache_serials as $_include_file_path=>$_cache_serial) { $_return = preg_replace_callback('!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s', array(&$smarty, '_process_compiled_include_callback'), diff --git a/include/smarty/internals/core.read_cache_file.php b/include/smarty/internals/core.read_cache_file.php index ecb147089..c60e113a7 100644 --- a/include/smarty/internals/core.read_cache_file.php +++ b/include/smarty/internals/core.read_cache_file.php @@ -90,16 +90,6 @@ function smarty_core_read_cache_file(&$params, &$smarty) } } - foreach ($_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) { - if (empty($smarty->_cache_serials[$_include_file_path])) { - $smarty->_include($_include_file_path, true); - } - - if ($smarty->_cache_serials[$_include_file_path] != $_cache_serial) { - /* regenerate */ - return false; - } - } $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $_cache_info); $smarty->_cache_info = $_cache_info; diff --git a/include/smarty/internals/core.rmdir.php b/include/smarty/internals/core.rmdir.php index 4fdbccc95..2166c44d2 100644 --- a/include/smarty/internals/core.rmdir.php +++ b/include/smarty/internals/core.rmdir.php @@ -32,7 +32,6 @@ function smarty_core_rmdir($params, &$smarty) 'level' => $params['level'] + 1, 'exp_time' => $params['exp_time'] ); - require_once(SMARTY_CORE_DIR . 'core.rmdir.php'); smarty_core_rmdir($_params, $smarty); } else { diff --git a/include/smarty/internals/core.write_compiled_include.php b/include/smarty/internals/core.write_compiled_include.php index 5e0b2e0dd..3a7809417 100644 --- a/include/smarty/internals/core.write_compiled_include.php +++ b/include/smarty/internals/core.write_compiled_include.php @@ -15,8 +15,8 @@ function smarty_core_write_compiled_include($params, &$smarty) { - $_tag_start = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\';\}'; - $_tag_end = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\';\}'; + $_tag_start = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\'; \};'; + $_tag_end = 'if \(\$this->caching && \!\$this->_cache_including\) \{ echo \'\{/nocache\:(\\2)#(\\3)\}\'; \};'; preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us', $params['compiled_content'], $_match_source, PREG_SET_ORDER); diff --git a/include/smarty/plugins/block.textformat.php b/include/smarty/plugins/block.textformat.php index aaebab2f5..8cd010acb 100644 --- a/include/smarty/plugins/block.textformat.php +++ b/include/smarty/plugins/block.textformat.php @@ -23,6 +23,7 @@ * indent_char: string (" ") * wrap_boundary: boolean (true) * + * @author Monte Ohrt * @param string contents of the block * @param Smarty clever simulation of a method * @return string string $content re-formatted diff --git a/include/smarty/plugins/compiler.assign.php b/include/smarty/plugins/compiler.assign.php index 2e0201779..be1729850 100644 --- a/include/smarty/plugins/compiler.assign.php +++ b/include/smarty/plugins/compiler.assign.php @@ -13,6 +13,8 @@ * Purpose: assign a value to a template variable * @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign} * (Smarty online manual) + * @author Monte Ohrt (initial author) + * @auther messju mohr (conversion to compiler function) * @param string containing var-attribute and value-attribute * @param Smarty_Compiler */ diff --git a/include/smarty/plugins/function.assign_debug_info.php b/include/smarty/plugins/function.assign_debug_info.php index 8015624b1..654049876 100644 --- a/include/smarty/plugins/function.assign_debug_info.php +++ b/include/smarty/plugins/function.assign_debug_info.php @@ -11,6 +11,7 @@ * Type: function
* Name: assign_debug_info
* Purpose: assign debug info to the template
+ * @author Monte Ohrt * @param array unused in this plugin, this plugin uses {@link Smarty::$_config}, * {@link Smarty::$_tpl_vars} and {@link Smarty::$_smarty_debug_info} * @param Smarty diff --git a/include/smarty/plugins/function.config_load.php b/include/smarty/plugins/function.config_load.php index db7f8f6b9..db89f638c 100644 --- a/include/smarty/plugins/function.config_load.php +++ b/include/smarty/plugins/function.config_load.php @@ -13,6 +13,8 @@ * Purpose: load config file vars * @link http://smarty.php.net/manual/en/language.function.config.load.php {config_load} * (Smarty online manual) + * @author Monte Ohrt + * @author messju mohr (added use of resources) * @param array Format: *
  * array('file' => required config file name,
diff --git a/include/smarty/plugins/function.counter.php b/include/smarty/plugins/function.counter.php
index cfe5dd886..1f26db5fb 100644
--- a/include/smarty/plugins/function.counter.php
+++ b/include/smarty/plugins/function.counter.php
@@ -12,6 +12,7 @@
  * Type:     function
* Name: counter
* Purpose: print out a counter value + * @author Monte Ohrt * @link http://smarty.php.net/manual/en/language.function.counter.php {counter} * (Smarty online manual) * @param array parameters diff --git a/include/smarty/plugins/function.eval.php b/include/smarty/plugins/function.eval.php index 3a4b8b2b8..ff0472de2 100644 --- a/include/smarty/plugins/function.eval.php +++ b/include/smarty/plugins/function.eval.php @@ -14,6 +14,7 @@ * Purpose: evaluate a template variable as a template
* @link http://smarty.php.net/manual/en/language.function.eval.php {eval} * (Smarty online manual) + * @author Monte Ohrt * @param array * @param Smarty */ diff --git a/include/smarty/plugins/function.fetch.php b/include/smarty/plugins/function.fetch.php index f5a6987a9..81b1bfc6b 100644 --- a/include/smarty/plugins/function.fetch.php +++ b/include/smarty/plugins/function.fetch.php @@ -14,6 +14,7 @@ * Purpose: fetch file, web or ftp data and display results * @link http://smarty.php.net/manual/en/language.function.fetch.php {fetch} * (Smarty online manual) + * @author Monte Ohrt * @param array * @param Smarty * @return string|null if the assign parameter is passed, Smarty assigns the diff --git a/include/smarty/plugins/function.html_image.php b/include/smarty/plugins/function.html_image.php index 19f3ad876..9abae72ef 100644 --- a/include/smarty/plugins/function.html_image.php +++ b/include/smarty/plugins/function.html_image.php @@ -19,9 +19,10 @@ * - width = image width (optional, default actual width) * - basedir = base directory for absolute paths, default * is environment variable DOCUMENT_ROOT + * - path_prefix = prefix for path output (optional, default empty) * - * Examples: {html_image file="images/masthead.gif"} - * Output: + * Examples: {html_image file="/images/masthead.gif"} + * Output: * @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image} * (Smarty online manual) * @author Monte Ohrt @@ -44,6 +45,7 @@ function smarty_function_html_image($params, &$smarty) $extra = ''; $prefix = ''; $suffix = ''; + $path_prefix = ''; $server_vars = ($smarty->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS']; $basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : ''; foreach($params as $_key => $_val) { @@ -52,6 +54,7 @@ function smarty_function_html_image($params, &$smarty) case 'height': case 'width': case 'dpi': + case 'path_prefix': case 'basedir': $$_key = $_val; break; @@ -90,15 +93,9 @@ function smarty_function_html_image($params, &$smarty) } else { $_image_path = $file; } - + if(!isset($params['width']) || !isset($params['height'])) { - if ($smarty->security && - ($_params = array('resource_type' => 'file', 'resource_name' => $_image_path)) && - (require_once(SMARTY_CORE_DIR . 'core.is_secure.php')) && - (!smarty_core_is_secure($_params, $smarty)) ) { - $smarty->trigger_error("html_image: (secure) '$_image_path' not in secure directory", E_USER_NOTICE); - - } elseif (!$_image_data = @getimagesize($_image_path)) { + if(!$_image_data = @getimagesize($_image_path)) { if(!file_exists($_image_path)) { $smarty->trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE); return; @@ -110,7 +107,13 @@ function smarty_function_html_image($params, &$smarty) return; } } - + if ($smarty->security && + ($_params = array('resource_type' => 'file', 'resource_name' => $_image_path)) && + (require_once(SMARTY_CORE_DIR . 'core.is_secure.php')) && + (!smarty_core_is_secure($_params, $smarty)) ) { + $smarty->trigger_error("html_image: (secure) '$_image_path' not in secure directory", E_USER_NOTICE); + } + if(!isset($params['width'])) { $width = $_image_data[0]; } @@ -131,7 +134,7 @@ function smarty_function_html_image($params, &$smarty) $height = round($height * $_resize); } - return $prefix . ''.$alt.'' . $suffix; + return $prefix . ''.$alt.'' . $suffix; } /* vim: set expandtab: */ diff --git a/include/smarty/plugins/function.html_options.php b/include/smarty/plugins/function.html_options.php index ae864f732..cebadde47 100644 --- a/include/smarty/plugins/function.html_options.php +++ b/include/smarty/plugins/function.html_options.php @@ -21,6 +21,7 @@ * the passed parameters * @link http://smarty.php.net/manual/en/language.function.html.options.php {html_image} * (Smarty online manual) + * @author Monte Ohrt * @param array * @param Smarty * @return string diff --git a/include/smarty/plugins/function.html_radios.php b/include/smarty/plugins/function.html_radios.php index dc7baee84..7503cfaca 100644 --- a/include/smarty/plugins/function.html_radios.php +++ b/include/smarty/plugins/function.html_radios.php @@ -48,6 +48,7 @@ function smarty_function_html_radios($params, &$smarty) $selected = null; $separator = ''; $labels = true; + $label_ids = false; $output = null; $extra = ''; @@ -68,6 +69,7 @@ function smarty_function_html_radios($params, &$smarty) break; case 'labels': + case 'label_ids': $$_key = (bool)$_val; break; @@ -106,13 +108,13 @@ function smarty_function_html_radios($params, &$smarty) if (isset($options)) { foreach ($options as $_key=>$_val) - $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels); + $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids); } else { foreach ($values as $_i=>$_key) { $_val = isset($output[$_i]) ? $output[$_i] : ''; - $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels); + $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids); } } @@ -125,19 +127,23 @@ function smarty_function_html_radios($params, &$smarty) } -function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels) { +function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids) { $_output = ''; if ($labels) { - $_id = smarty_function_escape_special_chars($name . '_' . $value); - $_output .= '
Smarty Debug Console
included templates & config files (load time in seconds):