removed tabs from the main and the core/*.php files

This commit is contained in:
messju
2003-10-11 08:55:53 +00:00
parent fd3a037433
commit f8db1a7ce8
24 changed files with 1371 additions and 1371 deletions

View File

@@ -37,273 +37,273 @@
* @package Smarty * @package Smarty
*/ */
class Config_File { class Config_File {
/**#@+ /**#@+
* Options * Options
* @var boolean * @var boolean
*/ */
/** /**
* Controls whether variables with the same name overwrite each other. * Controls whether variables with the same name overwrite each other.
*/ */
var $overwrite = true; var $overwrite = true;
/** /**
* Controls whether config values of on/true/yes and off/false/no get * Controls whether config values of on/true/yes and off/false/no get
* converted to boolean values automatically. * converted to boolean values automatically.
*/ */
var $booleanize = true; var $booleanize = true;
/** /**
* Controls whether hidden config sections/vars are read from the file. * Controls whether hidden config sections/vars are read from the file.
*/ */
var $read_hidden = true; var $read_hidden = true;
/** /**
* Controls whether or not to fix mac or dos formatted newlines. * Controls whether or not to fix mac or dos formatted newlines.
* If set to true, \r or \r\n will be changed to \n. * If set to true, \r or \r\n will be changed to \n.
*/ */
var $fix_newlines = true; var $fix_newlines = true;
/**#@-*/ /**#@-*/
/** @access private */ /** @access private */
var $_config_path = ""; var $_config_path = "";
var $_config_data = array(); var $_config_data = array();
/**#@-*/ /**#@-*/
/** /**
* Constructs a new config file class. * Constructs a new config file class.
* *
* @param string $config_path (optional) path to the config files * @param string $config_path (optional) path to the config files
*/ */
function Config_File($config_path = NULL) function Config_File($config_path = NULL)
{ {
if (isset($config_path)) if (isset($config_path))
$this->set_path($config_path); $this->set_path($config_path);
} }
/** /**
* Set the path where configuration files can be found. * Set the path where configuration files can be found.
* *
* @param string $config_path path to the config files * @param string $config_path path to the config files
*/ */
function set_path($config_path) function set_path($config_path)
{ {
if (!empty($config_path)) { if (!empty($config_path)) {
if (!is_string($config_path) || !file_exists($config_path) || !is_dir($config_path)) { if (!is_string($config_path) || !file_exists($config_path) || !is_dir($config_path)) {
$this->_trigger_error_msg("Bad config file path '$config_path'"); $this->_trigger_error_msg("Bad config file path '$config_path'");
return; return;
} }
if(substr($config_path, -1) != DIRECTORY_SEPARATOR) { if(substr($config_path, -1) != DIRECTORY_SEPARATOR) {
$config_path .= DIRECTORY_SEPARATOR; $config_path .= DIRECTORY_SEPARATOR;
} }
$this->_config_path = $config_path; $this->_config_path = $config_path;
} }
} }
/** /**
* Retrieves config info based on the file, section, and variable name. * Retrieves config info based on the file, section, and variable name.
* *
* @param string $file_name config file to get info for * @param string $file_name config file to get info for
* @param string $section_name (optional) section to get info for * @param string $section_name (optional) section to get info for
* @param string $var_name (optional) variable to get info for * @param string $var_name (optional) variable to get info for
* @return string|array a value or array of values * @return string|array a value or array of values
*/ */
function &get($file_name, $section_name = NULL, $var_name = NULL) function &get($file_name, $section_name = NULL, $var_name = NULL)
{ {
if (empty($file_name)) { if (empty($file_name)) {
$this->_trigger_error_msg('Empty config file name'); $this->_trigger_error_msg('Empty config file name');
return; return;
} else { } else {
$file_name = $this->_config_path . $file_name; $file_name = $this->_config_path . $file_name;
if (!isset($this->_config_data[$file_name])) if (!isset($this->_config_data[$file_name]))
$this->load_file($file_name, false); $this->load_file($file_name, false);
} }
if (!empty($var_name)) { if (!empty($var_name)) {
if (empty($section_name)) { if (empty($section_name)) {
return $this->_config_data[$file_name]["vars"][$var_name]; return $this->_config_data[$file_name]["vars"][$var_name];
} else { } else {
if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name])) if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]))
return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]; return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name];
else else
return array(); return array();
} }
} else { } else {
if (empty($section_name)) { if (empty($section_name)) {
return (array)$this->_config_data[$file_name]["vars"]; return (array)$this->_config_data[$file_name]["vars"];
} else { } else {
if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"])) if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"]))
return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"]; return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"];
else else
return array(); return array();
} }
} }
} }
/** /**
* Retrieves config info based on the key. * Retrieves config info based on the key.
* *
* @param $file_name string config key (filename/section/var) * @param $file_name string config key (filename/section/var)
* @return string|array same as get() * @return string|array same as get()
* @uses get() retrieves information from config file and returns it * @uses get() retrieves information from config file and returns it
*/ */
function &get_key($config_key) function &get_key($config_key)
{ {
list($file_name, $section_name, $var_name) = explode('/', $config_key, 3); list($file_name, $section_name, $var_name) = explode('/', $config_key, 3);
$result = &$this->get($file_name, $section_name, $var_name); $result = &$this->get($file_name, $section_name, $var_name);
return $result; return $result;
} }
/** /**
* Get all loaded config file names. * Get all loaded config file names.
* *
* @return array an array of loaded config file names * @return array an array of loaded config file names
*/ */
function get_file_names() function get_file_names()
{ {
return array_keys($this->_config_data); return array_keys($this->_config_data);
} }
/** /**
* Get all section names from a loaded file. * Get all section names from a loaded file.
* *
* @param string $file_name config file to get section names from * @param string $file_name config file to get section names from
* @return array an array of section names from the specified file * @return array an array of section names from the specified file
*/ */
function get_section_names($file_name) function get_section_names($file_name)
{ {
$file_name = $this->_config_path . $file_name; $file_name = $this->_config_path . $file_name;
if (!isset($this->_config_data[$file_name])) { if (!isset($this->_config_data[$file_name])) {
$this->_trigger_error_msg("Unknown config file '$file_name'"); $this->_trigger_error_msg("Unknown config file '$file_name'");
return; return;
} }
return array_keys($this->_config_data[$file_name]["sections"]); return array_keys($this->_config_data[$file_name]["sections"]);
} }
/** /**
* Get all global or section variable names. * Get all global or section variable names.
* *
* @param string $file_name config file to get info for * @param string $file_name config file to get info for
* @param string $section_name (optional) section to get info for * @param string $section_name (optional) section to get info for
* @return array an array of variables names from the specified file/section * @return array an array of variables names from the specified file/section
*/ */
function get_var_names($file_name, $section = NULL) function get_var_names($file_name, $section = NULL)
{ {
if (empty($file_name)) { if (empty($file_name)) {
$this->_trigger_error_msg('Empty config file name'); $this->_trigger_error_msg('Empty config file name');
return; return;
} else if (!isset($this->_config_data[$file_name])) { } else if (!isset($this->_config_data[$file_name])) {
$this->_trigger_error_msg("Unknown config file '$file_name'"); $this->_trigger_error_msg("Unknown config file '$file_name'");
return; return;
} }
if (empty($section)) if (empty($section))
return array_keys($this->_config_data[$file_name]["vars"]); return array_keys($this->_config_data[$file_name]["vars"]);
else else
return array_keys($this->_config_data[$file_name]["sections"][$section]["vars"]); return array_keys($this->_config_data[$file_name]["sections"][$section]["vars"]);
} }
/** /**
* Clear loaded config data for a certain file or all files. * Clear loaded config data for a certain file or all files.
* *
* @param string $file_name file to clear config data for * @param string $file_name file to clear config data for
*/ */
function clear($file_name = NULL) function clear($file_name = NULL)
{ {
if ($file_name === NULL) if ($file_name === NULL)
$this->_config_data = array(); $this->_config_data = array();
else if (isset($this->_config_data[$file_name])) else if (isset($this->_config_data[$file_name]))
$this->_config_data[$file_name] = array(); $this->_config_data[$file_name] = array();
} }
/** /**
* Load a configuration file manually. * Load a configuration file manually.
* *
* @param string $file_name file name to load * @param string $file_name file name to load
* @param boolean $prepend_path whether current config path should be * @param boolean $prepend_path whether current config path should be
* prepended to the filename * prepended to the filename
*/ */
function load_file($file_name, $prepend_path = true) function load_file($file_name, $prepend_path = true)
{ {
if ($prepend_path && $this->_config_path != "") if ($prepend_path && $this->_config_path != "")
$config_file = $this->_config_path . $file_name; $config_file = $this->_config_path . $file_name;
else else
$config_file = $file_name; $config_file = $file_name;
ini_set('track_errors', true); ini_set('track_errors', true);
$fp = @fopen($config_file, "r"); $fp = @fopen($config_file, "r");
if (!is_resource($fp)) { if (!is_resource($fp)) {
$this->_trigger_error_msg("Could not open config file '$config_file'"); $this->_trigger_error_msg("Could not open config file '$config_file'");
return false; return false;
} }
$contents = fread($fp, filesize($config_file)); $contents = fread($fp, filesize($config_file));
fclose($fp); fclose($fp);
if($this->fix_newlines) { if($this->fix_newlines) {
// fix mac/dos formatted newlines // fix mac/dos formatted newlines
$contents = preg_replace('!\r\n?!',"\n",$contents); $contents = preg_replace('!\r\n?!',"\n",$contents);
} }
$config_data = array(); $config_data = array();
/* Get global variables first. */ /* Get global variables first. */
if ($contents{0} != '[' && preg_match("/^(.*?)(\n\[|\Z)/s", $contents, $match)) if ($contents{0} != '[' && preg_match("/^(.*?)(\n\[|\Z)/s", $contents, $match))
$config_data["vars"] = $this->_parse_config_block($match[1]); $config_data["vars"] = $this->_parse_config_block($match[1]);
/* Get section variables. */ /* Get section variables. */
$config_data["sections"] = array(); $config_data["sections"] = array();
preg_match_all("/^\[(.*?)\]/m", $contents, $match); preg_match_all("/^\[(.*?)\]/m", $contents, $match);
foreach ($match[1] as $section) { foreach ($match[1] as $section) {
if ($section{0} == '.' && !$this->read_hidden) if ($section{0} == '.' && !$this->read_hidden)
continue; continue;
if (preg_match("/\[".preg_quote($section, '/')."\](.*?)(\n\[|\Z)/s", $contents, $match)) if (preg_match("/\[".preg_quote($section, '/')."\](.*?)(\n\[|\Z)/s", $contents, $match))
if ($section{0} == '.') if ($section{0} == '.')
$section = substr($section, 1); $section = substr($section, 1);
$config_data["sections"][$section]["vars"] = $this->_parse_config_block($match[1]); $config_data["sections"][$section]["vars"] = $this->_parse_config_block($match[1]);
} }
$this->_config_data[$config_file] = $config_data; $this->_config_data[$config_file] = $config_data;
return true; return true;
} }
/**#@+ @access private */ /**#@+ @access private */
/** /**
* @var string $config_block * @var string $config_block
*/ */
function _parse_config_block($config_block) function _parse_config_block($config_block)
{ {
$vars = array(); $vars = array();
/* First we grab the multi-line values. */ /* First we grab the multi-line values. */
if (preg_match_all("/^([^=\n]+)=\s*\"{3}(.*?)\"{3}\s*$/ms", $config_block, $match, PREG_SET_ORDER)) { if (preg_match_all("/^([^=\n]+)=\s*\"{3}(.*?)\"{3}\s*$/ms", $config_block, $match, PREG_SET_ORDER)) {
for ($i = 0; $i < count($match); $i++) { for ($i = 0; $i < count($match); $i++) {
$this->_set_config_var($vars, trim($match[$i][1]), $match[$i][2], false); $this->_set_config_var($vars, trim($match[$i][1]), $match[$i][2], false);
} }
$config_block = preg_replace("/^[^=\n]+=\s*\"{3}.*?\"{3}\s*$/ms", "", $config_block); $config_block = preg_replace("/^[^=\n]+=\s*\"{3}.*?\"{3}\s*$/ms", "", $config_block);
} }
$config_lines = preg_split("/\n+/", $config_block); $config_lines = preg_split("/\n+/", $config_block);
foreach ($config_lines as $line) { foreach ($config_lines as $line) {
if (preg_match("/^\s*(\.?\w+)\s*=(.*)/", $line, $match)) { if (preg_match("/^\s*(\.?\w+)\s*=(.*)/", $line, $match)) {
$var_value = preg_replace('/^([\'"])(.*)\1$/', '\2', trim($match[2])); $var_value = preg_replace('/^([\'"])(.*)\1$/', '\2', trim($match[2]));
$this->_set_config_var($vars, trim($match[1]), $var_value, $this->booleanize); $this->_set_config_var($vars, trim($match[1]), $var_value, $this->booleanize);
} }
} }
return $vars; return $vars;
} }
/** /**
* @param array &$container * @param array &$container
@@ -312,44 +312,44 @@ class Config_File {
* @param boolean $booleanize determines whether $var_value is converted to * @param boolean $booleanize determines whether $var_value is converted to
* to true/false * to true/false
*/ */
function _set_config_var(&$container, $var_name, $var_value, $booleanize) function _set_config_var(&$container, $var_name, $var_value, $booleanize)
{ {
if ($var_name{0} == '.') { if ($var_name{0} == '.') {
if (!$this->read_hidden) if (!$this->read_hidden)
return; return;
else else
$var_name = substr($var_name, 1); $var_name = substr($var_name, 1);
} }
if (!preg_match("/^[a-zA-Z_]\w*$/", $var_name)) { if (!preg_match("/^[a-zA-Z_]\w*$/", $var_name)) {
$this->_trigger_error_msg("Bad variable name '$var_name'"); $this->_trigger_error_msg("Bad variable name '$var_name'");
return; return;
} }
if ($booleanize) { if ($booleanize) {
if (preg_match("/^(on|true|yes)$/i", $var_value)) if (preg_match("/^(on|true|yes)$/i", $var_value))
$var_value = true; $var_value = true;
else if (preg_match("/^(off|false|no)$/i", $var_value)) else if (preg_match("/^(off|false|no)$/i", $var_value))
$var_value = false; $var_value = false;
} }
if (!isset($container[$var_name]) || $this->overwrite) if (!isset($container[$var_name]) || $this->overwrite)
$container[$var_name] = $var_value; $container[$var_name] = $var_value;
else { else {
settype($container[$var_name], 'array'); settype($container[$var_name], 'array');
$container[$var_name][] = $var_value; $container[$var_name][] = $var_value;
} }
} }
/** /**
* @uses trigger_error() creates a PHP warning/error * @uses trigger_error() creates a PHP warning/error
* @param string $error_msg * @param string $error_msg
* @param integer $error_type one of * @param integer $error_type one of
*/ */
function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING) function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING)
{ {
trigger_error("Config_File error: $error_msg", $error_type); trigger_error("Config_File error: $error_msg", $error_type);
} }
/**#@-*/ /**#@-*/
} }

