cvs: smarty / NEWS /libs Smarty.class.php Smarty_Compiler.class.php /libs/core core.assign_smarty_interface.php core.create_dir_structure.php
core.display_debug_console.php core.fetch_template_info.php core.get_include_path.php core.get_microtime.php core.get_php_resource.php
core.is_secure.php core.is_trusted.php core.load_plugins.php core.load_resource_plugin.php core.parse_file_path.php core.process_cached_inserts.php
core.read_cache_file.php core.rm_auto.php core.rmdir.php core.run_insert_handler.php core.smarty_include.php core.smarty_include_php.php
core.write_cache_file.php core.write_compiled_template.php core.write_file.php /libs/plugins core.assign_smarty_interface.php
core.create_dir_structure.php core.display_debug_console.php core.fetch_template_info.php core.get_include_path.php core.get_microtime.php
core.get_php_resource.php core.is_secure.php core.is_trusted.php core.load_plugins.php core.load_resource_plugin.php core.parse_file_path.php
core.process_cached_inserts.php core.read_cache_file.php core.rm_auto.php core.rmdir.php core.run_insert_handler.php core.smarty_include.php
core.smarty_include_php.php core.write_cache_file.php core.write_compiled_template.php core.write_file.php
| From: | Monte Ohrt | Date: | Mon, 16 Jun 2003 15:18:39 +0000 |
| Subject: | cvs: smarty / NEWS /libs Smarty.class.php Smarty_Compiler.class.php /libs/core core.assign_smarty_interface.php core.create_dir_structure.php core.display_debug_console.php core.fetch_template_info.php core.get_include_path.php core.get_microtime.php core.get_php_resource.php core.is_secure.php core.is_trusted.php core.load_plugins.php core.load_resource_plugin.php core.parse_file_path.php core.process_cached_inserts.php core.read_cache_file.php core.rm_auto.php core.rmdir.php core.run_insert_handler.php core.smarty_include.php core.smarty_include_php.php core.write_cache_file.php core.write_compiled_template.php core.write_file.php /libs/plugins core.assign_smarty_interface.php core.create_dir_structure.php core.display_debug_console.php core.fetch_template_info.php core.get_include_path.php core.get_microtime.php core.get_php_resource.php core.is_secure.php core.is_trusted.php core.load_plugins.php core.load_resource_plugin.php core.parse_file_path.php core.process_cached_inserts.php core.read_cache_file.php core.rm_auto.php core.rmdir.php core.run_insert_handler.php core.smarty_include.php core.smarty_include_php.php core.write_cache_file.php core.write_compiled_template.php core.write_file.php |
||
| Groups: | php.smarty.cvs | ||
| Request: | Send a blank email to php-smarty-cvs+get-647@lists.php.net to get a copy of this message | ||
mohrt Mon Jun 16 11:18:39 2003 EDT
Added files:
/smarty/libs/core core.assign_smarty_interface.php
core.create_dir_structure.php
core.display_debug_console.php
core.fetch_template_info.php
core.get_include_path.php core.get_microtime.php
core.get_php_resource.php core.is_secure.php
core.is_trusted.php core.load_plugins.php
core.load_resource_plugin.php
core.parse_file_path.php
core.process_cached_inserts.php
core.read_cache_file.php core.rm_auto.php
core.rmdir.php core.run_insert_handler.php
core.smarty_include.php
core.smarty_include_php.php
core.write_cache_file.php
core.write_compiled_template.php
core.write_file.php
Removed files:
/smarty/libs/plugins core.assign_smarty_interface.php
core.create_dir_structure.php
core.display_debug_console.php
core.fetch_template_info.php
core.get_include_path.php
core.get_microtime.php
core.get_php_resource.php core.is_secure.php
core.is_trusted.php core.load_plugins.php
core.load_resource_plugin.php
core.parse_file_path.php
core.process_cached_inserts.php
core.read_cache_file.php core.rm_auto.php
core.rmdir.php core.run_insert_handler.php
core.smarty_include.php
core.smarty_include_php.php
core.write_cache_file.php
core.write_compiled_template.php
core.write_file.php
Modified files:
/smarty NEWS
/smarty/libs Smarty.class.php Smarty_Compiler.class.php
Log:
move core files into their own directory under SMARTY_DIR,
remove abstraction function _execute_core_function
Index: smarty/NEWS diff -u smarty/NEWS:1.376 smarty/NEWS:1.377 --- smarty/NEWS:1.376 Wed Jun 11 18:17:52 2003 +++ smarty/NEWS Mon Jun 16 11:18:38 2003 @@ -1,3 +1,4 @@ + - fix newlines for tags without template output (Monte) - added config-option "request_use_auto_globals" to make auto-globals be used as request vars instead of HTTP_*_VARS (messju) - make config vars compile statically (Monte) Index: smarty/libs/Smarty.class.php diff -u smarty/libs/Smarty.class.php:1.402 smarty/libs/Smarty.class.php:1.403 --- smarty/libs/Smarty.class.php:1.402 Wed Jun 11 18:17:52 2003 +++ smarty/libs/Smarty.class.php Mon Jun 16 11:18:38 2003 @@ -42,7 +42,7 @@ * @version 2.5.0 */ -/* $Id: Smarty.class.php,v 1.402 2003/06/11 22:17:52 messju Exp $ */ +/* $Id: Smarty.class.php,v 1.403 2003/06/16 15:18:38 mohrt Exp $ */ /** * DIR_SEP isn't used anymore, but third party apps might @@ -934,7 +934,8 @@ switch ($type) { case 'output': $_params = array('plugins' => array(array($type . 'filter', $name, null, null, false))); - $this->_execute_core_function('load_plugins', $_params); + require_once(SMARTY_DIR . 'core/core.load_plugins.php'); + smarty_core_load_plugins($_params, $this); break; case 'pre': @@ -973,7 +974,8 @@ 'auto_source' => $tpl_file, 'auto_id' => $_auto_id, 'exp_time' => $exp_time); - return $this->_execute_core_function('rm_auto', $_params); + require_once(SMARTY_DIR . 'core/core.rm_auto.php'); + return smarty_core_rm_auto($_params, $this); } } @@ -995,7 +997,8 @@ 'auto_source' => null, 'auto_id' => null, 'exp_time' => $exp_time); - return $this->_execute_core_function('rm_auto', $_params); + require_once(SMARTY_DIR . 'core/core.rm_auto.php'); + return smarty_core_rm_auto($_params, $this); } } @@ -1021,7 +1024,8 @@ 'cache_id' => $cache_id, 'compile_id' => $compile_id ); - return $this->_execute_core_function('read_cache_file', $_params); + require_once(SMARTY_DIR . 'core/core.read_cache_file.php'); + return smarty_core_read_cache_file($_params, $this); } @@ -1053,7 +1057,8 @@ 'auto_source' => $tpl_file, 'auto_id' => $compile_id, 'exp_time' => $exp_time); - return $this->_execute_core_function('rm_auto', $_params); + require_once(SMARTY_DIR . 'core/core.rm_auto.php'); + return smarty_core_rm_auto($_params, $this); } /** @@ -1065,7 +1070,8 @@ function template_exists($tpl_file) { $_params = array('tpl_path' => $tpl_file); - return $this->_execute_core_function('fetch_template_info', $_params); + require_once(SMARTY_DIR . 'core/core.fetch_template_info.php'); + return smarty_core_fetch_template_info($_params, $this); } /** @@ -1153,7 +1159,8 @@ if ($this->debugging) { // capture time for debugging info $_params = array(); - $_debug_start_time = $this->_execute_core_function('get_microtime', $_params); + require_once(SMARTY_DIR . 'core/core.get_microtime.php'); + $_debug_start_time = smarty_core_get_microtime($_params, $this); $this->_smarty_debug_info[] = array('type' => 'template', 'filename' => $tpl_file, 'depth' => 0); @@ -1177,21 +1184,26 @@ 'compile_id' => $compile_id, 'results' => null ); - if ($this->_execute_core_function('read_cache_file', $_params)) { + require_once(SMARTY_DIR . 'core/core.read_cache_file.php'); + if (smarty_core_read_cache_file($_params, $this)) { $_smarty_results = $_params['results']; if (@count($this->_cache_info['insert_tags'])) { $_params = array('plugins' => $this->_cache_info['insert_tags']); - $this->_execute_core_function('load_plugins', $_params); + require_once(SMARTY_DIR . 'core/core.load_plugins.php'); + smarty_core_load_plugins($_params, $this); $_params = array('results' => $_smarty_results); - $_smarty_results = $this->_execute_core_function('process_cached_inserts', $_params); + require_once(SMARTY_DIR . 'core/core.process_cached_inserts.php'); + $_smarty_results = smarty_core_process_cached_inserts($_params, $this); } if ($display) { if ($this->debugging) { // capture time for debugging info $_params = array(); - $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = $this->_execute_core_function('get_microtime', $_params) - $_debug_start_time; - $_smarty_results .= $this->_execute_core_function('display_debug_console', $_params); + require_once(SMARTY_DIR . 'core/core.get_microtime.php'); + $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time; + require_once(SMARTY_DIR . 'core/core.display_debug_console.php'); + $_smarty_results .= smarty_core_display_debug_console($_params, $this); } if ($this->cache_modified_check) { $_last_modified_date = substr($GLOBALS['HTTP_SERVER_VARS']['HTTP_IF_MODIFIED_SINCE'], 0, strpos($GLOBALS['HTTP_SERVER_VARS']['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3); @@ -1261,8 +1273,10 @@ 'cache_id' => $cache_id, 'compile_id' => $compile_id, 'results' => $_smarty_results); - $this->_execute_core_function('write_cache_file', $_params); - $_smarty_results = $this->_execute_core_function('process_cached_inserts', $_params); + require_once(SMARTY_DIR . 'core/core.write_cache_file.php'); + smarty_core_write_cache_file($_params, $this); + require_once(SMARTY_DIR . 'core/core.process_cached_inserts.php'); + $_smarty_results = smarty_core_process_cached_inserts($_params, $this); // restore initial cache_info $this->_cache_info = array_pop($_cache_info); } @@ -1272,8 +1286,10 @@ if ($this->debugging) { // capture time for debugging info $_params = array(); - $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = ($this->_execute_core_function('get_microtime', $_params) - $_debug_start_time); - echo $this->_execute_core_function('display_debug_console', $_params); + require_once(SMARTY_DIR . 'core/core.get_microtime.php'); + $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time); + require_once(SMARTY_DIR . 'core/core.display_debug_console.php'); + echo smarty_core_display_debug_console($_params, $this); } error_reporting($_smarty_old_error_level); return; @@ -1338,17 +1354,6 @@ { return preg_replace('![\\$]\d!', '\\\\\\0', $string); } - - /** - * execute core function - * @return mixed value of function return - */ - function _execute_core_function($funcname, &$params) - { - require_once($this->_get_plugin_filepath('core', $funcname)); - $_core_funcname = 'smarty_core_' . $funcname; - return $_core_funcname($params, $this); - } /** * get filepath of requested plugin @@ -1386,7 +1391,8 @@ $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; $_params = array('file_path' => $_plugin_filepath); - if($this->_execute_core_function('get_include_path', $_params)) { + require_once(SMARTY_DIR . 'core/core.get_include_path.php'); + if(smarty_core_get_include_path($_params, $this)) { return $_params['new_file_path']; } } @@ -1411,7 +1417,8 @@ } else { // get template source and timestamp $_params = array('tpl_path' => $tpl_file); - if (!$this->_execute_core_function('fetch_template_info', $_params)) { + require_once(SMARTY_DIR . 'core/core.fetch_template_info.php'); + if (!smarty_core_fetch_template_info($_params, $this)) { return false; } $_template_source = $_params['template_source']; @@ -1423,21 +1430,24 @@ // compile template $this->_compile_template($tpl_file, $_template_source, $_template_compiled); $_params = array('compile_path' => $compile_path, 'template_compiled' => $_template_compiled, 'template_timestamp' => $_template_timestamp); - $this->_execute_core_function('write_compiled_template', $_params); + require_once(SMARTY_DIR . 'core/core.write_compiled_template.php'); + smarty_core_write_compiled_template($_params, $this); return true; } } } else { // compiled template does not exist, or forced compile $_params = array('tpl_path' => $tpl_file); - if (!$this->_execute_core_function('fetch_template_info', $_params)) { + require_once(SMARTY_DIR . 'core/core.fetch_template_info.php'); + if (!smarty_core_fetch_template_info($_params, $this)) { return false; } $_template_source = $_params['template_source']; $_template_timestamp = $_params['template_timestamp']; $this->_compile_template($tpl_file, $_template_source, $_template_compiled); $_params = array('compile_path' => $compile_path, 'template_compiled' => $_template_compiled, 'template_timestamp' => $_template_timestamp); - $this->_execute_core_function('write_compiled_template', $_params); + require_once(SMARTY_DIR . 'core/core.write_compiled_template.php'); + smarty_core_write_compiled_template($_params, $this); return true; } } @@ -1618,7 +1628,8 @@ } else { // auto_base not found, try include_path $_params = array('file_path' => $auto_base); - $this->_execute_core_function('get_include_path', $_params); + require_once(SMARTY_DIR . 'core/core.get_include_path.php'); + smarty_core_get_include_path($_params, $this); $_res = isset($_params['new_file_path']) ? $_params['new_file_path'] . DIRECTORY_SEPARATOR : null; } Index: smarty/libs/Smarty_Compiler.class.php diff -u smarty/libs/Smarty_Compiler.class.php:1.237 smarty/libs/Smarty_Compiler.class.php:1.238 --- smarty/libs/Smarty_Compiler.class.php:1.237 Mon Jun 16 10:38:57 2003 +++ smarty/libs/Smarty_Compiler.class.php Mon Jun 16 11:18:38 2003 @@ -39,7 +39,7 @@ * @package Smarty */ -/* $Id: Smarty_Compiler.class.php,v 1.237 2003/06/16 14:38:57 mohrt Exp $ */ +/* $Id: Smarty_Compiler.class.php,v 1.238 2003/06/16 15:18:38 mohrt Exp $ */ /** * Template compiling class * @package Smarty @@ -353,15 +353,13 @@ } } $_plugins_params .= '))'; - $_plugin_filepath = $this->_get_plugin_filepath('core', 'load_plugins'); - $plugins_code = "<?php require_once('$_plugin_filepath');\nsmarty_core_load_plugins($_plugins_params, \$this); ?>\n"; + $plugins_code = "<?php require_once(SMARTY_DIR . 'core/core.load_plugins.php');\nsmarty_core_load_plugins($_plugins_params, \$this); ?>\n"; $template_header .= $plugins_code; $this->_plugin_info = array(); } if ($this->_init_smarty_vars) { - $_plugin_filepath = $this->_get_plugin_filepath('core', 'assign_smarty_interface'); - $template_header .= "<?php require_once('$_plugin_filepath');\nsmarty_core_assign_smarty_interface(null, \$this); ?>\n"; + $template_header .= "<?php require_once(SMARTY_DIR . 'core/core.assign_smarty_interface.php');\nsmarty_core_assign_smarty_interface(null, \$this); ?>\n"; $this->_init_smarty_vars = false; } @@ -819,9 +817,8 @@ $this->_add_plugin('insert', $name, $delayed_loading); $_params = "array('args' => array(".implode(', ', (array)$arg_list)."))"; - $_plugin_filepath = $this->_get_plugin_filepath('core', 'run_insert_handler'); - return "<?php require_once('$_plugin_filepath');\necho smarty_core_run_insert_handler($_params, \$this); ?>\n"; + return "<?php require_once(SMARTY_DIR . 'core/core.run_insert_handler.php');\necho smarty_core_run_insert_handler($_params, \$this); ?>\n"; } /** @@ -863,9 +860,8 @@ $_params = "array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))"; - $_plugin_filepath = $this->_get_plugin_filepath('core', 'smarty_include'); - $output .= "require_once('$_plugin_filepath');\nsmarty_core_smarty_include($_params, \$this);\n" . + $output .= "require_once(SMARTY_DIR . 'core/core.smarty_include.php');\nsmarty_core_smarty_include($_params, \$this);\n" . "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" . "unset(\$_smarty_tpl_vars);\n"; @@ -905,9 +901,8 @@ } $_params = "array('smarty_file' => " . $attrs['file'] . ", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))"; - $_plugin_filepath = $this->_get_plugin_filepath('core', 'smarty_include_php'); - return "<?php require_once('$_plugin_filepath');\nsmarty_core_smarty_include_php($_params, \$this); ?>\n"; + return "<?php require_once(SMARTY_DIR . 'core/core.smarty_include_php.php');\nsmarty_core_smarty_include_php($_params, \$this); ?>\n"; } @@ -1713,7 +1708,8 @@ } if(!isset($this->_plugins['modifier'][$_modifier_name])) { $_params = array('plugins' => array(array('modifier', $_modifier_name, null, null, false))); - $this->_execute_core_function('load_plugins', $_params); + require_once(SMARTY_DIR . 'core/core.load_plugins.php'); + smarty_core_load_plugins($_params, $this); } array_unshift($_modifier_args, $output); $output = $this->_run_mod_handler($_modifier_name, $_map_array, $_modifier_args); @@ -1890,7 +1886,8 @@ if ($prefilter === false) { unset($this->_plugins['prefilter'][$filter_name]); $_params = array('plugins' => array(array('prefilter', $filter_name, null, null, false))); - $this->_execute_core_function('load_plugins', $_params); + require_once(SMARTY_DIR . 'core/core.load_plugins.php'); + smarty_core_load_plugins($_params, $this); } } } @@ -1899,7 +1896,8 @@ if ($postfilter === false) { unset($this->_plugins['postfilter'][$filter_name]); $_params = array('plugins' => array(array('postfilter', $filter_name, null, null, false))); - $this->_execute_core_function('load_plugins', $_params); + require_once(SMARTY_DIR . 'core/core.load_plugins.php'); + smarty_core_load_plugins($_params, $this); } } } Index: smarty/libs/core/core.assign_smarty_interface.php +++ smarty/libs/core/core.assign_smarty_interface.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /* * Smarty assign_smarty_interface core plugin * * Type: core<br> * Name: assign_smarty_interface<br> * Purpose: assign the $smarty interface variable * @param array Format: null * @param Smarty */ function smarty_core_assign_smarty_interface($params, &$this) { if (isset($this->_smarty_vars) && isset($this->_smarty_vars['request'])) { return; } $_globals_map = array('g' => 'HTTP_GET_VARS', 'p' => 'HTTP_POST_VARS', 'c' => 'HTTP_COOKIE_VARS', 's' => 'HTTP_SERVER_VARS', 'e' => 'HTTP_ENV_VARS'); $_smarty_vars_request = array(); foreach (preg_split('!!', strtolower($this->request_vars_order)) as $_c) { if (isset($_globals_map[$_c])) { $_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]); } } $_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']); $this->_smarty_vars['request'] = $_smarty_vars_request; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.create_dir_structure.php +++ smarty/libs/core/core.create_dir_structure.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * create full directory structure * * @param string $dir */ // $dir function smarty_core_create_dir_structure($params, &$this) { if (!file_exists($params['dir'])) { $_open_basedir_ini = ini_get('open_basedir'); if (DIRECTORY_SEPARATOR=='/') { /* unix-style paths */ $_dir = $params['dir']; $_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY); $_new_dir = ($_dir{0}=='/') ? '/' : getcwd().'/'; if($_use_open_basedir = !empty($_open_basedir_ini)) { $_open_basedirs = explode(':', $_open_basedir_ini); } } else { /* other-style paths */ $_dir = str_replace('\\','/', $params['dir']); $_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY); if (preg_match('!^((//)|([a-zA-Z]:/))!', $_dir, $_root_dir)) { /* leading "//" for network volume, or "[letter]:/" for full path */ $_new_dir = $_root_dir[1]; /* remove drive-letter from _dir_parts */ if (isset($_root_dir[3])) array_shift($_dir_parts); } else { $_new_dir = str_replace('\\','/', getcwd()).'/'; } if($_use_open_basedir = !empty($_open_basedir_ini)) { $_open_basedirs = explode(';', str_replace('\\','/', $_open_basedir_ini)); } } /* all paths use "/" only from here */ foreach ($_dir_parts as $_dir_part) { $_new_dir .= $_dir_part; if ($_use_open_basedir) { // do not attempt to test or make directories outside of open_basedir $_make_new_dir = false; foreach ($_open_basedirs as $_open_basedir) { if (substr($_new_dir.'/', 0, strlen($_open_basedir)) == $_open_basedir) { $_make_new_dir = true; break; } } } else { $_make_new_dir = true; } if ($_make_new_dir && !file_exists($_new_dir) && !@mkdir($_new_dir, $this->_dir_perms)) { $this->trigger_error("problem creating directory '" . $_new_dir . "'"); return false; } $_new_dir .= '/'; } } } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.display_debug_console.php +++ smarty/libs/core/core.display_debug_console.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /* * Smarty debug_console function plugin * * Type: core<br> * Name: display_debug_console<br> * Purpose: display the javascript debug console window * @param array Format: null * @param Smarty */ function smarty_core_display_debug_console($params, &$this) { // we must force compile the debug template in case the environment // changed between separate applications. if(empty($this->debug_tpl)) { // set path to debug template from SMARTY_DIR $this->debug_tpl = SMARTY_DIR . 'debug.tpl'; if($this->security && is_file($this->debug_tpl)) { $this->secure_dir[] = $this->debug_tpl; } } $_ldelim_orig = $this->left_delimiter; $_rdelim_orig = $this->right_delimiter; $this->left_delimiter = '{'; $this->right_delimiter = '}'; $_force_compile_orig = $this->force_compile; $this->force_compile = true; $_compile_id_orig = $this->_compile_id; $this->_compile_id = null; $_compile_path = $this->_get_compile_path($this->debug_tpl); if ($this->_process_template($this->debug_tpl, $_compile_path)) { ob_start(); include($_compile_path); $_results = ob_get_contents(); ob_end_clean(); } else { $_results = ''; } $this->force_compile = $_force_compile_orig; $this->_compile_id = $_compile_id_orig; $this->left_delimiter = $_ldelim_orig; $this->right_delimiter = $_rdelim_orig; return $_results; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.fetch_template_info.php +++ smarty/libs/core/core.fetch_template_info.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * fetch the template info. Gets timestamp, and source * if get_source is true * * sets $template_source to the source of the template, and * $template_timestamp to its time stamp * @param string $tpl_path * @param string $template_source * @param integer $template_timestamp * @param boolean $get_source * @param boolean $quiet * @return boolean */ // $tpl_path, &$template_source, &$template_timestamp, $get_source = true, $quiet = false function smarty_core_fetch_template_info(&$params, &$this) { if(!isset($params['get_source'])) { $params['get_source'] = true; } if(!isset($params['quiet'])) { $params['quiet'] = false; } $_return = false; $_params = array('file_base_path' => $this->template_dir, 'file_path' => $params['tpl_path']) ; require_once(SMARTY_DIR . 'core/core.parse_file_path.php'); if (smarty_core_parse_file_path($_params, $this)) { $_resource_type = $_params['resource_type']; $_resource_name = $_params['resource_name']; switch ($_resource_type) { case 'file': if ($params['get_source']) { $params['template_source'] = $this->_read_file($_resource_name); } $params['template_timestamp'] = filemtime($_resource_name); $_return = true; break; default: // call resource functions to fetch the template source and timestamp if ($params['get_source']) { $_source_return = isset($this->_plugins['resource'][$_resource_type]) && call_user_func_array($this->_plugins['resource'][$_resource_type][0][0], array($_resource_name, &$params['template_source'], &$this)); } else { $_source_return = true; } $_timestamp_return = isset($this->_plugins['resource'][$_resource_type]) && call_user_func_array($this->_plugins['resource'][$_resource_type][0][1], array($_resource_name, &$params['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 (!$this->_plugin_implementation_exists($this->default_template_handler_func)) { $this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist."); } else { $_return = call_user_func_array( $this->default_template_handler_func, array($_resource_type, $_resource_name, &$params['template_source'], &$params['template_timestamp'], &$this)); } } } require_once(SMARTY_DIR . 'core/core.is_secure.php'); if (!$_return) { if (!$params['quiet']) { $this->trigger_error('unable to read template resource: "' . $params['tpl_path'] . '"'); } } else if ($_return && $this->security && !smarty_core_is_secure($_params, $this)) { if (!$params['quiet']) $this->trigger_error('(secure mode) accessing "' . $params['tpl_path'] . '" is not allowed'); $params['template_source'] = null; $params['template_timestamp'] = null; return false; } return $_return; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.get_include_path.php +++ smarty/libs/core/core.get_include_path.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * Get path to file from include_path * * @param string $file_path * @param string $new_file_path * @return boolean * @staticvar array|null */ // $file_path, &$new_file_path function smarty_core_get_include_path(&$params, &$this) { static $_path_array = null; if(!isset($_path_array)) { $_ini_include_path = ini_get('include_path'); if(strstr($_ini_include_path,';')) { // windows pathnames $_path_array = explode(';',$_ini_include_path); } else { $_path_array = explode(':',$_ini_include_path); } } foreach ($_path_array as $_include_path) { if (file_exists($_include_path . DIRECTORY_SEPARATOR . $params['file_path'])) { $params['new_file_path'] = $_include_path . DIRECTORY_SEPARATOR . $params['file_path']; return true; } } return false; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.get_microtime.php +++ smarty/libs/core/core.get_microtime.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * Get seconds and microseconds * @return double */ function smarty_core_get_microtime($params, &$this) { $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = (double)($mtime[1]) + (double)($mtime[0]); return ($mtime); } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.get_php_resource.php +++ smarty/libs/core/core.get_php_resource.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * Retrieves PHP script resource * * sets $php_resource to the returned resource * @param string $resource * @param string $resource_type * @param $php_resource * @return boolean */ function smarty_core_get_php_resource(&$params, &$this) { $params['file_base_path'] = $this->trusted_dir; require_once(SMARTY_DIR . 'core/core.parse_file_path.php'); smarty_core_parse_file_path($params, $this); /* * Find out if the resource exists. */ if ($params['resource_type'] == 'file') { $_readable = false; if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) { $_readable = true; } else { // test for file in include_path $_params = array('file_path' => $params['resource_name']); require_once(SMARTY_DIR . 'core/core.get_include_path.php'); if(smarty_core_get_include_path($_params, $this)) { $_include_path = $_params['new_file_path']; $_readable = true; } } } else if ($params['resource_type'] != 'file') { $_template_source = null; $_readable = $this->_plugin_implementation_exists($this->_plugins['resource'][$params['resource_type']][0][0]) && call_user_func_array($this->_plugins['resource'][$params['resource_type']][0][0], array($params['resource_name'], &$_template_source, &$this)); } /* * Set the error function, depending on which class calls us. */ if (method_exists($this, '_syntax_error')) { $_error_funcc = '_syntax_error'; } else { $_error_funcc = 'trigger_error'; } if ($_readable) { if ($this->security) { require_once(SMARTY_DIR . 'core/core.is_trusted.php'); if (!smarty_core_is_trusted($params, $this)) { $this->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted'); return false; } } } else { $this->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable'); return false; } if ($params['resource_type'] == 'file') { $params['php_resource'] = $params['resource_name']; } else { $params['php_resource'] = $_template_source; } return true; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.is_secure.php +++ smarty/libs/core/core.is_secure.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * determines if a resource is secure or not. * * @param string $resource_type * @param string $resource_name * @return boolean */ // $resource_type, $resource_name function smarty_core_is_secure($params, &$this) { if (!$this->security || $this->security_settings['INCLUDE_ANY']) { return true; } $_smarty_secure = false; if ($params['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($params['resource_name']),0, strlen(realpath($curr_dir))) == realpath($curr_dir)) { $_smarty_secure = true; break; } } } } } else { // resource is not on local file system $_smarty_secure = call_user_func_array( $this->_plugins['resource'][$params['resource_type']][0][2], array($params['resource_name'], &$_smarty_secure, &$this)); } return $_smarty_secure; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.is_trusted.php +++ smarty/libs/core/core.is_trusted.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /**#@+ * @access private */ /** * determines if a resource is trusted or not * * @param string $resource_type * @param string $resource_name * @return boolean */ // $resource_type, $resource_name function smarty_core_is_trusted($params, &$this) { $_smarty_trusted = false; if ($params['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($params['resource_name']),0, strlen(realpath($curr_dir))) == realpath($curr_dir)) { $_smarty_trusted = true; break; } } } } } } else { // resource is not on local file system $_smarty_trusted = call_user_func_array($this->_plugins['resource'][$params['resource_type']][0][3], array($params['resource_name'], $this)); } return $_smarty_trusted; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.load_plugins.php +++ smarty/libs/core/core.load_plugins.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * Load requested plugins * * @param array $plugins */ // $plugins function smarty_core_load_plugins($params, &$this) { foreach ($params['plugins'] as $_plugin_info) { list($_type, $_name, $_tpl_file, $_tpl_line, $_delayed_loading) = $_plugin_info; $_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 (empty($_plugin[3])) { if (!$this->_plugin_implementation_exists($_plugin[0])) { $this->_trigger_fatal_error("[plugin] $_type '$_name' is not implemented", $_tpl_file, $_tpl_line, __FILE__, __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; } } $_plugin_file = $this->_get_plugin_filepath($_type, $_name); if (! $_found = ($_plugin_file != false)) { $_message = "could not load plugin file '$_type.$_name.php'\n"; } /* * 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 (!$this->_plugin_implementation_exists($_plugin_func)) { $this->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", $_tpl_file, $_tpl_line, __FILE__, __LINE__); continue; } } /* * 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; } /* * 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_fatal_error('[plugin] ' . $_message, $_tpl_file, $_tpl_line, __FILE__, __LINE__); } } } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.load_resource_plugin.php +++ smarty/libs/core/core.load_resource_plugin.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * load a resource plugin * * @param string $type */ // $type function smarty_core_load_resource_plugin($params, &$this) { /* * 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'][$params['type']]; if (isset($_plugin)) { if (!$_plugin[1] && count($_plugin[0])) { $_plugin[1] = true; foreach ($_plugin[0] as $_plugin_func) { if (!$this->_plugin_implementation_exists($_plugin_func)) { $_plugin[1] = false; break; } } } if (!$_plugin[1]) { $this->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__); } return; } $_plugin_file = $this->_get_plugin_filepath('resource', $params['type']); $_found = ($_plugin_file != false); if ($_found) { /* * 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_' . $params['type'] . '_' . $_op; if (!function_exists($_plugin_func)) { $this->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__); return; } else { $_resource_funcs[] = $_plugin_func; } } $this->_plugins['resource'][$params['type']] = array($_resource_funcs, true); } } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.parse_file_path.php +++ smarty/libs/core/core.parse_file_path.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * parse out the type and name from the template resource * * @param string $file_base_path * @param string $file_path * @param string $resource_type * @param string $resource_name * @return boolean */ // $file_base_path, $file_path, &$resource_type, &$resource_name function smarty_core_parse_file_path(&$params, &$this) { // split tpl_path by the first colon $_file_path_parts = explode(':', $params['file_path'], 2); if (count($_file_path_parts) == 1) { // no resource type given $params['resource_type'] = $this->default_resource_type; $params['resource_name'] = $_file_path_parts[0]; } else { if(strlen($_file_path_parts[0]) == 1) { // 1 char is not resource type, but part of filepath $params['resource_type'] = $this->default_resource_type; $params['resource_name'] = $params['file_path']; } else { $params['resource_type'] = $_file_path_parts[0]; $params['resource_name'] = $_file_path_parts[1]; } } if ($params['resource_type'] == 'file') { if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $params['resource_name'])) { // relative pathname to $params['file_base_path'] // use the first directory where the file is found $_file_base_path = $params['file_base_path']; settype($_file_base_path, 'array'); foreach ($_file_base_path as $_curr_path) { $_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name']; if (file_exists($_fullpath) && is_file($_fullpath)) { $params['resource_name'] = $_fullpath; return true; } // didn't find the file, try include_path $_params = array('file_path' => $_fullpath); require_once(SMARTY_DIR . 'core/core.get_include_path.php'); if(smarty_core_get_include_path($_params, $this)) { $params['resource_name'] = $_params['new_file_path']; return true; } } return false; } } else { $_params = array('type' => $params['resource_type']); require_once(SMARTY_DIR . 'core/core.load_resource_plugin.php'); smarty_core_load_resource_plugin($_params, $this); } return true; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.process_cached_inserts.php +++ smarty/libs/core/core.process_cached_inserts.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * Replace cached inserts with the actual results * * @param string $results * @return string */ function smarty_core_process_cached_inserts($params, &$this) { preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis', $params['results'], $match); list($cached_inserts, $insert_args) = $match; for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) { if ($this->debugging) { $_params = array(); require_once(SMARTY_DIR . 'core/core.get_microtime.php'); $debug_start_time = smarty_core_get_microtime($_params, $this); } $args = unserialize($insert_args[$i]); $name = $args['name']; if (isset($args['script'])) { $_params = array('file_path' => $this->_dequote($args['script'])); require_once(SMARTY_DIR . 'core/core.get_php_resource.php'); if(!smarty_core_get_php_resource($_params, $this)) { return false; } $resource_type = $_params['resource_type']; $php_resource = $_params['php_resource']; if ($resource_type == 'file') { include_once($php_resource); } else { eval($php_resource); } } $function_name = $this->_plugins['insert'][$name][0]; $replace = $function_name($args, $this); $params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']); if ($this->debugging) { $_params = array(); require_once(SMARTY_DIR . 'core/core.get_microtime.php'); $this->_smarty_debug_info[] = array('type' => 'insert', 'filename' => 'insert_'.$name, 'depth' => $this->_inclusion_depth, 'exec_time' => smarty_core_get_microtime($_params, $this) - $debug_start_time); } } return $params['results']; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.read_cache_file.php +++ smarty/libs/core/core.read_cache_file.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * read a cache file, determine if it needs to be * regenerated or not * * @param string $tpl_file * @param string $cache_id * @param string $compile_id * @param string $results * @return boolean */ // $tpl_file, $cache_id, $compile_id, &$results function smarty_core_read_cache_file(&$params, &$this) { static $content_cache = array(); if ($this->force_compile) { // force compile enabled, always regenerate return false; } if (isset($content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']])) { list($params['results'], $this->_cache_info) = $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']]; return true; } if (!empty($this->cache_handler_func)) { // use cache_handler function call_user_func_array($this->cache_handler_func, array('read', &$this, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'])); } else { // use local cache file $_auto_id = $this->_get_auto_id($params['cache_id'], $params['compile_id']); $_cache_file = $this->_get_auto_filename($this->cache_dir, $params['tpl_file'], $_auto_id); $params['results'] = $this->_read_file($_cache_file); } if (empty($params['results'])) { // nothing to parse (error?), regenerate cache return false; } $cache_split = explode("\n", $params['results'], 2); $cache_header = $cache_split[0]; $this->_cache_info = unserialize($cache_header); if ($this->caching == 2 && isset ($this->_cache_info['expires'])){ // caching by expiration time if ($this->_cache_info['expires'] > -1 && (time() > $this->_cache_info['expires'])) { // cache expired, regenerate return false; } } else { // caching by lifetime if ($this->cache_lifetime > -1 && (time() - $this->_cache_info['timestamp'] > $this->cache_lifetime)) { // cache expired, regenerate return false; } } if ($this->compile_check) { foreach (array_keys($this->_cache_info['template']) as $_template_dep) { $_params = array('tpl_path' => $_template_dep); require_once(SMARTY_DIR . 'core/core.fetch_template_info.php'); smarty_core_fetch_template_info($_params, $this); if ($this->_cache_info['timestamp'] < $_params['template_timestamp']) { // template file has changed, regenerate cache return false; } } if (isset($this->_cache_info['config'])) { foreach (array_keys($this->_cache_info['config']) as $config_dep) { if ($this->_cache_info['timestamp'] < filemtime($this->config_dir . DIRECTORY_SEPARATOR . $config_dep)) { // config file has changed, regenerate cache return false; } } } } $params['results'] = $cache_split[1]; $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $this->_cache_info); return true; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.rm_auto.php +++ smarty/libs/core/core.rm_auto.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * delete an automagically created file by name and id * * @param string $auto_base * @param string $auto_source * @param string $auto_id * @param integer $exp_time * @return boolean */ // $auto_base, $auto_source = null, $auto_id = null, $exp_time = null function smarty_core_rm_auto($params, &$this) { if (!@is_dir($params['auto_base'])) return false; if(!isset($params['auto_id']) && !isset($params['auto_source'])) { $_params = array( 'dirname' => $params['auto_base'], 'level' => 0, 'exp_time' => $params['exp_time'] ); require_once(SMARTY_DIR . 'core/core.rmdir.php'); $_res = smarty_core_rmdir($_params, $this); } else { $_tname = $this->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']); if(isset($params['auto_source'])) { $_res = $this->_unlink($_tname); } elseif ($this->use_sub_dirs) { $_params = array( 'dirname' => $_tname, 'level' => 1, 'exp_time' => $params['exp_time'] ); require_once(SMARTY_DIR . 'core/core.rmdir.php'); $_res = smarty_core_rmdir($_params, $this); } else { // remove matching file names $_handle = opendir($params['auto_base']); $_res = true; while (false !== ($_filename = readdir($_handle))) { if($_filename == '.' || $_filename == '..') { continue; } elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) { $_res &= (bool)$this->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']); } } } } return $_res; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.rmdir.php +++ smarty/libs/core/core.rmdir.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * delete a dir recursively (level=0 -> keep root) * WARNING: no tests, it will try to remove what you tell it! * * @param string $dirname * @param integer $level * @param integer $exp_time * @return boolean */ // $dirname, $level = 1, $exp_time = null function smarty_core_rmdir($params, &$this) { if(!isset($params['level'])) { $params['level'] = 1; } if(!isset($params['exp_time'])) { $params['exp_time'] = null; } if($_handle = @opendir($params['dirname'])) { while (false !== ($_entry = readdir($_handle))) { if ($_entry != '.' && $_entry != '..') { if (@is_dir($params['dirname'] . DIRECTORY_SEPARATOR . $_entry)) { $_params = array( 'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR . $_entry, 'level' => $params['level'] + 1, 'exp_time' => $params['exp_time'] ); require_once(SMARTY_DIR . 'core/core.rmdir.php'); smarty_core_rmdir($_params, $this); } else { $this->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']); } } } closedir($_handle); if ($params['level']) { @rmdir($params['dirname']); } return true; } else { return false; } } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.run_insert_handler.php +++ smarty/libs/core/core.run_insert_handler.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * Handle insert tags * * @param array $args * @return string */ function smarty_core_run_insert_handler($params, &$this) { require_once(SMARTY_DIR . 'core/core.get_microtime.php'); if ($this->debugging) { $_params = array(); $_debug_start_time = smarty_core_get_microtime($_params, $this); } if ($this->caching) { $_arg_string = serialize($params['args']); $_name = $params['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], !empty($params['args']['script']) ? true : false); } return $this->_smarty_md5."{insert_cache $_arg_string}".$this->_smarty_md5; } else { if (isset($params['args']['script'])) { $_params = array('file_path' => $this->_dequote($params['args']['script'])); require_once(SMARTY_DIR . 'core/core.get_php_resource.php'); if(!smarty_core_get_php_resource($_params, $this)) { return false; } if ($_params['resource_type'] == 'file') { include_once($_params['php_resource']); } else { eval($_params['php_resource']); } unset($params['args']['script']); } $_funcname = $this->_plugins['insert'][$params['args']['name']][0]; $_content = $_funcname($params['args'], $this); if ($this->debugging) { $_params = array(); require_once(SMARTY_DIR . 'core/core.get_microtime.php'); $this->_smarty_debug_info[] = array('type' => 'insert', 'filename' => 'insert_'.$params['args']['name'], 'depth' => $this->_inclusion_depth, 'exec_time' => smarty_core_get_microtime($_params, $this) - $_debug_start_time); } if (!empty($params['args']["assign"])) { $this->assign($params['args']["assign"], $_content); } else { return $_content; } } } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.smarty_include.php +++ smarty/libs/core/core.smarty_include.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * called for included templates * * @param string $_smarty_include_tpl_file * @param string $_smarty_include_vars */ // $_smarty_include_tpl_file, $_smarty_include_vars function smarty_core_smarty_include($params, &$this) { if ($this->debugging) { $_params = array(); require_once(SMARTY_DIR . 'core/core.get_microtime.php'); $debug_start_time = smarty_core_get_microtime($_params, $this); $this->_smarty_debug_info[] = array('type' => 'template', 'filename' => $params['smarty_include_tpl_file'], 'depth' => ++$this->_inclusion_depth); $included_tpls_idx = count($this->_smarty_debug_info) - 1; } $this->_tpl_vars = array_merge($this->_tpl_vars, $params['smarty_include_vars']); // config vars are treated as local, so push a copy of the // current ones onto the front of the stack array_unshift($this->_config, $this->_config[0]); $_smarty_compile_path = $this->_get_compile_path($params['smarty_include_tpl_file']); if ($this->_process_template($params['smarty_include_tpl_file'], $_smarty_compile_path)) { include($_smarty_compile_path); } // pop the local vars off the front of the stack array_shift($this->_config); $this->_inclusion_depth--; if ($this->debugging) { // capture time for debugging info $_params = array(); require_once(SMARTY_DIR . 'core/core.get_microtime.php'); $this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $debug_start_time; } if ($this->caching) { $this->_cache_info['template'][$params['smarty_include_tpl_file']] = true; } } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.smarty_include_php.php +++ smarty/libs/core/core.smarty_include_php.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * called for included php files within templates * * @param string $_smarty_include_php_file * @param string $_smarty_assign variable to assign the included template's * output into * @param boolean $_smarty_once uses include_once if this is true * @param array $_smarty_include_vars associative array of vars from * {include file="blah" var=$var} */ // $file, $assign, $once, $_smarty_include_vars function smarty_core_smarty_include_php($params, &$this) { $_params = array('file_path' => $params['smarty_file']); require_once(SMARTY_DIR . 'core/core.get_php_resource.php'); smarty_core_get_php_resource($_params, $this); $_smarty_resource_type = $_params['resource_type']; $_smarty_php_resource = $_params['php_resource']; extract($params['smarty_include_vars'], EXTR_PREFIX_SAME, 'include_php_'); if (!empty($params['smarty_assign'])) { ob_start(); if ($_smarty_resource_type == 'file') { if($params['smarty_once']) { include_once($_smarty_php_resource); } else { include($_smarty_php_resource); } } else { eval($_smarty_php_resource); } $this->assign($params['smarty_assign'], ob_get_contents()); ob_end_clean(); } else { if ($_smarty_resource_type == 'file') { if($params['smarty_once']) { include_once($_smarty_php_resource); } else { include($_smarty_php_resource); } } else { eval($_smarty_php_resource); } } } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.write_cache_file.php +++ smarty/libs/core/core.write_cache_file.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * Prepend the cache information to the cache file * and write it * * @param string $tpl_file * @param string $cache_id * @param string $compile_id * @param string $results * @return true|null */ // $tpl_file, $cache_id, $compile_id, $results function smarty_core_write_cache_file($params, &$this) { if(!@is_writable($this->cache_dir)) { // cache_dir not writable, see if it exists if(!@is_dir($this->cache_dir)) { $this->trigger_error('the $cache_dir \'' . $this->cache_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); return false; } $this->trigger_error('unable to write to $cache_dir \'' . realpath($this->cache_dir) . '\'. Be sure $cache_dir is writable by the web server user.', E_USER_ERROR); return false; } // put timestamp in cache header $this->_cache_info['timestamp'] = time(); if ($this->cache_lifetime > -1){ // expiration set $this->_cache_info['expires'] = $this->_cache_info['timestamp'] + $this->cache_lifetime; } else { // cache will never expire $this->_cache_info['expires'] = -1; } // prepend the cache header info into cache file $params['results'] = serialize($this->_cache_info)."\n".$params['results']; if (!empty($this->cache_handler_func)) { // use cache_handler function call_user_func_array($this->cache_handler_func, array('write', &$this, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'])); } else { // use local cache file $_auto_id = $this->_get_auto_id($params['cache_id'], $params['compile_id']); $_cache_file = $this->_get_auto_filename($this->cache_dir, $params['tpl_file'], $_auto_id); $_params = array('filename' => $_cache_file, 'contents' => $params['results'], 'create_dirs' => true); require_once(SMARTY_DIR . 'core/core.write_file.php'); smarty_core_write_file($_params, $this); return true; } } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.write_compiled_template.php +++ smarty/libs/core/core.write_compiled_template.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * write the compiled template * * @param string $compile_path * @param string $template_compiled * @param integer $template_timestamp * @return true */ function smarty_core_write_compiled_template($params, &$this) { if(!@is_writable($this->compile_dir)) { // compile_dir not writable, see if it exists if(!@is_dir($this->compile_dir)) { $this->trigger_error('the $compile_dir \'' . $this->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); return false; } $this->trigger_error('unable to write to $compile_dir \'' . realpath($this->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR); return false; } $_params = array('filename' => $params['compile_path'], 'contents' => $params['template_compiled'], 'create_dirs' => true); require_once(SMARTY_DIR . 'core/core.write_file.php'); smarty_core_write_file($_params, $this); touch($params['compile_path'], $params['template_timestamp']); return true; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.write_file.php +++ smarty/libs/core/core.write_file.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * write out a file to disk * * @param string $filename * @param string $contents * @param boolean $create_dirs * @return boolean */ function smarty_core_write_file($params, &$this) { $_dirname = dirname($params['filename']); if ($params['create_dirs']) { $_params = array('dir' => $_dirname); require_once(SMARTY_DIR . 'core/core.create_dir_structure.php'); smarty_core_create_dir_structure($_params, $this); } // write to tmp file, then rename it to avoid // file locking race condition $_tmp_file = $_dirname . '/' . uniqid(''); if (!($fd = @fopen($_tmp_file, 'w'))) { $this->trigger_error("problem writing temporary file '$_tmp_file'"); return false; } fwrite($fd, $params['contents']); fclose($fd); if(file_exists($params['filename'])) { @unlink($params['filename']); } @rename($_tmp_file, $params['filename']); chmod($params['filename'], $this->_file_perms); return true; } /* vim: set expandtab: */ ?>
Index: smarty/NEWS diff -u smarty/NEWS:1.376 smarty/NEWS:1.377 --- smarty/NEWS:1.376 Wed Jun 11 18:17:52 2003 +++ smarty/NEWS Mon Jun 16 11:18:38 2003 @@ -1,3 +1,4 @@ + - fix newlines for tags without template output (Monte) - added config-option "request_use_auto_globals" to make auto-globals be used as request vars instead of HTTP_*_VARS (messju) - make config vars compile statically (Monte) Index: smarty/libs/Smarty.class.php diff -u smarty/libs/Smarty.class.php:1.402 smarty/libs/Smarty.class.php:1.403 --- smarty/libs/Smarty.class.php:1.402 Wed Jun 11 18:17:52 2003 +++ smarty/libs/Smarty.class.php Mon Jun 16 11:18:38 2003 @@ -42,7 +42,7 @@ * @version 2.5.0 */ -/* $Id: Smarty.class.php,v 1.402 2003/06/11 22:17:52 messju Exp $ */ +/* $Id: Smarty.class.php,v 1.403 2003/06/16 15:18:38 mohrt Exp $ */ /** * DIR_SEP isn't used anymore, but third party apps might @@ -934,7 +934,8 @@ switch ($type) { case 'output': $_params = array('plugins' => array(array($type . 'filter', $name, null, null, false))); - $this->_execute_core_function('load_plugins', $_params); + require_once(SMARTY_DIR . 'core/core.load_plugins.php'); + smarty_core_load_plugins($_params, $this); break; case 'pre': @@ -973,7 +974,8 @@ 'auto_source' => $tpl_file, 'auto_id' => $_auto_id, 'exp_time' => $exp_time); - return $this->_execute_core_function('rm_auto', $_params); + require_once(SMARTY_DIR . 'core/core.rm_auto.php'); + return smarty_core_rm_auto($_params, $this); } } @@ -995,7 +997,8 @@ 'auto_source' => null, 'auto_id' => null, 'exp_time' => $exp_time); - return $this->_execute_core_function('rm_auto', $_params); + require_once(SMARTY_DIR . 'core/core.rm_auto.php'); + return smarty_core_rm_auto($_params, $this); } } @@ -1021,7 +1024,8 @@ 'cache_id' => $cache_id, 'compile_id' => $compile_id ); - return $this->_execute_core_function('read_cache_file', $_params); + require_once(SMARTY_DIR . 'core/core.read_cache_file.php'); + return smarty_core_read_cache_file($_params, $this); } @@ -1053,7 +1057,8 @@ 'auto_source' => $tpl_file, 'auto_id' => $compile_id, 'exp_time' => $exp_time); - return $this->_execute_core_function('rm_auto', $_params); + require_once(SMARTY_DIR . 'core/core.rm_auto.php'); + return smarty_core_rm_auto($_params, $this); } /** @@ -1065,7 +1070,8 @@ function template_exists($tpl_file) { $_params = array('tpl_path' => $tpl_file); - return $this->_execute_core_function('fetch_template_info', $_params); + require_once(SMARTY_DIR . 'core/core.fetch_template_info.php'); + return smarty_core_fetch_template_info($_params, $this); } /** @@ -1153,7 +1159,8 @@ if ($this->debugging) { // capture time for debugging info $_params = array(); - $_debug_start_time = $this->_execute_core_function('get_microtime', $_params); + require_once(SMARTY_DIR . 'core/core.get_microtime.php'); + $_debug_start_time = smarty_core_get_microtime($_params, $this); $this->_smarty_debug_info[] = array('type' => 'template', 'filename' => $tpl_file, 'depth' => 0); @@ -1177,21 +1184,26 @@ 'compile_id' => $compile_id, 'results' => null ); - if ($this->_execute_core_function('read_cache_file', $_params)) { + require_once(SMARTY_DIR . 'core/core.read_cache_file.php'); + if (smarty_core_read_cache_file($_params, $this)) { $_smarty_results = $_params['results']; if (@count($this->_cache_info['insert_tags'])) { $_params = array('plugins' => $this->_cache_info['insert_tags']); - $this->_execute_core_function('load_plugins', $_params); + require_once(SMARTY_DIR . 'core/core.load_plugins.php'); + smarty_core_load_plugins($_params, $this); $_params = array('results' => $_smarty_results); - $_smarty_results = $this->_execute_core_function('process_cached_inserts', $_params); + require_once(SMARTY_DIR . 'core/core.process_cached_inserts.php'); + $_smarty_results = smarty_core_process_cached_inserts($_params, $this); } if ($display) { if ($this->debugging) { // capture time for debugging info $_params = array(); - $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = $this->_execute_core_function('get_microtime', $_params) - $_debug_start_time; - $_smarty_results .= $this->_execute_core_function('display_debug_console', $_params); + require_once(SMARTY_DIR . 'core/core.get_microtime.php'); + $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time; + require_once(SMARTY_DIR . 'core/core.display_debug_console.php'); + $_smarty_results .= smarty_core_display_debug_console($_params, $this); } if ($this->cache_modified_check) { $_last_modified_date = substr($GLOBALS['HTTP_SERVER_VARS']['HTTP_IF_MODIFIED_SINCE'], 0, strpos($GLOBALS['HTTP_SERVER_VARS']['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3); @@ -1261,8 +1273,10 @@ 'cache_id' => $cache_id, 'compile_id' => $compile_id, 'results' => $_smarty_results); - $this->_execute_core_function('write_cache_file', $_params); - $_smarty_results = $this->_execute_core_function('process_cached_inserts', $_params); + require_once(SMARTY_DIR . 'core/core.write_cache_file.php'); + smarty_core_write_cache_file($_params, $this); + require_once(SMARTY_DIR . 'core/core.process_cached_inserts.php'); + $_smarty_results = smarty_core_process_cached_inserts($_params, $this); // restore initial cache_info $this->_cache_info = array_pop($_cache_info); } @@ -1272,8 +1286,10 @@ if ($this->debugging) { // capture time for debugging info $_params = array(); - $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = ($this->_execute_core_function('get_microtime', $_params) - $_debug_start_time); - echo $this->_execute_core_function('display_debug_console', $_params); + require_once(SMARTY_DIR . 'core/core.get_microtime.php'); + $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time); + require_once(SMARTY_DIR . 'core/core.display_debug_console.php'); + echo smarty_core_display_debug_console($_params, $this); } error_reporting($_smarty_old_error_level); return; @@ -1338,17 +1354,6 @@ { return preg_replace('![\\$]\d!', '\\\\\\0', $string); } - - /** - * execute core function - * @return mixed value of function return - */ - function _execute_core_function($funcname, &$params) - { - require_once($this->_get_plugin_filepath('core', $funcname)); - $_core_funcname = 'smarty_core_' . $funcname; - return $_core_funcname($params, $this); - } /** * get filepath of requested plugin @@ -1386,7 +1391,8 @@ $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; $_params = array('file_path' => $_plugin_filepath); - if($this->_execute_core_function('get_include_path', $_params)) { + require_once(SMARTY_DIR . 'core/core.get_include_path.php'); + if(smarty_core_get_include_path($_params, $this)) { return $_params['new_file_path']; } } @@ -1411,7 +1417,8 @@ } else { // get template source and timestamp $_params = array('tpl_path' => $tpl_file); - if (!$this->_execute_core_function('fetch_template_info', $_params)) { + require_once(SMARTY_DIR . 'core/core.fetch_template_info.php'); + if (!smarty_core_fetch_template_info($_params, $this)) { return false; } $_template_source = $_params['template_source']; @@ -1423,21 +1430,24 @@ // compile template $this->_compile_template($tpl_file, $_template_source, $_template_compiled); $_params = array('compile_path' => $compile_path, 'template_compiled' => $_template_compiled, 'template_timestamp' => $_template_timestamp); - $this->_execute_core_function('write_compiled_template', $_params); + require_once(SMARTY_DIR . 'core/core.write_compiled_template.php'); + smarty_core_write_compiled_template($_params, $this); return true; } } } else { // compiled template does not exist, or forced compile $_params = array('tpl_path' => $tpl_file); - if (!$this->_execute_core_function('fetch_template_info', $_params)) { + require_once(SMARTY_DIR . 'core/core.fetch_template_info.php'); + if (!smarty_core_fetch_template_info($_params, $this)) { return false; } $_template_source = $_params['template_source']; $_template_timestamp = $_params['template_timestamp']; $this->_compile_template($tpl_file, $_template_source, $_template_compiled); $_params = array('compile_path' => $compile_path, 'template_compiled' => $_template_compiled, 'template_timestamp' => $_template_timestamp); - $this->_execute_core_function('write_compiled_template', $_params); + require_once(SMARTY_DIR . 'core/core.write_compiled_template.php'); + smarty_core_write_compiled_template($_params, $this); return true; } } @@ -1618,7 +1628,8 @@ } else { // auto_base not found, try include_path $_params = array('file_path' => $auto_base); - $this->_execute_core_function('get_include_path', $_params); + require_once(SMARTY_DIR . 'core/core.get_include_path.php'); + smarty_core_get_include_path($_params, $this); $_res = isset($_params['new_file_path']) ? $_params['new_file_path'] . DIRECTORY_SEPARATOR : null; } Index: smarty/libs/Smarty_Compiler.class.php diff -u smarty/libs/Smarty_Compiler.class.php:1.237 smarty/libs/Smarty_Compiler.class.php:1.238 --- smarty/libs/Smarty_Compiler.class.php:1.237 Mon Jun 16 10:38:57 2003 +++ smarty/libs/Smarty_Compiler.class.php Mon Jun 16 11:18:38 2003 @@ -39,7 +39,7 @@ * @package Smarty */ -/* $Id: Smarty_Compiler.class.php,v 1.237 2003/06/16 14:38:57 mohrt Exp $ */ +/* $Id: Smarty_Compiler.class.php,v 1.238 2003/06/16 15:18:38 mohrt Exp $ */ /** * Template compiling class * @package Smarty @@ -353,15 +353,13 @@ } } $_plugins_params .= '))'; - $_plugin_filepath = $this->_get_plugin_filepath('core', 'load_plugins'); - $plugins_code = "<?php require_once('$_plugin_filepath');\nsmarty_core_load_plugins($_plugins_params, \$this); ?>\n"; + $plugins_code = "<?php require_once(SMARTY_DIR . 'core/core.load_plugins.php');\nsmarty_core_load_plugins($_plugins_params, \$this); ?>\n"; $template_header .= $plugins_code; $this->_plugin_info = array(); } if ($this->_init_smarty_vars) { - $_plugin_filepath = $this->_get_plugin_filepath('core', 'assign_smarty_interface'); - $template_header .= "<?php require_once('$_plugin_filepath');\nsmarty_core_assign_smarty_interface(null, \$this); ?>\n"; + $template_header .= "<?php require_once(SMARTY_DIR . 'core/core.assign_smarty_interface.php');\nsmarty_core_assign_smarty_interface(null, \$this); ?>\n"; $this->_init_smarty_vars = false; } @@ -819,9 +817,8 @@ $this->_add_plugin('insert', $name, $delayed_loading); $_params = "array('args' => array(".implode(', ', (array)$arg_list)."))"; - $_plugin_filepath = $this->_get_plugin_filepath('core', 'run_insert_handler'); - return "<?php require_once('$_plugin_filepath');\necho smarty_core_run_insert_handler($_params, \$this); ?>\n"; + return "<?php require_once(SMARTY_DIR . 'core/core.run_insert_handler.php');\necho smarty_core_run_insert_handler($_params, \$this); ?>\n"; } /** @@ -863,9 +860,8 @@ $_params = "array('smarty_include_tpl_file' => " . $include_file . ", 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))"; - $_plugin_filepath = $this->_get_plugin_filepath('core', 'smarty_include'); - $output .= "require_once('$_plugin_filepath');\nsmarty_core_smarty_include($_params, \$this);\n" . + $output .= "require_once(SMARTY_DIR . 'core/core.smarty_include.php');\nsmarty_core_smarty_include($_params, \$this);\n" . "\$this->_tpl_vars = \$_smarty_tpl_vars;\n" . "unset(\$_smarty_tpl_vars);\n"; @@ -905,9 +901,8 @@ } $_params = "array('smarty_file' => " . $attrs['file'] . ", 'smarty_assign' => '$assign_var', 'smarty_once' => $once_var, 'smarty_include_vars' => array(".implode(',', (array)$arg_list)."))"; - $_plugin_filepath = $this->_get_plugin_filepath('core', 'smarty_include_php'); - return "<?php require_once('$_plugin_filepath');\nsmarty_core_smarty_include_php($_params, \$this); ?>\n"; + return "<?php require_once(SMARTY_DIR . 'core/core.smarty_include_php.php');\nsmarty_core_smarty_include_php($_params, \$this); ?>\n"; } @@ -1713,7 +1708,8 @@ } if(!isset($this->_plugins['modifier'][$_modifier_name])) { $_params = array('plugins' => array(array('modifier', $_modifier_name, null, null, false))); - $this->_execute_core_function('load_plugins', $_params); + require_once(SMARTY_DIR . 'core/core.load_plugins.php'); + smarty_core_load_plugins($_params, $this); } array_unshift($_modifier_args, $output); $output = $this->_run_mod_handler($_modifier_name, $_map_array, $_modifier_args); @@ -1890,7 +1886,8 @@ if ($prefilter === false) { unset($this->_plugins['prefilter'][$filter_name]); $_params = array('plugins' => array(array('prefilter', $filter_name, null, null, false))); - $this->_execute_core_function('load_plugins', $_params); + require_once(SMARTY_DIR . 'core/core.load_plugins.php'); + smarty_core_load_plugins($_params, $this); } } } @@ -1899,7 +1896,8 @@ if ($postfilter === false) { unset($this->_plugins['postfilter'][$filter_name]); $_params = array('plugins' => array(array('postfilter', $filter_name, null, null, false))); - $this->_execute_core_function('load_plugins', $_params); + require_once(SMARTY_DIR . 'core/core.load_plugins.php'); + smarty_core_load_plugins($_params, $this); } } } Index: smarty/libs/core/core.assign_smarty_interface.php +++ smarty/libs/core/core.assign_smarty_interface.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /* * Smarty assign_smarty_interface core plugin * * Type: core<br> * Name: assign_smarty_interface<br> * Purpose: assign the $smarty interface variable * @param array Format: null * @param Smarty */ function smarty_core_assign_smarty_interface($params, &$this) { if (isset($this->_smarty_vars) && isset($this->_smarty_vars['request'])) { return; } $_globals_map = array('g' => 'HTTP_GET_VARS', 'p' => 'HTTP_POST_VARS', 'c' => 'HTTP_COOKIE_VARS', 's' => 'HTTP_SERVER_VARS', 'e' => 'HTTP_ENV_VARS'); $_smarty_vars_request = array(); foreach (preg_split('!!', strtolower($this->request_vars_order)) as $_c) { if (isset($_globals_map[$_c])) { $_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]); } } $_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']); $this->_smarty_vars['request'] = $_smarty_vars_request; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.create_dir_structure.php +++ smarty/libs/core/core.create_dir_structure.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * create full directory structure * * @param string $dir */ // $dir function smarty_core_create_dir_structure($params, &$this) { if (!file_exists($params['dir'])) { $_open_basedir_ini = ini_get('open_basedir'); if (DIRECTORY_SEPARATOR=='/') { /* unix-style paths */ $_dir = $params['dir']; $_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY); $_new_dir = ($_dir{0}=='/') ? '/' : getcwd().'/'; if($_use_open_basedir = !empty($_open_basedir_ini)) { $_open_basedirs = explode(':', $_open_basedir_ini); } } else { /* other-style paths */ $_dir = str_replace('\\','/', $params['dir']); $_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY); if (preg_match('!^((//)|([a-zA-Z]:/))!', $_dir, $_root_dir)) { /* leading "//" for network volume, or "[letter]:/" for full path */ $_new_dir = $_root_dir[1]; /* remove drive-letter from _dir_parts */ if (isset($_root_dir[3])) array_shift($_dir_parts); } else { $_new_dir = str_replace('\\','/', getcwd()).'/'; } if($_use_open_basedir = !empty($_open_basedir_ini)) { $_open_basedirs = explode(';', str_replace('\\','/', $_open_basedir_ini)); } } /* all paths use "/" only from here */ foreach ($_dir_parts as $_dir_part) { $_new_dir .= $_dir_part; if ($_use_open_basedir) { // do not attempt to test or make directories outside of open_basedir $_make_new_dir = false; foreach ($_open_basedirs as $_open_basedir) { if (substr($_new_dir.'/', 0, strlen($_open_basedir)) == $_open_basedir) { $_make_new_dir = true; break; } } } else { $_make_new_dir = true; } if ($_make_new_dir && !file_exists($_new_dir) && !@mkdir($_new_dir, $this->_dir_perms)) { $this->trigger_error("problem creating directory '" . $_new_dir . "'"); return false; } $_new_dir .= '/'; } } } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.display_debug_console.php +++ smarty/libs/core/core.display_debug_console.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /* * Smarty debug_console function plugin * * Type: core<br> * Name: display_debug_console<br> * Purpose: display the javascript debug console window * @param array Format: null * @param Smarty */ function smarty_core_display_debug_console($params, &$this) { // we must force compile the debug template in case the environment // changed between separate applications. if(empty($this->debug_tpl)) { // set path to debug template from SMARTY_DIR $this->debug_tpl = SMARTY_DIR . 'debug.tpl'; if($this->security && is_file($this->debug_tpl)) { $this->secure_dir[] = $this->debug_tpl; } } $_ldelim_orig = $this->left_delimiter; $_rdelim_orig = $this->right_delimiter; $this->left_delimiter = '{'; $this->right_delimiter = '}'; $_force_compile_orig = $this->force_compile; $this->force_compile = true; $_compile_id_orig = $this->_compile_id; $this->_compile_id = null; $_compile_path = $this->_get_compile_path($this->debug_tpl); if ($this->_process_template($this->debug_tpl, $_compile_path)) { ob_start(); include($_compile_path); $_results = ob_get_contents(); ob_end_clean(); } else { $_results = ''; } $this->force_compile = $_force_compile_orig; $this->_compile_id = $_compile_id_orig; $this->left_delimiter = $_ldelim_orig; $this->right_delimiter = $_rdelim_orig; return $_results; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.fetch_template_info.php +++ smarty/libs/core/core.fetch_template_info.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * fetch the template info. Gets timestamp, and source * if get_source is true * * sets $template_source to the source of the template, and * $template_timestamp to its time stamp * @param string $tpl_path * @param string $template_source * @param integer $template_timestamp * @param boolean $get_source * @param boolean $quiet * @return boolean */ // $tpl_path, &$template_source, &$template_timestamp, $get_source = true, $quiet = false function smarty_core_fetch_template_info(&$params, &$this) { if(!isset($params['get_source'])) { $params['get_source'] = true; } if(!isset($params['quiet'])) { $params['quiet'] = false; } $_return = false; $_params = array('file_base_path' => $this->template_dir, 'file_path' => $params['tpl_path']) ; require_once(SMARTY_DIR . 'core/core.parse_file_path.php'); if (smarty_core_parse_file_path($_params, $this)) { $_resource_type = $_params['resource_type']; $_resource_name = $_params['resource_name']; switch ($_resource_type) { case 'file': if ($params['get_source']) { $params['template_source'] = $this->_read_file($_resource_name); } $params['template_timestamp'] = filemtime($_resource_name); $_return = true; break; default: // call resource functions to fetch the template source and timestamp if ($params['get_source']) { $_source_return = isset($this->_plugins['resource'][$_resource_type]) && call_user_func_array($this->_plugins['resource'][$_resource_type][0][0], array($_resource_name, &$params['template_source'], &$this)); } else { $_source_return = true; } $_timestamp_return = isset($this->_plugins['resource'][$_resource_type]) && call_user_func_array($this->_plugins['resource'][$_resource_type][0][1], array($_resource_name, &$params['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 (!$this->_plugin_implementation_exists($this->default_template_handler_func)) { $this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist."); } else { $_return = call_user_func_array( $this->default_template_handler_func, array($_resource_type, $_resource_name, &$params['template_source'], &$params['template_timestamp'], &$this)); } } } require_once(SMARTY_DIR . 'core/core.is_secure.php'); if (!$_return) { if (!$params['quiet']) { $this->trigger_error('unable to read template resource: "' . $params['tpl_path'] . '"'); } } else if ($_return && $this->security && !smarty_core_is_secure($_params, $this)) { if (!$params['quiet']) $this->trigger_error('(secure mode) accessing "' . $params['tpl_path'] . '" is not allowed'); $params['template_source'] = null; $params['template_timestamp'] = null; return false; } return $_return; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.get_include_path.php +++ smarty/libs/core/core.get_include_path.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * Get path to file from include_path * * @param string $file_path * @param string $new_file_path * @return boolean * @staticvar array|null */ // $file_path, &$new_file_path function smarty_core_get_include_path(&$params, &$this) { static $_path_array = null; if(!isset($_path_array)) { $_ini_include_path = ini_get('include_path'); if(strstr($_ini_include_path,';')) { // windows pathnames $_path_array = explode(';',$_ini_include_path); } else { $_path_array = explode(':',$_ini_include_path); } } foreach ($_path_array as $_include_path) { if (file_exists($_include_path . DIRECTORY_SEPARATOR . $params['file_path'])) { $params['new_file_path'] = $_include_path . DIRECTORY_SEPARATOR . $params['file_path']; return true; } } return false; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.get_microtime.php +++ smarty/libs/core/core.get_microtime.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * Get seconds and microseconds * @return double */ function smarty_core_get_microtime($params, &$this) { $mtime = microtime(); $mtime = explode(" ", $mtime); $mtime = (double)($mtime[1]) + (double)($mtime[0]); return ($mtime); } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.get_php_resource.php +++ smarty/libs/core/core.get_php_resource.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * Retrieves PHP script resource * * sets $php_resource to the returned resource * @param string $resource * @param string $resource_type * @param $php_resource * @return boolean */ function smarty_core_get_php_resource(&$params, &$this) { $params['file_base_path'] = $this->trusted_dir; require_once(SMARTY_DIR . 'core/core.parse_file_path.php'); smarty_core_parse_file_path($params, $this); /* * Find out if the resource exists. */ if ($params['resource_type'] == 'file') { $_readable = false; if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) { $_readable = true; } else { // test for file in include_path $_params = array('file_path' => $params['resource_name']); require_once(SMARTY_DIR . 'core/core.get_include_path.php'); if(smarty_core_get_include_path($_params, $this)) { $_include_path = $_params['new_file_path']; $_readable = true; } } } else if ($params['resource_type'] != 'file') { $_template_source = null; $_readable = $this->_plugin_implementation_exists($this->_plugins['resource'][$params['resource_type']][0][0]) && call_user_func_array($this->_plugins['resource'][$params['resource_type']][0][0], array($params['resource_name'], &$_template_source, &$this)); } /* * Set the error function, depending on which class calls us. */ if (method_exists($this, '_syntax_error')) { $_error_funcc = '_syntax_error'; } else { $_error_funcc = 'trigger_error'; } if ($_readable) { if ($this->security) { require_once(SMARTY_DIR . 'core/core.is_trusted.php'); if (!smarty_core_is_trusted($params, $this)) { $this->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted'); return false; } } } else { $this->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable'); return false; } if ($params['resource_type'] == 'file') { $params['php_resource'] = $params['resource_name']; } else { $params['php_resource'] = $_template_source; } return true; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.is_secure.php +++ smarty/libs/core/core.is_secure.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * determines if a resource is secure or not. * * @param string $resource_type * @param string $resource_name * @return boolean */ // $resource_type, $resource_name function smarty_core_is_secure($params, &$this) { if (!$this->security || $this->security_settings['INCLUDE_ANY']) { return true; } $_smarty_secure = false; if ($params['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($params['resource_name']),0, strlen(realpath($curr_dir))) == realpath($curr_dir)) { $_smarty_secure = true; break; } } } } } else { // resource is not on local file system $_smarty_secure = call_user_func_array( $this->_plugins['resource'][$params['resource_type']][0][2], array($params['resource_name'], &$_smarty_secure, &$this)); } return $_smarty_secure; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.is_trusted.php +++ smarty/libs/core/core.is_trusted.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /**#@+ * @access private */ /** * determines if a resource is trusted or not * * @param string $resource_type * @param string $resource_name * @return boolean */ // $resource_type, $resource_name function smarty_core_is_trusted($params, &$this) { $_smarty_trusted = false; if ($params['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($params['resource_name']),0, strlen(realpath($curr_dir))) == realpath($curr_dir)) { $_smarty_trusted = true; break; } } } } } } else { // resource is not on local file system $_smarty_trusted = call_user_func_array($this->_plugins['resource'][$params['resource_type']][0][3], array($params['resource_name'], $this)); } return $_smarty_trusted; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.load_plugins.php +++ smarty/libs/core/core.load_plugins.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * Load requested plugins * * @param array $plugins */ // $plugins function smarty_core_load_plugins($params, &$this) { foreach ($params['plugins'] as $_plugin_info) { list($_type, $_name, $_tpl_file, $_tpl_line, $_delayed_loading) = $_plugin_info; $_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 (empty($_plugin[3])) { if (!$this->_plugin_implementation_exists($_plugin[0])) { $this->_trigger_fatal_error("[plugin] $_type '$_name' is not implemented", $_tpl_file, $_tpl_line, __FILE__, __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; } } $_plugin_file = $this->_get_plugin_filepath($_type, $_name); if (! $_found = ($_plugin_file != false)) { $_message = "could not load plugin file '$_type.$_name.php'\n"; } /* * 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 (!$this->_plugin_implementation_exists($_plugin_func)) { $this->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", $_tpl_file, $_tpl_line, __FILE__, __LINE__); continue; } } /* * 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; } /* * 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_fatal_error('[plugin] ' . $_message, $_tpl_file, $_tpl_line, __FILE__, __LINE__); } } } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.load_resource_plugin.php +++ smarty/libs/core/core.load_resource_plugin.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * load a resource plugin * * @param string $type */ // $type function smarty_core_load_resource_plugin($params, &$this) { /* * 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'][$params['type']]; if (isset($_plugin)) { if (!$_plugin[1] && count($_plugin[0])) { $_plugin[1] = true; foreach ($_plugin[0] as $_plugin_func) { if (!$this->_plugin_implementation_exists($_plugin_func)) { $_plugin[1] = false; break; } } } if (!$_plugin[1]) { $this->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__); } return; } $_plugin_file = $this->_get_plugin_filepath('resource', $params['type']); $_found = ($_plugin_file != false); if ($_found) { /* * 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_' . $params['type'] . '_' . $_op; if (!function_exists($_plugin_func)) { $this->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__); return; } else { $_resource_funcs[] = $_plugin_func; } } $this->_plugins['resource'][$params['type']] = array($_resource_funcs, true); } } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.parse_file_path.php +++ smarty/libs/core/core.parse_file_path.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * parse out the type and name from the template resource * * @param string $file_base_path * @param string $file_path * @param string $resource_type * @param string $resource_name * @return boolean */ // $file_base_path, $file_path, &$resource_type, &$resource_name function smarty_core_parse_file_path(&$params, &$this) { // split tpl_path by the first colon $_file_path_parts = explode(':', $params['file_path'], 2); if (count($_file_path_parts) == 1) { // no resource type given $params['resource_type'] = $this->default_resource_type; $params['resource_name'] = $_file_path_parts[0]; } else { if(strlen($_file_path_parts[0]) == 1) { // 1 char is not resource type, but part of filepath $params['resource_type'] = $this->default_resource_type; $params['resource_name'] = $params['file_path']; } else { $params['resource_type'] = $_file_path_parts[0]; $params['resource_name'] = $_file_path_parts[1]; } } if ($params['resource_type'] == 'file') { if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $params['resource_name'])) { // relative pathname to $params['file_base_path'] // use the first directory where the file is found $_file_base_path = $params['file_base_path']; settype($_file_base_path, 'array'); foreach ($_file_base_path as $_curr_path) { $_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name']; if (file_exists($_fullpath) && is_file($_fullpath)) { $params['resource_name'] = $_fullpath; return true; } // didn't find the file, try include_path $_params = array('file_path' => $_fullpath); require_once(SMARTY_DIR . 'core/core.get_include_path.php'); if(smarty_core_get_include_path($_params, $this)) { $params['resource_name'] = $_params['new_file_path']; return true; } } return false; } } else { $_params = array('type' => $params['resource_type']); require_once(SMARTY_DIR . 'core/core.load_resource_plugin.php'); smarty_core_load_resource_plugin($_params, $this); } return true; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.process_cached_inserts.php +++ smarty/libs/core/core.process_cached_inserts.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * Replace cached inserts with the actual results * * @param string $results * @return string */ function smarty_core_process_cached_inserts($params, &$this) { preg_match_all('!'.$this->_smarty_md5.'{insert_cache (.*)}'.$this->_smarty_md5.'!Uis', $params['results'], $match); list($cached_inserts, $insert_args) = $match; for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) { if ($this->debugging) { $_params = array(); require_once(SMARTY_DIR . 'core/core.get_microtime.php'); $debug_start_time = smarty_core_get_microtime($_params, $this); } $args = unserialize($insert_args[$i]); $name = $args['name']; if (isset($args['script'])) { $_params = array('file_path' => $this->_dequote($args['script'])); require_once(SMARTY_DIR . 'core/core.get_php_resource.php'); if(!smarty_core_get_php_resource($_params, $this)) { return false; } $resource_type = $_params['resource_type']; $php_resource = $_params['php_resource']; if ($resource_type == 'file') { include_once($php_resource); } else { eval($php_resource); } } $function_name = $this->_plugins['insert'][$name][0]; $replace = $function_name($args, $this); $params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']); if ($this->debugging) { $_params = array(); require_once(SMARTY_DIR . 'core/core.get_microtime.php'); $this->_smarty_debug_info[] = array('type' => 'insert', 'filename' => 'insert_'.$name, 'depth' => $this->_inclusion_depth, 'exec_time' => smarty_core_get_microtime($_params, $this) - $debug_start_time); } } return $params['results']; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.read_cache_file.php +++ smarty/libs/core/core.read_cache_file.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * read a cache file, determine if it needs to be * regenerated or not * * @param string $tpl_file * @param string $cache_id * @param string $compile_id * @param string $results * @return boolean */ // $tpl_file, $cache_id, $compile_id, &$results function smarty_core_read_cache_file(&$params, &$this) { static $content_cache = array(); if ($this->force_compile) { // force compile enabled, always regenerate return false; } if (isset($content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']])) { list($params['results'], $this->_cache_info) = $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']]; return true; } if (!empty($this->cache_handler_func)) { // use cache_handler function call_user_func_array($this->cache_handler_func, array('read', &$this, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'])); } else { // use local cache file $_auto_id = $this->_get_auto_id($params['cache_id'], $params['compile_id']); $_cache_file = $this->_get_auto_filename($this->cache_dir, $params['tpl_file'], $_auto_id); $params['results'] = $this->_read_file($_cache_file); } if (empty($params['results'])) { // nothing to parse (error?), regenerate cache return false; } $cache_split = explode("\n", $params['results'], 2); $cache_header = $cache_split[0]; $this->_cache_info = unserialize($cache_header); if ($this->caching == 2 && isset ($this->_cache_info['expires'])){ // caching by expiration time if ($this->_cache_info['expires'] > -1 && (time() > $this->_cache_info['expires'])) { // cache expired, regenerate return false; } } else { // caching by lifetime if ($this->cache_lifetime > -1 && (time() - $this->_cache_info['timestamp'] > $this->cache_lifetime)) { // cache expired, regenerate return false; } } if ($this->compile_check) { foreach (array_keys($this->_cache_info['template']) as $_template_dep) { $_params = array('tpl_path' => $_template_dep); require_once(SMARTY_DIR . 'core/core.fetch_template_info.php'); smarty_core_fetch_template_info($_params, $this); if ($this->_cache_info['timestamp'] < $_params['template_timestamp']) { // template file has changed, regenerate cache return false; } } if (isset($this->_cache_info['config'])) { foreach (array_keys($this->_cache_info['config']) as $config_dep) { if ($this->_cache_info['timestamp'] < filemtime($this->config_dir . DIRECTORY_SEPARATOR . $config_dep)) { // config file has changed, regenerate cache return false; } } } } $params['results'] = $cache_split[1]; $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $this->_cache_info); return true; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.rm_auto.php +++ smarty/libs/core/core.rm_auto.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * delete an automagically created file by name and id * * @param string $auto_base * @param string $auto_source * @param string $auto_id * @param integer $exp_time * @return boolean */ // $auto_base, $auto_source = null, $auto_id = null, $exp_time = null function smarty_core_rm_auto($params, &$this) { if (!@is_dir($params['auto_base'])) return false; if(!isset($params['auto_id']) && !isset($params['auto_source'])) { $_params = array( 'dirname' => $params['auto_base'], 'level' => 0, 'exp_time' => $params['exp_time'] ); require_once(SMARTY_DIR . 'core/core.rmdir.php'); $_res = smarty_core_rmdir($_params, $this); } else { $_tname = $this->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']); if(isset($params['auto_source'])) { $_res = $this->_unlink($_tname); } elseif ($this->use_sub_dirs) { $_params = array( 'dirname' => $_tname, 'level' => 1, 'exp_time' => $params['exp_time'] ); require_once(SMARTY_DIR . 'core/core.rmdir.php'); $_res = smarty_core_rmdir($_params, $this); } else { // remove matching file names $_handle = opendir($params['auto_base']); $_res = true; while (false !== ($_filename = readdir($_handle))) { if($_filename == '.' || $_filename == '..') { continue; } elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) { $_res &= (bool)$this->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']); } } } } return $_res; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.rmdir.php +++ smarty/libs/core/core.rmdir.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * delete a dir recursively (level=0 -> keep root) * WARNING: no tests, it will try to remove what you tell it! * * @param string $dirname * @param integer $level * @param integer $exp_time * @return boolean */ // $dirname, $level = 1, $exp_time = null function smarty_core_rmdir($params, &$this) { if(!isset($params['level'])) { $params['level'] = 1; } if(!isset($params['exp_time'])) { $params['exp_time'] = null; } if($_handle = @opendir($params['dirname'])) { while (false !== ($_entry = readdir($_handle))) { if ($_entry != '.' && $_entry != '..') { if (@is_dir($params['dirname'] . DIRECTORY_SEPARATOR . $_entry)) { $_params = array( 'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR . $_entry, 'level' => $params['level'] + 1, 'exp_time' => $params['exp_time'] ); require_once(SMARTY_DIR . 'core/core.rmdir.php'); smarty_core_rmdir($_params, $this); } else { $this->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']); } } } closedir($_handle); if ($params['level']) { @rmdir($params['dirname']); } return true; } else { return false; } } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.run_insert_handler.php +++ smarty/libs/core/core.run_insert_handler.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * Handle insert tags * * @param array $args * @return string */ function smarty_core_run_insert_handler($params, &$this) { require_once(SMARTY_DIR . 'core/core.get_microtime.php'); if ($this->debugging) { $_params = array(); $_debug_start_time = smarty_core_get_microtime($_params, $this); } if ($this->caching) { $_arg_string = serialize($params['args']); $_name = $params['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], !empty($params['args']['script']) ? true : false); } return $this->_smarty_md5."{insert_cache $_arg_string}".$this->_smarty_md5; } else { if (isset($params['args']['script'])) { $_params = array('file_path' => $this->_dequote($params['args']['script'])); require_once(SMARTY_DIR . 'core/core.get_php_resource.php'); if(!smarty_core_get_php_resource($_params, $this)) { return false; } if ($_params['resource_type'] == 'file') { include_once($_params['php_resource']); } else { eval($_params['php_resource']); } unset($params['args']['script']); } $_funcname = $this->_plugins['insert'][$params['args']['name']][0]; $_content = $_funcname($params['args'], $this); if ($this->debugging) { $_params = array(); require_once(SMARTY_DIR . 'core/core.get_microtime.php'); $this->_smarty_debug_info[] = array('type' => 'insert', 'filename' => 'insert_'.$params['args']['name'], 'depth' => $this->_inclusion_depth, 'exec_time' => smarty_core_get_microtime($_params, $this) - $_debug_start_time); } if (!empty($params['args']["assign"])) { $this->assign($params['args']["assign"], $_content); } else { return $_content; } } } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.smarty_include.php +++ smarty/libs/core/core.smarty_include.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * called for included templates * * @param string $_smarty_include_tpl_file * @param string $_smarty_include_vars */ // $_smarty_include_tpl_file, $_smarty_include_vars function smarty_core_smarty_include($params, &$this) { if ($this->debugging) { $_params = array(); require_once(SMARTY_DIR . 'core/core.get_microtime.php'); $debug_start_time = smarty_core_get_microtime($_params, $this); $this->_smarty_debug_info[] = array('type' => 'template', 'filename' => $params['smarty_include_tpl_file'], 'depth' => ++$this->_inclusion_depth); $included_tpls_idx = count($this->_smarty_debug_info) - 1; } $this->_tpl_vars = array_merge($this->_tpl_vars, $params['smarty_include_vars']); // config vars are treated as local, so push a copy of the // current ones onto the front of the stack array_unshift($this->_config, $this->_config[0]); $_smarty_compile_path = $this->_get_compile_path($params['smarty_include_tpl_file']); if ($this->_process_template($params['smarty_include_tpl_file'], $_smarty_compile_path)) { include($_smarty_compile_path); } // pop the local vars off the front of the stack array_shift($this->_config); $this->_inclusion_depth--; if ($this->debugging) { // capture time for debugging info $_params = array(); require_once(SMARTY_DIR . 'core/core.get_microtime.php'); $this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $debug_start_time; } if ($this->caching) { $this->_cache_info['template'][$params['smarty_include_tpl_file']] = true; } } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.smarty_include_php.php +++ smarty/libs/core/core.smarty_include_php.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * called for included php files within templates * * @param string $_smarty_include_php_file * @param string $_smarty_assign variable to assign the included template's * output into * @param boolean $_smarty_once uses include_once if this is true * @param array $_smarty_include_vars associative array of vars from * {include file="blah" var=$var} */ // $file, $assign, $once, $_smarty_include_vars function smarty_core_smarty_include_php($params, &$this) { $_params = array('file_path' => $params['smarty_file']); require_once(SMARTY_DIR . 'core/core.get_php_resource.php'); smarty_core_get_php_resource($_params, $this); $_smarty_resource_type = $_params['resource_type']; $_smarty_php_resource = $_params['php_resource']; extract($params['smarty_include_vars'], EXTR_PREFIX_SAME, 'include_php_'); if (!empty($params['smarty_assign'])) { ob_start(); if ($_smarty_resource_type == 'file') { if($params['smarty_once']) { include_once($_smarty_php_resource); } else { include($_smarty_php_resource); } } else { eval($_smarty_php_resource); } $this->assign($params['smarty_assign'], ob_get_contents()); ob_end_clean(); } else { if ($_smarty_resource_type == 'file') { if($params['smarty_once']) { include_once($_smarty_php_resource); } else { include($_smarty_php_resource); } } else { eval($_smarty_php_resource); } } } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.write_cache_file.php +++ smarty/libs/core/core.write_cache_file.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * Prepend the cache information to the cache file * and write it * * @param string $tpl_file * @param string $cache_id * @param string $compile_id * @param string $results * @return true|null */ // $tpl_file, $cache_id, $compile_id, $results function smarty_core_write_cache_file($params, &$this) { if(!@is_writable($this->cache_dir)) { // cache_dir not writable, see if it exists if(!@is_dir($this->cache_dir)) { $this->trigger_error('the $cache_dir \'' . $this->cache_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); return false; } $this->trigger_error('unable to write to $cache_dir \'' . realpath($this->cache_dir) . '\'. Be sure $cache_dir is writable by the web server user.', E_USER_ERROR); return false; } // put timestamp in cache header $this->_cache_info['timestamp'] = time(); if ($this->cache_lifetime > -1){ // expiration set $this->_cache_info['expires'] = $this->_cache_info['timestamp'] + $this->cache_lifetime; } else { // cache will never expire $this->_cache_info['expires'] = -1; } // prepend the cache header info into cache file $params['results'] = serialize($this->_cache_info)."\n".$params['results']; if (!empty($this->cache_handler_func)) { // use cache_handler function call_user_func_array($this->cache_handler_func, array('write', &$this, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'])); } else { // use local cache file $_auto_id = $this->_get_auto_id($params['cache_id'], $params['compile_id']); $_cache_file = $this->_get_auto_filename($this->cache_dir, $params['tpl_file'], $_auto_id); $_params = array('filename' => $_cache_file, 'contents' => $params['results'], 'create_dirs' => true); require_once(SMARTY_DIR . 'core/core.write_file.php'); smarty_core_write_file($_params, $this); return true; } } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.write_compiled_template.php +++ smarty/libs/core/core.write_compiled_template.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * write the compiled template * * @param string $compile_path * @param string $template_compiled * @param integer $template_timestamp * @return true */ function smarty_core_write_compiled_template($params, &$this) { if(!@is_writable($this->compile_dir)) { // compile_dir not writable, see if it exists if(!@is_dir($this->compile_dir)) { $this->trigger_error('the $compile_dir \'' . $this->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); return false; } $this->trigger_error('unable to write to $compile_dir \'' . realpath($this->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR); return false; } $_params = array('filename' => $params['compile_path'], 'contents' => $params['template_compiled'], 'create_dirs' => true); require_once(SMARTY_DIR . 'core/core.write_file.php'); smarty_core_write_file($_params, $this); touch($params['compile_path'], $params['template_timestamp']); return true; } /* vim: set expandtab: */ ?> Index: smarty/libs/core/core.write_file.php +++ smarty/libs/core/core.write_file.php <?php /** * Smarty plugin * @package Smarty * @subpackage plugins */ /** * write out a file to disk * * @param string $filename * @param string $contents * @param boolean $create_dirs * @return boolean */ function smarty_core_write_file($params, &$this) { $_dirname = dirname($params['filename']); if ($params['create_dirs']) { $_params = array('dir' => $_dirname); require_once(SMARTY_DIR . 'core/core.create_dir_structure.php'); smarty_core_create_dir_structure($_params, $this); } // write to tmp file, then rename it to avoid // file locking race condition $_tmp_file = $_dirname . '/' . uniqid(''); if (!($fd = @fopen($_tmp_file, 'w'))) { $this->trigger_error("problem writing temporary file '$_tmp_file'"); return false; } fwrite($fd, $params['contents']); fclose($fd); if(file_exists($params['filename'])) { @unlink($params['filename']); } @rename($_tmp_file, $params['filename']); chmod($params['filename'], $this->_file_perms); return true; } /* vim: set expandtab: */ ?>