]> git.sur5r.net Git - bacula/bacula/commitdiff
- Upgraded Smarty to 2.6.10 version.
authorJuan Luis Francis <indpnday@users.sourceforge.net>
Thu, 6 Oct 2005 14:45:48 +0000 (14:45 +0000)
committerJuan Luis Francis <indpnday@users.sourceforge.net>
Thu, 6 Oct 2005 14:45:48 +0000 (14:45 +0000)
- Added multicatalog support

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2422 91ce42f0-d328-0410-95d8-f526ca767f89

42 files changed:
gui/bacula-web/ChangeLog
gui/bacula-web/README
gui/bacula-web/TODO
gui/bacula-web/classes.inc
gui/bacula-web/configs/bacula.conf
gui/bacula-web/external_packages/smarty/Config_File.class.php
gui/bacula-web/external_packages/smarty/Smarty.class.php
gui/bacula-web/external_packages/smarty/Smarty_Compiler.class.php
gui/bacula-web/external_packages/smarty/internals/core.display_debug_console.php
gui/bacula-web/external_packages/smarty/internals/core.is_secure.php
gui/bacula-web/external_packages/smarty/internals/core.process_compiled_include.php
gui/bacula-web/external_packages/smarty/internals/core.read_cache_file.php
gui/bacula-web/external_packages/smarty/internals/core.rmdir.php
gui/bacula-web/external_packages/smarty/internals/core.write_cache_file.php
gui/bacula-web/external_packages/smarty/internals/core.write_compiled_include.php
gui/bacula-web/external_packages/smarty/plugins/function.cycle.php
gui/bacula-web/external_packages/smarty/plugins/function.debug.php
gui/bacula-web/external_packages/smarty/plugins/function.html_checkboxes.php
gui/bacula-web/external_packages/smarty/plugins/function.html_image.php
gui/bacula-web/external_packages/smarty/plugins/function.html_options.php
gui/bacula-web/external_packages/smarty/plugins/function.html_radios.php
gui/bacula-web/external_packages/smarty/plugins/function.html_select_date.php
gui/bacula-web/external_packages/smarty/plugins/function.html_table.php
gui/bacula-web/external_packages/smarty/plugins/function.mailto.php
gui/bacula-web/external_packages/smarty/plugins/function.math.php
gui/bacula-web/external_packages/smarty/plugins/function.popup.php
gui/bacula-web/external_packages/smarty/plugins/modifier.cat.php
gui/bacula-web/external_packages/smarty/plugins/modifier.escape.php
gui/bacula-web/external_packages/smarty/plugins/modifier.nl2br.php
gui/bacula-web/external_packages/smarty/plugins/modifier.regex_replace.php
gui/bacula-web/external_packages/smarty/plugins/modifier.strip.php
gui/bacula-web/external_packages/smarty/plugins/modifier.truncate.php
gui/bacula-web/external_packages/smarty/plugins/outputfilter.trimwhitespace.php
gui/bacula-web/external_packages/smarty/plugins/shared.make_timestamp.php
gui/bacula-web/images/refresh.gif [new file with mode: 0644]
gui/bacula-web/index.php
gui/bacula-web/messages.po
gui/bacula-web/paths.php
gui/bacula-web/report.php
gui/bacula-web/stats.php
gui/bacula-web/templates/header.tpl
gui/bacula-web/tsmarty2c.php

index c08452e9f1668c3899e7fb7f4c1dee35efab27c2..e939e2e2e14887f7b20d59ce42e74b78bbd42a7a 100644 (file)
@@ -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
index f1c02c3724b1c8e5dc818c6b2f4ba11ac6549aa4..091abbdbb18536a8f1ae5b076965c2b9c5c5fccf 100644 (file)
@@ -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
 
                 
index a6ef5aa3cce9b36b554ec95d34b9b72a788498e3..98ceb4234385707aba07a3d54675060dd2b1fb4f 100644 (file)
@@ -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
index ad3a72a6f77250b525836cce0adb716399607ffa..8465a018e8d754008f22f9a0246d294ba8b21514 100644 (file)
@@ -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 
 
                  
 