View File

@@ -49,7 +49,7 @@
* DIR_SEP isn't used anymore, but third party apps might * DIR_SEP isn't used anymore, but third party apps might
*/ */
if(!defined('DIR_SEP')) { if(!defined('DIR_SEP')) {
define('DIR_SEP', DIRECTORY_SEPARATOR); define('DIR_SEP', DIRECTORY_SEPARATOR);
} }
/** /**
@@ -234,7 +234,7 @@ class Smarty
'isset', 'empty', 'isset', 'empty',
'count', 'sizeof', 'count', 'sizeof',
'in_array', 'is_array', 'in_array', 'is_array',
'true','false'), 'true','false'),
'INCLUDE_ANY' => false, 'INCLUDE_ANY' => false,
'PHP_TAGS' => false, 'PHP_TAGS' => false,
'MODIFIER_FUNCS' => array('count'), 'MODIFIER_FUNCS' => array('count'),
@@ -313,13 +313,13 @@ class Smarty
/** /**
* This is the resource type to be used when not specified * This is the resource type to be used when not specified
* at the beginning of the resource path. examples: * at the beginning of the resource path. examples:
* $smarty->display('file:index.tpl'); * $smarty->display('file:index.tpl');
* $smarty->display('db:index.tpl'); * $smarty->display('db:index.tpl');
* $smarty->display('index.tpl'); // will use default resource type * $smarty->display('index.tpl'); // will use default resource type
* {include file="file:index.tpl"} * {include file="file:index.tpl"}
* {include file="db:index.tpl"} * {include file="db:index.tpl"}
* {include file="index.tpl"} {* will use default resource type *} * {include file="index.tpl"} {* will use default resource type *}
* *
* @var array * @var array
*/ */
@@ -657,33 +657,33 @@ class Smarty
function append($tpl_var, $value=null, $merge=false) function append($tpl_var, $value=null, $merge=false)
{ {
if (is_array($tpl_var)) { if (is_array($tpl_var)) {
// $tpl_var is an array, ignore $value // $tpl_var is an array, ignore $value
foreach ($tpl_var as $_key => $_val) { foreach ($tpl_var as $_key => $_val) {
if ($_key != '') { if ($_key != '') {
if(!@is_array($this->_tpl_vars[$_key])) { if(!@is_array($this->_tpl_vars[$_key])) {
settype($this->_tpl_vars[$_key],'array'); settype($this->_tpl_vars[$_key],'array');
} }
if($merge && is_array($_val)) { if($merge && is_array($_val)) {
foreach($_val as $_mkey => $_mval) { foreach($_val as $_mkey => $_mval) {
$this->_tpl_vars[$_key][$_mkey] = $_mval; $this->_tpl_vars[$_key][$_mkey] = $_mval;
} }
} else { } else {
$this->_tpl_vars[$_key][] = $_val; $this->_tpl_vars[$_key][] = $_val;
} }
} }
} }
} else { } else {
if ($tpl_var != '' && isset($value)) { if ($tpl_var != '' && isset($value)) {
if(!@is_array($this->_tpl_vars[$tpl_var])) { if(!@is_array($this->_tpl_vars[$tpl_var])) {
settype($this->_tpl_vars[$tpl_var],'array'); settype($this->_tpl_vars[$tpl_var],'array');
} }
if($merge && is_array($value)) { if($merge && is_array($value)) {
foreach($value as $_mkey => $_mval) { foreach($value as $_mkey => $_mval) {
$this->_tpl_vars[$tpl_var][$_mkey] = $_mval; $this->_tpl_vars[$tpl_var][$_mkey] = $_mval;
} }
} else { } else {
$this->_tpl_vars[$tpl_var][] = $value; $this->_tpl_vars[$tpl_var][] = $value;
} }
} }
} }
} }
@@ -697,16 +697,16 @@ class Smarty
function append_by_ref($tpl_var, &$value, $merge=false) function append_by_ref($tpl_var, &$value, $merge=false)
{ {
if ($tpl_var != '' && isset($value)) { if ($tpl_var != '' && isset($value)) {
if(!@is_array($this->_tpl_vars[$tpl_var])) { if(!@is_array($this->_tpl_vars[$tpl_var])) {
settype($this->_tpl_vars[$tpl_var],'array'); settype($this->_tpl_vars[$tpl_var],'array');
} }
if ($merge && is_array($value)) { if ($merge && is_array($value)) {
foreach($value as $_key => $_val) { foreach($value as $_key => $_val) {
$this->_tpl_vars[$tpl_var][$_key] = &$value[$_key]; $this->_tpl_vars[$tpl_var][$_key] = &$value[$_key];
} }
} else { } else {
$this->_tpl_vars[$tpl_var][] = &$value; $this->_tpl_vars[$tpl_var][] = &$value;
} }
} }
} }
@@ -887,7 +887,7 @@ class Smarty
*/ */
function register_prefilter($function) function register_prefilter($function)
{ {
$_name = (is_array($function)) ? $function[1] : $function; $_name = (is_array($function)) ? $function[1] : $function;
$this->_plugins['prefilter'][$_name] $this->_plugins['prefilter'][$_name]
= array($function, null, null, false); = array($function, null, null, false);
} }
@@ -910,7 +910,7 @@ class Smarty
*/ */
function register_postfilter($function) function register_postfilter($function)
{ {
$_name = (is_array($function)) ? $function[1] : $function; $_name = (is_array($function)) ? $function[1] : $function;
$this->_plugins['postfilter'][$_name] $this->_plugins['postfilter'][$_name]
= array($function, null, null, false); = array($function, null, null, false);
} }
@@ -933,7 +933,7 @@ class Smarty
*/ */
function register_outputfilter($function) function register_outputfilter($function)
{ {
$_name = (is_array($function)) ? $function[1] : $function; $_name = (is_array($function)) ? $function[1] : $function;
$this->_plugins['outputfilter'][$_name] $this->_plugins['outputfilter'][$_name]
= array($function, null, null, false); = array($function, null, null, false);
} }
@@ -958,8 +958,8 @@ class Smarty
{ {
switch ($type) { switch ($type) {
case 'output': case 'output':
$_params = array('plugins' => array(array($type . 'filter', $name, null, null, false))); $_params = array('plugins' => array(array($type . 'filter', $name, null, null, false)));
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php');
smarty_core_load_plugins($_params, $this); smarty_core_load_plugins($_params, $this);
break; break;
@@ -986,21 +986,21 @@ class Smarty
if (!isset($compile_id)) if (!isset($compile_id))
$compile_id = $this->compile_id; $compile_id = $this->compile_id;
if (!isset($tpl_file)) if (!isset($tpl_file))
$compile_id = null; $compile_id = null;
$_auto_id = $this->_get_auto_id($cache_id, $compile_id); $_auto_id = $this->_get_auto_id($cache_id, $compile_id);
if (!empty($this->cache_handler_func)) { if (!empty($this->cache_handler_func)) {
return call_user_func_array($this->cache_handler_func, return call_user_func_array($this->cache_handler_func,
array('clear', &$this, &$dummy, $tpl_file, $cache_id, $compile_id)); array('clear', &$this, &$dummy, $tpl_file, $cache_id, $compile_id));
} else { } else {
$_params = array('auto_base' => $this->cache_dir, $_params = array('auto_base' => $this->cache_dir,
'auto_source' => $tpl_file, 'auto_source' => $tpl_file,
'auto_id' => $_auto_id, 'auto_id' => $_auto_id,
'exp_time' => $exp_time); 'exp_time' => $exp_time);
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php');
return smarty_core_rm_auto($_params, $this); return smarty_core_rm_auto($_params, $this);
} }
} }
@@ -1018,12 +1018,12 @@ class Smarty
call_user_func_array($this->cache_handler_func, call_user_func_array($this->cache_handler_func,
array('clear', &$this, &$dummy)); array('clear', &$this, &$dummy));
} else { } else {
$_params = array('auto_base' => $this->cache_dir, $_params = array('auto_base' => $this->cache_dir,
'auto_source' => null, 'auto_source' => null,
'auto_id' => null, 'auto_id' => null,
'exp_time' => $exp_time); 'exp_time' => $exp_time);
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php');
return smarty_core_rm_auto($_params, $this); return smarty_core_rm_auto($_params, $this);
} }
} }
@@ -1044,12 +1044,12 @@ class Smarty
if (!isset($compile_id)) if (!isset($compile_id))
$compile_id = $this->compile_id; $compile_id = $this->compile_id;
$_params = array( $_params = array(
'tpl_file' => $tpl_file, 'tpl_file' => $tpl_file,
'cache_id' => $cache_id, 'cache_id' => $cache_id,
'compile_id' => $compile_id 'compile_id' => $compile_id
); );
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.read_cache_file.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.read_cache_file.php');
return smarty_core_read_cache_file($_params, $this); return smarty_core_read_cache_file($_params, $this);
} }
@@ -1076,15 +1076,15 @@ class Smarty
function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null) function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
{ {
if (!isset($compile_id)) { if (!isset($compile_id)) {
$compile_id = $this->compile_id; $compile_id = $this->compile_id;
} }
$_params = array('auto_base' => $this->compile_dir, $_params = array('auto_base' => $this->compile_dir,
'auto_source' => $tpl_file, 'auto_source' => $tpl_file,
'auto_id' => $compile_id, 'auto_id' => $compile_id,
'exp_time' => $exp_time, 'exp_time' => $exp_time,
'extensions' => array('.inc', '.php')); 'extensions' => array('.inc', '.php'));
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php');
return smarty_core_rm_auto($_params, $this); return smarty_core_rm_auto($_params, $this);
} }
/** /**
@@ -1095,7 +1095,7 @@ class Smarty
*/ */
function template_exists($tpl_file) function template_exists($tpl_file)
{ {
$_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false); $_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false);
return $this->_fetch_resource_info($_params); return $this->_fetch_resource_info($_params);
} }
@@ -1108,12 +1108,12 @@ class Smarty
*/ */
function &get_template_vars($name=null) function &get_template_vars($name=null)
{ {
if(!isset($name)) { if(!isset($name)) {
return $this->_tpl_vars; return $this->_tpl_vars;
} }
if(isset($this->_tpl_vars[$name])) { if(isset($this->_tpl_vars[$name])) {
return $this->_tpl_vars[$name]; return $this->_tpl_vars[$name];
} }
} }
/** /**
@@ -1125,11 +1125,11 @@ class Smarty
*/ */
function &get_config_vars($name=null) function &get_config_vars($name=null)
{ {
if(!isset($name) && is_array($this->_config[0])) { if(!isset($name) && is_array($this->_config[0])) {
return $this->_config[0]['vars']; return $this->_config[0]['vars'];
} else if(isset($this->_config[0]['vars'][$name])) { } else if(isset($this->_config[0]['vars'][$name])) {
return $this->_config[0]['vars'][$name]; return $this->_config[0]['vars'][$name];
} }
} }
/** /**
@@ -1183,8 +1183,8 @@ class Smarty
if ($this->debugging) { if ($this->debugging) {
// capture time for debugging info // capture time for debugging info
$_params = array(); $_params = array();
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
$_debug_start_time = smarty_core_get_microtime($_params, $this); $_debug_start_time = smarty_core_get_microtime($_params, $this);
$this->_smarty_debug_info[] = array('type' => 'template', $this->_smarty_debug_info[] = array('type' => 'template',
'filename' => $resource_name, 'filename' => $resource_name,
@@ -1203,21 +1203,21 @@ class Smarty
// save old cache_info, initialize cache_info // save old cache_info, initialize cache_info
array_push($_cache_info, $this->_cache_info); array_push($_cache_info, $this->_cache_info);
$this->_cache_info = array(); $this->_cache_info = array();
$_params = array( $_params = array(
'tpl_file' => $resource_name, 'tpl_file' => $resource_name,
'cache_id' => $cache_id, 'cache_id' => $cache_id,
'compile_id' => $compile_id, 'compile_id' => $compile_id,
'results' => null 'results' => null
); );
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.read_cache_file.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.read_cache_file.php');
if (smarty_core_read_cache_file($_params, $this)) { if (smarty_core_read_cache_file($_params, $this)) {
$_smarty_results = $_params['results']; $_smarty_results = $_params['results'];
if (@count($this->_cache_info['insert_tags'])) { if (@count($this->_cache_info['insert_tags'])) {
$_params = array('plugins' => $this->_cache_info['insert_tags']); $_params = array('plugins' => $this->_cache_info['insert_tags']);
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php');
smarty_core_load_plugins($_params, $this); smarty_core_load_plugins($_params, $this);
$_params = array('results' => $_smarty_results); $_params = array('results' => $_smarty_results);
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_cached_inserts.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_cached_inserts.php');
$_smarty_results = smarty_core_process_cached_inserts($_params, $this); $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
} }
if (@count($this->_cache_info['cache_serials'])) { if (@count($this->_cache_info['cache_serials'])) {
@@ -1231,10 +1231,10 @@ class Smarty
if ($this->debugging) if ($this->debugging)
{ {
// capture time for debugging info // capture time for debugging info
$_params = array(); $_params = array();
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
$this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time; $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time;
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.display_debug_console.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.display_debug_console.php');
$_smarty_results .= smarty_core_display_debug_console($_params, $this); $_smarty_results .= smarty_core_display_debug_console($_params, $this);
} }
if ($this->cache_modified_check) { if ($this->cache_modified_check) {
@@ -1273,13 +1273,13 @@ class Smarty
} }
} }
// load filters that are marked as autoload // load filters that are marked as autoload
if (count($this->autoload_filters)) { if (count($this->autoload_filters)) {
foreach ($this->autoload_filters as $_filter_type => $_filters) { foreach ($this->autoload_filters as $_filter_type => $_filters) {
foreach ($_filters as $_filter) { foreach ($_filters as $_filter) {
$this->load_filter($_filter_type, $_filter); $this->load_filter($_filter_type, $_filter);
} }
} }
} }
$_smarty_compile_path = $this->_get_compile_path($resource_name); $_smarty_compile_path = $this->_get_compile_path($resource_name);
@@ -1290,14 +1290,14 @@ class Smarty
$this->_cache_including = false; $this->_cache_including = false;
if ($display && !$this->caching && count($this->_plugins['outputfilter']) == 0) { if ($display && !$this->caching && count($this->_plugins['outputfilter']) == 0) {
if ($this->_is_compiled($resource_name, $_smarty_compile_path) if ($this->_is_compiled($resource_name, $_smarty_compile_path)
|| $this->_compile_resource($resource_name, $_smarty_compile_path)) || $this->_compile_resource($resource_name, $_smarty_compile_path))
{ {
include($_smarty_compile_path); include($_smarty_compile_path);
} }
} else { } else {
ob_start(); ob_start();
if ($this->_is_compiled($resource_name, $_smarty_compile_path) if ($this->_is_compiled($resource_name, $_smarty_compile_path)
|| $this->_compile_resource($resource_name, $_smarty_compile_path)) || $this->_compile_resource($resource_name, $_smarty_compile_path))
{ {
include($_smarty_compile_path); include($_smarty_compile_path);
} }
@@ -1310,14 +1310,14 @@ class Smarty
} }
if ($this->caching) { if ($this->caching) {
$_params = array('tpl_file' => $resource_name, $_params = array('tpl_file' => $resource_name,
'cache_id' => $cache_id, 'cache_id' => $cache_id,
'compile_id' => $compile_id, 'compile_id' => $compile_id,
'results' => $_smarty_results); 'results' => $_smarty_results);
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_cache_file.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_cache_file.php');
smarty_core_write_cache_file($_params, $this); smarty_core_write_cache_file($_params, $this);
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_cached_inserts.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_cached_inserts.php');
$_smarty_results = smarty_core_process_cached_inserts($_params, $this); $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
if ($this->_cache_serials) { if ($this->_cache_serials) {
// strip nocache-tags from output // strip nocache-tags from output
@@ -1334,10 +1334,10 @@ class Smarty
if (isset($_smarty_results)) { echo $_smarty_results; } if (isset($_smarty_results)) { echo $_smarty_results; }
if ($this->debugging) { if ($this->debugging) {
// capture time for debugging info // capture time for debugging info
$_params = array(); $_params = array();
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
$this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time); $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time);
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.display_debug_console.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.display_debug_console.php');
echo smarty_core_display_debug_console($_params, $this); echo smarty_core_display_debug_console($_params, $this);
} }
error_reporting($_smarty_old_error_level); error_reporting($_smarty_old_error_level);
@@ -1357,8 +1357,8 @@ class Smarty
*/ */
function config_load($file, $section = null, $scope = 'global') function config_load($file, $section = null, $scope = 'global')
{ {
require_once($this->_get_plugin_filepath('function', 'config_load')); require_once($this->_get_plugin_filepath('function', 'config_load'));
smarty_function_config_load(array('file' => $file, 'section' => $section, 'scope' => $scope), $this); smarty_function_config_load(array('file' => $file, 'section' => $section, 'scope' => $scope), $this);
} }
/** /**
@@ -1367,15 +1367,15 @@ class Smarty
* @param string $name * @param string $name
* @return object * @return object
*/ */
function &get_registered_object($name) { function &get_registered_object($name) {
if (!isset($this->_reg_objects[$name])) if (!isset($this->_reg_objects[$name]))
$this->_trigger_fatal_error("'$name' is not a registered object"); $this->_trigger_fatal_error("'$name' is not a registered object");
if (!is_object($this->_reg_objects[$name][0])) if (!is_object($this->_reg_objects[$name][0]))
$this->_trigger_fatal_error("registered '$name' is not an object"); $this->_trigger_fatal_error("registered '$name' is not an object");
return $this->_reg_objects[$name][0]; return $this->_reg_objects[$name][0];
} }
/** /**
* clear configuration values * clear configuration values
@@ -1413,9 +1413,9 @@ class Smarty
*/ */
function _get_plugin_filepath($type, $name) function _get_plugin_filepath($type, $name)
{ {
$_params = array('type' => $type, 'name' => $name); $_params = array('type' => $type, 'name' => $name);
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.assemble_plugin_filepath.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.assemble_plugin_filepath.php');
return smarty_core_assemble_plugin_filepath($_params, $this); return smarty_core_assemble_plugin_filepath($_params, $this);
} }
/** /**
@@ -1433,7 +1433,7 @@ class Smarty
return true; return true;
} else { } else {
// get file source and timestamp // get file source and timestamp
$_params = array('resource_name' => $resource_name, 'get_source'=>false); $_params = array('resource_name' => $resource_name, 'get_source'=>false);
if (!$this->_fetch_resource_info($_params, $this)) { if (!$this->_fetch_resource_info($_params, $this)) {
return false; return false;
} }
@@ -1441,7 +1441,7 @@ class Smarty
// template not expired, no recompile // template not expired, no recompile
return true; return true;
} else { } else {
// compile template // compile template
return false; return false;
} }
} }
@@ -1461,13 +1461,13 @@ class Smarty
function _compile_resource($resource_name, $compile_path) function _compile_resource($resource_name, $compile_path)
{ {
$_params = array('resource_name' => $resource_name); $_params = array('resource_name' => $resource_name);
if (!$this->_fetch_resource_info($_params)) { if (!$this->_fetch_resource_info($_params)) {
return false; return false;
} }
$_source_content = $_params['source_content']; $_source_content = $_params['source_content'];
$_resource_timestamp = $_params['resource_timestamp']; $_resource_timestamp = $_params['resource_timestamp'];
$_cache_include = substr($compile_path, 0, -4).'.inc'; $_cache_include = substr($compile_path, 0, -4).'.inc';
if ($this->_compile_source($resource_name, $_source_content, $_compiled_content, $_cache_include)) { if ($this->_compile_source($resource_name, $_source_content, $_compiled_content, $_cache_include)) {
@@ -1477,9 +1477,9 @@ class Smarty
smarty_core_write_compiled_include(array_merge($this->_cache_include_info, array('compiled_content'=>$_compiled_content)), $this); smarty_core_write_compiled_include(array_merge($this->_cache_include_info, array('compiled_content'=>$_compiled_content)), $this);
} }
$_params = array('compile_path'=>$compile_path, 'compiled_content' => $_compiled_content, 'resource_timestamp' => $_resource_timestamp); $_params = array('compile_path'=>$compile_path, 'compiled_content' => $_compiled_content, 'resource_timestamp' => $_resource_timestamp);
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_resource.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_resource.php');
smarty_core_write_compiled_resource($_params, $this); smarty_core_write_compiled_resource($_params, $this);
return true; return true;
} else { } else {
@@ -1528,14 +1528,14 @@ class Smarty
$smarty_compiler->_tpl_vars = &$this->_tpl_vars; $smarty_compiler->_tpl_vars = &$this->_tpl_vars;
$smarty_compiler->default_modifiers = $this->default_modifiers; $smarty_compiler->default_modifiers = $this->default_modifiers;
$smarty_compiler->compile_id = $this->_compile_id; $smarty_compiler->compile_id = $this->_compile_id;
$smarty_compiler->_config = $this->_config; $smarty_compiler->_config = $this->_config;
$smarty_compiler->request_use_auto_globals = $this->request_use_auto_globals; $smarty_compiler->request_use_auto_globals = $this->request_use_auto_globals;
$smarty_compiler->_cache_serial = null; $smarty_compiler->_cache_serial = null;
$smarty_compiler->_cache_include = $cache_include_path; $smarty_compiler->_cache_include = $cache_include_path;
$_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content); $_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content);
if ($smarty_compiler->_cache_serial) { if ($smarty_compiler->_cache_serial) {
$this->_cache_include_info = array( $this->_cache_include_info = array(
@@ -1548,8 +1548,8 @@ class Smarty
} }
return $_results; return $_results;
} }
/** /**
* Get the compile path for this resource * Get the compile path for this resource
@@ -1867,12 +1867,12 @@ class Smarty
* @return string|null * @return string|null
*/ */
function _get_auto_id($cache_id=null, $compile_id=null) { function _get_auto_id($cache_id=null, $compile_id=null) {
if (isset($cache_id)) if (isset($cache_id))
return (isset($compile_id)) ? $cache_id . '|' . $compile_id : $cache_id; return (isset($compile_id)) ? $cache_id . '|' . $compile_id : $cache_id;
elseif(isset($compile_id)) elseif(isset($compile_id))
return $compile_id; return $compile_id;
else else
return null; return null;
} }
/** /**

File diff suppressed because it is too large Load Diff

View File

@@ -38,21 +38,21 @@ function smarty_core_assemble_plugin_filepath($params, &$smarty)
} }
} }
if($_return === false) { if($_return === false) {
// still not found, try PHP include_path // still not found, try PHP include_path
if(isset($_relative_paths)) { if(isset($_relative_paths)) {
foreach ((array)$_relative_paths as $_plugin_dir) { foreach ((array)$_relative_paths as $_plugin_dir) {
$_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
$_params = array('file_path' => $_plugin_filepath); $_params = array('file_path' => $_plugin_filepath);
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php');
if(smarty_core_get_include_path($_params, $smarty)) { if(smarty_core_get_include_path($_params, $smarty)) {
return $_params['new_file_path']; return $_params['new_file_path'];
} }
} }
} }
} }
return $_return; return $_return;
} }

View File

@@ -18,7 +18,7 @@ function smarty_core_assign_smarty_interface($params, &$smarty)
{ {
if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars['request'])) { if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars['request'])) {
return; return;
} }
$_globals_map = array('g' => 'HTTP_GET_VARS', $_globals_map = array('g' => 'HTTP_GET_VARS',
'p' => 'HTTP_POST_VARS', 'p' => 'HTTP_POST_VARS',

View File

@@ -16,43 +16,43 @@
*/ */
function smarty_core_display_debug_console($params, &$smarty) function smarty_core_display_debug_console($params, &$smarty)
{ {
// we must force compile the debug template in case the environment // we must force compile the debug template in case the environment
// changed between separate applications. // changed between separate applications.
if(empty($smarty->debug_tpl)) { if(empty($smarty->debug_tpl)) {
// set path to debug template from SMARTY_DIR // set path to debug template from SMARTY_DIR
$smarty->debug_tpl = SMARTY_DIR . 'debug.tpl'; $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl';
if($smarty->security && is_file($smarty->debug_tpl)) { if($smarty->security && is_file($smarty->debug_tpl)) {
$smarty->secure_dir[] = dirname(realpath($smarty->debug_tpl)); $smarty->secure_dir[] = dirname(realpath($smarty->debug_tpl));
} }
} }
$_ldelim_orig = $smarty->left_delimiter; $_ldelim_orig = $smarty->left_delimiter;
$_rdelim_orig = $smarty->right_delimiter; $_rdelim_orig = $smarty->right_delimiter;
$smarty->left_delimiter = '{'; $smarty->left_delimiter = '{';
$smarty->right_delimiter = '}'; $smarty->right_delimiter = '}';
$_compile_id_orig = $smarty->_compile_id; $_compile_id_orig = $smarty->_compile_id;
$smarty->_compile_id = null; $smarty->_compile_id = null;
$_compile_path = $smarty->_get_compile_path($smarty->debug_tpl); $_compile_path = $smarty->_get_compile_path($smarty->debug_tpl);
if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path)) if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path))
{ {
ob_start(); ob_start();
$smarty->_include($_compile_path); $smarty->_include($_compile_path);
$_results = ob_get_contents(); $_results = ob_get_contents();
ob_end_clean(); ob_end_clean();
} else { } else {
$_results = ''; $_results = '';
} }
$smarty->_compile_id = $_compile_id_orig; $smarty->_compile_id = $_compile_id_orig;
$smarty->left_delimiter = $_ldelim_orig; $smarty->left_delimiter = $_ldelim_orig;
$smarty->right_delimiter = $_rdelim_orig; $smarty->right_delimiter = $_rdelim_orig;
return $_results; return $_results;
} }
/* vim: set expandtab: */ /* vim: set expandtab: */

