From: Juan Luis Francis Date: Thu, 6 Oct 2005 14:45:48 +0000 (+0000) Subject: - Upgraded Smarty to 2.6.10 version. X-Git-Tag: Release-1.38.0~91 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1c145946245c7b172dd50692715154e1a1aed546;p=bacula%2Fbacula - Upgraded Smarty to 2.6.10 version. - Added multicatalog support git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2422 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/gui/bacula-web/ChangeLog b/gui/bacula-web/ChangeLog index c08452e9f1..e939e2e2e1 100644 --- a/gui/bacula-web/ChangeLog +++ b/gui/bacula-web/ChangeLog @@ -7,11 +7,13 @@ - Added German translation - Fix mysql database size (reported by Roland Arendes) - Added JobID column in report template. (thanks to Stephan Ebeit) + - Upgraded Smarty to 2.6.10 version. + - Added multicatalog support 25-10-2004 Bacula web 1.1 - Add array_fill function (as Mikael suggested) - Fix url encode of links. (reported by Phil Stracchino) - - Upgrade Smarty to 2.6.6 version. + - Upgraded Smarty to 2.6.6 version. - Add French translation 04-08-2004 Bacula web 1.0 diff --git a/gui/bacula-web/README b/gui/bacula-web/README index f1c02c3724..091abbdbb1 100644 --- a/gui/bacula-web/README +++ b/gui/bacula-web/README @@ -15,6 +15,7 @@ REQUIREMENTS: - TrueType (optional) - Pear DB (http://pear.php.net/package/DB) - MySQL or PostgreSQL + - Sessions - Bacula (Oh!, yes, you need this ;-) ) http://www.bacula.org diff --git a/gui/bacula-web/TODO b/gui/bacula-web/TODO index a6ef5aa3cc..98ceb42343 100644 --- a/gui/bacula-web/TODO +++ b/gui/bacula-web/TODO @@ -1,4 +1,3 @@ -- Multi catalog - Improve check errors routines. - Improve security. (stats.php mainly) - Optimize database querys (Very poor now) (TO_DAYS,etc.). @@ -15,4 +14,4 @@ LOW PRIORITY - WebConsole!!! - Add support to PDF creation. - Build documentation of classes. -- Best icons ;-) \ No newline at end of file +- Best icons and design ;-) \ No newline at end of file diff --git a/gui/bacula-web/classes.inc b/gui/bacula-web/classes.inc index ad3a72a6f7..8465a018e8 100644 --- a/gui/bacula-web/classes.inc +++ b/gui/bacula-web/classes.inc @@ -34,21 +34,45 @@ class Bweb extends DB { var $StartDate; var $EndDate; var $driver; + var $dbs; function Bweb() { $conf = new Config_File (CONFIG_DIR); - - - $this->dsn['hostspec'] = $conf->get(CONFIG_FILE,"DATABASE","host"); - $this->dsn['username'] = $conf->get(CONFIG_FILE,"DATABASE","login"); - $this->dsn['password'] = $conf->get(CONFIG_FILE,"DATABASE","pass"); - $this->dsn['database'] = $conf->get(CONFIG_FILE,"DATABASE","db_name"); - $this->dsn['phptype'] = $conf->get(CONFIG_FILE,"DATABASE","db_type"); // mysql, (sqlite, pgsql) -->> Yet not checked - if ( $conf->get(CONFIG_FILE,"DATABASE","db_port") ) - $this->dsn[port] = $conf->get(CONFIG_FILE,"DATABASE","db_port"); + $this->dbs = array(); + $i = 2; + $sections = $conf->get(CONFIG_FILE,"DATABASE","host"); + array_push($this->dbs, "DATABASE"); + while ( !empty($sections) ) { + $sections = $conf->get(CONFIG_FILE,"DATABASE".$i,"host"); + if ( !empty($sections) ) + array_push($this->dbs,"DATABASE".$i); + $i++; + } + + if ( $i < 4) + $sec = "DATABASE"; + else { + if ( !empty($_POST['sel_database']) ) { + $_SESSION['DATABASE'] = $_POST['sel_database']; + $sec = $_POST['sel_database']; + } else { + if (isset($_SESSION['DATABASE']) ) + $sec = $_SESSION['DATABASE']; + else + $sec = "DATABASE"; + } + } + + $this->dsn['hostspec'] = $conf->get(CONFIG_FILE,$sec,"host"); + $this->dsn['username'] = $conf->get(CONFIG_FILE,$sec,"login"); + $this->dsn['password'] = $conf->get(CONFIG_FILE,$sec,"pass"); + $this->dsn['database'] = $conf->get(CONFIG_FILE,$sec,"db_name"); + $this->dsn['phptype'] = $conf->get(CONFIG_FILE,$sec,"db_type"); // mysql, (sqlite, pgsql) -->> Yet not checked + if ( $conf->get(CONFIG_FILE,$sec,"db_port") ) + $this->dsn[port] = $conf->get(CONFIG_FILE,$sec,"db_port"); $this->link =& $this->connect($this->dsn); @@ -56,14 +80,12 @@ class Bweb extends DB { die($this->link->getMessage()); $this->driver = $this->dsn[phptype]; register_shutdown_function(array(&$this,'close')); - } - - + } function close() { $this->link->disconnect(); - } + } @@ -73,7 +95,7 @@ class Bweb extends DB { or die("classes.inc: Error query: 1"); $return =& $result->fetchRow(); return $return[0]; - }//end function + }//end function @@ -83,7 +105,7 @@ class Bweb extends DB { or die("classes.inc: Error query: 2"); $return =& $result->fetchRow(); return $return[0]; - }//end function + }//end function diff --git a/gui/bacula-web/configs/bacula.conf b/gui/bacula-web/configs/bacula.conf index 930a6c2414..7d37a8ab6e 100644 --- a/gui/bacula-web/configs/bacula.conf +++ b/gui/bacula-web/configs/bacula.conf @@ -38,8 +38,8 @@ lang = en_EN -# DATABASE INFORMATION -# -------------------- +# DATABASE INFORMATION AND MULTICATALOG SUPPORT +# --------------------------------------------- # This section contains the database configuration. # You must create a user or to give it permissions to access # from web machine. @@ -65,3 +65,23 @@ db_type = mysql # Uncomment this and modify it if your database runs on a non standard port. # db_port = 3306 +# MULTICATALOG SUPPORT +# --------------------- +# If you have only one catalog don't remove the comments. +# If you have 2 or more catalogs, please remove the coments of this section +# and configure with your preferences. +# You can add so many as you want. + +#[.DATABASE2] +#host = 192.168.2.55 +#login = bacula +#pass = +#db_name = bacula +#db_type = mysql + +#[.DATABASE3] +#host = 192.168.20.40 +#login = bacula +#pass = +#dbname = bacula +#db_type= pgsql diff --git a/gui/bacula-web/external_packages/smarty/Config_File.class.php b/gui/bacula-web/external_packages/smarty/Config_File.class.php index c7e30bd346..a8cc755167 100644 --- a/gui/bacula-web/external_packages/smarty/Config_File.class.php +++ b/gui/bacula-web/external_packages/smarty/Config_File.class.php @@ -18,8 +18,8 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @link http://smarty.php.net/ - * @version 2.6.6 - * @copyright Copyright: 2001-2004 ispi of Lincoln, Inc. + * @version 2.6.10 + * @copyright Copyright: 2001-2005 New Digital Group, Inc. * @author Andrei Zmievski * @access public * @package Smarty @@ -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'); diff --git a/gui/bacula-web/external_packages/smarty/Smarty.class.php b/gui/bacula-web/external_packages/smarty/Smarty.class.php index cdaf396a06..ebc04c02b3 100644 --- a/gui/bacula-web/external_packages/smarty/Smarty.class.php +++ b/gui/bacula-web/external_packages/smarty/Smarty.class.php @@ -23,11 +23,11 @@ * smarty-general-subscribe@lists.php.net * * @link http://smarty.php.net/ - * @copyright 2001-2004 ispi of Lincoln, Inc. - * @author Monte Ohrt + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt * @author Andrei Zmievski * @package Smarty - * @version 2.6.6 + * @version 2.6.10 */ /* $Id$ */ @@ -232,7 +232,7 @@ class Smarty 'isset', 'empty', 'count', 'sizeof', 'in_array', 'is_array', - 'true','false'), + 'true', 'false', 'null'), 'INCLUDE_ANY' => false, 'PHP_TAGS' => false, 'MODIFIER_FUNCS' => array('count'), @@ -464,7 +464,7 @@ class Smarty * * @var string */ - var $_version = '2.6.6'; + var $_version = '2.6.10'; /** * current template inclusion depth @@ -1132,8 +1132,7 @@ class Smarty $this->debugging = true; } } else { - $_cookie_var = $this->request_use_auto_globals ? $_COOKIE['SMARTY_DEBUG'] : $GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']; - $this->debugging = $_cookie_var ? true : false; + $this->debugging = (bool)($this->request_use_auto_globals ? @$_COOKIE['SMARTY_DEBUG'] : @$GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']); } } @@ -1701,12 +1700,9 @@ class Smarty /** - * read in a file from line $start for $lines. - * read the entire file if $start and $lines are null. + * read in a file * * @param string $filename - * @param integer $start - * @param integer $lines * @return string */ function _read_file($filename) @@ -1893,7 +1889,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/gui/bacula-web/external_packages/smarty/Smarty_Compiler.class.php b/gui/bacula-web/external_packages/smarty/Smarty_Compiler.class.php index 140fa2ee2b..1b7217270f 100644 --- a/gui/bacula-web/external_packages/smarty/Smarty_Compiler.class.php +++ b/gui/bacula-web/external_packages/smarty/Smarty_Compiler.class.php @@ -19,10 +19,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @link http://smarty.php.net/ - * @author Monte Ohrt + * @author Monte Ohrt * @author Andrei Zmievski - * @version 2.6.6 - * @copyright 2001-2004 ispi of Lincoln, Inc. + * @version 2.6.10 + * @copyright 2001-2005 New Digital Group, Inc. * @package Smarty */ @@ -318,6 +318,36 @@ class Smarty_Compiler extends Smarty { return; } + /* Reformat $text_blocks between 'strip' and '/strip' tags, + removing spaces, tabs and newlines. */ + $strip = false; + for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) { + if ($compiled_tags[$i] == '{strip}') { + $compiled_tags[$i] = ''; + $strip = true; + /* remove leading whitespaces */ + $text_blocks[$i + 1] = ltrim($text_blocks[$i + 1]); + } + if ($strip) { + /* strip all $text_blocks before the next '/strip' */ + for ($j = $i + 1; $j < $for_max; $j++) { + /* remove leading and trailing whitespaces of each line */ + $text_blocks[$j] = preg_replace('![\t ]*[\r\n]+[\t ]*!', '', $text_blocks[$j]); + if ($compiled_tags[$j] == '{/strip}') { + /* remove trailing whitespaces from the last text_block */ + $text_blocks[$j] = rtrim($text_blocks[$j]); + } + $text_blocks[$j] = ""\'", "\\"=>"\\\\")) . "'; ?>"; + if ($compiled_tags[$j] == '{/strip}') { + $compiled_tags[$j] = "\n"; /* slurped by php, but necessary + if a newline is following the closing strip-tag */ + $strip = false; + $i = $j; + break; + } + } + } + } $compiled_content = ''; /* Interleave the compiled contents and text blocks to get the final result. */ @@ -330,17 +360,6 @@ class Smarty_Compiler extends Smarty { } $compiled_content .= $text_blocks[$i]; - /* Reformat data between 'strip' and '/strip' tags, removing spaces, tabs and newlines. */ - if (preg_match_all("~{$ldq}strip{$rdq}.*?{$ldq}/strip{$rdq}~s", $compiled_content, $_match)) { - $strip_tags = $_match[0]; - $strip_tags_modified = preg_replace("~{$ldq}/?strip{$rdq}|[\t ]+$|^[\t ]+~m", '', $strip_tags); - $strip_tags_modified = preg_replace('~[\r\n]+~m', '', $strip_tags_modified); - for ($i = 0, $for_max = count($strip_tags); $i < $for_max; $i++) - $compiled_content = preg_replace("~{$ldq}strip{$rdq}.*?{$ldq}/strip{$rdq}~s", - $this->_quote_replace($strip_tags_modified[$i]), - $compiled_content, 1); - } - // remove \n from the end of the file, if any if (($_len=strlen($compiled_content)) && ($compiled_content{$_len - 1} == "\n" )) { $compiled_content = substr($compiled_content, 0, -1); @@ -377,7 +396,7 @@ class Smarty_Compiler extends Smarty { $_plugins_params = "array('plugins' => array("; foreach ($this->_plugin_info as $plugin_type => $plugins) { foreach ($plugins as $plugin_name => $plugin_info) { - $_plugins_params .= "array('$plugin_type', '$plugin_name', '$plugin_info[0]', $plugin_info[1], "; + $_plugins_params .= "array('$plugin_type', '$plugin_name', '" . strtr($plugin_info[0], array("'" => "\\'", "\\" => "\\\\")) . "', $plugin_info[1], "; $_plugins_params .= $plugin_info[2] ? 'true),' : 'false),'; } } @@ -423,12 +442,8 @@ class Smarty_Compiler extends Smarty { if (preg_match('~^' . $this->_num_const_regexp . '|' . $this->_obj_call_regexp . '|' . $this->_var_regexp . '$~', $tag_command)) { /* tag name is a variable or object */ - $_return = $this->_parse_var_props($tag_command . $tag_modifier, $this->_parse_attrs($tag_args)); - if(isset($_tag_attrs['assign'])) { - return "assign('" . $this->_dequote($_tag_attrs['assign']) . "', $_return ); ?>\n"; - } else { - return "" . $this->_additional_newline; - } + $_return = $this->_parse_var_props($tag_command . $tag_modifier); + return "" . $this->_additional_newline; } /* If the tag name is a registered object, we process it. */ @@ -502,14 +517,14 @@ class Smarty_Compiler extends Smarty { case 'foreachelse': $this->_push_tag('foreachelse'); - return ""; + return ""; case '/foreach': $_open_tag = $this->_pop_tag('foreach'); if ($_open_tag == 'foreachelse') - return ""; + return ""; else - return ""; + return ""; break; case 'strip': @@ -518,13 +533,13 @@ class Smarty_Compiler extends Smarty { $this->_pop_tag('strip'); if (--$this->_strip_depth==0) { /* outermost closing {/strip} */ $this->_additional_newline = "\n"; - return $this->left_delimiter.$tag_command.$this->right_delimiter; + return '{' . $tag_command . '}'; } } else { $this->_push_tag('strip'); if ($this->_strip_depth++==0) { /* outermost opening {strip} */ $this->_additional_newline = ""; - return $this->left_delimiter.$tag_command.$this->right_delimiter; + return '{' . $tag_command . '}'; } } return ''; @@ -716,8 +731,8 @@ class Smarty_Compiler extends Smarty { $output .= $this->_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat=true);'; $output .= 'while ($_block_repeat) { ob_start(); ?>'; } else { - $output = '_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], $this->_block_content, $this, $_block_repeat=false)'; + $output = '_compile_plugin_call('block', $tag_command).'($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat=false)'; if ($tag_modifier != '') { $this->_parse_modifiers($_out_tag_text, $tag_modifier); } @@ -864,8 +879,8 @@ class Smarty_Compiler extends Smarty { $return = null; $postfix = ''; } else { - $prefix = "\$this->_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], \$this->_obj_block_content, \$this, \$_block_repeat=false)"; + $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)"; $postfix = "} array_pop(\$this->_tag_stack);"; } } else { @@ -1161,19 +1176,15 @@ class Smarty_Compiler extends Smarty { } $output = '_foreach[$name]"; - $output .= "if (isset(\$this->_foreach[$name])) unset(\$this->_foreach[$name]);\n"; - $output .= "{$foreach_props}['total'] = count(\$_from = (array)$from);\n"; - $output .= "{$foreach_props}['show'] = {$foreach_props}['total'] > 0;\n"; - $output .= "if ({$foreach_props}['show']):\n"; - $output .= "{$foreach_props}['iteration'] = 0;\n"; + $output .= "{$foreach_props} = array('total' => count(\$_from), 'iteration' => 0);\n"; + $output .= "if ({$foreach_props}['total'] > 0):\n"; $output .= " foreach (\$_from as $key_part\$this->_tpl_vars['$item']):\n"; $output .= " {$foreach_props}['iteration']++;\n"; - $output .= " {$foreach_props}['first'] = ({$foreach_props}['iteration'] == 1);\n"; - $output .= " {$foreach_props}['last'] = ({$foreach_props}['iteration'] == {$foreach_props}['total']);\n"; } else { - $output .= "if (count(\$_from = (array)$from)):\n"; + $output .= "if (count(\$_from)):\n"; $output .= " foreach (\$_from as $key_part\$this->_tpl_vars['$item']):\n"; } $output .= '?>'; @@ -1239,6 +1250,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[')']) { @@ -1361,6 +1379,9 @@ 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] == '(') { + // 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)) { // object or variable $token = $this->_parse_var_props($token); @@ -1629,7 +1650,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; } @@ -1969,13 +1990,41 @@ class Smarty_Compiler extends Smarty { break; case 'foreach': + array_shift($indexes); + $_var = $this->_parse_var_props(substr($indexes[0], 1)); + $_propname = substr($indexes[1], 1); + $_max_index = 1; + switch ($_propname) { + case 'index': + array_shift($indexes); + $compiled_ref = "(\$this->_foreach[$_var]['iteration']-1)"; + break; + + case 'first': + array_shift($indexes); + $compiled_ref = "(\$this->_foreach[$_var]['iteration'] <= 1)"; + break; + + case 'last': + array_shift($indexes); + $compiled_ref = "(\$this->_foreach[$_var]['iteration'] == \$this->_foreach[$_var]['total'])"; + break; + + case 'show': + array_shift($indexes); + $compiled_ref = "(\$this->_foreach[$_var]['total'] > 0)"; + break; + + default: + unset($_max_index); + $compiled_ref = "\$this->_foreach[$_var]"; + } + break; + case 'section': array_shift($indexes); $_var = $this->_parse_var_props(substr($indexes[0], 1)); - if ($_ref == 'foreach') - $compiled_ref = "\$this->_foreach[$_var]"; - else - $compiled_ref = "\$this->_sections[$_var]"; + $compiled_ref = "\$this->_sections[$_var]"; break; case 'get': @@ -2035,8 +2084,12 @@ class Smarty_Compiler extends Smarty { return; } array_shift($indexes); - $_val = $this->_parse_var_props(substr($indexes[0],1)); - $compiled_ref = '@constant(' . $_val . ')'; + if (preg_match('!^\.\w+$!', $indexes[0])) { + $compiled_ref = '@' . substr($indexes[0], 1); + } else { + $_val = $this->_parse_var_props(substr($indexes[0], 1)); + $compiled_ref = '@constant(' . $_val . ')'; + } $_max_index = 1; break; diff --git a/gui/bacula-web/external_packages/smarty/internals/core.display_debug_console.php b/gui/bacula-web/external_packages/smarty/internals/core.display_debug_console.php index a5d72913c0..1a80f39096 100644 --- a/gui/bacula-web/external_packages/smarty/internals/core.display_debug_console.php +++ b/gui/bacula-web/external_packages/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/gui/bacula-web/external_packages/smarty/internals/core.is_secure.php b/gui/bacula-web/external_packages/smarty/internals/core.is_secure.php index 342f3aff87..9bec5c21ef 100644 --- a/gui/bacula-web/external_packages/smarty/internals/core.is_secure.php +++ b/gui/bacula-web/external_packages/smarty/internals/core.is_secure.php @@ -34,11 +34,14 @@ function smarty_core_is_secure($params, &$smarty) } 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 && + if ( ($_cd = realpath($curr_dir)) !== false) { + if( strncmp($_rp, $_cd, strlen($_cd)) == 0 && $_rp{strlen($_cd)} == DIRECTORY_SEPARATOR ) { - return true; - } + return true; + } elseif ($_cd == $_rp) { + return true; + } + } } } } else { diff --git a/gui/bacula-web/external_packages/smarty/internals/core.process_compiled_include.php b/gui/bacula-web/external_packages/smarty/internals/core.process_compiled_include.php index 3e1d4c15a0..d539423bf7 100644 --- a/gui/bacula-web/external_packages/smarty/internals/core.process_compiled_include.php +++ b/gui/bacula-web/external_packages/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/gui/bacula-web/external_packages/smarty/internals/core.read_cache_file.php b/gui/bacula-web/external_packages/smarty/internals/core.read_cache_file.php index 2ab428111d..c60e113a71 100644 --- a/gui/bacula-web/external_packages/smarty/internals/core.read_cache_file.php +++ b/gui/bacula-web/external_packages/smarty/internals/core.read_cache_file.php @@ -48,10 +48,11 @@ function smarty_core_read_cache_file(&$params, &$smarty) return false; } - $cache_split = explode("\n", $params['results'], 2); - $cache_header = $cache_split[0]; - - $_cache_info = unserialize($cache_header); + $_contents = $params['results']; + $_info_start = strpos($_contents, "\n") + 1; + $_info_len = (int)substr($_contents, 0, $_info_start - 1); + $_cache_info = unserialize(substr($_contents, $_info_start, $_info_len)); + $params['results'] = substr($_contents, $_info_start + $_info_len); if ($smarty->caching == 2 && isset ($_cache_info['expires'])){ // caching by expiration time @@ -89,17 +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; - } - } - $params['results'] = $cache_split[1]; $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $_cache_info); $smarty->_cache_info = $_cache_info; diff --git a/gui/bacula-web/external_packages/smarty/internals/core.rmdir.php b/gui/bacula-web/external_packages/smarty/internals/core.rmdir.php index 4fdbccc95c..2166c44d28 100644 --- a/gui/bacula-web/external_packages/smarty/internals/core.rmdir.php +++ b/gui/bacula-web/external_packages/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/gui/bacula-web/external_packages/smarty/internals/core.write_cache_file.php b/gui/bacula-web/external_packages/smarty/internals/core.write_cache_file.php index d7a828492f..72f785b74e 100644 --- a/gui/bacula-web/external_packages/smarty/internals/core.write_cache_file.php +++ b/gui/bacula-web/external_packages/smarty/internals/core.write_cache_file.php @@ -62,7 +62,8 @@ function smarty_core_write_cache_file($params, &$smarty) $smarty->_cache_info['cache_serials'] = $smarty->_cache_serials; // prepend the cache header info into cache file - $params['results'] = serialize($smarty->_cache_info)."\n".$params['results']; + $_cache_info = serialize($smarty->_cache_info); + $params['results'] = strlen($_cache_info) . "\n" . $_cache_info . $params['results']; if (!empty($smarty->cache_handler_func)) { // use cache_handler function diff --git a/gui/bacula-web/external_packages/smarty/internals/core.write_compiled_include.php b/gui/bacula-web/external_packages/smarty/internals/core.write_compiled_include.php index d17bee11c1..5e0b2e0dde 100644 --- a/gui/bacula-web/external_packages/smarty/internals/core.write_compiled_include.php +++ b/gui/bacula-web/external_packages/smarty/internals/core.write_compiled_include.php @@ -43,7 +43,19 @@ function smarty_core_write_compiled_include($params, &$smarty) if ($this_varname == '_smarty') { /* rename $this to $_smarty in the sourcecode */ $tokens = token_get_all(' * @link http://smarty.php.net/manual/en/language.function.cycle.php {cycle} * (Smarty online manual) - * @author Monte Ohrt + * @author Monte Ohrt * @author credit to Mark Priatel * @author credit to Gerard * @author credit to Jason Sweat diff --git a/gui/bacula-web/external_packages/smarty/plugins/function.debug.php b/gui/bacula-web/external_packages/smarty/plugins/function.debug.php index 77e7109219..43452307bc 100644 --- a/gui/bacula-web/external_packages/smarty/plugins/function.debug.php +++ b/gui/bacula-web/external_packages/smarty/plugins/function.debug.php @@ -15,7 +15,7 @@ * Purpose: popup debug window * @link http://smarty.php.net/manual/en/language.function.debug.php {debug} * (Smarty online manual) - * @author Monte Ohrt + * @author Monte Ohrt * @version 1.0 * @param array * @param Smarty diff --git a/gui/bacula-web/external_packages/smarty/plugins/function.html_checkboxes.php b/gui/bacula-web/external_packages/smarty/plugins/function.html_checkboxes.php index a64d7db7ad..ed8ad7f33d 100644 --- a/gui/bacula-web/external_packages/smarty/plugins/function.html_checkboxes.php +++ b/gui/bacula-web/external_packages/smarty/plugins/function.html_checkboxes.php @@ -31,7 +31,7 @@ * @link http://smarty.php.net/manual/en/language.function.html.checkboxes.php {html_checkboxes} * (Smarty online manual) * @author Christopher Kvarme - * @author credits to Monte Ohrt + * @author credits to Monte Ohrt * @version 1.0 * @param array * @param Smarty @@ -101,7 +101,7 @@ function smarty_function_html_checkboxes($params, &$smarty) settype($selected, 'array'); $_html_result = array(); - if (is_array($options)) { + if (isset($options)) { foreach ($options as $_key=>$_val) $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels); diff --git a/gui/bacula-web/external_packages/smarty/plugins/function.html_image.php b/gui/bacula-web/external_packages/smarty/plugins/function.html_image.php index aa2aa18751..c62b0fea69 100644 --- a/gui/bacula-web/external_packages/smarty/plugins/function.html_image.php +++ b/gui/bacula-web/external_packages/smarty/plugins/function.html_image.php @@ -15,17 +15,16 @@ * Purpose: format HTML tags for the image
* Input:
* - file = file (and path) of image (required) - * - border = border width (optional, default 0) * - height = image height (optional, default actual height) - * - image =image width (optional, default actual width) + * - width = image width (optional, default actual width) * - basedir = base directory for absolute paths, default * is environment variable DOCUMENT_ROOT * * Examples: {html_image file="images/masthead.gif"} - * Output: + * Output: * @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image} * (Smarty online manual) - * @author Monte Ohrt + * @author Monte Ohrt * @author credits to Duda - wrote first image function * in repository, helped with lots of functionality * @version 1.0 @@ -40,7 +39,6 @@ function smarty_function_html_image($params, &$smarty) $alt = ''; $file = ''; - $border = 0; $height = ''; $width = ''; $extra = ''; @@ -51,7 +49,6 @@ function smarty_function_html_image($params, &$smarty) foreach($params as $_key => $_val) { switch($_key) { case 'file': - case 'border': case 'height': case 'width': case 'dpi': @@ -134,7 +131,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/gui/bacula-web/external_packages/smarty/plugins/function.html_options.php b/gui/bacula-web/external_packages/smarty/plugins/function.html_options.php index da5571c5b8..ae864f7327 100644 --- a/gui/bacula-web/external_packages/smarty/plugins/function.html_options.php +++ b/gui/bacula-web/external_packages/smarty/plugins/function.html_options.php @@ -72,14 +72,14 @@ function smarty_function_html_options($params, &$smarty) $_html_result = ''; - if (is_array($options)) { + if (isset($options)) { foreach ($options as $_key=>$_val) $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected); } else { - foreach ((array)$values as $_i=>$_key) { + foreach ($values as $_i=>$_key) { $_val = isset($output[$_i]) ? $output[$_i] : ''; $_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected); } diff --git a/gui/bacula-web/external_packages/smarty/plugins/function.html_radios.php b/gui/bacula-web/external_packages/smarty/plugins/function.html_radios.php index c8633c5dd4..7503cfaca8 100644 --- a/gui/bacula-web/external_packages/smarty/plugins/function.html_radios.php +++ b/gui/bacula-web/external_packages/smarty/plugins/function.html_radios.php @@ -31,7 +31,7 @@ * @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios} * (Smarty online manual) * @author Christopher Kvarme - * @author credits to Monte Ohrt + * @author credits to Monte Ohrt * @version 1.0 * @param array * @param Smarty @@ -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; @@ -103,16 +105,16 @@ function smarty_function_html_radios($params, &$smarty) $_html_result = array(); - if (isset($options) && is_array($options)) { + if (isset($options)) { - foreach ((array)$options as $_key=>$_val) - $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels); + foreach ($options as $_key=>$_val) + $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids); } else { - foreach ((array)$values as $_i=>$_key) { + 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,14 +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) $_output .= '