index 930a6c24149ae2ab260defa5a1e109fac5fe61e3..7d37a8ab6e76abef6f2c4dc45a8f7254a530838c 100644 (file)
@@ -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
index c7e30bd346d1de1308f3913bd8083083877b662e..a8cc75516753b0aea8f85ae88b298385f3f1ea9f 100644 (file)
@@ -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 <andrei@php.net>
  * @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');
index cdaf396a06604f47f1e9ab1f58338aa3e3570824..ebc04c02b3b83cbe729dde884daf037d08cb88d5 100644 (file)
  * smarty-general-subscribe@lists.php.net
  *
  * @link http://smarty.php.net/
- * @copyright 2001-2004 ispi of Lincoln, Inc.
- * @author Monte Ohrt <monte@ispi.net>
+ * @copyright 2001-2005 New Digital Group, Inc.
+ * @author Monte Ohrt <monte at ohrt dot com>
  * @author Andrei Zmievski <andrei@php.net>
  * @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;
 
index 140fa2ee2b1ce4ebf1381460ae893aed78254ea9..1b7217270f1331556d75158952c3ea17c97366d9 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  * @link http://smarty.php.net/
- * @author Monte Ohrt <monte@ispi.net>
+ * @author Monte Ohrt <monte at ohrt dot com>
  * @author Andrei Zmievski <andrei@php.net>
- * @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] = "<?php echo '" . strtr($text_blocks[$j], array("'"=>"\'", "\\"=>"\\\\")) . "'; ?>";
+                    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 "<?php \$this->assign('" . $this->_dequote($_tag_attrs['assign']) . "', $_return ); ?>\n";
-            } else {
-                return "<?php echo $_return; ?>" . $this->_additional_newline;
-            }
+            $_return = $this->_parse_var_props($tag_command . $tag_modifier);
+            return "<?php echo $_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 "<?php endforeach; unset(\$_from); else: ?>";
+                return "<?php endforeach; else: ?>";
 
             case '/foreach':
                 $_open_tag = $this->_pop_tag('foreach');
                 if ($_open_tag == 'foreachelse')
-                    return "<?php endif; ?>";
+                    return "<?php endif; unset(\$_from); ?>";
                 else
-                    return "<?php endforeach; unset(\$_from); endif; ?>";
+                    return "<?php endforeach; endif; unset(\$_from); ?>";
                 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 = '<?php $this->_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 = '<?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)';
             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 = '<?php ';
+        $output .= "\$_from = $from; if (!is_array(\$_from) && !is_object(\$_from)) { settype(\$_from, 'array'); }";
         if (isset($name)) {
             $foreach_props = "\$this->_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;
 
index a5d72913c0817510cb8e3d9ff8f81dc8d1356de9..1a80f39096a096099424c7630f79d6de640b84d9 100644 (file)
@@ -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';
     }