View File

@@ -18,8 +18,8 @@
function smarty_core_get_php_resource(&$params, &$smarty) function smarty_core_get_php_resource(&$params, &$smarty)
{ {
$params['resource_base_path'] = $smarty->trusted_dir; $params['resource_base_path'] = $smarty->trusted_dir;
$smarty->_parse_resource_name($params, $smarty); $smarty->_parse_resource_name($params, $smarty);
/* /*
* Find out if the resource exists. * Find out if the resource exists.
@@ -31,15 +31,15 @@ function smarty_core_get_php_resource(&$params, &$smarty)
$_readable = true; $_readable = true;
} else { } else {
// test for file in include_path // test for file in include_path
$_params = array('file_path' => $params['resource_name']); $_params = array('file_path' => $params['resource_name']);
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_include_path.php');
if(smarty_core_get_include_path($_params, $smarty)) { if(smarty_core_get_include_path($_params, $smarty)) {
$_include_path = $_params['new_file_path']; $_include_path = $_params['new_file_path'];
$_readable = true; $_readable = true;
} }
} }
} else if ($params['resource_type'] != 'file') { } else if ($params['resource_type'] != 'file') {
$_template_source = null; $_template_source = null;
$_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0]) $_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0])
&& call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0], && call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0],
array($params['resource_name'], &$_template_source, &$smarty)); array($params['resource_name'], &$_template_source, &$smarty));
@@ -56,7 +56,7 @@ function smarty_core_get_php_resource(&$params, &$smarty)
if ($_readable) { if ($_readable) {
if ($smarty->security) { if ($smarty->security) {
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_trusted.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.is_trusted.php');
if (!smarty_core_is_trusted($params, $smarty)) { if (!smarty_core_is_trusted($params, $smarty)) {
$smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted'); $smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted');
return false; return false;

View File

@@ -19,8 +19,8 @@ function smarty_core_process_cached_inserts($params, &$smarty)
for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) { for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) {
if ($smarty->debugging) { if ($smarty->debugging) {
$_params = array(); $_params = array();
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
$debug_start_time = smarty_core_get_microtime($_params, $smarty); $debug_start_time = smarty_core_get_microtime($_params, $smarty);
} }
@@ -28,13 +28,13 @@ function smarty_core_process_cached_inserts($params, &$smarty)
$name = $args['name']; $name = $args['name'];
if (isset($args['script'])) { if (isset($args['script'])) {
$_params = array('resource_name' => $smarty->_dequote($args['script'])); $_params = array('resource_name' => $smarty->_dequote($args['script']));
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php');
if(!smarty_core_get_php_resource($_params, $smarty)) { if(!smarty_core_get_php_resource($_params, $smarty)) {
return false; return false;
} }
$resource_type = $_params['resource_type']; $resource_type = $_params['resource_type'];
$php_resource = $_params['php_resource']; $php_resource = $_params['php_resource'];
if ($resource_type == 'file') { if ($resource_type == 'file') {
@@ -49,8 +49,8 @@ function smarty_core_process_cached_inserts($params, &$smarty)
$params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']); $params['results'] = str_replace($cached_inserts[$i], $replace, $params['results']);
if ($smarty->debugging) { if ($smarty->debugging) {
$_params = array(); $_params = array();
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
$smarty->_smarty_debug_info[] = array('type' => 'insert', $smarty->_smarty_debug_info[] = array('type' => 'insert',
'filename' => 'insert_'.$name, 'filename' => 'insert_'.$name,
'depth' => $smarty->_inclusion_depth, 'depth' => $smarty->_inclusion_depth,

View File

@@ -23,12 +23,12 @@ function smarty_core_rm_auto($params, &$smarty)
return false; return false;
if(!isset($params['auto_id']) && !isset($params['auto_source'])) { if(!isset($params['auto_id']) && !isset($params['auto_source'])) {
$_params = array( $_params = array(
'dirname' => $params['auto_base'], 'dirname' => $params['auto_base'],
'level' => 0, 'level' => 0,
'exp_time' => $params['exp_time'] 'exp_time' => $params['exp_time']
); );
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php');
$_res = smarty_core_rmdir($_params, $smarty); $_res = smarty_core_rmdir($_params, $smarty);
} else { } else {
$_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']); $_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']);
@@ -42,17 +42,17 @@ function smarty_core_rm_auto($params, &$smarty)
$_res = $smarty->_unlink($_tname, $params['exp_time']); $_res = $smarty->_unlink($_tname, $params['exp_time']);
} }
} elseif ($smarty->use_sub_dirs) { } elseif ($smarty->use_sub_dirs) {
$_params = array( $_params = array(
'dirname' => $_tname, 'dirname' => $_tname,
'level' => 1, 'level' => 1,
'exp_time' => $params['exp_time'] 'exp_time' => $params['exp_time']
); );
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php');
$_res = smarty_core_rmdir($_params, $smarty); $_res = smarty_core_rmdir($_params, $smarty);
} else { } else {
// remove matching file names // remove matching file names
$_handle = opendir($params['auto_base']); $_handle = opendir($params['auto_base']);
$_res = true; $_res = true;
while (false !== ($_filename = readdir($_handle))) { while (false !== ($_filename = readdir($_handle))) {
if($_filename == '.' || $_filename == '..') { if($_filename == '.' || $_filename == '..') {
continue; continue;

View File

@@ -27,13 +27,13 @@ function smarty_core_rmdir($params, &$smarty)
while (false !== ($_entry = readdir($_handle))) { while (false !== ($_entry = readdir($_handle))) {
if ($_entry != '.' && $_entry != '..') { if ($_entry != '.' && $_entry != '..') {
if (@is_dir($params['dirname'] . DIRECTORY_SEPARATOR . $_entry)) { if (@is_dir($params['dirname'] . DIRECTORY_SEPARATOR . $_entry)) {
$_params = array( $_params = array(
'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR . $_entry, 'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR . $_entry,
'level' => $params['level'] + 1, 'level' => $params['level'] + 1,
'exp_time' => $params['exp_time'] 'exp_time' => $params['exp_time']
); );
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rmdir.php');
smarty_core_rmdir($_params, $smarty); smarty_core_rmdir($_params, $smarty);
} }
else { else {
$smarty->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']); $smarty->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']);

View File

@@ -14,9 +14,9 @@
function smarty_core_run_insert_handler($params, &$smarty) function smarty_core_run_insert_handler($params, &$smarty)
{ {
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
if ($smarty->debugging) { if ($smarty->debugging) {
$_params = array(); $_params = array();
$_debug_start_time = smarty_core_get_microtime($_params, $smarty); $_debug_start_time = smarty_core_get_microtime($_params, $smarty);
} }
@@ -33,11 +33,11 @@ function smarty_core_run_insert_handler($params, &$smarty)
return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5; return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5;
} else { } else {
if (isset($params['args']['script'])) { if (isset($params['args']['script'])) {
$_params = array('resource_name' => $smarty->_dequote($params['args']['script'])); $_params = array('resource_name' => $smarty->_dequote($params['args']['script']));
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_php_resource.php');
if(!smarty_core_get_php_resource($_params, $smarty)) { if(!smarty_core_get_php_resource($_params, $smarty)) {
return false; return false;
} }
if ($_params['resource_type'] == 'file') { if ($_params['resource_type'] == 'file') {
$smarty->_include($_params['php_resource'], true); $smarty->_include($_params['php_resource'], true);
@@ -50,8 +50,8 @@ function smarty_core_run_insert_handler($params, &$smarty)
$_funcname = $smarty->_plugins['insert'][$params['args']['name']][0]; $_funcname = $smarty->_plugins['insert'][$params['args']['name']][0];
$_content = $_funcname($params['args'], $smarty); $_content = $_funcname($params['args'], $smarty);
if ($smarty->debugging) { if ($smarty->debugging) {
$_params = array(); $_params = array();
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.get_microtime.php');
$smarty->_smarty_debug_info[] = array('type' => 'insert', $smarty->_smarty_debug_info[] = array('type' => 'insert',
'filename' => 'insert_'.$params['args']['name'], 'filename' => 'insert_'.$params['args']['name'],
'depth' => $smarty->_inclusion_depth, 'depth' => $smarty->_inclusion_depth,

View File

@@ -47,12 +47,12 @@ $_match[4]
} }
$_include_compiled .= "\n\n?>\n"; $_include_compiled .= "\n\n?>\n";
$_params = array('filename' => $_compile_path, $_params = array('filename' => $_compile_path,
'contents' => $_include_compiled, 'create_dirs' => true); 'contents' => $_include_compiled, 'create_dirs' => true);
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php');
smarty_core_write_file($_params, $smarty); smarty_core_write_file($_params, $smarty);
return true; return true;
} }

View File

@@ -15,19 +15,19 @@
*/ */
function smarty_core_write_compiled_resource($params, &$smarty) function smarty_core_write_compiled_resource($params, &$smarty)
{ {
if(!@is_writable($smarty->compile_dir)) { if(!@is_writable($smarty->compile_dir)) {
// compile_dir not writable, see if it exists // compile_dir not writable, see if it exists
if(!@is_dir($smarty->compile_dir)) { if(!@is_dir($smarty->compile_dir)) {
$smarty->trigger_error('the $compile_dir \'' . $smarty->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); $smarty->trigger_error('the $compile_dir \'' . $smarty->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR);
return false; return false;
} }
$smarty->trigger_error('unable to write to $compile_dir \'' . realpath($smarty->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR); $smarty->trigger_error('unable to write to $compile_dir \'' . realpath($smarty->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR);
return false; return false;
} }
$_params = array('filename' => $params['compile_path'], 'contents' => $params['compiled_content'], 'create_dirs' => true); $_params = array('filename' => $params['compile_path'], 'contents' => $params['compiled_content'], 'create_dirs' => true);
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php'); require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_file.php');
smarty_core_write_file($_params, $smarty); smarty_core_write_file($_params, $smarty);
touch($params['compile_path'], $params['resource_timestamp']); touch($params['compile_path'], $params['resource_timestamp']);
return true; return true;
} }