| 
									
										
										
										
											2001-12-04 16:44:15 +00:00
										 |  |  |  | <?php | 
					
						
							|  |  |  |  | /* | 
					
						
							|  |  |  |  |  * Project:     Smarty: the PHP compiling template engine | 
					
						
							|  |  |  |  |  * File:        Smarty.class.php | 
					
						
							|  |  |  |  |  * Author:      Monte Ohrt <monte@ispi.net> | 
					
						
							|  |  |  |  |  *              Andrei Zmievski <andrei@php.net> | 
					
						
							|  |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2002-03-20 17:15:21 +00:00
										 |  |  |  |  * Version:     2.0.1 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |  * Copyright:   2001,2002 ispi of Lincoln, Inc. | 
					
						
							| 
									
										
										
										
											2001-12-04 16:44:15 +00:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * This library is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  |  * modify it under the terms of the GNU Lesser General Public | 
					
						
							|  |  |  |  |  * License as published by the Free Software Foundation; either | 
					
						
							|  |  |  |  |  * version 2.1 of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  |  * | 
					
						
							| 
									
										
										
										
											2002-03-28 19:53:27 +00:00
										 |  |  |  |  * This library is distributed in the hope that it will be useful, | 
					
						
							| 
									
										
										
										
											2001-12-04 16:44:15 +00:00
										 |  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
					
						
							|  |  |  |  |  * Lesser General Public License for more details. | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * You should have received a copy of the GNU Lesser General Public | 
					
						
							|  |  |  |  |  * License along with this library; if not, write to the Free Software | 
					
						
							|  |  |  |  |  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * For questions, help, comments, discussion, etc., please join the | 
					
						
							| 
									
										
										
										
											2002-03-28 19:53:27 +00:00
										 |  |  |  |  * Smarty mailing list. Send a blank e-mail to | 
					
						
							|  |  |  |  |  * smarty-general-subscribe@lists.php.net | 
					
						
							| 
									
										
										
										
											2001-12-04 16:44:15 +00:00
										 |  |  |  |  * | 
					
						
							|  |  |  |  |  * You may contact the authors of Smarty by e-mail at: | 
					
						
							|  |  |  |  |  * monte@ispi.net | 
					
						
							|  |  |  |  |  * andrei@php.net | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * Or, write to: | 
					
						
							|  |  |  |  |  * Monte Ohrt | 
					
						
							|  |  |  |  |  * Director of Technology, ispi | 
					
						
							|  |  |  |  |  * 237 S. 70th suite 220 | 
					
						
							|  |  |  |  |  * Lincoln, NE 68510 | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  * The latest version of Smarty can be obtained from: | 
					
						
							|  |  |  |  |  * http://www.phpinsider.com/ | 
					
						
							|  |  |  |  |  * | 
					
						
							|  |  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-06-29 22:52:45 +00:00
										 |  |  |  | // set SMARTY_DIR to absolute path to Smarty library files.
 | 
					
						
							|  |  |  |  | // if not defined, include_path will be used.
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-04-11 20:27:04 +00:00
										 |  |  |  | define('DIR_SEP', DIRECTORY_SEPARATOR); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | if (!defined('SMARTY_DIR')) { | 
					
						
							| 
									
										
										
										
											2002-04-11 20:27:04 +00:00
										 |  |  |  |     define('SMARTY_DIR', dirname(__FILE__) . DIR_SEP); | 
					
						
							| 
									
										
										
										
											2001-06-29 22:52:45 +00:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | define('SMARTY_PHP_PASSTHRU',   0); | 
					
						
							|  |  |  |  | define('SMARTY_PHP_QUOTE',      1); | 
					
						
							|  |  |  |  | define('SMARTY_PHP_REMOVE',     2); | 
					
						
							|  |  |  |  | define('SMARTY_PHP_ALLOW',      3); | 
					
						
							| 
									
										
										
										
											2001-02-20 21:20:08 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | class Smarty | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | /**************************************************************************/ | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | /* BEGIN SMARTY CONFIGURATION SECTION                                     */ | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | /* Set the following config variables to your liking.                     */ | 
					
						
							|  |  |  |  | /**************************************************************************/ | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     // public vars
 | 
					
						
							| 
									
										
										
										
											2002-04-11 20:27:04 +00:00
										 |  |  |  |     var $template_dir    =  'templates';       // name of directory for templates
 | 
					
						
							|  |  |  |  |     var $compile_dir     =  'templates_c';     // name of directory for compiled templates
 | 
					
						
							|  |  |  |  |     var $config_dir      =  'configs';         // directory where config files are located
 | 
					
						
							| 
									
										
										
										
											2002-02-05 19:05:39 +00:00
										 |  |  |  |     var $plugins_dir     =  'plugins';         // directory where plugins are kept
 | 
					
						
							|  |  |  |  |                                                // (relative to Smarty directory)
 | 
					
						
							| 
									
										
										
										
											2001-06-20 16:39:52 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-06-26 21:12:54 +00:00
										 |  |  |  |     var $debugging       =  false;             // enable debugging console true/false
 | 
					
						
							|  |  |  |  |     var $debug_tpl       =  'file:debug.tpl';  // path to debug console template
 | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     var $debugging_ctrl  =  'NONE';            // Possible values:
 | 
					
						
							|  |  |  |  |                                                // NONE - no debug control allowed
 | 
					
						
							|  |  |  |  |                                                // URL - enable debugging when keyword
 | 
					
						
							|  |  |  |  |                                                //       SMARTY_DEBUG is found in $QUERY_STRING
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-26 22:07:06 +00:00
										 |  |  |  |     var $global_assign   =  array( 'HTTP_SERVER_VARS' => array( 'SCRIPT_NAME' ) | 
					
						
							| 
									
										
										
										
											2001-04-24 15:16:14 +00:00
										 |  |  |  |                                  );     // variables from the GLOBALS array
 | 
					
						
							|  |  |  |  |                                         // that are implicitly assigned
 | 
					
						
							|  |  |  |  |                                         // to all templates
 | 
					
						
							|  |  |  |  |     var $undefined       =  null;       // undefined variables in $global_assign will be
 | 
					
						
							|  |  |  |  |                                         // created with this value
 | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     var $compile_check   =  true;       // whether to check for compiling step or not:
 | 
					
						
							| 
									
										
										
										
											2001-01-31 22:42:05 +00:00
										 |  |  |  |                                         // This is generally set to false once the
 | 
					
						
							|  |  |  |  |                                         // application is entered into production and
 | 
					
						
							|  |  |  |  |                                         // initially compiled. Leave set to true
 | 
					
						
							| 
									
										
										
										
											2001-02-05 21:10:20 +00:00
										 |  |  |  |                                         // during development. true/false default true.
 | 
					
						
							| 
									
										
										
										
											2001-01-31 22:42:05 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-30 15:23:10 +00:00
										 |  |  |  |     var $force_compile   =  false;      // force templates to compile every time,
 | 
					
						
							|  |  |  |  |                                         // overrides cache settings. default false.
 | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-30 15:23:10 +00:00
										 |  |  |  |     var $caching         =  false;      // enable caching. true/false default false.
 | 
					
						
							| 
									
										
										
										
											2002-04-11 20:27:04 +00:00
										 |  |  |  |     var $cache_dir       =  'cache';    // name of directory for template cache files
 | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     var $cache_lifetime  =  3600;       // number of seconds cached content will persist.
 | 
					
						
							| 
									
										
										
										
											2002-04-12 14:41:04 +00:00
										 |  |  |  | 										// 0 = always regenerate cache,
 | 
					
						
							|  |  |  |  |                                         // -1 = never expires. default is one hour (3600)
 | 
					
						
							| 
									
										
										
										
											2001-12-11 23:06:38 +00:00
										 |  |  |  |     var $cache_handler_func   = null;   // function used for cached content. this is
 | 
					
						
							| 
									
										
										
										
											2001-11-30 15:23:10 +00:00
										 |  |  |  |                                         // an alternative to using the built-in file
 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |                                         // based caching.
 | 
					
						
							| 
									
										
										
										
											2002-02-19 22:40:49 +00:00
										 |  |  |  |     var $cache_modified_check = false;  // respect If-Modified-Since headers on cached content
 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-05 21:10:20 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     var $default_template_handler_func = ''; // function to handle missing templates
 | 
					
						
							| 
									
										
										
										
											2001-12-10 18:10:46 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |     var $php_handling    =  SMARTY_PHP_PASSTHRU; | 
					
						
							|  |  |  |  |                                         // how smarty handles php tags in the templates
 | 
					
						
							| 
									
										
										
										
											2001-02-26 16:33:30 +00:00
										 |  |  |  |                                         // possible values:
 | 
					
						
							|  |  |  |  |                                         // SMARTY_PHP_PASSTHRU -> echo tags as is
 | 
					
						
							|  |  |  |  |                                         // SMARTY_PHP_QUOTE    -> escape tags as entities
 | 
					
						
							|  |  |  |  |                                         // SMARTY_PHP_REMOVE   -> remove php tags
 | 
					
						
							|  |  |  |  |                                         // SMARTY_PHP_ALLOW    -> execute php tags
 | 
					
						
							|  |  |  |  |                                         // default: SMARTY_PHP_PASSTHRU
 | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-06-15 14:52:48 +00:00
										 |  |  |  |     var $security       =   false;      // enable template security (default false)
 | 
					
						
							| 
									
										
										
										
											2002-04-11 20:27:04 +00:00
										 |  |  |  |     var $secure_dir     =   array('templates'); // array of directories considered secure
 | 
					
						
							| 
									
										
										
										
											2001-06-15 14:52:48 +00:00
										 |  |  |  |     var $security_settings  = array( | 
					
						
							|  |  |  |  |                                     'PHP_HANDLING'    => false, | 
					
						
							|  |  |  |  |                                     'IF_FUNCS'        => array('array', 'list', | 
					
						
							|  |  |  |  |                                                                'isset', 'empty', | 
					
						
							| 
									
										
										
										
											2001-07-10 15:15:42 +00:00
										 |  |  |  |                                                                'count', 'sizeof', | 
					
						
							| 
									
										
										
										
											2001-12-10 14:22:47 +00:00
										 |  |  |  |                                                                'in_array', 'is_array'), | 
					
						
							| 
									
										
										
										
											2001-06-15 14:52:48 +00:00
										 |  |  |  |                                     'INCLUDE_ANY'     => false, | 
					
						
							|  |  |  |  |                                     'PHP_TAGS'        => false, | 
					
						
							|  |  |  |  |                                     'MODIFIER_FUNCS'  => array('count') | 
					
						
							|  |  |  |  |                                    ); | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     var $trusted_dir        = array();  // directories where trusted templates & php scripts
 | 
					
						
							|  |  |  |  |                                         // reside ($security is disabled during their
 | 
					
						
							|  |  |  |  |                                         // inclusion/execution).
 | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-06 21:17:37 +00:00
										 |  |  |  |     var $left_delimiter  =  '{';        // template tag delimiters.
 | 
					
						
							|  |  |  |  |     var $right_delimiter =  '}'; | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-12 21:00:47 +00:00
										 |  |  |  |     var $compiler_class        =   'Smarty_Compiler'; // the compiler class used by
 | 
					
						
							|  |  |  |  |                                                       // Smarty to compile templates
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-07-03 21:24:27 +00:00
										 |  |  |  |     var $request_vars_order    = "EGPCS";   // the order in which request variables are
 | 
					
						
							|  |  |  |  |                                             // registered, similar to variables_order
 | 
					
						
							|  |  |  |  |                                             // in php.ini
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-03 20:20:06 +00:00
										 |  |  |  |     var $compile_id            = null;      // persistent compile identifier
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | /**************************************************************************/ | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | /* END SMARTY CONFIGURATION SECTION                                       */ | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | /* There should be no need to touch anything below this line.             */ | 
					
						
							|  |  |  |  | /**************************************************************************/ | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     // internal vars
 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     var $_error_msg            = false;      // error messages. true/false
 | 
					
						
							|  |  |  |  |     var $_tpl_vars             = array();    // where assigned template vars are kept
 | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |     var $_smarty_vars          = null;       // stores run-time $smarty.* vars
 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     var $_sections             = array();    // keeps track of sections
 | 
					
						
							|  |  |  |  |     var $_foreach              = array();    // keeps track of foreach blocks
 | 
					
						
							| 
									
										
										
										
											2002-03-26 21:01:52 +00:00
										 |  |  |  |     var $_tag_stack            = array();    // keeps track of tag hierarchy
 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     var $_conf_obj             = null;       // configuration object
 | 
					
						
							|  |  |  |  |     var $_config               = array();    // loaded configuration settings
 | 
					
						
							|  |  |  |  |     var $_smarty_md5           = 'f8d698aea36fcbead2b9d5359ffca76f'; // md5 checksum of the string 'Smarty'
 | 
					
						
							| 
									
										
										
										
											2002-03-20 17:15:21 +00:00
										 |  |  |  |     var $_version              = '2.0.1';    // Smarty version number
 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     var $_extract              = false;      // flag for custom functions
 | 
					
						
							|  |  |  |  |     var $_inclusion_depth      = 0;          // current template inclusion depth
 | 
					
						
							|  |  |  |  |     var $_compile_id           = null;       // for different compiled templates
 | 
					
						
							|  |  |  |  |     var $_smarty_debug_id      = 'SMARTY_DEBUG'; // text in URL to enable debug mode
 | 
					
						
							|  |  |  |  |     var $_smarty_debug_info    = array();    // debugging information for debug console
 | 
					
						
							|  |  |  |  |     var $_cache_info           = array();    // info that makes up a cache file
 | 
					
						
							|  |  |  |  |     var $_plugins              = array(      // table keeping track of plugins
 | 
					
						
							|  |  |  |  |                                        'modifier'  => array(), | 
					
						
							|  |  |  |  |                                        'function'  => array(), | 
					
						
							| 
									
										
										
										
											2002-03-25 22:32:05 +00:00
										 |  |  |  |                                        'block'     => array(), | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |                                        'compiler'  => array(), | 
					
						
							|  |  |  |  |                                        'prefilter' => array(), | 
					
						
							|  |  |  |  |                                        'postfilter'=> array(), | 
					
						
							|  |  |  |  |                                        'resource'  => array(), | 
					
						
							|  |  |  |  |                                        'insert'    => array()); | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-06-19 21:29:02 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-11-22 16:23:19 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     Function: Smarty | 
					
						
							|  |  |  |  |     Purpose:  Constructor | 
					
						
							| 
									
										
										
										
											2000-11-22 16:23:19 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     function Smarty() | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2001-04-24 15:16:14 +00:00
										 |  |  |  |         foreach ($this->global_assign as $key => $var_name) { | 
					
						
							|  |  |  |  |             if (is_array($var_name)) { | 
					
						
							|  |  |  |  |                 foreach ($var_name as $var) { | 
					
						
							|  |  |  |  |                     if (isset($GLOBALS[$key][$var])) { | 
					
						
							|  |  |  |  |                         $this->assign($var, $GLOBALS[$key][$var]); | 
					
						
							|  |  |  |  |                     } else { | 
					
						
							|  |  |  |  |                         $this->assign($var, $this->undefined); | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } else { | 
					
						
							|  |  |  |  |                 if (isset($GLOBALS[$var_name])) { | 
					
						
							|  |  |  |  |                     $this->assign($var_name, $GLOBALS[$var_name]); | 
					
						
							|  |  |  |  |                 } else { | 
					
						
							|  |  |  |  |                     $this->assign($var_name, $this->undefined); | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2001-03-02 18:07:51 +00:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2000-11-22 16:23:19 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     Function:   assign() | 
					
						
							|  |  |  |  |     Purpose:    assigns values to template variables | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     function assign($tpl_var, $value = NULL) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         if (is_array($tpl_var)){ | 
					
						
							|  |  |  |  |             foreach ($tpl_var as $key => $val) { | 
					
						
							| 
									
										
										
										
											2001-10-30 20:52:50 +00:00
										 |  |  |  |                 if (!empty($key) && isset($val)) { | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |                     $this->_tpl_vars[$key] = $val; | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } else { | 
					
						
							|  |  |  |  |             if (!empty($tpl_var) && isset($value)) | 
					
						
							|  |  |  |  |                 $this->_tpl_vars[$tpl_var] = $value; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-06-15 14:52:48 +00:00
										 |  |  |  |         $this->_extract = true; | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-11-21 15:21:16 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     Function: append | 
					
						
							|  |  |  |  |     Purpose:  appens values to template variables | 
					
						
							| 
									
										
										
										
											2000-11-21 15:21:16 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     function append($tpl_var, $value = NULL) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         if (is_array($tpl_var)) { | 
					
						
							|  |  |  |  |             foreach ($tpl_var as $key => $val) { | 
					
						
							|  |  |  |  |                 if (!empty($key)) { | 
					
						
							|  |  |  |  |                     if (!is_array($this->_tpl_vars[$key])) | 
					
						
							|  |  |  |  |                         settype($this->_tpl_vars[$key], 'array'); | 
					
						
							|  |  |  |  |                     $this->_tpl_vars[$key][] = $val; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } else { | 
					
						
							|  |  |  |  |             if (!empty($tpl_var) && isset($value)) { | 
					
						
							|  |  |  |  |                 if (!is_array($this->_tpl_vars[$tpl_var])) | 
					
						
							|  |  |  |  |                     settype($this->_tpl_vars[$tpl_var], 'array'); | 
					
						
							|  |  |  |  |                 $this->_tpl_vars[$tpl_var][] = $value; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-06-15 14:52:48 +00:00
										 |  |  |  |         $this->_extract = true; | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2000-11-21 15:21:16 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     Function:   clear_assign() | 
					
						
							|  |  |  |  |     Purpose:    clear the given assigned template variable. | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     function clear_assign($tpl_var) | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2001-04-12 20:53:21 +00:00
										 |  |  |  |         if (is_array($tpl_var)) | 
					
						
							|  |  |  |  |             foreach ($tpl_var as $curr_var) | 
					
						
							| 
									
										
										
										
											2001-02-08 14:18:25 +00:00
										 |  |  |  |                 unset($this->_tpl_vars[$curr_var]); | 
					
						
							|  |  |  |  |         else | 
					
						
							|  |  |  |  |             unset($this->_tpl_vars[$tpl_var]); | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-02 16:55:55 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-02-07 20:55:39 +00:00
										 |  |  |  |     Function: register_function | 
					
						
							| 
									
										
										
										
											2001-02-02 16:55:55 +00:00
										 |  |  |  |     Purpose:  Registers custom function to be used in templates | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-02-07 20:55:39 +00:00
										 |  |  |  |     function register_function($function, $function_impl) | 
					
						
							| 
									
										
										
										
											2001-02-02 16:55:55 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         $this->_plugins['function'][$function] = | 
					
						
							|  |  |  |  |             array($function_impl, null, null, false); | 
					
						
							| 
									
										
										
										
											2001-02-02 16:55:55 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-03-02 17:02:44 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: unregister_function | 
					
						
							|  |  |  |  |     Purpose:  Unregisters custom function
 | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function unregister_function($function) | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         unset($this->_plugins['function'][$function]); | 
					
						
							| 
									
										
										
										
											2001-03-02 17:02:44 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-03-26 21:01:52 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: register_block | 
					
						
							|  |  |  |  |     Purpose:  Registers block function to be used in templates | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function register_block($block, $block_impl) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         $this->_plugins['block'][$block] = | 
					
						
							|  |  |  |  |             array($block_impl, null, null, false); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: unregister_block | 
					
						
							|  |  |  |  |     Purpose:  Unregisters block function
 | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function unregister_block($block) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         unset($this->_plugins['block'][$block]); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-24 16:43:05 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: register_compiler_function | 
					
						
							|  |  |  |  |     Purpose:  Registers compiler function
 | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function register_compiler_function($function, $function_impl) | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         $this->_plugins['compiler'][$function] = | 
					
						
							|  |  |  |  |             array($function_impl, null, null, false); | 
					
						
							| 
									
										
										
										
											2001-04-24 16:43:05 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: unregister_compiler_function | 
					
						
							|  |  |  |  |     Purpose:  Unregisters compiler function
 | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function unregister_compiler_function($function) | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         unset($this->_plugins['compiler'][$function]); | 
					
						
							| 
									
										
										
										
											2001-04-24 16:43:05 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-02 16:55:55 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-02-07 20:55:39 +00:00
										 |  |  |  |     Function: register_modifier | 
					
						
							| 
									
										
										
										
											2001-02-02 16:55:55 +00:00
										 |  |  |  |     Purpose:  Registers modifier to be used in templates | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-02-07 20:55:39 +00:00
										 |  |  |  |     function register_modifier($modifier, $modifier_impl) | 
					
						
							| 
									
										
										
										
											2001-02-02 16:55:55 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         $this->_plugins['modifier'][$modifier] = | 
					
						
							|  |  |  |  |             array($modifier_impl, null, null, false); | 
					
						
							| 
									
										
										
										
											2001-02-02 16:55:55 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-03-02 17:02:44 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: unregister_modifier | 
					
						
							|  |  |  |  |     Purpose:  Unregisters modifier | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function unregister_modifier($modifier) | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         unset($this->_plugins['modifier'][$modifier]); | 
					
						
							| 
									
										
										
										
											2001-03-02 17:02:44 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-19 16:18:17 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: register_resource | 
					
						
							|  |  |  |  |     Purpose:  Registers a resource to fetch a template | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     function register_resource($type, $functions) | 
					
						
							| 
									
										
										
										
											2001-04-19 16:18:17 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         $this->_plugins['resource'][$type] = | 
					
						
							|  |  |  |  |             array((array)$functions, false); | 
					
						
							| 
									
										
										
										
											2001-04-19 16:18:17 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: unregister_resource | 
					
						
							|  |  |  |  |     Purpose:  Unregisters a resource | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     function unregister_resource($type) | 
					
						
							| 
									
										
										
										
											2001-04-19 16:18:17 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         unset($this->_plugins['resource'][$type]); | 
					
						
							| 
									
										
										
										
											2001-04-19 16:18:17 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-19 21:08:17 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-04-26 17:27:40 +00:00
										 |  |  |  |     Function: register_prefilter | 
					
						
							|  |  |  |  |     Purpose:  Registers a prefilter function to apply | 
					
						
							| 
									
										
										
										
											2001-04-19 21:08:17 +00:00
										 |  |  |  |               to a template before compiling | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     function register_prefilter($function) | 
					
						
							| 
									
										
										
										
											2001-04-19 21:08:17 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         $this->_plugins['prefilter'][$function] | 
					
						
							|  |  |  |  |             = array($function, null, null, false); | 
					
						
							| 
									
										
										
										
											2001-04-19 21:08:17 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-04-26 17:27:40 +00:00
										 |  |  |  |     Function: unregister_prefilter | 
					
						
							| 
									
										
										
										
											2001-09-28 21:39:57 +00:00
										 |  |  |  |     Purpose:  Unregisters a prefilter function
 | 
					
						
							| 
									
										
										
										
											2001-04-19 21:08:17 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     function unregister_prefilter($function) | 
					
						
							| 
									
										
										
										
											2001-04-19 21:08:17 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-04-05 17:16:52 +00:00
										 |  |  |  |         if (isset($this->_plugins['prefilter'][$function])) | 
					
						
							|  |  |  |  |             unset($this->_plugins['prefilter'][$function]); | 
					
						
							|  |  |  |  |         else | 
					
						
							|  |  |  |  |             $this->_plugins['prefilter'][$function] = false; | 
					
						
							| 
									
										
										
										
											2001-04-19 21:08:17 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-09-28 21:39:57 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: register_postfilter | 
					
						
							|  |  |  |  |     Purpose:  Registers a postfilter function to apply | 
					
						
							|  |  |  |  |               to a compiled template after compilation | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     function register_postfilter($function) | 
					
						
							| 
									
										
										
										
											2001-09-28 21:39:57 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         $this->_plugins['postfilter'][$function] | 
					
						
							|  |  |  |  |             = array($function, null, null, false); | 
					
						
							| 
									
										
										
										
											2001-09-28 21:39:57 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: unregister_postfilter | 
					
						
							|  |  |  |  |     Purpose:  Unregisters a postfilter function
 | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     function unregister_postfilter($function) | 
					
						
							| 
									
										
										
										
											2001-09-28 21:39:57 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-04-05 17:16:52 +00:00
										 |  |  |  |         if (isset($this->_plugins['postfilter'][$function])) | 
					
						
							|  |  |  |  |             unset($this->_plugins['postfilter'][$function]); | 
					
						
							|  |  |  |  |         else | 
					
						
							|  |  |  |  |             $this->_plugins['postfilter'][$function] = false; | 
					
						
							| 
									
										
										
										
											2001-09-28 21:39:57 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-01 21:09:17 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     Function:   clear_cache() | 
					
						
							| 
									
										
										
										
											2001-02-07 20:55:39 +00:00
										 |  |  |  |     Purpose:    clear cached content for the given template and cache id | 
					
						
							| 
									
										
										
										
											2001-02-01 21:09:17 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-11-26 22:44:23 +00:00
										 |  |  |  |     function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null) | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2001-12-03 20:20:06 +00:00
										 |  |  |  |         if (!isset($compile_id)) | 
					
						
							|  |  |  |  |             $compile_id = $this->compile_id; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-18 15:18:51 +00:00
										 |  |  |  |         if (isset($compile_id) || isset($cache_id)) | 
					
						
							| 
									
										
										
										
											2001-12-03 20:20:06 +00:00
										 |  |  |  |             $auto_id = $compile_id . $cache_id; | 
					
						
							|  |  |  |  |         else | 
					
						
							|  |  |  |  |             $auto_id = null; | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         if (!empty($this->cache_handler_func)) { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |             $funcname = $this->cache_handler_func; | 
					
						
							| 
									
										
										
										
											2001-11-29 15:25:24 +00:00
										 |  |  |  |             return $funcname('clear', $this, $dummy, $tpl_file, $cache_id, $compile_id); | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2001-12-03 20:20:06 +00:00
										 |  |  |  |             return $this->_rm_auto($this->cache_dir, $tpl_file, $auto_id); | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-01 20:21:02 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     Function:   clear_all_cache() | 
					
						
							| 
									
										
										
										
											2001-02-06 21:17:37 +00:00
										 |  |  |  |     Purpose:    clear the entire contents of cache (all templates) | 
					
						
							| 
									
										
										
										
											2001-02-01 20:21:02 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     function clear_all_cache() | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         if (!empty($this->cache_handler_func)) { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |             $funcname = $this->cache_handler_func; | 
					
						
							| 
									
										
										
										
											2001-11-29 15:25:24 +00:00
										 |  |  |  |             return $funcname('clear', $this, $dummy); | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         } else { | 
					
						
							|  |  |  |  |             return $this->_rm_auto($this->cache_dir); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-02-05 21:10:20 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-07 20:55:39 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-05 21:10:20 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function:   is_cached() | 
					
						
							|  |  |  |  |     Purpose:    test to see if valid cache exists for this template | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  |     function is_cached($tpl_file, $cache_id = null, $compile_id = null) | 
					
						
							| 
									
										
										
										
											2001-02-05 21:10:20 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2001-02-07 23:08:00 +00:00
										 |  |  |  |         if (!$this->caching) | 
					
						
							|  |  |  |  |             return false; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-03 20:20:06 +00:00
										 |  |  |  |         if (!isset($compile_id)) | 
					
						
							|  |  |  |  |             $compile_id = $this->compile_id; | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         return $this->_read_cache_file($tpl_file, $cache_id, $compile_id, $results); | 
					
						
							| 
									
										
										
										
											2001-02-05 21:10:20 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     Function:   clear_all_assign() | 
					
						
							|  |  |  |  |     Purpose:    clear all the assigned template variables. | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     function clear_all_assign() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         $this->_tpl_vars = array(); | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-26 17:27:40 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  |     Function:   clear_compiled_tpl() | 
					
						
							| 
									
										
										
										
											2001-06-15 14:52:48 +00:00
										 |  |  |  |     Purpose:    clears compiled version of specified template resource, | 
					
						
							|  |  |  |  |                 or all compiled template files if one is not specified. | 
					
						
							| 
									
										
										
										
											2001-04-26 22:07:06 +00:00
										 |  |  |  |                 This function is for advanced use only, not normally needed. | 
					
						
							| 
									
										
										
										
											2001-04-26 17:27:40 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-09-26 20:40:56 +00:00
										 |  |  |  |     function clear_compiled_tpl($tpl_file = null, $compile_id = null) | 
					
						
							| 
									
										
										
										
											2001-04-26 17:27:40 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2001-12-03 20:20:06 +00:00
										 |  |  |  |         if (!isset($compile_id)) | 
					
						
							|  |  |  |  |             $compile_id = $this->compile_id; | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  |         return $this->_rm_auto($this->compile_dir, $tpl_file, $compile_id); | 
					
						
							| 
									
										
										
										
											2001-04-26 17:27:40 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2000-11-21 15:21:16 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-04-03 19:31:11 +00:00
										 |  |  |  |     function template_exists($tpl_file) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         return $this->_fetch_template_info($tpl_file, $source, $timestamp, true, true); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-11-21 15:21:16 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     Function: get_template_vars | 
					
						
							|  |  |  |  |     Purpose:  Returns an array containing template variables | 
					
						
							| 
									
										
										
										
											2000-11-21 15:21:16 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     function &get_template_vars() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         return $this->_tpl_vars; | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2000-11-21 15:21:16 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-02-20 22:24:32 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: trigger_error | 
					
						
							|  |  |  |  |     Purpose:  trigger Smarty error | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function trigger_error($error_msg, $error_type = E_USER_WARNING) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         trigger_error("Smarty error: $error_msg", $error_type); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     Function:   display() | 
					
						
							|  |  |  |  |     Purpose:    executes & displays the template results | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  |     function display($tpl_file, $cache_id = null, $compile_id = null) | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  |         $this->fetch($tpl_file, $cache_id, $compile_id, true); | 
					
						
							| 
									
										
										
										
											2001-06-19 15:30:29 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     Function:   fetch() | 
					
						
							|  |  |  |  |     Purpose:    executes & returns or displays the template results | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  |     function fetch($_smarty_tpl_file, $_smarty_cache_id = null, $_smarty_compile_id = null, $_smarty_display = false) | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-04-15 16:39:16 +00:00
										 |  |  |  |         $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(error_reporting() & ~E_NOTICE); | 
					
						
							| 
									
										
										
										
											2002-03-22 19:20:22 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-28 17:16:04 +00:00
										 |  |  |  |         if (!$this->debugging && $this->debugging_ctrl == 'URL' | 
					
						
							| 
									
										
										
										
											2002-02-21 17:14:10 +00:00
										 |  |  |  |                && strstr($GLOBALS['QUERY_STRING'], $this->_smarty_debug_id)) { | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |             $this->debugging = true; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-11-29 15:17:57 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         if ($this->debugging) { | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |             // capture time for debugging info
 | 
					
						
							|  |  |  |  |             $debug_start_time = $this->_get_microtime(); | 
					
						
							|  |  |  |  |             $this->_smarty_debug_info[] = array('type'      => 'template', | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  |                                                 'filename'  => $_smarty_tpl_file, | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |                                                 'depth'     => 0); | 
					
						
							|  |  |  |  |             $included_tpls_idx = count($this->_smarty_debug_info) - 1; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-03 20:53:56 +00:00
										 |  |  |  |         if (!isset($_smarty_compile_id)) | 
					
						
							|  |  |  |  |             $_smarty_compile_id = $this->compile_id; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-31 19:53:06 +00:00
										 |  |  |  |         $this->_compile_id = $_smarty_compile_id; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-03 20:53:56 +00:00
										 |  |  |  |         $this->_inclusion_depth = 0; | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-06 21:17:37 +00:00
										 |  |  |  |         if ($this->caching) { | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  |             if ($this->_read_cache_file($_smarty_tpl_file, $_smarty_cache_id, $_smarty_compile_id, $_smarty_results)) { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |                 if (@count($this->_cache_info['insert_tags'])) { | 
					
						
							|  |  |  |  |                     $this->_load_plugins($this->_cache_info['insert_tags']); | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  |                     $_smarty_results = $this->_process_cached_inserts($_smarty_results); | 
					
						
							| 
									
										
										
										
											2001-11-26 22:44:23 +00:00
										 |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  |                 if ($_smarty_display) { | 
					
						
							| 
									
										
										
										
											2001-11-26 22:44:23 +00:00
										 |  |  |  |                     if ($this->debugging) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         // capture time for debugging info
 | 
					
						
							|  |  |  |  |                         $this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = $this->_get_microtime() - $debug_start_time; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-01-28 23:29:06 +00:00
										 |  |  |  |                         $_smarty_results .= $this->_generate_debug_output(); | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2002-02-19 22:40:49 +00:00
										 |  |  |  |                     if ($this->cache_modified_check) { | 
					
						
							| 
									
										
										
										
											2002-02-21 17:14:10 +00:00
										 |  |  |  |                         $last_modified_date = substr($GLOBALS['HTTP_IF_MODIFIED_SINCE'], 0, strpos($GLOBALS['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3); | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |                         $gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']).' GMT'; | 
					
						
							|  |  |  |  |                         if (@count($this->_cache_info['insert_tags']) == 0 | 
					
						
							|  |  |  |  |                             && $gmt_mtime == $last_modified_date) { | 
					
						
							|  |  |  |  |                             header("HTTP/1.1 304 Not Modified"); | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |                         } else { | 
					
						
							|  |  |  |  |                             header("Last-Modified: ".$gmt_mtime); | 
					
						
							|  |  |  |  |                         } | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |                     } | 
					
						
							| 
									
										
										
										
											2002-01-28 23:29:06 +00:00
										 |  |  |  |                     echo $_smarty_results; | 
					
						
							| 
									
										
										
										
											2002-04-15 16:39:16 +00:00
										 |  |  |  |                     error_reporting($_smarty_old_error_level); | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |                     return true;     | 
					
						
							| 
									
										
										
										
											2001-11-26 22:44:23 +00:00
										 |  |  |  |                 } else { | 
					
						
							| 
									
										
										
										
											2002-04-15 16:39:16 +00:00
										 |  |  |  |                     error_reporting($_smarty_old_error_level); | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  |                     return $_smarty_results; | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |             } else { | 
					
						
							|  |  |  |  |                 $this->_cache_info = array(); | 
					
						
							|  |  |  |  |                 $this->_cache_info['template'][] = $_smarty_tpl_file; | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-01-30 21:54:59 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-01-31 22:42:05 +00:00
										 |  |  |  |         extract($this->_tpl_vars); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-06-15 18:55:28 +00:00
										 |  |  |  |         /* Initialize config array. */ | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         $this->_config = array(array('vars'  => array(), | 
					
						
							|  |  |  |  |                                      'files' => array())); | 
					
						
							| 
									
										
										
										
											2001-06-15 18:55:28 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  |         $compile_path = $this->_get_compile_path($_smarty_tpl_file); | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         // if we just need to display the results, don't perform output
 | 
					
						
							| 
									
										
										
										
											2001-02-06 22:17:51 +00:00
										 |  |  |  |         // buffering - for speed
 | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  |         if ($_smarty_display && !$this->caching) { | 
					
						
							|  |  |  |  |             if ($this->_process_template($_smarty_tpl_file, $compile_path)) | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2001-12-03 23:28:12 +00:00
										 |  |  |  |                 include($compile_path); | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2001-04-19 21:08:17 +00:00
										 |  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2001-01-31 22:42:05 +00:00
										 |  |  |  |             ob_start(); | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  |             if ($this->_process_template($_smarty_tpl_file, $compile_path)) | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |                 include($compile_path); | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  |             $_smarty_results = ob_get_contents(); | 
					
						
							| 
									
										
										
										
											2001-01-31 22:42:05 +00:00
										 |  |  |  |             ob_end_clean(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-12 20:53:21 +00:00
										 |  |  |  |         if ($this->caching) { | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  |             $this->_write_cache_file($_smarty_tpl_file, $_smarty_cache_id, $_smarty_compile_id, $_smarty_results); | 
					
						
							|  |  |  |  |             $_smarty_results = $this->_process_cached_inserts($_smarty_results); | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  |         if ($_smarty_display) { | 
					
						
							|  |  |  |  |             if (isset($_smarty_results)) { echo $_smarty_results; } | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |             if ($this->debugging) { | 
					
						
							|  |  |  |  |                 // capture time for debugging info
 | 
					
						
							|  |  |  |  |                 $this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = ($this->_get_microtime() - $debug_start_time); | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |                 echo $this->_generate_debug_output(); | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2002-04-15 16:39:16 +00:00
										 |  |  |  |             error_reporting($_smarty_old_error_level); | 
					
						
							| 
									
										
										
										
											2001-01-31 22:42:05 +00:00
										 |  |  |  |             return; | 
					
						
							| 
									
										
										
										
											2001-03-02 18:07:51 +00:00
										 |  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2002-04-15 16:39:16 +00:00
										 |  |  |  |             error_reporting($_smarty_old_error_level); | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  |             if (isset($_smarty_results)) { return $_smarty_results; } | 
					
						
							| 
									
										
										
										
											2001-03-02 18:07:51 +00:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-06-20 18:38:00 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-07-03 21:24:27 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: _assign_smarty_interface | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     Purpose:  assign $smarty interface variable | 
					
						
							| 
									
										
										
										
											2001-07-03 21:24:27 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function _assign_smarty_interface() | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |         if ($this->_smarty_vars !== null) | 
					
						
							|  |  |  |  |             return; | 
					
						
							| 
									
										
										
										
											2001-08-01 16:22:55 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |         $globals_map = array('g'  => 'HTTP_GET_VARS', | 
					
						
							|  |  |  |  |                              'p'  => 'HTTP_POST_VARS', | 
					
						
							|  |  |  |  |                              'c'  => 'HTTP_COOKIE_VARS', | 
					
						
							|  |  |  |  |                              's'  => 'HTTP_SERVER_VARS', | 
					
						
							|  |  |  |  |                              'e'  => 'HTTP_ENV_VARS'); | 
					
						
							| 
									
										
										
										
											2001-08-01 16:22:55 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |         $smarty  = array('request'  => array()); | 
					
						
							| 
									
										
										
										
											2001-08-01 16:22:55 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         foreach (preg_split('!!', strtolower($this->request_vars_order)) as $c) { | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |             if (isset($globals_map[$c])) { | 
					
						
							|  |  |  |  |                 $smarty['request'] = array_merge($smarty['request'], $GLOBALS[$globals_map[$c]]); | 
					
						
							| 
									
										
										
										
											2001-07-03 21:24:27 +00:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |         $smarty['request'] = @array_merge($smarty['request'], $GLOBALS['HTTP_SESSION_VARS']); | 
					
						
							| 
									
										
										
										
											2001-08-01 16:22:55 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-27 15:27:22 +00:00
										 |  |  |  |         $this->_smarty_vars = $smarty; | 
					
						
							| 
									
										
										
										
											2001-07-03 21:24:27 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-06-20 16:39:52 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-06-26 21:12:54 +00:00
										 |  |  |  |     Function:   _generate_debug_output() | 
					
						
							|  |  |  |  |     Purpose:    generate debug output | 
					
						
							| 
									
										
										
										
											2001-06-20 16:39:52 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | function _generate_debug_output() { | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     // we must force compile the debug template in case the environment
 | 
					
						
							|  |  |  |  |     // changed between separate applications.
 | 
					
						
							| 
									
										
										
										
											2001-06-20 16:39:52 +00:00
										 |  |  |  |     ob_start(); | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     $force_compile_orig = $this->force_compile; | 
					
						
							|  |  |  |  |     $this->force_compile = true; | 
					
						
							| 
									
										
										
										
											2001-10-26 19:41:05 +00:00
										 |  |  |  |     $compile_path = $this->_get_compile_path($this->debug_tpl); | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     if ($this->_process_template($this->debug_tpl, $compile_path)) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         include($compile_path); | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-06-20 16:39:52 +00:00
										 |  |  |  |     $results = ob_get_contents(); | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     $this->force_compile = $force_compile_orig; | 
					
						
							| 
									
										
										
										
											2001-06-20 16:39:52 +00:00
										 |  |  |  |     ob_end_clean(); | 
					
						
							| 
									
										
										
										
											2001-06-26 21:12:54 +00:00
										 |  |  |  |     return $results; | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function:   _is_trusted() | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     Purpose:    determines if a resource is trusted or not | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     function _is_trusted($resource_type, $resource_name) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         $_smarty_trusted = false; | 
					
						
							|  |  |  |  |         if ($resource_type == 'file') { | 
					
						
							|  |  |  |  |             if (!empty($this->trusted_dir)) { | 
					
						
							|  |  |  |  |                 // see if template file is within a trusted directory. If so,
 | 
					
						
							|  |  |  |  |                 // disable security during the execution of the template.
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if (!empty($this->trusted_dir)) { | 
					
						
							|  |  |  |  |                     foreach ((array)$this->trusted_dir as $curr_dir) { | 
					
						
							|  |  |  |  |                         if (!empty($curr_dir) && is_readable ($curr_dir)) { | 
					
						
							|  |  |  |  |                             if (substr(realpath($resource_name),0, strlen(realpath($curr_dir))) == realpath($curr_dir)) { | 
					
						
							|  |  |  |  |                                 $_smarty_trusted = true; | 
					
						
							|  |  |  |  |                                 break; | 
					
						
							|  |  |  |  |                             } | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } else { | 
					
						
							|  |  |  |  |             // resource is not on local file system
 | 
					
						
							|  |  |  |  |             $resource_func = $this->_plugins['resource'][$resource_type][0][3]; | 
					
						
							|  |  |  |  |             $_smarty_trusted = $resource_func($resource_name, $this); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         return $_smarty_trusted; | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function:   _is_secure() | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     Purpose:    determines if a resource is secure or not. | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function _is_secure($resource_type, $resource_name) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         if (!$this->security || $this->security_settings['INCLUDE_ANY']) { | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         $_smarty_secure = false; | 
					
						
							|  |  |  |  |         if ($resource_type == 'file') { | 
					
						
							|  |  |  |  |             if (!empty($this->secure_dir)) { | 
					
						
							|  |  |  |  |                 foreach ((array)$this->secure_dir as $curr_dir) { | 
					
						
							|  |  |  |  |                     if ( !empty($curr_dir) && is_readable ($curr_dir)) { | 
					
						
							|  |  |  |  |                         if (substr(realpath($resource_name),0, strlen(realpath($curr_dir))) == realpath($curr_dir)) { | 
					
						
							|  |  |  |  |                             $_smarty_secure = true; | 
					
						
							|  |  |  |  |                             break; | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } else { | 
					
						
							|  |  |  |  |             // resource is not on local file system
 | 
					
						
							|  |  |  |  |             $resource_func = $this->_plugins['resource'][$resource_type][0][2]; | 
					
						
							|  |  |  |  |             $_smarty_secure = $resource_func($resource_name, $_smarty_secure, $this); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         return $_smarty_secure; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function:   _get_php_resource | 
					
						
							|  |  |  |  |     Purpose:    Retrieves PHP script resource | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     function _get_php_resource($resource, &$resource_type, &$php_resource) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         $this->_parse_file_path($this->trusted_dir, $resource, $resource_type, $resource_name); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /* | 
					
						
							|  |  |  |  |          * Find out if the resource exists. | 
					
						
							|  |  |  |  |          */ | 
					
						
							| 
									
										
										
										
											2002-04-04 20:34:44 +00:00
										 |  |  |  | 		 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         $readable = true; | 
					
						
							|  |  |  |  |         if ($resource_type == 'file' && !@is_file($resource_name)) { | 
					
						
							|  |  |  |  |             $readable = false; | 
					
						
							|  |  |  |  |         } else if ($resource_type != 'file') { | 
					
						
							|  |  |  |  |             $resource_func = $this->_plugins['resource'][$resource_type][0][0]; | 
					
						
							|  |  |  |  |             $readable = $resource_func($resource_name, $template_source, $this); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /* | 
					
						
							|  |  |  |  |          * Set the error function, depending on which class calls us. | 
					
						
							|  |  |  |  |          */ | 
					
						
							|  |  |  |  |         if (method_exists($this, '_syntax_error')) { | 
					
						
							|  |  |  |  |             $error_func = '_syntax_error'; | 
					
						
							|  |  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2002-02-20 22:24:32 +00:00
										 |  |  |  |             $error_func = 'trigger_error'; | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         if ($readable) { | 
					
						
							|  |  |  |  |             if ($this->security) { | 
					
						
							|  |  |  |  |                 if (!$this->_is_trusted($resource_type, $resource_name)) { | 
					
						
							|  |  |  |  |                     $this->$error_func("(secure mode) '$resource_type:$resource_name' is not trusted"); | 
					
						
							|  |  |  |  |                     return false; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } else { | 
					
						
							|  |  |  |  |             $this->$error_func("'$resource_type: $resource_name' is not readable"); | 
					
						
							|  |  |  |  |             return false; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         if ($resource_type == 'file') { | 
					
						
							|  |  |  |  |             $php_resource = $resource_name; | 
					
						
							|  |  |  |  |         } else { | 
					
						
							|  |  |  |  |             $php_resource = $template_source; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         return true; | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function:   _process_template() | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     Purpose: | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-10-25 16:32:00 +00:00
										 |  |  |  |     function _process_template($tpl_file, $compile_path) | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     { | 
					
						
							|  |  |  |  |         // test if template needs to be compiled
 | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |         if (!$this->force_compile && file_exists($compile_path)) { | 
					
						
							| 
									
										
										
										
											2001-04-12 20:14:30 +00:00
										 |  |  |  |             if (!$this->compile_check) { | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |                 // no need to check if the template needs recompiled
 | 
					
						
							| 
									
										
										
										
											2001-06-19 15:30:29 +00:00
										 |  |  |  |                 return true; | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |                 // get template source and timestamp
 | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |                 if (!$this->_fetch_template_info($tpl_file, $template_source, | 
					
						
							|  |  |  |  |                                                  $template_timestamp)) { | 
					
						
							|  |  |  |  |                     return false; | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |                 if ($template_timestamp <= filemtime($compile_path)) { | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |                     // template not expired, no recompile
 | 
					
						
							|  |  |  |  |                     return true; | 
					
						
							|  |  |  |  |                 } else { | 
					
						
							| 
									
										
										
										
											2001-04-12 20:14:30 +00:00
										 |  |  |  |                     // compile template
 | 
					
						
							|  |  |  |  |                     $this->_compile_template($tpl_file, $template_source, $template_compiled); | 
					
						
							|  |  |  |  |                     $this->_write_compiled_template($compile_path, $template_compiled); | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |                     return true; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } else { | 
					
						
							|  |  |  |  |             // compiled template does not exist, or forced compile
 | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |             if (!$this->_fetch_template_info($tpl_file, $template_source, | 
					
						
							|  |  |  |  |                                              $template_timestamp)) { | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2001-04-12 20:14:30 +00:00
										 |  |  |  |             $this->_compile_template($tpl_file, $template_source, $template_compiled); | 
					
						
							|  |  |  |  |             $this->_write_compiled_template($compile_path, $template_compiled); | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-06-19 15:30:29 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-10-25 16:32:00 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function:   _get_compile_path | 
					
						
							|  |  |  |  |     Purpose:    Get the compile path for this template file | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function _get_compile_path($tpl_file) | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |         return $this->_get_auto_filename($this->compile_dir, $tpl_file, | 
					
						
							|  |  |  |  |                                          $this->_compile_id); | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function:   _write_compiled_template | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     Purpose: | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-04-12 20:14:30 +00:00
										 |  |  |  |     function _write_compiled_template($compile_path, $template_compiled) | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2001-04-24 15:16:14 +00:00
										 |  |  |  |         // we save everything into $compile_dir
 | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  |         $this->_write_file($compile_path, $template_compiled, true); | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |         return true; | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-12-04 22:31:47 +00:00
										 |  |  |  |     Function:   _parse_file_path | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     Purpose:    parse out the type and name from the template resource | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |     function _parse_file_path($file_base_path, $file_path, &$resource_type, &$resource_name) | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |         // split tpl_path by the first colon
 | 
					
						
							| 
									
										
										
										
											2001-12-04 22:31:47 +00:00
										 |  |  |  |         $file_path_parts = explode(':', $file_path, 2); | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-04 22:31:47 +00:00
										 |  |  |  |         if (count($file_path_parts) == 1) { | 
					
						
							| 
									
										
										
										
											2001-04-12 19:56:38 +00:00
										 |  |  |  |             // no resource type, treat as type "file"
 | 
					
						
							| 
									
										
										
										
											2001-04-12 20:14:30 +00:00
										 |  |  |  |             $resource_type = 'file'; | 
					
						
							| 
									
										
										
										
											2001-12-04 22:31:47 +00:00
										 |  |  |  |             $resource_name = $file_path_parts[0]; | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2001-12-04 22:31:47 +00:00
										 |  |  |  |             $resource_type = $file_path_parts[0]; | 
					
						
							|  |  |  |  |             $resource_name = $file_path_parts[1]; | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |             if ($resource_type != 'file') { | 
					
						
							|  |  |  |  |                 $this->_load_resource_plugin($resource_type); | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2001-04-12 20:14:30 +00:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         if ($resource_type == 'file') { | 
					
						
							|  |  |  |  |             if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $resource_name)) { | 
					
						
							|  |  |  |  |                 // relative pathname to $file_base_path
 | 
					
						
							|  |  |  |  |                 // use the first directory where the file is found
 | 
					
						
							|  |  |  |  |                 foreach ((array)$file_base_path as $curr_path) { | 
					
						
							| 
									
										
										
										
											2002-04-11 20:27:04 +00:00
										 |  |  |  |                     if (@is_file($curr_path.DIR_SEP.$resource_name)) { | 
					
						
							|  |  |  |  |                         $resource_name = $curr_path.DIR_SEP.$resource_name; | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |                         return true; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 // didn't find the file
 | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         // resource type != file
 | 
					
						
							|  |  |  |  |         return true; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-03 23:28:12 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function:   _fetch_template_info() | 
					
						
							|  |  |  |  |     Purpose:    fetch the template info. Gets timestamp, and source | 
					
						
							|  |  |  |  |                 if get_source is true | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2002-04-03 19:31:11 +00:00
										 |  |  |  |     function _fetch_template_info($tpl_path, &$template_source, &$template_timestamp, $get_source = true, $quiet = false) | 
					
						
							| 
									
										
										
										
											2001-12-03 23:28:12 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2001-12-11 23:06:38 +00:00
										 |  |  |  |         $_return = false; | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         if ($this->_parse_file_path($this->template_dir, $tpl_path, $resource_type, $resource_name)) { | 
					
						
							|  |  |  |  |             switch ($resource_type) { | 
					
						
							|  |  |  |  |                 case 'file': | 
					
						
							|  |  |  |  |                     if (@is_file($resource_name)) { | 
					
						
							|  |  |  |  |                         if ($get_source) { | 
					
						
							|  |  |  |  |                             $template_source = $this->_read_file($resource_name); | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                         $template_timestamp = filemtime($resource_name); | 
					
						
							|  |  |  |  |                         $_return = true; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     break; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 default: | 
					
						
							|  |  |  |  |                     // call resource functions to fetch the template source and timestamp
 | 
					
						
							|  |  |  |  |                     if ($get_source) { | 
					
						
							|  |  |  |  |                         $resource_func = $this->_plugins['resource'][$resource_type][0][0]; | 
					
						
							|  |  |  |  |                         $_source_return = $resource_func($resource_name, $template_source, $this); | 
					
						
							|  |  |  |  |                     } else { | 
					
						
							|  |  |  |  |                         $_source_return = true; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     $resource_func = $this->_plugins['resource'][$resource_type][0][1]; | 
					
						
							|  |  |  |  |                     $_timestamp_return = $resource_func($resource_name, $template_timestamp, $this); | 
					
						
							|  |  |  |  |                     $_return = $_source_return && $_timestamp_return; | 
					
						
							|  |  |  |  |                     break; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         if (!$_return) { | 
					
						
							|  |  |  |  |             // see if we can get a template with the default template handler
 | 
					
						
							|  |  |  |  |             if (!empty($this->default_template_handler_func)) { | 
					
						
							|  |  |  |  |                 if (!function_exists($this->default_template_handler_func)) { | 
					
						
							| 
									
										
										
										
											2002-02-20 22:24:32 +00:00
										 |  |  |  |                     $this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist.");
 | 
					
						
							| 
									
										
										
										
											2001-12-11 23:06:38 +00:00
										 |  |  |  |                     $_return = false; | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |                 $funcname = $this->default_template_handler_func; | 
					
						
							|  |  |  |  |                 $_return = $funcname($resource_type, $resource_name, $template_source, $template_timestamp, $this); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         if (!$_return) { | 
					
						
							| 
									
										
										
										
											2002-04-03 19:31:11 +00:00
										 |  |  |  |             if (!$quiet) | 
					
						
							|  |  |  |  |                 $this->trigger_error("unable to read template resource: \"$tpl_path\"");
 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         } else if ($_return && $this->security && !$this->_is_secure($resource_type, $resource_name)) { | 
					
						
							| 
									
										
										
										
											2002-04-03 19:31:11 +00:00
										 |  |  |  |             if (!$quiet) | 
					
						
							|  |  |  |  |                 $this->trigger_error("(secure mode) accessing \"$tpl_path\" is not allowed");
 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |             $template_source = null; | 
					
						
							|  |  |  |  |             $template_timestamp = null; | 
					
						
							|  |  |  |  |             return false; | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-11 23:06:38 +00:00
										 |  |  |  |         return $_return; | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function:   _compile_template() | 
					
						
							|  |  |  |  |     Purpose:    called to compile the templates | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-04-12 20:14:30 +00:00
										 |  |  |  |     function _compile_template($tpl_file, $template_source, &$template_compiled) | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-02-05 16:46:05 +00:00
										 |  |  |  |         require_once SMARTY_DIR.$this->compiler_class . '.class.php'; | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-12 21:00:47 +00:00
										 |  |  |  |         $smarty_compiler = new $this->compiler_class; | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-12 21:00:47 +00:00
										 |  |  |  |         $smarty_compiler->template_dir      = $this->template_dir; | 
					
						
							|  |  |  |  |         $smarty_compiler->compile_dir       = $this->compile_dir; | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         $smarty_compiler->plugins_dir       = $this->plugins_dir; | 
					
						
							| 
									
										
										
										
											2001-04-12 21:00:47 +00:00
										 |  |  |  |         $smarty_compiler->config_dir        = $this->config_dir; | 
					
						
							|  |  |  |  |         $smarty_compiler->force_compile     = $this->force_compile; | 
					
						
							|  |  |  |  |         $smarty_compiler->caching           = $this->caching; | 
					
						
							|  |  |  |  |         $smarty_compiler->php_handling      = $this->php_handling; | 
					
						
							|  |  |  |  |         $smarty_compiler->left_delimiter    = $this->left_delimiter; | 
					
						
							|  |  |  |  |         $smarty_compiler->right_delimiter   = $this->right_delimiter; | 
					
						
							| 
									
										
										
										
											2001-06-11 14:33:47 +00:00
										 |  |  |  |         $smarty_compiler->_version          = $this->_version; | 
					
						
							| 
									
										
										
										
											2001-06-15 14:52:48 +00:00
										 |  |  |  |         $smarty_compiler->security          = $this->security; | 
					
						
							|  |  |  |  |         $smarty_compiler->secure_dir        = $this->secure_dir; | 
					
						
							| 
									
										
										
										
											2001-06-13 14:03:04 +00:00
										 |  |  |  |         $smarty_compiler->security_settings = $this->security_settings; | 
					
						
							| 
									
										
										
										
											2001-12-04 22:31:47 +00:00
										 |  |  |  |         $smarty_compiler->trusted_dir       = $this->trusted_dir; | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         $smarty_compiler->_plugins          = &$this->_plugins; | 
					
						
							| 
									
										
										
										
											2002-03-21 15:49:12 +00:00
										 |  |  |  |         $smarty_compiler->_tpl_vars         = &$this->_tpl_vars; | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-12 20:14:30 +00:00
										 |  |  |  |         if ($smarty_compiler->_compile_file($tpl_file, $template_source, $template_compiled)) | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |             return true; | 
					
						
							|  |  |  |  |         else { | 
					
						
							| 
									
										
										
										
											2002-02-20 22:24:32 +00:00
										 |  |  |  |             $this->trigger_error($smarty_compiler->_error_msg); | 
					
						
							| 
									
										
										
										
											2001-03-02 21:38:42 +00:00
										 |  |  |  |             return false; | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2000-11-27 17:39:40 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function:   _smarty_include() | 
					
						
							|  |  |  |  |     Purpose:    called for included templates | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-06-15 18:55:28 +00:00
										 |  |  |  |     function _smarty_include($_smarty_include_tpl_file, $_smarty_include_vars) | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         if ($this->debugging) { | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |             $debug_start_time = $this->_get_microtime(); | 
					
						
							|  |  |  |  |             $this->_smarty_debug_info[] = array('type'      => 'template', | 
					
						
							|  |  |  |  |                                                 'filename'  => $_smarty_include_tpl_file, | 
					
						
							|  |  |  |  |                                                 'depth'     => ++$this->_inclusion_depth); | 
					
						
							|  |  |  |  |             $included_tpls_idx = count($this->_smarty_debug_info) - 1; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-10-23 19:04:40 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-28 16:52:27 +00:00
										 |  |  |  |         $this->_tpl_vars = array_merge($this->_tpl_vars, $_smarty_include_vars); | 
					
						
							| 
									
										
										
										
											2001-04-30 14:13:47 +00:00
										 |  |  |  |         extract($this->_tpl_vars); | 
					
						
							| 
									
										
										
										
											2001-06-15 18:55:28 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         array_unshift($this->_config, $this->_config[0]); | 
					
						
							| 
									
										
										
										
											2001-10-25 16:32:00 +00:00
										 |  |  |  |         $compile_path = $this->_get_compile_path($_smarty_include_tpl_file); | 
					
						
							| 
									
										
										
										
											2001-12-03 20:29:51 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-10-25 16:32:00 +00:00
										 |  |  |  |         if ($this->_process_template($_smarty_include_tpl_file, $compile_path)) { | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  |             include($compile_path); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-06-15 18:55:28 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         array_shift($this->_config); | 
					
						
							| 
									
										
										
										
											2001-06-19 21:29:02 +00:00
										 |  |  |  |         $this->_inclusion_depth--; | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         if ($this->debugging) { | 
					
						
							|  |  |  |  |             // capture time for debugging info
 | 
					
						
							|  |  |  |  |             $this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = $this->_get_microtime() - $debug_start_time; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-10-23 19:04:40 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-10-25 16:32:00 +00:00
										 |  |  |  |         if ($this->caching) { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |             $this->_cache_info['template'][] = $_smarty_include_tpl_file; | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-04-03 16:31:59 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function:   _smarty_include_php() | 
					
						
							|  |  |  |  |     Purpose:    called for included templates | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function _smarty_include_php($_smarty_include_php_file, $_smarty_assign) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         $this->_get_php_resource($_smarty_include_php_file, $_smarty_resource_type, | 
					
						
							|  |  |  |  |                                  $_smarty_php_resource); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         if (!empty($_smarty_assign)) { | 
					
						
							|  |  |  |  |             ob_start(); | 
					
						
							|  |  |  |  |             if ($_smarty_resource_type == 'file') { | 
					
						
							|  |  |  |  |                 include_once($_smarty_php_resource); | 
					
						
							|  |  |  |  |             } else { | 
					
						
							|  |  |  |  |                 eval($_smarty_php_resource); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             $this->assign($_smarty_assign, ob_get_contents()); | 
					
						
							|  |  |  |  |             ob_end_clean(); | 
					
						
							|  |  |  |  |         } else { | 
					
						
							|  |  |  |  |             if ($_smarty_resource_type == 'file') { | 
					
						
							|  |  |  |  |                 include_once($_smarty_php_resource); | 
					
						
							|  |  |  |  |             } else { | 
					
						
							|  |  |  |  |                 eval($_smarty_php_resource); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-06-19 15:30:29 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: _config_load | 
					
						
							|  |  |  |  |     Purpose:  load configuration values | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function _config_load($file, $section, $scope) | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |         if ($this->_conf_obj === null) { | 
					
						
							|  |  |  |  |             /* Prepare the configuration object. */ | 
					
						
							|  |  |  |  |             if (!class_exists('Config_File')) | 
					
						
							|  |  |  |  |                 require_once SMARTY_DIR.'Config_File.class.php'; | 
					
						
							|  |  |  |  |             $this->_conf_obj = new Config_File($this->config_dir); | 
					
						
							|  |  |  |  |             $this->_conf_obj->read_hidden = false; | 
					
						
							|  |  |  |  |         } else { | 
					
						
							|  |  |  |  |             $this->_conf_obj->set_path($this->config_dir); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         if ($this->debugging) { | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |             $debug_start_time = $this->_get_microtime(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         if ($this->caching) { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |             $this->_cache_info['config'][] = $file; | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         if (!isset($this->_config[0]['files'][$file])) { | 
					
						
							|  |  |  |  |             $this->_config[0]['vars'] = array_merge($this->_config[0]['vars'], $this->_conf_obj->get($file)); | 
					
						
							|  |  |  |  |             $this->_config[0]['files'][$file] = true; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-06-19 15:30:29 +00:00
										 |  |  |  |         if ($scope == 'parent') { | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |             if (count($this->_config) > 0 && !isset($this->_config[1]['files'][$file])) { | 
					
						
							|  |  |  |  |                 $this->_config[1]['vars'] = array_merge($this->_config[1]['vars'], $this->_conf_obj->get($file)); | 
					
						
							|  |  |  |  |                 $this->_config[1]['files'][$file] = true; | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2001-06-19 15:30:29 +00:00
										 |  |  |  |         } else if ($scope == 'global') | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |             for ($i = 1; $i < count($this->_config); $i++) { | 
					
						
							|  |  |  |  |                 if (!isset($this->_config[$i]['files'][$file])) { | 
					
						
							|  |  |  |  |                     $this->_config[$i]['vars'] = array_merge($this->_config[$i]['vars'], $this->_conf_obj->get($file)); | 
					
						
							|  |  |  |  |                     $this->_config[$i]['files'][$file] = true; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2001-06-19 15:30:29 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         if (!empty($section)) { | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |             $this->_config[0]['vars'] = array_merge($this->_config[0]['vars'], $this->_conf_obj->get($file, $section)); | 
					
						
							| 
									
										
										
										
											2001-06-19 15:30:29 +00:00
										 |  |  |  |             if ($scope == 'parent') { | 
					
						
							|  |  |  |  |                 if (count($this->_config) > 0) | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |                     $this->_config[1]['vars'] = array_merge($this->_config[1]['vars'], $this->_conf_obj->get($file, $section)); | 
					
						
							| 
									
										
										
										
											2001-06-19 15:30:29 +00:00
										 |  |  |  |             } else if ($scope == 'global') | 
					
						
							|  |  |  |  |                 for ($i = 1; $i < count($this->_config); $i++) | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |                     $this->_config[$i]['vars'] = array_merge($this->_config[$i]['vars'], $this->_conf_obj->get($file, $section)); | 
					
						
							| 
									
										
										
										
											2001-06-19 15:30:29 +00:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         if ($this->debugging) { | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |             $debug_start_time = $this->_get_microtime(); | 
					
						
							|  |  |  |  |             $this->_smarty_debug_info[] = array('type'      => 'config', | 
					
						
							|  |  |  |  |                                                 'filename'  => $file.' ['.$section.'] '.$scope, | 
					
						
							|  |  |  |  |                                                 'depth'     => $this->_inclusion_depth, | 
					
						
							|  |  |  |  |                                                 'exec_time' => $this->_get_microtime() - $debug_start_time); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-06-19 15:30:29 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-03-02 23:13:01 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: _process_cached_inserts | 
					
						
							|  |  |  |  |     Purpose:  Replace cached inserts with the actual results | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function _process_cached_inserts($results) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis', | 
					
						
							|  |  |  |  |                        $results, $match); | 
					
						
							|  |  |  |  |         list($cached_inserts, $insert_args) = $match; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         for ($i = 0; $i < count($cached_inserts); $i++) { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |             if ($this->debugging) { | 
					
						
							|  |  |  |  |                 $debug_start_time = $this->_get_microtime(); | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2001-03-03 15:41:52 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-03-02 23:13:01 +00:00
										 |  |  |  |             $args = unserialize($insert_args[$i]); | 
					
						
							| 
									
										
										
										
											2001-03-03 15:41:52 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-03-02 23:13:01 +00:00
										 |  |  |  |             $name = $args['name']; | 
					
						
							|  |  |  |  |             unset($args['name']); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-11 21:34:22 +00:00
										 |  |  |  |             if (isset($args['script'])) { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |                 if (!$this->_get_php_resource($this->_dequote($args['script']), $resource_type, $php_resource)) { | 
					
						
							|  |  |  |  |                     return false; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if ($resource_type == 'file') { | 
					
						
							|  |  |  |  |                     include_once($php_resource); | 
					
						
							|  |  |  |  |                 } else { | 
					
						
							|  |  |  |  |                     eval($php_resource); | 
					
						
							| 
									
										
										
										
											2001-12-11 21:34:22 +00:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |                 unset($args['script']); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |             $function_name = $this->_plugins['insert'][$name][0]; | 
					
						
							| 
									
										
										
										
											2001-08-10 20:58:15 +00:00
										 |  |  |  |             $replace = $function_name($args, $this); | 
					
						
							| 
									
										
										
										
											2001-03-02 23:13:01 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             $results = str_replace($cached_inserts[$i], $replace, $results); | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |             if ($this->debugging) { | 
					
						
							|  |  |  |  |                 $this->_smarty_debug_info[] = array('type'      => 'insert', | 
					
						
							|  |  |  |  |                                                     'filename'  => 'insert_'.$name, | 
					
						
							|  |  |  |  |                                                     'depth'     => $this->_inclusion_depth, | 
					
						
							|  |  |  |  |                                                     'exec_time' => $this->_get_microtime() - $debug_start_time); | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2001-03-02 23:13:01 +00:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         return $results; | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-08-10 20:58:15 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: _run_insert_handler | 
					
						
							|  |  |  |  |     Purpose:  Handle insert tags | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  | function _run_insert_handler($args) | 
					
						
							|  |  |  |  | { | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |     if ($this->debugging) { | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |         $debug_start_time = $this->_get_microtime(); | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-10-04 20:58:32 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-08-10 20:58:15 +00:00
										 |  |  |  |     if ($this->caching) { | 
					
						
							|  |  |  |  |         $arg_string = serialize($args); | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         $name = $args['name']; | 
					
						
							|  |  |  |  |         if (!isset($this->_cache_info['insert_tags'][$name])) { | 
					
						
							|  |  |  |  |             $this->_cache_info['insert_tags'][$name] = array('insert', | 
					
						
							|  |  |  |  |                                                              $name, | 
					
						
							|  |  |  |  |                                                              $this->_plugins['insert'][$name][1], | 
					
						
							|  |  |  |  |                                                              $this->_plugins['insert'][$name][2], | 
					
						
							|  |  |  |  |                                                              false); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-08-10 20:58:15 +00:00
										 |  |  |  |         return $this->_smarty_md5."{insert_cache $arg_string}".$this->_smarty_md5; | 
					
						
							|  |  |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2001-12-11 21:34:22 +00:00
										 |  |  |  |         if (isset($args['script'])) { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |             if (!$this->_get_php_resource($this->_dequote($args['script']), $resource_type, $php_resource)) { | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							| 
									
										
										
										
											2001-12-11 21:34:22 +00:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             if ($resource_type == 'file') { | 
					
						
							|  |  |  |  |                 include_once($php_resource); | 
					
						
							|  |  |  |  |             } else { | 
					
						
							|  |  |  |  |                 eval($php_resource); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             unset($args['script']); | 
					
						
							| 
									
										
										
										
											2001-12-11 21:34:22 +00:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         $function_name = $this->_plugins['insert'][$args['name']][0]; | 
					
						
							| 
									
										
										
										
											2001-10-04 20:58:32 +00:00
										 |  |  |  |         $content = $function_name($args, $this); | 
					
						
							| 
									
										
										
										
											2001-10-23 19:04:40 +00:00
										 |  |  |  |         if ($this->debugging) { | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |             $this->_smarty_debug_info[] = array('type'      => 'insert', | 
					
						
							|  |  |  |  |                                                 'filename'  => 'insert_'.$args['name'], | 
					
						
							|  |  |  |  |                                                 'depth'     => $this->_inclusion_depth, | 
					
						
							|  |  |  |  |                                                 'exec_time' => $this->_get_microtime() - $debug_start_time); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-29 15:17:57 +00:00
										 |  |  |  |         if (!empty($args["assign"])) { | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |             $this->assign($args["assign"], $content); | 
					
						
							| 
									
										
										
										
											2001-11-29 15:17:57 +00:00
										 |  |  |  |         } else { | 
					
						
							|  |  |  |  |             return $content; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-08-10 20:58:15 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: _run_mod_handler | 
					
						
							|  |  |  |  |     Purpose:  Handle modifiers | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |     function _run_mod_handler() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         $args = func_get_args(); | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         list($modifier_name, $map_array) = array_splice($args, 0, 2); | 
					
						
							|  |  |  |  |         list($func_name, $tpl_file, $tpl_line) = | 
					
						
							|  |  |  |  |             $this->_plugins['modifier'][$modifier_name]; | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         $var = $args[0]; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         if ($map_array && is_array($var)) { | 
					
						
							|  |  |  |  |             foreach ($var as $key => $val) { | 
					
						
							|  |  |  |  |                 $args[0] = $val; | 
					
						
							|  |  |  |  |                 $var[$key] = call_user_func_array($func_name, $args); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return $var; | 
					
						
							|  |  |  |  |         } else { | 
					
						
							|  |  |  |  |             return call_user_func_array($func_name, $args); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-08-10 20:58:15 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-11-27 17:39:40 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     Function: _dequote | 
					
						
							|  |  |  |  |     Purpose:  Remove starting and ending quotes from the string | 
					
						
							| 
									
										
										
										
											2000-11-27 17:39:40 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     function _dequote($string) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         if (($string{0} == "'" || $string{0} == '"') && | 
					
						
							|  |  |  |  |             $string{strlen($string)-1} == $string{0}) | 
					
						
							|  |  |  |  |             return substr($string, 1, -1); | 
					
						
							|  |  |  |  |         else | 
					
						
							|  |  |  |  |             return $string; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     Function:   _read_file() | 
					
						
							| 
									
										
										
										
											2001-11-05 21:24:49 +00:00
										 |  |  |  |     Purpose:    read in a file from line $start for $lines. | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |                 read the entire file if $start and $lines are null. | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |     function _read_file($filename, $start=null, $lines=null) | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2001-11-02 15:07:41 +00:00
										 |  |  |  |         if (!($fd = @fopen($filename, 'r'))) { | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |             return false; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-02-07 23:08:00 +00:00
										 |  |  |  |         flock($fd, LOCK_SH); | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         if ($start == null && $lines == null) { | 
					
						
							|  |  |  |  |             // read the entire file
 | 
					
						
							|  |  |  |  |             $contents = fread($fd, filesize($filename)); | 
					
						
							|  |  |  |  |         } else { | 
					
						
							|  |  |  |  |             if ( $start > 1 ) { | 
					
						
							|  |  |  |  |                 // skip the first lines before $start
 | 
					
						
							|  |  |  |  |                 for ($loop=1; $loop < $start; $loop++) { | 
					
						
							| 
									
										
										
										
											2001-12-03 20:53:56 +00:00
										 |  |  |  |                     fgets($fd, 65536); | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             if ( $lines == null ) { | 
					
						
							|  |  |  |  |                 // read the rest of the file
 | 
					
						
							|  |  |  |  |                 while (!feof($fd)) { | 
					
						
							| 
									
										
										
										
											2001-12-03 20:53:56 +00:00
										 |  |  |  |                     $contents .= fgets($fd, 65536); | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |             } else { | 
					
						
							|  |  |  |  |                 // read up to $lines lines
 | 
					
						
							|  |  |  |  |                 for ($loop=0; $loop < $lines; $loop++) { | 
					
						
							| 
									
										
										
										
											2001-12-03 20:53:56 +00:00
										 |  |  |  |                     $contents .= fgets($fd, 65536); | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |                     if (feof($fd)) { | 
					
						
							|  |  |  |  |                         break; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |         fclose($fd); | 
					
						
							|  |  |  |  |         return $contents; | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     Function:   _write_file() | 
					
						
							|  |  |  |  |     Purpose:    write out a file | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-02-06 21:17:37 +00:00
										 |  |  |  |     function _write_file($filename, $contents, $create_dirs = false) | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2001-04-12 20:14:30 +00:00
										 |  |  |  |         if ($create_dirs) | 
					
						
							| 
									
										
										
										
											2001-02-06 21:17:37 +00:00
										 |  |  |  |             $this->_create_dir_structure(dirname($filename)); | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-02 15:07:41 +00:00
										 |  |  |  |         if (!($fd = @fopen($filename, 'w'))) { | 
					
						
							| 
									
										
										
										
											2002-02-20 22:24:32 +00:00
										 |  |  |  |             $this->trigger_error("problem writing '$filename.'"); | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |             return false; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-06-15 14:52:48 +00:00
										 |  |  |  |         // flock doesn't seem to work on several windows platforms (98, NT4, NT5, ?),
 | 
					
						
							|  |  |  |  |         // so we'll not use it at all in windows.
 | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-03 20:53:56 +00:00
										 |  |  |  |         if ( strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' || (flock($fd, LOCK_EX)) ) { | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |             fwrite( $fd, $contents ); | 
					
						
							|  |  |  |  |             fclose($fd); | 
					
						
							| 
									
										
										
										
											2001-12-03 20:53:56 +00:00
										 |  |  |  |             chmod($filename, 0644); | 
					
						
							| 
									
										
										
										
											2001-04-11 18:35:17 +00:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-02-07 23:08:00 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  |         return true; | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-02-06 21:17:37 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: _get_auto_filename | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     Purpose:  get a concrete filename for automagically created content | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function _get_auto_filename($auto_base, $auto_source, $auto_id = null) | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-03-20 16:44:17 +00:00
										 |  |  |  |         $source_hash = str_replace('-','N',crc32($auto_source)); | 
					
						
							| 
									
										
										
										
											2002-04-11 20:27:04 +00:00
										 |  |  |  |         $res = $auto_base . DIR_SEP . substr($source_hash, 0, 3) . DIR_SEP . | 
					
						
							|  |  |  |  |             $source_hash . DIR_SEP . str_replace('-','N',crc32($auto_id)) . '.php'; | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         return $res; | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-02-06 21:17:37 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: _rm_auto | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     Purpose: delete an automagically created file by name and id | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function _rm_auto($auto_base, $auto_source = null, $auto_id = null) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         if (!is_dir($auto_base)) | 
					
						
							|  |  |  |  |           return false; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-03 20:20:06 +00:00
										 |  |  |  |         if (!isset($auto_source)) { | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  |             $res = $this->_rmdir($auto_base, 0); | 
					
						
							|  |  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2001-12-03 20:20:06 +00:00
										 |  |  |  |             if (isset($auto_id)) { | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  |                 $tname = $this->_get_auto_filename($auto_base, $auto_source, $auto_id); | 
					
						
							|  |  |  |  |                 $res = is_file($tname) && unlink( $tname); | 
					
						
							|  |  |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2002-03-20 16:44:17 +00:00
										 |  |  |  |                 $source_hash = str_replace('-','N',crc32($auto_source)); | 
					
						
							| 
									
										
										
										
											2002-04-11 20:27:04 +00:00
										 |  |  |  |                 $tname = $auto_base . DIR_SEP . substr($source_hash, 0, 3) . DIR_SEP . $source_hash; | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  |                 $res = $this->_rmdir($tname); | 
					
						
							| 
									
										
										
										
											2001-02-06 21:17:37 +00:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         return $res; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: _rmdir | 
					
						
							|  |  |  |  |     Purpose: delete a dir recursively (level=0 -> keep root) | 
					
						
							|  |  |  |  |     WARNING: no security whatsoever!! | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function _rmdir($dirname, $level = 1) | 
					
						
							|  |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |         $handle = opendir($dirname); | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |         while ($entry = readdir($handle)) { | 
					
						
							|  |  |  |  |             if ($entry != '.' && $entry != '..') { | 
					
						
							| 
									
										
										
										
											2002-04-11 20:27:04 +00:00
										 |  |  |  |                 if (is_dir($dirname . DIR_SEP . $entry)) { | 
					
						
							|  |  |  |  |                     $this->_rmdir($dirname . DIR_SEP . $entry, $level + 1); | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else { | 
					
						
							| 
									
										
										
										
											2002-04-11 20:27:04 +00:00
										 |  |  |  |                     unlink($dirname . DIR_SEP . $entry); | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-08-31 03:33:41 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         closedir($handle); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         if ($level) | 
					
						
							| 
									
										
										
										
											2001-10-26 19:06:01 +00:00
										 |  |  |  |             @rmdir($dirname); | 
					
						
							| 
									
										
										
										
											2001-02-06 21:17:37 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         return true; | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-03-02 23:13:01 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: _create_dir_structure | 
					
						
							|  |  |  |  |     Purpose:  create full directory structure | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function _create_dir_structure($dir) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         if (!file_exists($dir)) { | 
					
						
							| 
									
										
										
										
											2002-04-11 20:27:04 +00:00
										 |  |  |  |             $dir_parts = preg_split('!\\'.DIR_SEP.'+!', $dir, -1, PREG_SPLIT_NO_EMPTY); | 
					
						
							|  |  |  |  |             $new_dir = ($dir{0} == DIR_SEP) ? DIR_SEP : ''; | 
					
						
							| 
									
										
										
										
											2001-03-02 23:13:01 +00:00
										 |  |  |  |             foreach ($dir_parts as $dir_part) { | 
					
						
							|  |  |  |  |                 $new_dir .= $dir_part; | 
					
						
							| 
									
										
										
										
											2001-10-30 20:52:50 +00:00
										 |  |  |  |                 if (!file_exists($new_dir) && !mkdir($new_dir, 0771)) { | 
					
						
							| 
									
										
										
										
											2002-02-20 22:24:32 +00:00
										 |  |  |  |                     $this->trigger_error("problem creating directory \"$dir\"");
 | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |                     return false; | 
					
						
							| 
									
										
										
										
											2001-03-02 23:13:01 +00:00
										 |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2002-04-11 20:27:04 +00:00
										 |  |  |  |                 $new_dir .= DIR_SEP; | 
					
						
							| 
									
										
										
										
											2001-03-02 23:13:01 +00:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-10-25 16:32:00 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function:   _write_cache_file | 
					
						
							|  |  |  |  |     Purpose:    Prepend the cache information to the cache file | 
					
						
							| 
									
										
										
										
											2001-11-26 22:44:23 +00:00
										 |  |  |  |                 and write it | 
					
						
							| 
									
										
										
										
											2001-10-25 16:32:00 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-11-26 22:44:23 +00:00
										 |  |  |  |     function _write_cache_file($tpl_file, $cache_id, $compile_id, $results) | 
					
						
							| 
									
										
										
										
											2001-10-25 16:32:00 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         // put timestamp in cache header
 | 
					
						
							|  |  |  |  |         $this->_cache_info['timestamp'] = time(); | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |          | 
					
						
							| 
									
										
										
										
											2001-11-26 22:44:23 +00:00
										 |  |  |  |         // prepend the cache header info into cache file
 | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |         $results = serialize($this->_cache_info)."\n".$results; | 
					
						
							| 
									
										
										
										
											2001-11-26 22:44:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         if (!empty($this->cache_handler_func)) { | 
					
						
							| 
									
										
										
										
											2001-11-29 15:25:24 +00:00
										 |  |  |  |             // use cache_handler function
 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |             $funcname = $this->cache_handler_func; | 
					
						
							| 
									
										
										
										
											2001-11-29 15:25:24 +00:00
										 |  |  |  |             return $funcname('write', $this, $results, $tpl_file, $cache_id, $compile_id); | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |             // use local cache file
 | 
					
						
							| 
									
										
										
										
											2001-12-10 14:22:47 +00:00
										 |  |  |  |             if (isset($compile_id) || isset($cache_id)) | 
					
						
							| 
									
										
										
										
											2001-12-03 20:20:06 +00:00
										 |  |  |  |                 $auto_id = $compile_id . $cache_id; | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |                 $auto_id = null; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             $cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $auto_id); | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |             $this->_write_file($cache_file, $results, true); | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-10-25 16:32:00 +00:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function:   _read_cache_file | 
					
						
							| 
									
										
										
										
											2001-11-26 22:44:23 +00:00
										 |  |  |  |     Purpose:    read a cache file, determine if it needs to be | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |                 regenerated or not | 
					
						
							| 
									
										
										
										
											2001-10-25 16:32:00 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-11-26 22:44:23 +00:00
										 |  |  |  |     function _read_cache_file($tpl_file, $cache_id, $compile_id, &$results) | 
					
						
							| 
									
										
										
										
											2001-10-25 16:32:00 +00:00
										 |  |  |  |     { | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |         static  $content_cache = array(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-03-02 07:26:02 +00:00
										 |  |  |  |         if ($this->force_compile) { | 
					
						
							|  |  |  |  |             // force compile enabled, always regenerate
 | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |             return false; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-11-29 15:17:57 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |         if (isset($content_cache["$tpl_file,$cache_id,$compile_id"])) { | 
					
						
							|  |  |  |  |             list($results, $this->_cache_info) = $content_cache["$tpl_file,$cache_id,$compile_id"]; | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         if (!empty($this->cache_handler_func)) { | 
					
						
							| 
									
										
										
										
											2001-11-29 15:25:24 +00:00
										 |  |  |  |             // use cache_handler function
 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |             $funcname = $this->cache_handler_func; | 
					
						
							| 
									
										
										
										
											2001-11-29 15:25:24 +00:00
										 |  |  |  |             $funcname('read', $this, $results, $tpl_file, $cache_id, $compile_id); | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         } else { | 
					
						
							|  |  |  |  |             // use local file cache
 | 
					
						
							| 
									
										
										
										
											2001-12-10 14:22:47 +00:00
										 |  |  |  |             if (isset($compile_id) || isset($cache_id)) | 
					
						
							| 
									
										
										
										
											2001-12-03 20:20:06 +00:00
										 |  |  |  |                 $auto_id = $compile_id . $cache_id; | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |                 $auto_id = null; | 
					
						
							| 
									
										
										
										
											2001-11-29 15:17:57 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-03 20:20:06 +00:00
										 |  |  |  |             $cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $auto_id); | 
					
						
							| 
									
										
										
										
											2001-11-28 17:16:04 +00:00
										 |  |  |  |             $results = $this->_read_file($cache_file); | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         if (empty($results)) { | 
					
						
							|  |  |  |  |             // nothing to parse (error?), regenerate cache
 | 
					
						
							|  |  |  |  |             return false; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-12-03 20:53:56 +00:00
										 |  |  |  |         $cache_split = explode("\n", $results, 2); | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         $cache_header = $cache_split[0]; | 
					
						
							| 
									
										
										
										
											2001-11-29 15:17:57 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |         $this->_cache_info = unserialize($cache_header); | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-04-12 14:41:04 +00:00
										 |  |  |  |         if ($this->cache_lifetime > -1 && (time() - $this->_cache_info['timestamp'] > $this->cache_lifetime)) { | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |             // cache expired, regenerate
 | 
					
						
							|  |  |  |  |             return false; | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2001-11-29 15:17:57 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |         if ($this->compile_check) { | 
					
						
							|  |  |  |  |             foreach ($this->_cache_info['template'] as $template_dep) { | 
					
						
							|  |  |  |  |                 $this->_fetch_template_info($template_dep, $template_source, $template_timestamp, false); | 
					
						
							| 
									
										
										
										
											2002-03-01 20:26:06 +00:00
										 |  |  |  |                 if ($this->_cache_info['timestamp'] < $template_timestamp) { | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |                     // template file has changed, regenerate cache
 | 
					
						
							|  |  |  |  |                     return false; | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |             if (isset($this->_cache_info['config'])) { | 
					
						
							|  |  |  |  |                 foreach ($this->_cache_info['config'] as $config_dep) { | 
					
						
							| 
									
										
										
										
											2002-04-11 20:27:04 +00:00
										 |  |  |  |                     if ($this->_cache_info['timestamp'] < filemtime($this->config_dir.DIR_SEP.$config_dep)) { | 
					
						
							| 
									
										
										
										
											2002-03-01 20:26:06 +00:00
										 |  |  |  |                         // config file has changed, regenerate cache
 | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |                         return false; | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2001-11-27 17:17:53 +00:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         $results = $cache_split[1]; | 
					
						
							|  |  |  |  |         $content_cache["$tpl_file,$cache_id,$compile_id"] = array($results, $this->_cache_info); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         return true; | 
					
						
							| 
									
										
										
										
											2001-10-25 16:32:00 +00:00
										 |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function:  _load_plugins | 
					
						
							|  |  |  |  |     Purpose:   Load requested plugins | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function _load_plugins($plugins) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         foreach ($plugins as $plugin_info) { | 
					
						
							| 
									
										
										
										
											2002-03-19 22:21:22 +00:00
										 |  |  |  |             list($type, $name, $tpl_file, $tpl_line, $delayed_loading) = $plugin_info; | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |             $plugin = &$this->_plugins[$type][$name]; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             /* | 
					
						
							|  |  |  |  |              * We do not load plugin more than once for each instance of Smarty. | 
					
						
							|  |  |  |  |              * The following code checks for that. The plugin can also be | 
					
						
							|  |  |  |  |              * registered dynamically at runtime, in which case template file | 
					
						
							|  |  |  |  |              * and line number will be unknown, so we fill them in. | 
					
						
							|  |  |  |  |              * | 
					
						
							|  |  |  |  |              * The final element of the info array is a flag that indicates | 
					
						
							|  |  |  |  |              * whether the dynamically registered plugin function has been | 
					
						
							|  |  |  |  |              * checked for existence yet or not. | 
					
						
							|  |  |  |  |              */ | 
					
						
							|  |  |  |  |             if (isset($plugin)) { | 
					
						
							|  |  |  |  |                 if (!$plugin[3]) { | 
					
						
							|  |  |  |  |                     if (!function_exists($plugin[0])) { | 
					
						
							|  |  |  |  |                         $this->_trigger_plugin_error("$type '$name' is not implemented", $tpl_file, $tpl_line); | 
					
						
							|  |  |  |  |                     } else { | 
					
						
							|  |  |  |  |                         $plugin[1] = $tpl_file; | 
					
						
							|  |  |  |  |                         $plugin[2] = $tpl_line; | 
					
						
							|  |  |  |  |                         $plugin[3] = true; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 continue; | 
					
						
							|  |  |  |  |             } else if ($type == 'insert') { | 
					
						
							|  |  |  |  |                 /* | 
					
						
							|  |  |  |  |                  * For backwards compatibility, we check for insert functions in | 
					
						
							|  |  |  |  |                  * the symbol table before trying to load them as a plugin. | 
					
						
							|  |  |  |  |                  */ | 
					
						
							|  |  |  |  |                 $plugin_func = 'insert_' . $name; | 
					
						
							|  |  |  |  |                 if (function_exists($plugin_func)) { | 
					
						
							|  |  |  |  |                     $plugin = array($plugin_func, $tpl_file, $tpl_line, true); | 
					
						
							|  |  |  |  |                     continue; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-02-05 16:46:05 +00:00
										 |  |  |  |             $plugin_file = SMARTY_DIR . | 
					
						
							|  |  |  |  |                            $this->plugins_dir . | 
					
						
							| 
									
										
										
										
											2002-04-11 20:27:04 +00:00
										 |  |  |  |                            DIR_SEP . | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |                            $type . | 
					
						
							|  |  |  |  |                            '.' . | 
					
						
							|  |  |  |  |                            $name . | 
					
						
							|  |  |  |  |                            '.php'; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             $found = true; | 
					
						
							|  |  |  |  |             if (!file_exists($plugin_file) || !is_readable($plugin_file)) { | 
					
						
							|  |  |  |  |                 $message = "could not load plugin file $plugin_file\n"; | 
					
						
							|  |  |  |  |                 $found = false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             /* | 
					
						
							|  |  |  |  |              * If plugin file is found, it -must- provide the properly named | 
					
						
							|  |  |  |  |              * plugin function. In case it doesn't, simply output the error and | 
					
						
							|  |  |  |  |              * do not fall back on any other method. | 
					
						
							|  |  |  |  |              */ | 
					
						
							|  |  |  |  |             if ($found) { | 
					
						
							|  |  |  |  |                 include_once $plugin_file; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 $plugin_func = 'smarty_' . $type . '_' . $name; | 
					
						
							|  |  |  |  |                 if (!function_exists($plugin_func)) { | 
					
						
							|  |  |  |  |                     $this->_trigger_plugin_error("plugin function $plugin_func() not found in $plugin_file", $tpl_file, $tpl_line); | 
					
						
							|  |  |  |  |                     continue; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2002-03-19 22:21:22 +00:00
										 |  |  |  |             /* | 
					
						
							|  |  |  |  |              * In case of insert plugins, their code may be loaded later via | 
					
						
							|  |  |  |  |              * 'script' attribute. | 
					
						
							|  |  |  |  |              */ | 
					
						
							|  |  |  |  |             else if ($type == 'insert' && $delayed_loading) { | 
					
						
							|  |  |  |  |                 $plugin_func = 'smarty_' . $type . '_' . $name; | 
					
						
							|  |  |  |  |                 $found = true; | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             /* | 
					
						
							|  |  |  |  |              * Plugin specific processing and error checking. | 
					
						
							|  |  |  |  |              */ | 
					
						
							|  |  |  |  |             if (!$found) { | 
					
						
							|  |  |  |  |                 if ($type == 'modifier') { | 
					
						
							|  |  |  |  |                     /* | 
					
						
							|  |  |  |  |                      * In case modifier falls back on using PHP functions | 
					
						
							|  |  |  |  |                      * directly, we only allow those specified in the security | 
					
						
							|  |  |  |  |                      * context. | 
					
						
							|  |  |  |  |                      */ | 
					
						
							|  |  |  |  |                     if ($this->security && !in_array($name, $this->security_settings['MODIFIER_FUNCS'])) { | 
					
						
							|  |  |  |  |                         $message = "(secure mode) modifier '$name' is not allowed"; | 
					
						
							|  |  |  |  |                     } else { | 
					
						
							|  |  |  |  |                         if (!function_exists($name)) { | 
					
						
							|  |  |  |  |                             $message = "modifier '$name' is not implemented"; | 
					
						
							|  |  |  |  |                         } else { | 
					
						
							|  |  |  |  |                             $plugin_func = $name; | 
					
						
							|  |  |  |  |                             $found = true; | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } else if ($type == 'function') { | 
					
						
							|  |  |  |  |                     /* | 
					
						
							|  |  |  |  |                      * This is a catch-all situation. | 
					
						
							|  |  |  |  |                      */ | 
					
						
							|  |  |  |  |                     $message = "unknown tag - '$name'"; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if ($found) { | 
					
						
							|  |  |  |  |                 $this->_plugins[$type][$name] = array($plugin_func, $tpl_file, $tpl_line, true); | 
					
						
							|  |  |  |  |             } else { | 
					
						
							|  |  |  |  |                 // output error
 | 
					
						
							|  |  |  |  |                 $this->_trigger_plugin_error($message, $tpl_file, $tpl_line); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function:   _load_resource_plugin | 
					
						
							|  |  |  |  |     Purpose:    | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function _load_resource_plugin($type) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         /* | 
					
						
							|  |  |  |  |          * Resource plugins are not quite like the other ones, so they are | 
					
						
							|  |  |  |  |          * handled differently. The first element of plugin info is the array of | 
					
						
							|  |  |  |  |          * functions provided by the plugin, the second one indicates whether | 
					
						
							|  |  |  |  |          * all of them exist or not. | 
					
						
							|  |  |  |  |          */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         $plugin = &$this->_plugins['resource'][$type]; | 
					
						
							|  |  |  |  |         if (isset($plugin)) { | 
					
						
							|  |  |  |  |             if (!$plugin[1] && count($plugin[0])) { | 
					
						
							|  |  |  |  |                 $plugin[1] = true; | 
					
						
							|  |  |  |  |                 foreach ($plugin[0] as $plugin_func) { | 
					
						
							|  |  |  |  |                     if (!function_exists($plugin_func)) { | 
					
						
							|  |  |  |  |                         $plugin[1] = false; | 
					
						
							|  |  |  |  |                         break; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (!$plugin[1]) { | 
					
						
							|  |  |  |  |                 $this->_trigger_plugin_error("resource '$type' is not implemented"); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-02-05 16:46:05 +00:00
										 |  |  |  |         $plugin_file = SMARTY_DIR . | 
					
						
							| 
									
										
										
										
											2002-04-11 20:27:04 +00:00
										 |  |  |  |                        $this->plugins_dir . DIR_SEP . | 
					
						
							|  |  |  |  |                        'resource.' . | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  |                        $type . | 
					
						
							|  |  |  |  |                        '.php'; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         $found = true; | 
					
						
							|  |  |  |  |         if (!file_exists($plugin_file) || !is_readable($plugin_file)) { | 
					
						
							|  |  |  |  |             $this->_trigger_plugin_error("could not load plugin file $plugin_file"); | 
					
						
							|  |  |  |  |             $found = false; | 
					
						
							|  |  |  |  |         } else { | 
					
						
							|  |  |  |  |             /* | 
					
						
							|  |  |  |  |              * If the plugin file is found, it -must- provide the properly named | 
					
						
							|  |  |  |  |              * plugin functions. | 
					
						
							|  |  |  |  |              */ | 
					
						
							|  |  |  |  |             include_once $plugin_file; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             /* | 
					
						
							|  |  |  |  |              * Locate functions that we require the plugin to provide. | 
					
						
							|  |  |  |  |              */ | 
					
						
							|  |  |  |  |             $resource_ops = array('source', 'timestamp', 'secure', 'trusted'); | 
					
						
							|  |  |  |  |             $resource_funcs = array(); | 
					
						
							|  |  |  |  |             foreach ($resource_ops as $op) { | 
					
						
							|  |  |  |  |                 $plugin_func = 'smarty_resource_' . $type . '_' . $op; | 
					
						
							|  |  |  |  |                 if (!function_exists($plugin_func)) { | 
					
						
							|  |  |  |  |                     $this->_trigger_plugin_error("plugin function $plugin_func() not found in $plugin_file"); | 
					
						
							|  |  |  |  |                     return; | 
					
						
							|  |  |  |  |                 } else { | 
					
						
							|  |  |  |  |                     $resource_funcs[] = $plugin_func; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             $this->_plugins['resource'][$type] = array($resource_funcs, true); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-02-15 20:50:44 +00:00
										 |  |  |  |     function _init_conf_obj() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-03-01 15:32:56 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function:   quote_replace | 
					
						
							|  |  |  |  |     Purpose:    Quote subpattern references | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function quote_replace($string) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         return preg_replace('![\\$]\d!', '\\\\\\0', $string); | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-02-06 21:17:37 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-04-12 20:14:30 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2002-01-31 20:49:40 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							|  |  |  |  |     Function: _trigger_plugin_error | 
					
						
							|  |  |  |  |     Purpose:  trigger Smarty plugin error | 
					
						
							|  |  |  |  | \*======================================================================*/ | 
					
						
							|  |  |  |  |     function _trigger_plugin_error($error_msg, $tpl_file = null, $tpl_line = null, $error_type = E_USER_WARNING) | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         if (isset($tpl_line) && isset($tpl_file)) { | 
					
						
							|  |  |  |  |             trigger_error("Smarty plugin error: [in " . $tpl_file . " line " . | 
					
						
							|  |  |  |  |                           $tpl_line . "]: $error_msg", $error_type); | 
					
						
							|  |  |  |  |         } else { | 
					
						
							|  |  |  |  |             trigger_error("Smarty plugin error: $error_msg", $error_type); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-10-04 20:58:32 +00:00
										 |  |  |  | /*======================================================================*\ | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     Function:   _get_microtime | 
					
						
							|  |  |  |  |     Purpose:    Get seconds and microseconds | 
					
						
							| 
									
										
										
										
											2001-10-04 20:58:32 +00:00
										 |  |  |  | \*======================================================================*/ | 
					
						
							| 
									
										
										
										
											2001-10-26 14:12:23 +00:00
										 |  |  |  |     function _get_microtime() | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         $mtime = microtime(); | 
					
						
							|  |  |  |  |         $mtime = explode(" ", $mtime); | 
					
						
							|  |  |  |  |         $mtime = (double)($mtime[1]) + (double)($mtime[0]); | 
					
						
							|  |  |  |  |         return ($mtime); | 
					
						
							|  |  |  |  |     } | 
					
						
							| 
									
										
										
										
											2001-10-04 20:58:32 +00:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2001-02-01 21:39:29 +00:00
										 |  |  |  | /* vim: set expandtab: */ | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2000-08-08 17:05:38 +00:00
										 |  |  |  | ?>
 |