index 342f3aff876a9324b5df3bbbfeeb39965d520756..9bec5c21efb57166ef324e30d39dcd9904b3c6f3 100644 (file)
@@ -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 {
index 3e1d4c15a038f3c4b5d7ee87ad947744948903ef..d539423bf740ee58787d4352a9e83b2990696b1f 100644 (file)
@@ -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'),
index 2ab428111d0b0ffb932ac2e0eab73f1efc4751fb..c60e113a71a02c0f6e6423d71b4403134d73685d 100644 (file)
@@ -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;
index 4fdbccc95cd65beae478a7f639d53b2b08ef376d..2166c44d28aea09e7d044ad04b661f8bfe8aefce 100644 (file)
@@ -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 {
index d7a828492f2100be91d293450778442e00755fe2..72f785b74ef07a0eea7ede689262409b246eccec 100644 (file)
@@ -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
index d17bee11c1b36e2a3f2af466b4cdd89dbd2b050e..5e0b2e0dde63a24f75477b1cfbe7e82f6d569404 100644 (file)
@@ -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('<?php ' . $_match[4]);
-            array_shift($tokens); /* remove the opening <.?.php */
+
+            /* remove trailing <?php */
+            $open_tag = '';
+            while ($tokens) {
+                $token = array_shift($tokens);
+                if (is_array($token)) {
+                    $open_tag .= $token[1];
+                } else {
+                    $open_tag .= $token;
+                }
+                if ($open_tag == '<?php ') break;
+            }
+
             for ($i=0, $count = count($tokens); $i < $count; $i++) {
                 if (is_array($tokens[$i])) {
                     if ($tokens[$i][0] == T_VARIABLE && $tokens[$i][1] == '$this') {
index f61ff0b1302f09ad63a54a2f66b66be8a71ed4a5..fe78bb87da02a617af79964a02c944543c68c27b 100644 (file)
@@ -32,7 +32,7 @@
  * </pre>
  * @link http://smarty.php.net/manual/en/language.function.cycle.php {cycle}
  *       (Smarty online manual)
- * @author Monte Ohrt <monte@ispi.net>
+ * @author Monte Ohrt <monte at ohrt dot com>
  * @author credit to Mark Priatel <mpriatel@rogers.com>
  * @author credit to Gerard <gerard@interfold.com>
  * @author credit to Jason Sweat <jsweat_php@yahoo.com>
index 77e710921956f13467787c063f9269fadd1158ee..43452307bcb26bab280df03dfb481ec659442853 100644 (file)
@@ -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 <monte@ispi.net>
+ * @author   Monte Ohrt <monte at ohrt dot com>
  * @version  1.0
  * @param array
  * @param Smarty
index a64d7db7adf2553ae481df91735cc199a2c0bc2c..ed8ad7f33db888b4dad1d50847e865b1389e9117 100644 (file)
@@ -31,7 +31,7 @@
  * @link http://smarty.php.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
  *      (Smarty online manual)
  * @author     Christopher Kvarme <christopher.kvarme@flashjab.com>
- * @author credits to Monte Ohrt <monte@ispi.net>
+ * @author credits to Monte Ohrt <monte at ohrt dot com>
  * @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);
index aa2aa1875138f8ab04f7de536158558d4e86db9e..c62b0fea6916a079678e45653b15820a110dbde3 100644 (file)
  * Purpose:  format HTML tags for the image<br>
  * Input:<br>
  *         - 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:   <img src="images/masthead.gif" border=0 width=400 height=23>
+ * 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@ispi.net>
+ * @author   Monte Ohrt <monte at ohrt dot com>
  * @author credits to Duda <duda@big.hu> - 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 . '<img src="'.$file.'" alt="'.$alt.'" border="'.$border.'" width="'.$width.'" height="'.$height.'"'.$extra.' />' . $suffix;
+    return $prefix . '<img src="'.$file.'" alt="'.$alt.'" width="'.$width.'" height="'.$height.'"'.$extra.' />' . $suffix;
 }
 
 /* vim: set expandtab: */
index da5571c5b8eddd7bd34be542f746b72ef1041f0d..ae864f7327ca9c9f80d055ddb96ca2d09ef5cfaa 100644 (file)
@@ -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);
         }
index c8633c5dd4624b3e6d735841033e2cdcb4be44c8..7503cfaca8f01a1b7652ff69820b242e7e8497d2 100644 (file)
@@ -31,7 +31,7 @@
  * @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
  *      (Smarty online manual)
  * @author     Christopher Kvarme <christopher.kvarme@flashjab.com>
- * @author credits to Monte Ohrt <monte@ispi.net>
+ * @author credits to Monte Ohrt <monte at ohrt dot com>
  * @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 .= '<label>';
-    $_output .= '<input type="radio" name="'
+    if ($labels) {
+      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 ($value==$selected) {
+   if ($labels && $label_ids) $_output .= ' id="' . $_id . '"';
+
+    if ((string)$value==$selected) {
         $_output .= ' checked="checked"';
     }
     $_output .= $extra . ' />' . $output;
index fc2d449a8e152ea15c593eb9e4d171a5efb3afc5..d8c334aec0779d6dd2e447f090df1513c2e0b003 100644 (file)
@@ -34,6 +34,7 @@
  */
 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. */
@@ -78,6 +79,7 @@ function smarty_function_html_select_date($params, &$smarty)
     $day_empty       = null;
     $month_empty     = null;
     $year_empty      = null;
+    $extra_attrs     = '';
 
     foreach ($params as $_key=>$_value) {
         switch ($_key) {
@@ -119,8 +121,12 @@ function smarty_function_html_select_date($params, &$smarty)
                 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;
         }
     }
 
@@ -194,11 +200,11 @@ function smarty_function_html_select_date($params, &$smarty)
         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>';
@@ -230,7 +236,7 @@ function smarty_function_html_select_date($params, &$smarty)
         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],
@@ -253,7 +259,7 @@ function smarty_function_html_select_date($params, &$smarty)
             if (null !== $year_extra){
                 $year_result .= ' ' . $year_extra;
             }
-            $year_result .= '>';
+            $year_result .= ' />';
         } else {
             $years = range((int)$start_year, (int)$end_year);
             if ($reverse_years) {
@@ -276,7 +282,7 @@ function smarty_function_html_select_date($params, &$smarty)
             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],
index 0f6d03b932751f17cdbd869491a80ccd9c360cd6..62d7410b8d4c4a111bfac40519d167205d019e21 100644 (file)
@@ -33,7 +33,7 @@
  * {table loop=$data cols=4 tr_attr='"bgcolor=red"'}
  * {table loop=$data cols=4 tr_attr=$colors}
  * </pre>
- * @author   Monte Ohrt <monte@ispi.net>
+ * @author   Monte Ohrt <monte at ohrt dot com>
  * @version  1.0
  * @link http://smarty.php.net/manual/en/language.function.html.table.php {html_table}
  *          (Smarty online manual)
index a4f4d2d5d92c0d0d8f6819d28a983ddaa8c5c676..64c122ce4e090e15a90ff4bc80f8647555f45cf1 100644 (file)
@@ -20,6 +20,7 @@
  *         - encode = (optional) can be one of:
  *                * none : no encoding (default)
  *                * javascript : encode with javascript
+ *                * javascript_charcode : encode with javascript charcode
  *                * hex : encode with hexidecimal (no javascript)
  *         - cc = (optional) address(es) to carbon copy
  *         - bcc = (optional) address(es) to blind carbon copy
@@ -40,7 +41,7 @@
  * @link http://smarty.php.net/manual/en/language.function.mailto.php {mailto}
  *          (Smarty online manual)
  * @version  1.2
- * @author   Monte Ohrt <monte@ispi.net>
+ * @author   Monte Ohrt <monte at ohrt dot com>
  * @author   credits to Jason Sweat (added cc, bcc and subject functionality)
  * @param    array
  * @param    Smarty
@@ -92,7 +93,7 @@ function smarty_function_mailto($params, &$smarty)
     $address .= $mail_parm_vals;
 
     $encode = (empty($params['encode'])) ? 'none' : $params['encode'];
-    if (!in_array($encode,array('javascript','hex','none')) ) {
+    if (!in_array($encode,array('javascript','javascript_charcode','hex','none')) ) {
         $smarty->trigger_error("mailto: 'encode' parameter must be none, javascript or hex");
         return;
     }
@@ -107,6 +108,25 @@ function smarty_function_mailto($params, &$smarty)
 
         return '<script type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>';
 
+    } elseif ($encode == 'javascript_charcode' ) {
+        $string = '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>';
+
+        for($x = 0, $y = strlen($string); $x < $y; $x++ ) {
+            $ord[] = ord($string[$x]);   
+        }
+
+        $_ret = "<script type=\"text/javascript\" language=\"javascript\">\n";
+        $_ret .= "<!--\n";
+        $_ret .= "{document.write(String.fromCharCode(";
+        $_ret .= implode(',',$ord);
+        $_ret .= "))";
+        $_ret .= "}\n";
+        $_ret .= "//-->\n";
+        $_ret .= "</script>\n";
+        
+        return $_ret;
+        
+        
     } elseif ($encode == 'hex') {
 
         preg_match('!^(.*)(\?.*)$!',$address,$match);
index c080d4dfe68242a05e7c1f1b26311f41b13b85f7..043910770621bee215263b1063016b05e37adaea 100644 (file)
@@ -35,12 +35,13 @@ function smarty_function_math($params, &$smarty)
     }
 
     // match all vars in equation, make sure all are passed
-    preg_match_all("!\!(0x)([a-zA-Z][a-zA-Z0-9_]*)!",$equation, $match);
+    preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]+)!",$equation, $match);
     $allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10',
                            'max','min','pi','pow','rand','round','sin','sqrt','srand','tan');
