summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0b9c86a)
raw | patch | inline | side by side (parent: 0b9c86a)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 2 Jun 2006 14:03:58 +0000 (14:03 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 2 Jun 2006 14:03:58 +0000 (14:03 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3644 594d385d-05f5-0310-b6e9-bd551577e9d8
52 files changed:
index 5c1f3fe14675d394575d11e5505780bace77abb9..921155625116905e9f9170ccf27e82302815f17b 100644 (file)
--- a/TODO
+++ b/TODO
-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 0c5378852d039baadcf912056466c649c3a1891b..a9a9af2fd16034521447c0a47902e9b448ea02ed 100644 (file)
--- a/debian/README.debian
+++ b/debian/README.debian
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 <cajus@debian.org> Fri 02 Jun 2006 16:23:50 +0200
diff --git a/debian/control b/debian/control
index d87bda78265811313479f95144f16a5290df9d1a..d27ec4c022b58d494c8e3a880eb2d528c0b43d4b 100644 (file)
--- a/debian/control
+++ b/debian/control
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
index b5fdd22694311760c32c73b94786b93982544772..622c0e8a021abede358101b641507d52f695dc7f 100644 (file)
* 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 <andrei@php.net>
* @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
* @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');
$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);
*/
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
index bb51290079a7b5c8ded032a92f8a8756924e3180..47ec24efaa2bfbdd72c9a0e4bcf0c703addd46c3 100644 (file)
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei@php.net>
* @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
*
* @var string
*/
- var $_version = '2.6.9';
+ var $_version = '2.6.14';
/**
* current template inclusion depth
{
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;
}
}
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;
}
}
*/
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;
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 {
if ($this->_cache_including) {
/* return next set of cache_attrs */
- $_return =& current($_cache_attrs);
+ $_return = current($_cache_attrs);
next($_cache_attrs);
return $_return;
index b444b72454528ae06bd9e4809c748373191f406c..cbcbddb1bd65701972b563de0241ff9d820cb3fa 100644 (file)
* @link http://smarty.php.net/
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei@php.net>
- * @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
$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) {
$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);
}
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. */
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";
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__);
*/
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
if ($start_tag) {
$output = '<?php ' . $this->_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 = '<?php $_block_content = ob_get_contents(); ob_end_clean(); ';
- $_out_tag_text = $this->_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) . '?>';
}
$_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 != '') {
*/
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 {
// 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 {
$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[')']) {
!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)) {
}
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;
}
}
// 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);
$_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)
{
}
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 {
$_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) . "']";
$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 {
} else {
$_output .= $_index;
}
- } elseif ($_index{0} == '(') {
+ } elseif (substr($_index, 0, 1) == '(') {
$_index = $this->_parse_parenth_args($_index);
$_output .= $_index;
} else {
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 {
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];
}
}
/* 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__);
}
}
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;
}
|| --$this->_cacheable_state>0) return '';
return 'if ($this->caching && !$this->_cache_including) { echo \'{/nocache:'
. $this->_cache_serial . '#' . ($this->_nocache_count++)
- . '}\';}';
+ . '}\'; };';
}
index 7a52cc5ff3e04d3d7a4894296dc2e95397e78712..7f1c9d42587ceb21a097334af84aa6292f352f67 100644 (file)
--- a/include/smarty/debug.tpl
+++ b/include/smarty/debug.tpl
{assign_debug_info}
{if isset($_smarty_debug_output) and $_smarty_debug_output eq "html"}
- <table summary="" border=0 width="100%">
+ <table border=0 width=100%>
<tr bgcolor=#cccccc><th colspan=2>Smarty Debug Console</th></tr>
<tr bgcolor=#cccccc><td colspan=2><b>included templates & config files (load time in seconds):</b></td></tr>
{section name=templates loop=$_debug_tpls}
{rdelim}
_smarty_console = window.open("",title.value,"width=680,height=600,resizable,scrollbars=yes");
_smarty_console.document.write("<HTML><HEAD><TITLE>Smarty Debug Console_"+self.name+"</TITLE></HEAD><BODY bgcolor=#ffffff>");
- _smarty_console.document.write("<table summary="" border=0 width='100%'>");
+ _smarty_console.document.write("<table border=0 width=100%>");
_smarty_console.document.write("<tr bgcolor=#cccccc><th colspan=2>Smarty Debug Console</th></tr>");
_smarty_console.document.write("<tr bgcolor=#cccccc><td colspan=2><b>included templates & config files (load time in seconds):</b></td></tr>");
{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 999cf59302c690c14e488f57d48c6761abcddb68..3eecc49723c78615f8e28d0623984d07d09a58c9 100644 (file)
/* 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 a5d72913c0817510cb8e3d9ff8f81dc8d1356de9..1a80f39096a096099424c7630f79d6de640b84d9 100644 (file)
// 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 342f3aff876a9324b5df3bbbfeeb39965d520756..d54abd432275a75bba7c53274ca5c9866039c871 100644 (file)
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 f0bd2fb8c96f945e9e0d9015749e07a6e9bf84b4..429973158d6cb75b3a6126f471aac3218fb6dc56 100644 (file)
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 29cb007eb1d3eb945d960776d18aa475de4afa55..1d78edd937a587cf793a4d74a2bd65560b440563 100644 (file)
$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 3e1d4c15a038f3c4b5d7ee87ad947744948903ef..d539423bf740ee58787d4352a9e83b2990696b1f 100644 (file)
$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 ecb14708999be2e1b581333971c01b15444d7b72..c60e113a71a02c0f6e6423d71b4403134d73685d 100644 (file)
}
}
- 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;
index 4fdbccc95cd65beae478a7f639d53b2b08ef376d..2166c44d28aea09e7d044ad04b661f8bfe8aefce 100644 (file)
'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 5e0b2e0dde63a24f75477b1cfbe7e82f6d569404..3a7809417d7ab0c57d626c51d99a7dcdc5eb3f1a 100644 (file)
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 aaebab2f512c3710124ff1eba65995e2cf4f9b03..8cd010acb4e29089db5122c40b119c08de316028 100644 (file)
* indent_char: string (" ")
* wrap_boundary: boolean (true)
* </pre>
+ * @author Monte Ohrt <monte at ohrt dot com>
* @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 2e0201779628ea68db65d965499e5d00e8f6f5df..be1729850197a6bcbd5c0b82bfaaadc59fe50043 100644 (file)
* 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 <monte at ohrt dot com> (initial author)
+ * @auther messju mohr <messju at lammfellpuschen dot de> (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 8015624b1f781391900d3f843a705aeb28c3f69b..654049876a92f6797ce0773202c6e521426ca17d 100644 (file)
* Type: function<br>
* Name: assign_debug_info<br>
* Purpose: assign debug info to the template<br>
+ * @author Monte Ohrt <monte at ohrt dot com>
* @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 db7f8f6b9b4281a97d49ede001aece3fb032fc24..db89f638c28aba5755ee2ee58715fc250758dcdd 100644 (file)
* 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 <monte at ohrt dot com>
+ * @author messju mohr <messju at lammfellpuschen dot de> (added use of resources)
* @param array Format:
* <pre>
* array('file' => required config file name,
diff --git a/include/smarty/plugins/function.counter.php b/include/smarty/plugins/function.counter.php
index cfe5dd886f987736a39173d7fbbf5a1cd60957d7..1f26db5fb632166ad33d46d15faa9449cfd84dd4 100644 (file)
* Type: function<br>
* Name: counter<br>
* Purpose: print out a counter value
+ * @author Monte Ohrt <monte at ohrt dot com>
* @link http://smarty.php.net/manual/en/language.function.counter.php {counter}
* (Smarty online manual)
* @param array parameters
index 3a4b8b2b8c4e3514e7352849084b8979f27432bd..ff0472de250e235d88243cedac343572723e508d 100644 (file)
* Purpose: evaluate a template variable as a template<br>
* @link http://smarty.php.net/manual/en/language.function.eval.php {eval}
* (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param array
* @param Smarty
*/
index f5a6987a9052504e8318e769532aabb301163105..81b1bfc6b9a03f916fcdb62209f6f458c5e712e5 100644 (file)
* 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 <monte at ohrt dot com>
* @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 19f3ad876ea6180cade2e3d99315c087d1888a41..9abae72ef7623066530109baf7d72dfde8f5422e 100644 (file)
* - 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: <img alt="" src="images/masthead.gif" width=400 height=23>
+ * Examples: {html_image file="/images/masthead.gif"}
+ * Output: <img src="/images/masthead.gif" width=400 height=23>
* @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
$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) {
case 'height':
case 'width':
case 'dpi':
+ case 'path_prefix':
case 'basedir':
$$_key = $_val;
break;
} 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;
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];
}
$height = round($height * $_resize);
}
- return $prefix . '<img src="'.$file.'" alt="'.$alt.'" width="'.$width.'" height="'.$height.'"'.$extra.' />' . $suffix;
+ return $prefix . '<img src="'.$path_prefix.$file.'" alt="'.$alt.'" width="'.$width.'" height="'.$height.'"'.$extra.' />' . $suffix;
}
/* vim: set expandtab: */
diff --git a/include/smarty/plugins/function.html_options.php b/include/smarty/plugins/function.html_options.php
index ae864f7327ca9c9f80d055ddb96ca2d09ef5cfaa..cebadde4794cca9e3883ef39c47828851683b754 100644 (file)
* the passed parameters
* @link http://smarty.php.net/manual/en/language.function.html.options.php {html_image}
* (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @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 dc7baee84febc7dfa1b9a28f58aceb6c1ef229a5..7503cfaca8f01a1b7652ff69820b242e7e8497d2 100644 (file)
$selected = null;
$separator = '';
$labels = true;
+ $label_ids = false;
$output = null;
$extra = '';
break;
case 'labels':
+ case 'label_ids':
$$_key = (bool)$_val;
break;
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);
}
}
}
-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 .= '<label for="' . $_id . '">';
+ if($label_ids) {
+ $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!', '_', $name . '_' . $value));
+ $_output .= '<label for="' . $_id . '">';
+ } else {
+ $_output .= '<label>';
+ }
}
$_output .= '<input type="radio" name="'
. smarty_function_escape_special_chars($name) . '" value="'
. smarty_function_escape_special_chars($value) . '"';
- if ($labels) $_output .= ' id="' . $_id . '"';
+ if ($labels && $label_ids) $_output .= ' id="' . $_id . '"';
- if ($value==$selected) {
+ if ((string)$value==$selected) {
$_output .= ' checked="checked"';
}
$_output .= $extra . ' />' . $output;
diff --git a/include/smarty/plugins/function.html_select_date.php b/include/smarty/plugins/function.html_select_date.php
index fc2d449a8e152ea15c593eb9e4d171a5efb3afc5..6153c59f26ea23905461ab354cf7fe696a4f87cd 100644 (file)
* month values (Gary Loescher)
* - 1.3.1 added support for choosing format for
* day values (Marcus Bointon)
- * - 1.3.2 suppport negative timestamps, force year
+ * - 1.3.2 support negative timestamps, force year
* dropdown to include given date unless explicitly set (Monte)
* @link http://smarty.php.net/manual/en/language.function.html.select.date.php {html_select_date}
* (Smarty online manual)
* @version 1.3.2
- * @author Andrei Zmievski
+ * @author Andrei Zmievski
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param array
* @param Smarty
* @return string
*/
function smarty_function_html_select_date($params, &$smarty)
{
+ require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
require_once $smarty->_get_plugin_filepath('function','html_options');
/* Default values. */
$day_empty = null;
$month_empty = null;
$year_empty = null;
+ $extra_attrs = '';
foreach ($params as $_key=>$_value) {
switch ($_key) {
break;
default:
- $smarty->trigger_error("[html_select_date] unknown parameter $_key", E_USER_WARNING);
-
+ if(!is_array($_value)) {
+ $extra_attrs .= ' '.$_key.'="'.smarty_function_escape_special_chars($_value).'"';
+ } else {
+ $smarty->trigger_error("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
+ }
+ break;
}
}
if (null !== $all_extra){
$month_result .= ' ' . $all_extra;
}
- $month_result .= '>'."\n";
+ $month_result .= $extra_attrs . '>'."\n";
$month_result .= smarty_function_html_options(array('output' => $month_names,
'values' => $month_values,
- 'selected' => $a=$time[1] ? strftime($month_value_format, mktime(0, 0, 0, (int)$time[1], 1, 2000)) : '',
+ 'selected' => (int)$time[1] ? strftime($month_value_format, mktime(0, 0, 0, (int)$time[1], 1, 2000)) : '',
'print_result' => false),
$smarty);
$month_result .= '</select>';
if (null !== $day_extra){
$day_result .= ' ' . $day_extra;
}
- $day_result .= '>'."\n";
+ $day_result .= $extra_attrs . '>'."\n";
$day_result .= smarty_function_html_options(array('output' => $days,
'values' => $day_values,
'selected' => $time[2],
if (null !== $year_extra){
$year_result .= ' ' . $year_extra;
}
- $year_result .= '>';
+ $year_result .= ' />';
} else {
$years = range((int)$start_year, (int)$end_year);
if ($reverse_years) {
if (null !== $year_extra){
$year_result .= ' ' . $year_extra;
}
- $year_result .= '>'."\n";
+ $year_result .= $extra_attrs . '>'."\n";
$year_result .= smarty_function_html_options(array('output' => $years,
'values' => $yearvals,
'selected' => $time[0],
diff --git a/include/smarty/plugins/function.html_select_time.php b/include/smarty/plugins/function.html_select_time.php
index 00cd1ae88966a494d276442b5cd684fe50c1e230..2e5be7efe3ff0bc9d17ec69686163d39a97f76c1 100644 (file)
* Purpose: Prints the dropdowns for time selection
* @link http://smarty.php.net/manual/en/language.function.html.select.time.php {html_select_time}
* (Smarty online manual)
+ * @author Roberto Berto <roberto@berto.net>
+ * @credits Monte Ohrt <monte AT ohrt DOT com>
* @param array
* @param Smarty
* @return string
index 043910770621bee215263b1063016b05e37adaea..71672fea41f6c9a81bd848d938952b256ba7f00d 100644 (file)
* Purpose: handle math computations in template<br>
* @link http://smarty.php.net/manual/en/language.function.math.php {math}
* (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param array
* @param Smarty
* @return string
$smarty->trigger_error("math: parameter $key: is not numeric");
return;
}
- $equation = preg_replace("/\b$key\b/",$val, $equation);
+ $equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
}
}
index 2ba54de5ab70a0fe1ac8c84f728234257b62e21d..3a76b785a4e73f4f415d51bab0551b1a6b4faf0f 100644 (file)
* 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
* @param Smarty
* @return string
case 'vauto':
case 'mouseoff':
case 'followmouse':
+ case 'closeclick':
if ($_value) $append .= ',' . strtoupper($_key);
break;
diff --git a/include/smarty/plugins/function.popup_init.php b/include/smarty/plugins/function.popup_init.php
index f62c33c13f68d8e2d65c09b6e8827ef53d923807..93cb45450c7fd5638117cb2c6a07d7c1f02a7d2c 100644 (file)
* 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
* @param Smarty
* @return string
diff --git a/include/smarty/plugins/modifier.capitalize.php b/include/smarty/plugins/modifier.capitalize.php
index 2b9169cefa67b6ec415950c5ea68f94c0133c161..bca951a08bc39c652bb167cbcf6dd9e8372a9a55 100644 (file)
* Purpose: capitalize words in the string
* @link http://smarty.php.net/manual/en/language.modifiers.php#LANGUAGE.MODIFIER.CAPITALIZE
* capitalize (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @return string
*/
diff --git a/include/smarty/plugins/modifier.count_characters.php b/include/smarty/plugins/modifier.count_characters.php
index 49ce655e85354a7a121bcad6380167ed49fd9da5..5ed9a87cd1f099b7a5d45944e7405e6c139ed58c 100644 (file)
* Purpose: count the number of characters in a text
* @link http://smarty.php.net/manual/en/language.modifier.count.characters.php
* count_characters (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param boolean include whitespace in the character count
* @return integer
diff --git a/include/smarty/plugins/modifier.count_paragraphs.php b/include/smarty/plugins/modifier.count_paragraphs.php
index 6a9833c97ca009f4a963095cc6bf8d6d6d2f1276..e0e274da77a9c70324fbb7a207a9a177a8ce1005 100644 (file)
* Purpose: count the number of paragraphs in a text
* @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php
* count_paragraphs (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @return integer
*/
diff --git a/include/smarty/plugins/modifier.count_sentences.php b/include/smarty/plugins/modifier.count_sentences.php
index 0c210f08fe97801fe36bc63847f00b69544f5387..f66ea1703d3c236398f491293adcb7a0d9a4d909 100644 (file)
* Purpose: count the number of sentences in a text
* @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php
* count_sentences (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @return integer
*/
diff --git a/include/smarty/plugins/modifier.count_words.php b/include/smarty/plugins/modifier.count_words.php
index 42c8a741c5cdd6754dc3f18b4e83f56b0e990408..9d339f5422f93440c9539b508ac97e1b450d91b6 100644 (file)
* Purpose: count the number of words in a text
* @link http://smarty.php.net/manual/en/language.modifier.count.words.php
* count_words (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @return integer
*/
diff --git a/include/smarty/plugins/modifier.date_format.php b/include/smarty/plugins/modifier.date_format.php
index 2f36b3b79c0ae2418f1228a164429492403d5321..523c144f12443914db57487f98c03b66ad2f9d7c 100644 (file)
* - default_date: default date if $string is empty
* @link http://smarty.php.net/manual/en/language.modifier.date.format.php
* date_format (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param string
* @param string
diff --git a/include/smarty/plugins/modifier.debug_print_var.php b/include/smarty/plugins/modifier.debug_print_var.php
index b9bb1848802ef8884a6069d662d7402b0644b9f6..d28956a0ba8e48f48c6034123063863e8b7f7a74 100644 (file)
* Purpose: formats variable contents for display in the console
* @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php
* debug_print_var (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param array|object
* @param integer
* @param integer
diff --git a/include/smarty/plugins/modifier.default.php b/include/smarty/plugins/modifier.default.php
index 8268e396ff0dc77837d3f81a64d8b4ab62718e29..70011fd6b55edc9c7f5a3352eaa85aec1d542e17 100644 (file)
* Purpose: designate default value for empty variables
* @link http://smarty.php.net/manual/en/language.modifier.default.php
* default (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param string
* @return string
diff --git a/include/smarty/plugins/modifier.escape.php b/include/smarty/plugins/modifier.escape.php
index a32a8766caf7565b1e2d0ebafb39247eb74cf737..a2f52b232c1316ee9b7d0a2ea70cfc41c1b012c6 100644 (file)
* Purpose: Escape the string according to escapement type
* @link http://smarty.php.net/manual/en/language.modifier.escape.php
* escape (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param html|htmlall|url|quotes|hex|hexentity|javascript
* @return string
*/
-function smarty_modifier_escape($string, $esc_type = 'html')
+function smarty_modifier_escape($string, $esc_type = 'html', $char_set = 'ISO-8859-1')
{
switch ($esc_type) {
case 'html':
- return htmlspecialchars($string, ENT_QUOTES);
+ return htmlspecialchars($string, ENT_QUOTES, $char_set);
case 'htmlall':
- return htmlentities($string, ENT_QUOTES);
+ return htmlentities($string, ENT_QUOTES, $char_set);
case 'url':
return rawurlencode($string);
+ case 'urlpathinfo':
+ return str_replace('%2F','/',rawurlencode($string));
+
case 'quotes':
// escape unescaped single quotes
return preg_replace("%(?<!\\\\)'%", "\\'", $string);
// escape non-standard chars, such as ms document quotes
$_res = '';
for($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) {
- $_ord = ord($string{$_i});
+ $_ord = ord(substr($string, $_i, 1));
// non-standard char, escape it
if($_ord >= 126){
$_res .= '&#' . $_ord . ';';
}
else {
- $_res .= $string{$_i};
+ $_res .= substr($string, $_i, 1);
}
}
return $_res;
diff --git a/include/smarty/plugins/modifier.indent.php b/include/smarty/plugins/modifier.indent.php
index 1642bac3ded676bd8785aab923b783d920396307..394147a29d6a203475f91ba386ff1112dd3ae4ee 100644 (file)
* Purpose: indent lines of text
* @link http://smarty.php.net/manual/en/language.modifier.indent.php
* indent (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param integer
* @param string
index 0b4d1517dc668fef314e393171ab46f61a6b3aef..20e7a8d39c641888b3c29c77317f8fb65ecee944 100644 (file)
* Purpose: convert string to lowercase
* @link http://smarty.php.net/manual/en/language.modifier.lower.php
* lower (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @return string
*/
diff --git a/include/smarty/plugins/modifier.regex_replace.php b/include/smarty/plugins/modifier.regex_replace.php
index 7eee497c85bd677c1757c0bd586be00cf963a720..d4d20309d2d3b51f9723eea0229ac263fcaf4e56 100644 (file)
*
* Type: modifier<br>
* Name: regex_replace<br>
- * Purpose: regular epxression search/replace
+ * Purpose: regular expression search/replace
* @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
* regex_replace (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param string|array
* @param string|array
*/
function smarty_modifier_regex_replace($string, $search, $replace)
{
- if (preg_match('!\W(\w+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
+ if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
/* remove eval-modifier from $search */
- $search = substr($search, 0, -strlen($match[1])) . str_replace('e', '', $match[1]);
+ $search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]);
}
+
return preg_replace($search, $replace, $string);
}
diff --git a/include/smarty/plugins/modifier.replace.php b/include/smarty/plugins/modifier.replace.php
index 2a43515f7eae0057ffb44f140df2542a07249249..df041c884393769d845d17ce0c09e93f8bfe4902 100644 (file)
* Purpose: simple search/replace
* @link http://smarty.php.net/manual/en/language.modifier.replace.php
* replace (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param string
* @param string
diff --git a/include/smarty/plugins/modifier.spacify.php b/include/smarty/plugins/modifier.spacify.php
index dad057f9b5ec0513cbdb6d4b7a8a91cb7e43c162..c2423f4f2ff306b242ff6bc2329fb07f7650659c 100644 (file)
* Purpose: add spaces between characters in a string
* @link http://smarty.php.net/manual/en/language.modifier.spacify.php
* spacify (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param string
* @return string
diff --git a/include/smarty/plugins/modifier.string_format.php b/include/smarty/plugins/modifier.string_format.php
index efd621506fa5a6c9c1400104e9cca645aa71257c..9e051a578e1d28b2b42c59458845ef9d6f63ac16 100644 (file)
* Purpose: format strings via sprintf
* @link http://smarty.php.net/manual/en/language.modifier.string.format.php
* string_format (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param string
* @return string
diff --git a/include/smarty/plugins/modifier.strip_tags.php b/include/smarty/plugins/modifier.strip_tags.php
index 45f1ec14d15c2da03905bb8811d3061166f79b0a..93011a892c8d1427bb63ad4a040f808cb6f32673 100644 (file)
* Purpose: strip html tags from text
* @link http://smarty.php.net/manual/en/language.modifier.strip.tags.php
* strip_tags (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param boolean
* @return string
diff --git a/include/smarty/plugins/modifier.truncate.php b/include/smarty/plugins/modifier.truncate.php
index 15a26ba9755b2ef6c36580a806c8b4e581958dda..d96de5f12397bffa4769000c3ae9a09be39cb843 100644 (file)
* Name: truncate<br>
* Purpose: Truncate a string to a certain length if necessary,
* optionally splitting in the middle of a word, and
- * appending the $etc string.
+ * appending the $etc string or inserting $etc into the middle.
* @link http://smarty.php.net/manual/en/language.modifier.truncate.php
* truncate (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param integer
* @param string
* @param boolean
+ * @param boolean
* @return string
*/
function smarty_modifier_truncate($string, $length = 80, $etc = '...',
- $break_words = false)
+ $break_words = false, $middle = false)
{
if ($length == 0)
return '';
if (strlen($string) > $length) {
$length -= strlen($etc);
- if (!$break_words)
+ if (!$break_words && !$middle) {
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
-
- return substr($string, 0, $length).$etc;
- } else
+ }
+ if(!$middle) {
+ return substr($string, 0, $length).$etc;
+ } else {
+ return substr($string, 0, $length/2) . $etc . substr($string, -$length/2);
+ }
+ } else {
return $string;
+ }
}
/* vim: set expandtab: */
index 69960ae7217ee19cdd6af03eca9f2ab462148cc5..c12480fbda7adc5b1bdcca41f1c4d193b0bb258e 100644 (file)
* Purpose: convert string to uppercase
* @link http://smarty.php.net/manual/en/language.modifier.upper.php
* upper (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @return string
*/
diff --git a/include/smarty/plugins/modifier.wordwrap.php b/include/smarty/plugins/modifier.wordwrap.php
index b9a9fe94b3fb38c3fcd2164bf42bbe48edba5e71..ce07181569fff87cb0108fa4772537ec2cb9f1f1 100644 (file)
* Purpose: wrap a string of text at a given length
* @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php
* wordwrap (Smarty online manual)
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @param integer
* @param string
diff --git a/include/smarty/plugins/shared.escape_special_chars.php b/include/smarty/plugins/shared.escape_special_chars.php
index 515763abedc096e496cfbf3dd8424c197d0e387c..c07ce31be2ca033b9500eb68b4c8dcb3bcf7bbd6 100644 (file)
* Function: smarty_function_escape_special_chars<br>
* Purpose: used by other smarty functions to escape
* special chars except for already escaped ones
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @return string
*/
diff --git a/include/smarty/plugins/shared.make_timestamp.php b/include/smarty/plugins/shared.make_timestamp.php
index acdd777359265b61a18b159784775a7be00a4c05..b42eb11d85d1b6f0a5a2064d88f102d958dfd302 100644 (file)
* Function: smarty_make_timestamp<br>
* Purpose: used by other smarty functions to make a timestamp
* from a string.
+ * @author Monte Ohrt <monte at ohrt dot com>
* @param string
* @return string
*/
function smarty_make_timestamp($string)
{
if(empty($string)) {
- $string = "now";
- }
- $time = strtotime($string);
- if (is_numeric($time) && $time != -1)
- return $time;
-
- // is mysql timestamp format of YYYYMMDDHHMMSS?
- if (preg_match('/^\d{14}$/', $string)) {
- $time = 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));
+ // use "now":
+ $time = time();
- return $time;
+ } elseif (preg_match('/^\d{14}$/', $string)) {
+ // it is mysql timestamp format of YYYYMMDDHHMMSS?
+ $time = 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));
+
+ } elseif (is_numeric($string)) {
+ // it is a numeric string, we handle it as timestamp
+ $time = (int)$string;
+
+ } else {
+ // strtotime should handle it
+ $time = strtotime($string);
+ if ($time == -1 || $time === false) {
+ // strtotime() was not able to parse $string, use "now":
+ $time = time();
+ }
}
+ return $time;
- // couldn't recognize it, try to return a time
- $time = (int) $string;
- if ($time > 0)
- return $time;
- else
- return time();
}
/* vim: set expandtab: */