-    foreach($match[2] as $curr_var) {
-        if (!in_array($curr_var,array_keys($params)) && !in_array($curr_var, $allowed_funcs)) {
-            $smarty->trigger_error("math: parameter $curr_var not passed as argument");
+    
+    foreach($match[1] as $curr_var) {
+        if ($curr_var && !in_array($curr_var, array_keys($params)) && !in_array($curr_var, $allowed_funcs)) {
+            $smarty->trigger_error("math: function call $curr_var not allowed");
             return;
         }
     }
index 80bd62aafb39522617d031c519f7a02afd02aa0a..2ba54de5ab70a0fe1ac8c84f728234257b62e21d 100644 (file)
@@ -25,7 +25,11 @@ function smarty_function_popup($params, &$smarty)
         switch ($_key) {
             case 'text':
             case 'trigger':
+            case 'function':
+            case 'inarray':
                 $$_key = (string)$_value;
+                if ($_key == 'function' || $_key == 'inarray')
+                    $append .= ',' . strtoupper($_key) . ",'$_value'";
                 break;
 
             case 'caption':
@@ -44,12 +48,10 @@ function smarty_function_popup($params, &$smarty)
             case 'closefont':
             case 'fgbackground':
             case 'bgbackground':
-            case 'inarray':
             case 'caparray':
             case 'capicon':
             case 'background':
             case 'frame':
-            case 'function':
                 $append .= ',' . strtoupper($_key) . ",'$_value'";
                 break;
 
@@ -84,6 +86,8 @@ function smarty_function_popup($params, &$smarty)
             case 'fullhtml':
             case 'hauto':
             case 'vauto':
+            case 'mouseoff':
+            case 'followmouse':
                 if ($_value) $append .= ',' . strtoupper($_key);
                 break;
 
@@ -100,7 +104,10 @@ function smarty_function_popup($params, &$smarty)
     if (empty($trigger)) { $trigger = "onmouseover"; }
 
     $retval = $trigger . '="return overlib(\''.preg_replace(array("!'!","![\r\n]!"),array("\'",'\r'),$text).'\'';
-    $retval .= $append . ');" onmouseout="nd();"';
+    $retval .= $append . ');"';
+    if ($trigger == 'onmouseover')
+       $retval .= ' onmouseout="nd();"';
+
 
     return $retval;
 }
index f5dc3d6893caa708767eff969ab144a463c4b02a..2e37940d432de11a7b3f3269f5f419da64ce4c32 100644 (file)
@@ -17,7 +17,7 @@
  * Example:  {$var|cat:"foo"}
  * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
  *          (Smarty online manual)
- * @author   Monte Ohrt <monte@ispi.net>
+ * @author   Monte Ohrt <monte at ohrt dot com>
  * @version 1.0
  * @param string
  * @param string
index 0a0270c564b7d9b37beb945d6fa7f40b86d39d15..a32a8766caf7565b1e2d0ebafb39247eb74cf737 100644 (file)
@@ -28,7 +28,7 @@ function smarty_modifier_escape($string, $esc_type = 'html')
             return htmlentities($string, ENT_QUOTES);
 
         case 'url':
-            return urlencode($string);
+            return rawurlencode($string);
 
         case 'quotes':
             // escape unescaped single quotes
index 86a28d207ac67974e51c8d6a9d372c6a86723a28..d6fabff64d0be4e66ff47352390fb39cfc5337b3 100644 (file)
@@ -21,7 +21,7 @@
  * @link http://smarty.php.net/manual/en/language.modifier.nl2br.php
  *          nl2br (Smarty online manual)
  * @version  1.0
- * @author   Monte Ohrt <monte@ispi.net>
+ * @author   Monte Ohrt <monte at ohrt dot com>
  * @param string
  * @return string
  */
index b9cc865ea894831221390abba9922683bf613dcb..7eee497c85bd677c1757c0bd586be00cf963a720 100644 (file)
  */
 function smarty_modifier_regex_replace($string, $search, $replace)
 {
+    if (preg_match('!\W(\w+)$!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]);
+    }
     return preg_replace($search, $replace, $string);
 }
 
index 738c6407e6c58627ffc9aef4c21acad150b9bdbf..cc5c453c8a76d24fe59c114728a937ffb9633c35 100644 (file)
@@ -17,7 +17,7 @@
  * Date:     September 25th, 2002
  * @link http://smarty.php.net/manual/en/language.modifier.strip.php
  *          strip (Smarty online manual)
- * @author   Monte Ohrt <monte@ispi.net>
+ * @author   Monte Ohrt <monte at ohrt dot com>
  * @version  1.0
  * @param string
  * @param string
index 15a26ba9755b2ef6c36580a806c8b4e581958dda..93c3f510882d7111a915abcffb634f16873ddfbb 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)
  * @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 9979e85867a4576622228999a557a9702afd367f..01e35e03df93c829d32c127d9a8bf698da9fb2b2 100644 (file)
@@ -19,7 +19,7 @@
  * Install:  Drop into the plugin directory, call
  *           <code>$smarty->load_filter('output','trimwhitespace');</code>
  *           from application.
- * @author   Monte Ohrt <monte@ispi.net>
+ * @author   Monte Ohrt <monte at ohrt dot com>
  * @author Contributions from Lars Noschinski <lars@usenet.noschinski.de>
  * @version  1.3
  * @param string
index acdd777359265b61a18b159784775a7be00a4c05..8d3dc3ad844179203aab96f10951777eb8b409a3 100644 (file)
 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: */
diff --git a/gui/bacula-web/images/refresh.gif b/gui/bacula-web/images/refresh.gif
new file mode 100644 (file)
index 0000000..561a0a9
Binary files /dev/null and b/gui/bacula-web/images/refresh.gif differ
index cc13c78b4b9c0f31f7b788a5a86e5e23cb12fa82..b1c869d6475ce8ebe61e349366660afeaa671066 100644 (file)
@@ -15,6 +15,7 @@
 +-------------------------------------------------------------------------+ 
 */
 // Last Err: 
+session_start();
 require ("paths.php");
 require($smarty_path."Smarty.class.php");
 include "classes.inc";
@@ -32,6 +33,11 @@ $mode = $smarty->get_config_vars("mode");
 
 require("lang.php");
 
+//Assign dbs
+if ( count($dbSql->dbs) >1 ) {
+  $smarty->assign("dbs", $dbSql->dbs);
+  $smarty->assign("dbs_now", $_SESSION['DATABASE']);
+}
 
 // generaldata.tpl & last_run_report.tpl (last24bytes)
 $client = $dbSql->link->query("select count(*) from Client")
index df3c5aedef4f1ab647906f520b5f425d41ae2973..9a4c2da7861e34ead91c781957ebbb941719051c 100644 (file)
@@ -1,18 +1,20 @@
 # SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR Free Software Foundation, Inc.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
 #
 #, fuzzy
 msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
-"POT-Creation-Date: 2004-06-11 13:02+0200\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2005-10-06 16:30+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=CHARSET\n"
-"Content-Transfer-Encoding: ENCODING\n"
+"Content-Transfer-Encoding: 8bit\n"
 
 #: lang.c:1 lang.c:2
 msgid "Bytes transferred last 30 days from ALL clients"
@@ -35,205 +37,217 @@ msgid "Total files:"
 msgstr ""
 
 #: lang.c:7
-msgid "Last month, bytes transferred"
+msgid "Database size"
 msgstr ""
 
 #: lang.c:8
-msgid "Last month, bytes transferred (pie)"
+msgid "Last month, bytes transferred"
 msgstr ""
 
 #: lang.c:9
-msgid "General%20report"
+msgid "Last month, bytes transferred (pie)"
 msgstr ""
 
 #: lang.c:10
-msgid "Status from last 24h"
+msgid "Select"
 msgstr ""
 
 #: lang.c:11
-msgid "Errors:"
+msgid "General%20report"
 msgstr ""
 
 #: lang.c:12
-msgid "Terminated Jobs:"
+msgid "Status from last 24h"
 msgstr ""
 
 #: lang.c:13
-msgid "Total time spent to do backup:"
+msgid "Errors:"
 msgstr ""
 
 #: lang.c:14
-msgid "Bytes transferred last 24h"
+msgid "Terminated Jobs:"
 msgstr ""
 
 #: lang.c:15
-msgid "Show details"
+msgid "Total time spent to do backup:"
 msgstr ""
 
 #: lang.c:16
-msgid "Jobs with errors"
+msgid "Bytes transferred last 24h"
 msgstr ""
 
 #: lang.c:17
-msgid "Name"
+msgid "Show details"
 msgstr ""
 
 #: lang.c:18
-msgid "EndTime"
+msgid "Jobs with errors"
 msgstr ""
 
 #: lang.c:19
-msgid "JobStatus"
+msgid "Name"
 msgstr ""
 
 #: lang.c:20
+msgid "EndTime"
+msgstr ""
+
+#: lang.c:21
+msgid "JobStatus"
+msgstr ""
+
+#: lang.c:22
 msgid "Detailed report"
 msgstr ""
 
-#: lang.c:21 lang.c:42
+#: lang.c:23 lang.c:45
 msgid "Select a job:"
 msgstr ""
 
-#: lang.c:22
+#: lang.c:24
 msgid "go"
 msgstr ""
 
-#: lang.c:23
+#: lang.c:25
 msgid "Elapsed time"
 msgstr ""
 
-#: lang.c:24
-msgid "Job"
+#: lang.c:26
+msgid "Client"
 msgstr ""
 
-#: lang.c:25
+#: lang.c:27
 msgid "Start Time"
 msgstr ""
 
-#: lang.c:26
+#: lang.c:28
 msgid "End Time"
 msgstr ""
 
-#: lang.c:27
+#: lang.c:29
 msgid "Type"
 msgstr ""
 
-#: lang.c:28
+#: lang.c:30
 msgid "Pool"
 msgstr ""
 
-#: lang.c:29 lang.c:40
+#: lang.c:31 lang.c:43
 msgid "Status"
 msgstr ""
 
-#: lang.c:30
+#: lang.c:32
 msgid "Stats Bacula: Job"
 msgstr ""
 
-#: lang.c:31
-msgid "Client:"
+#: lang.c:33
+msgid "Job:"
 msgstr ""
 
-#: lang.c:32
+#: lang.c:34
 msgid "Period: From"
 msgstr ""
 
-#: lang.c:33
+#: lang.c:35
 msgid "to"
 msgstr ""
 
-#: lang.c:34
+#: lang.c:36
 msgid "Bytes transferred in the period:"
 msgstr ""
 
-#: lang.c:35
+#: lang.c:37
 msgid "Files transferred in the period:"
 msgstr ""
 
-#: lang.c:36
+#: lang.c:38
+msgid "JobID"
+msgstr ""
+
+#: lang.c:39
 msgid "Date"
 msgstr ""
 
-#: lang.c:37
+#: lang.c:40
 msgid "Elapsed"
 msgstr ""
 
-#: lang.c:38
+#: lang.c:41
 msgid "Level"
 msgstr ""
 
-#: lang.c:39
+#: lang.c:42
 msgid "Bytes"
 msgstr ""
 
-#: lang.c:41
+#: lang.c:44
 msgid "SELECT NEW REPORT"
 msgstr ""
 
-#: lang.c:43
+#: lang.c:46
 msgid "Graph mode:"
 msgstr ""
 
-#: lang.c:44
+#: lang.c:47
 msgid "lines"
 msgstr ""
 
-#: lang.c:45
+#: lang.c:48
 msgid "linepoints"
 msgstr ""
 
-#: lang.c:46
+#: lang.c:49
 msgid "points"
 msgstr ""
 
-#: lang.c:47
+#: lang.c:50
 msgid "bars"
 msgstr ""
 
-#: lang.c:48
+#: lang.c:51
 msgid "area"
 msgstr ""
 
-#: lang.c:49
+#: lang.c:52
 msgid "Data to show:"
 msgstr ""
 
-#: lang.c:50
+#: lang.c:53
 msgid "Transferred bytes"
 msgstr ""
 
-#: lang.c:51
+#: lang.c:54
 msgid "Start period:"
 msgstr ""
 
-#: lang.c:52
+#: lang.c:55
 msgid "End period:"
 msgstr ""
 
-#: lang.c:53
+#: lang.c:56
 msgid "Create report"
 msgstr ""
 
-#: lang.c:54
+#: lang.c:57
 msgid "Volume Name"
 msgstr ""
 
-#: lang.c:55
+#: lang.c:58
 msgid "Volume Bytes"
 msgstr ""
 
-#: lang.c:56
+#: lang.c:59
 msgid "Media Type"
 msgstr ""
 
-#: lang.c:57
+#: lang.c:60
 msgid "When expire?"
 msgstr ""
 
-#: lang.c:58
+#: lang.c:61
 msgid "Last Written"
 msgstr ""
 
-#: lang.c:59
+#: lang.c:62
 msgid "Volume Status"
 msgstr ""
index c85282984c26309a80fab51feb1c40900115115a..54135707fcebfd23f71932fa2df1fa0e87bc513f 100644 (file)
@@ -5,7 +5,7 @@
 // PhPlot package. version 5.0RC1. http://www.phplot.com
 $phplot_path = "external_packages/phplot/";
 
-//Smarty package. version 2.6.6. http://smarty.php.net
+//Smarty package. version 2.6.10. http://smarty.php.net
 $smarty_path = "external_packages/smarty/";
 
 //Smarty_gettext. version 0.9. http://www.boom.org.il/smarty/gettext/
index ba6028784ce2a4afe9ad7f5822f97d58526eb3ac..8dc2c163dc7706f61a900e2abbdecfd386762988 100644 (file)
@@ -14,7 +14,7 @@
 | GNU General Public License for more details.                            |
 +-------------------------------------------------------------------------+ 
 */
-
+session_start();
 require ("paths.php");
 require($smarty_path."Smarty.class.php");
 include "classes.inc";
index edfcb92ef34a1c729b64fed21306b34f836a4ec9..51baaa5cf32f64f731e3d5ac3ad8c7363c075de2 100644 (file)
@@ -26,7 +26,7 @@
 // $MBottom = Margin of the bottom of the graph
 // $modo_graph= Type of graph (bars, lines, linepoints, area, points, and pie).
 // $elapsed = Period in seconds to show complex graph (tipo_dato <3) 1 month = 18144000
-
+session_start();
 require ("classes.inc");
 
 $graph = new BCreateGraph();
index 564369e694161eb2473054e2b1d775ae04a8d636..023d6e9fe8fb575775963e9f7234cbcf7602c365 100644 (file)
 <BODY bgcolor="#ffffff">
 <table width=1000px cellpadding=0 cellspacing=0 border=0 bgcolor="#2F92AF">
  <tr>
-       <td class=titulo2 background="images/bg2.png">
+       <td class=titulo2 background="images/bg2.png" valign="bottom">
         {#title#}
        </td>
-       <td background="images/bg2.png" align=right>
+       {if $dbs ne ""}
+               <form method=post action=index.php>
+               <td background="{#root#}/images/bg2.png" align="right" valign="top">
+               {t}Select{/t}: 
+               <select name=sel_database style="font-family:verdana;font-size: 6px;color: white; background-color:#666;" onchange=submit()>
+               {html_options values=$dbs output=$dbs selected=$dbs_now}
+               </select>
+               </td>
+               </form>
+       {/if}
+       <td background="{#root#}/images/bg2.png" align=right width=7%>
+       <a href="{php $_SERVER['PHP_SELF'];}"><img src="{#root#}/images/refresh.gif" alt='Refresh'></a>
        <a href="http://indpnday.com/bacula_stuff/bacula-web/mantisbt/login_page.php" target="_blank" {popup text="They grow thanks to Juan Luis Francés...Please, click here to report them"}>
        Bugs?
        </a>
index 51d9b8bc231376e72dc2b8837d35d68a5b3261fd..32cb89fe0cb53451083262f23b167b1f685ec767 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/local/bin/php -qn
+#!/usr/bin/php -qn
 <?php
 /**
  * tsmarty2c.php - rips gettext strings from smarty template