mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
Fixup some naming.
This commit is contained in:
@@ -463,6 +463,16 @@ class Smarty
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*======================================================================*\
|
||||||
|
Function: trigger_error
|
||||||
|
Purpose: trigger Smarty error
|
||||||
|
\*======================================================================*/
|
||||||
|
function trigger_error($error_msg, $error_type = E_USER_WARNING)
|
||||||
|
{
|
||||||
|
trigger_error("Smarty error: $error_msg", $error_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: display()
|
Function: display()
|
||||||
Purpose: executes & displays the template results
|
Purpose: executes & displays the template results
|
||||||
@@ -751,7 +761,7 @@ function _generate_debug_output() {
|
|||||||
if (method_exists($this, '_syntax_error')) {
|
if (method_exists($this, '_syntax_error')) {
|
||||||
$error_func = '_syntax_error';
|
$error_func = '_syntax_error';
|
||||||
} else {
|
} else {
|
||||||
$error_func = '_trigger_error_msg';
|
$error_func = 'trigger_error';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($readable) {
|
if ($readable) {
|
||||||
@@ -916,7 +926,7 @@ function _generate_debug_output() {
|
|||||||
// see if we can get a template with the default template handler
|
// see if we can get a template with the default template handler
|
||||||
if (!empty($this->default_template_handler_func)) {
|
if (!empty($this->default_template_handler_func)) {
|
||||||
if (!function_exists($this->default_template_handler_func)) {
|
if (!function_exists($this->default_template_handler_func)) {
|
||||||
$this->_trigger_error_msg("default template handler function \"$this->default_template_handler_func\" doesn't exist.");
|
$this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist.");
|
||||||
$_return = false;
|
$_return = false;
|
||||||
}
|
}
|
||||||
$funcname = $this->default_template_handler_func;
|
$funcname = $this->default_template_handler_func;
|
||||||
@@ -925,9 +935,9 @@ function _generate_debug_output() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$_return) {
|
if (!$_return) {
|
||||||
$this->_trigger_error_msg("unable to read template resource: \"$tpl_path\"");
|
$this->trigger_error("unable to read template resource: \"$tpl_path\"");
|
||||||
} else if ($_return && $this->security && !$this->_is_secure($resource_type, $resource_name)) {
|
} else if ($_return && $this->security && !$this->_is_secure($resource_type, $resource_name)) {
|
||||||
$this->_trigger_error_msg("(secure mode) accessing \"$tpl_path\" is not allowed");
|
$this->trigger_error("(secure mode) accessing \"$tpl_path\" is not allowed");
|
||||||
$template_source = null;
|
$template_source = null;
|
||||||
$template_timestamp = null;
|
$template_timestamp = null;
|
||||||
return false;
|
return false;
|
||||||
@@ -966,7 +976,7 @@ function _generate_debug_output() {
|
|||||||
if ($smarty_compiler->_compile_file($tpl_file, $template_source, $template_compiled))
|
if ($smarty_compiler->_compile_file($tpl_file, $template_source, $template_compiled))
|
||||||
return true;
|
return true;
|
||||||
else {
|
else {
|
||||||
$this->_trigger_error_msg($smarty_compiler->_error_msg);
|
$this->trigger_error($smarty_compiler->_error_msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1265,7 +1275,7 @@ function _run_insert_handler($args)
|
|||||||
$this->_create_dir_structure(dirname($filename));
|
$this->_create_dir_structure(dirname($filename));
|
||||||
|
|
||||||
if (!($fd = @fopen($filename, 'w'))) {
|
if (!($fd = @fopen($filename, 'w'))) {
|
||||||
$this->_trigger_error_msg("problem writing '$filename.'");
|
$this->trigger_error("problem writing '$filename.'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1359,7 +1369,7 @@ function _run_insert_handler($args)
|
|||||||
foreach ($dir_parts as $dir_part) {
|
foreach ($dir_parts as $dir_part) {
|
||||||
$new_dir .= $dir_part;
|
$new_dir .= $dir_part;
|
||||||
if (!file_exists($new_dir) && !mkdir($new_dir, 0771)) {
|
if (!file_exists($new_dir) && !mkdir($new_dir, 0771)) {
|
||||||
$this->_trigger_error_msg("problem creating directory \"$dir\"");
|
$this->trigger_error("problem creating directory \"$dir\"");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$new_dir .= '/';
|
$new_dir .= '/';
|
||||||
@@ -1664,15 +1674,6 @@ function _run_insert_handler($args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*======================================================================*\
|
|
||||||
Function: _trigger_error_msg
|
|
||||||
Purpose: trigger Smarty error
|
|
||||||
\*======================================================================*/
|
|
||||||
function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING)
|
|
||||||
{
|
|
||||||
trigger_error("Smarty error: $error_msg", $error_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: _trigger_plugin_error
|
Function: _trigger_plugin_error
|
||||||
Purpose: trigger Smarty plugin error
|
Purpose: trigger Smarty plugin error
|
||||||
|
@@ -463,6 +463,16 @@ class Smarty
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*======================================================================*\
|
||||||
|
Function: trigger_error
|
||||||
|
Purpose: trigger Smarty error
|
||||||
|
\*======================================================================*/
|
||||||
|
function trigger_error($error_msg, $error_type = E_USER_WARNING)
|
||||||
|
{
|
||||||
|
trigger_error("Smarty error: $error_msg", $error_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: display()
|
Function: display()
|
||||||
Purpose: executes & displays the template results
|
Purpose: executes & displays the template results
|
||||||
@@ -751,7 +761,7 @@ function _generate_debug_output() {
|
|||||||
if (method_exists($this, '_syntax_error')) {
|
if (method_exists($this, '_syntax_error')) {
|
||||||
$error_func = '_syntax_error';
|
$error_func = '_syntax_error';
|
||||||
} else {
|
} else {
|
||||||
$error_func = '_trigger_error_msg';
|
$error_func = 'trigger_error';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($readable) {
|
if ($readable) {
|
||||||
@@ -916,7 +926,7 @@ function _generate_debug_output() {
|
|||||||
// see if we can get a template with the default template handler
|
// see if we can get a template with the default template handler
|
||||||
if (!empty($this->default_template_handler_func)) {
|
if (!empty($this->default_template_handler_func)) {
|
||||||
if (!function_exists($this->default_template_handler_func)) {
|
if (!function_exists($this->default_template_handler_func)) {
|
||||||
$this->_trigger_error_msg("default template handler function \"$this->default_template_handler_func\" doesn't exist.");
|
$this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist.");
|
||||||
$_return = false;
|
$_return = false;
|
||||||
}
|
}
|
||||||
$funcname = $this->default_template_handler_func;
|
$funcname = $this->default_template_handler_func;
|
||||||
@@ -925,9 +935,9 @@ function _generate_debug_output() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!$_return) {
|
if (!$_return) {
|
||||||
$this->_trigger_error_msg("unable to read template resource: \"$tpl_path\"");
|
$this->trigger_error("unable to read template resource: \"$tpl_path\"");
|
||||||
} else if ($_return && $this->security && !$this->_is_secure($resource_type, $resource_name)) {
|
} else if ($_return && $this->security && !$this->_is_secure($resource_type, $resource_name)) {
|
||||||
$this->_trigger_error_msg("(secure mode) accessing \"$tpl_path\" is not allowed");
|
$this->trigger_error("(secure mode) accessing \"$tpl_path\" is not allowed");
|
||||||
$template_source = null;
|
$template_source = null;
|
||||||
$template_timestamp = null;
|
$template_timestamp = null;
|
||||||
return false;
|
return false;
|
||||||
@@ -966,7 +976,7 @@ function _generate_debug_output() {
|
|||||||
if ($smarty_compiler->_compile_file($tpl_file, $template_source, $template_compiled))
|
if ($smarty_compiler->_compile_file($tpl_file, $template_source, $template_compiled))
|
||||||
return true;
|
return true;
|
||||||
else {
|
else {
|
||||||
$this->_trigger_error_msg($smarty_compiler->_error_msg);
|
$this->trigger_error($smarty_compiler->_error_msg);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1265,7 +1275,7 @@ function _run_insert_handler($args)
|
|||||||
$this->_create_dir_structure(dirname($filename));
|
$this->_create_dir_structure(dirname($filename));
|
||||||
|
|
||||||
if (!($fd = @fopen($filename, 'w'))) {
|
if (!($fd = @fopen($filename, 'w'))) {
|
||||||
$this->_trigger_error_msg("problem writing '$filename.'");
|
$this->trigger_error("problem writing '$filename.'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1359,7 +1369,7 @@ function _run_insert_handler($args)
|
|||||||
foreach ($dir_parts as $dir_part) {
|
foreach ($dir_parts as $dir_part) {
|
||||||
$new_dir .= $dir_part;
|
$new_dir .= $dir_part;
|
||||||
if (!file_exists($new_dir) && !mkdir($new_dir, 0771)) {
|
if (!file_exists($new_dir) && !mkdir($new_dir, 0771)) {
|
||||||
$this->_trigger_error_msg("problem creating directory \"$dir\"");
|
$this->trigger_error("problem creating directory \"$dir\"");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$new_dir .= '/';
|
$new_dir .= '/';
|
||||||
@@ -1664,15 +1674,6 @@ function _run_insert_handler($args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*======================================================================*\
|
|
||||||
Function: _trigger_error_msg
|
|
||||||
Purpose: trigger Smarty error
|
|
||||||
\*======================================================================*/
|
|
||||||
function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING)
|
|
||||||
{
|
|
||||||
trigger_error("Smarty error: $error_msg", $error_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*======================================================================*\
|
/*======================================================================*\
|
||||||
Function: _trigger_plugin_error
|
Function: _trigger_plugin_error
|
||||||
Purpose: trigger Smarty plugin error
|
Purpose: trigger Smarty plugin error
|
||||||
|
@@ -8,22 +8,21 @@
|
|||||||
* Purpose: assign a value to a template variable
|
* Purpose: assign a value to a template variable
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_assign($args, &$smarty_obj)
|
function smarty_function_assign($params, &$smarty)
|
||||||
{
|
{
|
||||||
extract($args);
|
extract($params);
|
||||||
|
|
||||||
if (empty($var)) {
|
if (empty($var)) {
|
||||||
$smarty_obj->_trigger_error_msg("assign: missing 'var' parameter");
|
$smarty->trigger_error("assign: missing 'var' parameter");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array('value', array_keys($args))) {
|
if (!in_array('value', array_keys($params))) {
|
||||||
$smarty_obj->_trigger_error_msg("assign: missing 'value' parameter");
|
$smarty->trigger_error("assign: missing 'value' parameter");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$smarty_obj->assign($var, $value);
|
$smarty->assign($var, $value);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
/* vim: set expandtab: */
|
||||||
|
@@ -8,23 +8,23 @@
|
|||||||
* Purpose: assign debug info to the template
|
* Purpose: assign debug info to the template
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_assign_debug_info($args, &$smarty_obj)
|
function smarty_function_assign_debug_info($params, &$smarty)
|
||||||
{
|
{
|
||||||
$assigned_vars = $smarty_obj->_tpl_vars;
|
$assigned_vars = $smarty->_tpl_vars;
|
||||||
ksort($assigned_vars);
|
ksort($assigned_vars);
|
||||||
if (is_array($smarty_obj->_config[0])) {
|
if (is_array($smarty->_config[0])) {
|
||||||
$config_vars = $smarty_obj->_config[0];
|
$config_vars = $smarty->_config[0];
|
||||||
ksort($config_vars);
|
ksort($config_vars);
|
||||||
$smarty_obj->assign("_debug_config_keys", array_keys($config_vars));
|
$smarty->assign("_debug_config_keys", array_keys($config_vars));
|
||||||
$smarty_obj->assign("_debug_config_vals", array_values($config_vars));
|
$smarty->assign("_debug_config_vals", array_values($config_vars));
|
||||||
}
|
}
|
||||||
|
|
||||||
$included_templates = $smarty_obj->_smarty_debug_info;
|
$included_templates = $smarty->_smarty_debug_info;
|
||||||
|
|
||||||
$smarty_obj->assign("_debug_keys", array_keys($assigned_vars));
|
$smarty->assign("_debug_keys", array_keys($assigned_vars));
|
||||||
$smarty_obj->assign("_debug_vals", array_values($assigned_vars));
|
$smarty->assign("_debug_vals", array_values($assigned_vars));
|
||||||
|
|
||||||
$smarty_obj->assign("_debug_tpls", $included_templates);
|
$smarty->assign("_debug_tpls", $included_templates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
/* vim: set expandtab: */
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
* Purpose: print out a counter value
|
* Purpose: print out a counter value
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_counter($args, &$smarty_obj)
|
function smarty_function_counter($params, &$smarty)
|
||||||
{
|
{
|
||||||
static $count = array();
|
static $count = array();
|
||||||
static $skipval = array();
|
static $skipval = array();
|
||||||
@@ -17,7 +17,7 @@ function smarty_function_counter($args, &$smarty_obj)
|
|||||||
static $printval = array();
|
static $printval = array();
|
||||||
static $assign = "";
|
static $assign = "";
|
||||||
|
|
||||||
extract($args);
|
extract($params);
|
||||||
|
|
||||||
if (!isset($id))
|
if (!isset($id))
|
||||||
$id = "default";
|
$id = "default";
|
||||||
@@ -34,7 +34,7 @@ function smarty_function_counter($args, &$smarty_obj)
|
|||||||
|
|
||||||
if (!empty($assign)) {
|
if (!empty($assign)) {
|
||||||
$printval[$id] = false;
|
$printval[$id] = false;
|
||||||
$smarty_obj->assign($assign, $count[$id]);
|
$smarty->assign($assign, $count[$id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($printval[$id])
|
if ($printval[$id])
|
||||||
@@ -54,8 +54,6 @@ function smarty_function_counter($args, &$smarty_obj)
|
|||||||
$count[$id] -= $skipval[$id];
|
$count[$id] -= $skipval[$id];
|
||||||
else
|
else
|
||||||
$count[$id] += $skipval[$id];
|
$count[$id] += $skipval[$id];
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
/* vim: set expandtab: */
|
||||||
|
@@ -8,29 +8,29 @@
|
|||||||
* Purpose: fetch file, web or ftp data and display results
|
* Purpose: fetch file, web or ftp data and display results
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_fetch($args, &$smarty_obj)
|
function smarty_function_fetch($params, &$smarty)
|
||||||
{
|
{
|
||||||
extract($args);
|
extract($params);
|
||||||
|
|
||||||
if (empty($file)) {
|
if (empty($file)) {
|
||||||
$smarty_obj->_trigger_error_msg("parameter 'file' cannot be empty");
|
$smarty->trigger_error("parameter 'file' cannot be empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($smarty_obj->security && !preg_match('!^(http|ftp)://!', $file)) {
|
if ($smarty->security && !preg_match('!^(http|ftp)://!', $file)) {
|
||||||
// make sure fetched file comes from secure directory
|
// make sure fetched file comes from secure directory
|
||||||
foreach ($smarty_obj->secure_dir as $curr_dir) {
|
foreach ($smarty->secure_dir as $curr_dir) {
|
||||||
if (substr(realpath($file), 0, strlen(realpath($curr_dir))) == realpath($curr_dir)) {
|
if (substr(realpath($file), 0, strlen(realpath($curr_dir))) == realpath($curr_dir)) {
|
||||||
$resource_is_secure = true;
|
$resource_is_secure = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$resource_is_secure) {
|
if (!$resource_is_secure) {
|
||||||
$smarty_obj->_trigger_error_msg("(secure mode) fetch '$file' is not allowed");
|
$smarty->trigger_error("(secure mode) fetch '$file' is not allowed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!@is_readable($file)) {
|
if (!@is_readable($file)) {
|
||||||
$smarty_obj->_trigger_error_msg("fetch cannot read file '$file'");
|
$smarty->trigger_error("fetch cannot read file '$file'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ function smarty_function_fetch($args, &$smarty_obj)
|
|||||||
if (!empty($assign)) {
|
if (!empty($assign)) {
|
||||||
ob_start();
|
ob_start();
|
||||||
readfile($file);
|
readfile($file);
|
||||||
$smarty_obj->assign($assign,ob_get_contents());
|
$smarty->assign($assign,ob_get_contents());
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
} else {
|
} else {
|
||||||
readfile($file);
|
readfile($file);
|
||||||
|
@@ -8,19 +8,19 @@
|
|||||||
* Purpose: handle math computations in template
|
* Purpose: handle math computations in template
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_math($args, &$smarty_obj)
|
function smarty_function_math($params, &$smarty)
|
||||||
{
|
{
|
||||||
// be sure equation parameter is present
|
// be sure equation parameter is present
|
||||||
if (empty($args["equation"])) {
|
if (empty($params["equation"])) {
|
||||||
$smarty_obj->_trigger_error_msg("math: missing equation parameter");
|
$smarty->trigger_error("math: missing equation parameter");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$equation = $args["equation"];
|
$equation = $params["equation"];
|
||||||
|
|
||||||
// make sure parenthesis are balanced
|
// make sure parenthesis are balanced
|
||||||
if (substr_count($equation,"(") != substr_count($equation,")")) {
|
if (substr_count($equation,"(") != substr_count($equation,")")) {
|
||||||
$smarty_obj->_trigger_error_msg("math: unbalanced parenthesis");
|
$smarty->trigger_error("math: unbalanced parenthesis");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,21 +30,21 @@ function smarty_function_math($args, &$smarty_obj)
|
|||||||
'max','min','pi','pow','rand','round','sin','sqrt','srand','tan');
|
'max','min','pi','pow','rand','round','sin','sqrt','srand','tan');
|
||||||
|
|
||||||
foreach($match[0] as $curr_var) {
|
foreach($match[0] as $curr_var) {
|
||||||
if (!in_array($curr_var,array_keys($args)) && !in_array($curr_var, $allowed_funcs)) {
|
if (!in_array($curr_var,array_keys($params)) && !in_array($curr_var, $allowed_funcs)) {
|
||||||
$smarty_obj->_trigger_error_msg("math: parameter $curr_var not passed as argument");
|
$smarty->trigger_error("math: parameter $curr_var not passed as argument");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($args as $key => $val) {
|
foreach($params as $key => $val) {
|
||||||
if ($key != "equation" && $key != "format" && $key != "assign") {
|
if ($key != "equation" && $key != "format" && $key != "assign") {
|
||||||
// make sure value is not empty
|
// make sure value is not empty
|
||||||
if (strlen($val)==0) {
|
if (strlen($val)==0) {
|
||||||
$smarty_obj->_trigger_error_msg("math: parameter $key is empty");
|
$smarty->trigger_error("math: parameter $key is empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!is_numeric($val)) {
|
if (!is_numeric($val)) {
|
||||||
$smarty_obj->_trigger_error_msg("math: parameter $key: is not numeric");
|
$smarty->trigger_error("math: parameter $key: is not numeric");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$equation = preg_replace("/\b$key\b/",$val, $equation);
|
$equation = preg_replace("/\b$key\b/",$val, $equation);
|
||||||
@@ -53,17 +53,17 @@ function smarty_function_math($args, &$smarty_obj)
|
|||||||
|
|
||||||
eval("\$smarty_math_result = ".$equation.";");
|
eval("\$smarty_math_result = ".$equation.";");
|
||||||
|
|
||||||
if (empty($args["format"])) {
|
if (empty($params["format"])) {
|
||||||
if (empty($args["assign"])) {
|
if (empty($params["assign"])) {
|
||||||
echo $smarty_math_result;
|
echo $smarty_math_result;
|
||||||
} else {
|
} else {
|
||||||
$smarty_obj->assign($args["assign"],$smarty_math_result);
|
$smarty->assign($params["assign"],$smarty_math_result);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (empty($args["assign"])){
|
if (empty($params["assign"])){
|
||||||
printf($args["format"],$smarty_math_result);
|
printf($params["format"],$smarty_math_result);
|
||||||
} else {
|
} else {
|
||||||
$smarty_obj->assign($assign,sprintf($args["format"],$smarty_math_result));
|
$smarty->assign($assign,sprintf($params["format"],$smarty_math_result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,12 +8,12 @@
|
|||||||
* Purpose: make text pop up in windows via overlib
|
* Purpose: make text pop up in windows via overlib
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_popup($args, &$smarty_obj)
|
function smarty_function_popup($params, &$smarty)
|
||||||
{
|
{
|
||||||
extract($args);
|
extract($params);
|
||||||
|
|
||||||
if (empty($text) && !isset($inarray) && empty($function)) {
|
if (empty($text) && !isset($inarray) && empty($function)) {
|
||||||
$smarty_obj->_trigger_error_msg("overlib: attribute 'text' or 'inarray' or 'function' required");
|
$smarty->trigger_error("overlib: attribute 'text' or 'inarray' or 'function' required");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,6 @@ function smarty_function_popup($args, &$smarty_obj)
|
|||||||
if (!empty($hauto)) { echo ",HAUTO"; }
|
if (!empty($hauto)) { echo ",HAUTO"; }
|
||||||
if (!empty($vauto)) { echo ",VAUTO"; }
|
if (!empty($vauto)) { echo ",VAUTO"; }
|
||||||
echo ');" onMouseOut="nd();"';
|
echo ');" onMouseOut="nd();"';
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
/* vim: set expandtab: */
|
||||||
|
@@ -8,11 +8,11 @@
|
|||||||
* Purpose: initialize overlib
|
* Purpose: initialize overlib
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_popup_init($args, &$smarty_obj)
|
function smarty_function_popup_init($params, &$smarty)
|
||||||
{
|
{
|
||||||
// be sure to place overlib.js where Smarty can locate it.
|
// be sure to place overlib.js where Smarty can locate it.
|
||||||
// overlib.js came with the distribution of Smarty.
|
// overlib.js came with the distribution of Smarty.
|
||||||
extract($args);
|
extract($params);
|
||||||
echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'."\n";
|
echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'."\n";
|
||||||
if (empty($src)) {
|
if (empty($src)) {
|
||||||
echo '<script language="JavaScript">'."\n".'<!--'."\n";
|
echo '<script language="JavaScript">'."\n".'<!--'."\n";
|
||||||
@@ -21,7 +21,6 @@ function smarty_function_popup_init($args, &$smarty_obj)
|
|||||||
} else {
|
} else {
|
||||||
echo '<script language="JavaScript" src="'.$src.'"></script>'."\n";
|
echo '<script language="JavaScript" src="'.$src.'"></script>'."\n";
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
/* vim: set expandtab: */
|
||||||
|
@@ -23,15 +23,17 @@ function smarty_modifier_escape($string, $esc_type = 'html')
|
|||||||
|
|
||||||
case 'hex':
|
case 'hex':
|
||||||
// escape every character into hex
|
// escape every character into hex
|
||||||
for ($x=0; $x<strlen($string); $x++) {
|
for ($x=0; $x < strlen($string); $x++) {
|
||||||
$return .= '%'.bin2hex($string[$x]);
|
$return .= '%' . bin2hex($string[$x]);
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
case 'hexentity':
|
case 'hexentity':
|
||||||
for ($x=0; $x<strlen($string); $x++) {
|
for ($x=0; $x < strlen($string); $x++) {
|
||||||
$return .= '&#x'.bin2hex($string[$x]).';';
|
$return .= '&#x' . bin2hex($string[$x]) . ';';
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
@@ -8,22 +8,21 @@
|
|||||||
* Purpose: assign a value to a template variable
|
* Purpose: assign a value to a template variable
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_assign($args, &$smarty_obj)
|
function smarty_function_assign($params, &$smarty)
|
||||||
{
|
{
|
||||||
extract($args);
|
extract($params);
|
||||||
|
|
||||||
if (empty($var)) {
|
if (empty($var)) {
|
||||||
$smarty_obj->_trigger_error_msg("assign: missing 'var' parameter");
|
$smarty->trigger_error("assign: missing 'var' parameter");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array('value', array_keys($args))) {
|
if (!in_array('value', array_keys($params))) {
|
||||||
$smarty_obj->_trigger_error_msg("assign: missing 'value' parameter");
|
$smarty->trigger_error("assign: missing 'value' parameter");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$smarty_obj->assign($var, $value);
|
$smarty->assign($var, $value);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
/* vim: set expandtab: */
|
||||||
|
@@ -8,23 +8,23 @@
|
|||||||
* Purpose: assign debug info to the template
|
* Purpose: assign debug info to the template
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_assign_debug_info($args, &$smarty_obj)
|
function smarty_function_assign_debug_info($params, &$smarty)
|
||||||
{
|
{
|
||||||
$assigned_vars = $smarty_obj->_tpl_vars;
|
$assigned_vars = $smarty->_tpl_vars;
|
||||||
ksort($assigned_vars);
|
ksort($assigned_vars);
|
||||||
if (is_array($smarty_obj->_config[0])) {
|
if (is_array($smarty->_config[0])) {
|
||||||
$config_vars = $smarty_obj->_config[0];
|
$config_vars = $smarty->_config[0];
|
||||||
ksort($config_vars);
|
ksort($config_vars);
|
||||||
$smarty_obj->assign("_debug_config_keys", array_keys($config_vars));
|
$smarty->assign("_debug_config_keys", array_keys($config_vars));
|
||||||
$smarty_obj->assign("_debug_config_vals", array_values($config_vars));
|
$smarty->assign("_debug_config_vals", array_values($config_vars));
|
||||||
}
|
}
|
||||||
|
|
||||||
$included_templates = $smarty_obj->_smarty_debug_info;
|
$included_templates = $smarty->_smarty_debug_info;
|
||||||
|
|
||||||
$smarty_obj->assign("_debug_keys", array_keys($assigned_vars));
|
$smarty->assign("_debug_keys", array_keys($assigned_vars));
|
||||||
$smarty_obj->assign("_debug_vals", array_values($assigned_vars));
|
$smarty->assign("_debug_vals", array_values($assigned_vars));
|
||||||
|
|
||||||
$smarty_obj->assign("_debug_tpls", $included_templates);
|
$smarty->assign("_debug_tpls", $included_templates);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
/* vim: set expandtab: */
|
||||||
|
@@ -8,7 +8,7 @@
|
|||||||
* Purpose: print out a counter value
|
* Purpose: print out a counter value
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_counter($args, &$smarty_obj)
|
function smarty_function_counter($params, &$smarty)
|
||||||
{
|
{
|
||||||
static $count = array();
|
static $count = array();
|
||||||
static $skipval = array();
|
static $skipval = array();
|
||||||
@@ -17,7 +17,7 @@ function smarty_function_counter($args, &$smarty_obj)
|
|||||||
static $printval = array();
|
static $printval = array();
|
||||||
static $assign = "";
|
static $assign = "";
|
||||||
|
|
||||||
extract($args);
|
extract($params);
|
||||||
|
|
||||||
if (!isset($id))
|
if (!isset($id))
|
||||||
$id = "default";
|
$id = "default";
|
||||||
@@ -34,7 +34,7 @@ function smarty_function_counter($args, &$smarty_obj)
|
|||||||
|
|
||||||
if (!empty($assign)) {
|
if (!empty($assign)) {
|
||||||
$printval[$id] = false;
|
$printval[$id] = false;
|
||||||
$smarty_obj->assign($assign, $count[$id]);
|
$smarty->assign($assign, $count[$id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($printval[$id])
|
if ($printval[$id])
|
||||||
@@ -54,8 +54,6 @@ function smarty_function_counter($args, &$smarty_obj)
|
|||||||
$count[$id] -= $skipval[$id];
|
$count[$id] -= $skipval[$id];
|
||||||
else
|
else
|
||||||
$count[$id] += $skipval[$id];
|
$count[$id] += $skipval[$id];
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
/* vim: set expandtab: */
|
||||||
|
@@ -8,29 +8,29 @@
|
|||||||
* Purpose: fetch file, web or ftp data and display results
|
* Purpose: fetch file, web or ftp data and display results
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_fetch($args, &$smarty_obj)
|
function smarty_function_fetch($params, &$smarty)
|
||||||
{
|
{
|
||||||
extract($args);
|
extract($params);
|
||||||
|
|
||||||
if (empty($file)) {
|
if (empty($file)) {
|
||||||
$smarty_obj->_trigger_error_msg("parameter 'file' cannot be empty");
|
$smarty->trigger_error("parameter 'file' cannot be empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($smarty_obj->security && !preg_match('!^(http|ftp)://!', $file)) {
|
if ($smarty->security && !preg_match('!^(http|ftp)://!', $file)) {
|
||||||
// make sure fetched file comes from secure directory
|
// make sure fetched file comes from secure directory
|
||||||
foreach ($smarty_obj->secure_dir as $curr_dir) {
|
foreach ($smarty->secure_dir as $curr_dir) {
|
||||||
if (substr(realpath($file), 0, strlen(realpath($curr_dir))) == realpath($curr_dir)) {
|
if (substr(realpath($file), 0, strlen(realpath($curr_dir))) == realpath($curr_dir)) {
|
||||||
$resource_is_secure = true;
|
$resource_is_secure = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!$resource_is_secure) {
|
if (!$resource_is_secure) {
|
||||||
$smarty_obj->_trigger_error_msg("(secure mode) fetch '$file' is not allowed");
|
$smarty->trigger_error("(secure mode) fetch '$file' is not allowed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!@is_readable($file)) {
|
if (!@is_readable($file)) {
|
||||||
$smarty_obj->_trigger_error_msg("fetch cannot read file '$file'");
|
$smarty->trigger_error("fetch cannot read file '$file'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -39,7 +39,7 @@ function smarty_function_fetch($args, &$smarty_obj)
|
|||||||
if (!empty($assign)) {
|
if (!empty($assign)) {
|
||||||
ob_start();
|
ob_start();
|
||||||
readfile($file);
|
readfile($file);
|
||||||
$smarty_obj->assign($assign,ob_get_contents());
|
$smarty->assign($assign,ob_get_contents());
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
} else {
|
} else {
|
||||||
readfile($file);
|
readfile($file);
|
||||||
|
@@ -8,19 +8,19 @@
|
|||||||
* Purpose: handle math computations in template
|
* Purpose: handle math computations in template
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_math($args, &$smarty_obj)
|
function smarty_function_math($params, &$smarty)
|
||||||
{
|
{
|
||||||
// be sure equation parameter is present
|
// be sure equation parameter is present
|
||||||
if (empty($args["equation"])) {
|
if (empty($params["equation"])) {
|
||||||
$smarty_obj->_trigger_error_msg("math: missing equation parameter");
|
$smarty->trigger_error("math: missing equation parameter");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$equation = $args["equation"];
|
$equation = $params["equation"];
|
||||||
|
|
||||||
// make sure parenthesis are balanced
|
// make sure parenthesis are balanced
|
||||||
if (substr_count($equation,"(") != substr_count($equation,")")) {
|
if (substr_count($equation,"(") != substr_count($equation,")")) {
|
||||||
$smarty_obj->_trigger_error_msg("math: unbalanced parenthesis");
|
$smarty->trigger_error("math: unbalanced parenthesis");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,21 +30,21 @@ function smarty_function_math($args, &$smarty_obj)
|
|||||||
'max','min','pi','pow','rand','round','sin','sqrt','srand','tan');
|
'max','min','pi','pow','rand','round','sin','sqrt','srand','tan');
|
||||||
|
|
||||||
foreach($match[0] as $curr_var) {
|
foreach($match[0] as $curr_var) {
|
||||||
if (!in_array($curr_var,array_keys($args)) && !in_array($curr_var, $allowed_funcs)) {
|
if (!in_array($curr_var,array_keys($params)) && !in_array($curr_var, $allowed_funcs)) {
|
||||||
$smarty_obj->_trigger_error_msg("math: parameter $curr_var not passed as argument");
|
$smarty->trigger_error("math: parameter $curr_var not passed as argument");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($args as $key => $val) {
|
foreach($params as $key => $val) {
|
||||||
if ($key != "equation" && $key != "format" && $key != "assign") {
|
if ($key != "equation" && $key != "format" && $key != "assign") {
|
||||||
// make sure value is not empty
|
// make sure value is not empty
|
||||||
if (strlen($val)==0) {
|
if (strlen($val)==0) {
|
||||||
$smarty_obj->_trigger_error_msg("math: parameter $key is empty");
|
$smarty->trigger_error("math: parameter $key is empty");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!is_numeric($val)) {
|
if (!is_numeric($val)) {
|
||||||
$smarty_obj->_trigger_error_msg("math: parameter $key: is not numeric");
|
$smarty->trigger_error("math: parameter $key: is not numeric");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$equation = preg_replace("/\b$key\b/",$val, $equation);
|
$equation = preg_replace("/\b$key\b/",$val, $equation);
|
||||||
@@ -53,17 +53,17 @@ function smarty_function_math($args, &$smarty_obj)
|
|||||||
|
|
||||||
eval("\$smarty_math_result = ".$equation.";");
|
eval("\$smarty_math_result = ".$equation.";");
|
||||||
|
|
||||||
if (empty($args["format"])) {
|
if (empty($params["format"])) {
|
||||||
if (empty($args["assign"])) {
|
if (empty($params["assign"])) {
|
||||||
echo $smarty_math_result;
|
echo $smarty_math_result;
|
||||||
} else {
|
} else {
|
||||||
$smarty_obj->assign($args["assign"],$smarty_math_result);
|
$smarty->assign($params["assign"],$smarty_math_result);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (empty($args["assign"])){
|
if (empty($params["assign"])){
|
||||||
printf($args["format"],$smarty_math_result);
|
printf($params["format"],$smarty_math_result);
|
||||||
} else {
|
} else {
|
||||||
$smarty_obj->assign($assign,sprintf($args["format"],$smarty_math_result));
|
$smarty->assign($assign,sprintf($params["format"],$smarty_math_result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,12 +8,12 @@
|
|||||||
* Purpose: make text pop up in windows via overlib
|
* Purpose: make text pop up in windows via overlib
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_popup($args, &$smarty_obj)
|
function smarty_function_popup($params, &$smarty)
|
||||||
{
|
{
|
||||||
extract($args);
|
extract($params);
|
||||||
|
|
||||||
if (empty($text) && !isset($inarray) && empty($function)) {
|
if (empty($text) && !isset($inarray) && empty($function)) {
|
||||||
$smarty_obj->_trigger_error_msg("overlib: attribute 'text' or 'inarray' or 'function' required");
|
$smarty->trigger_error("overlib: attribute 'text' or 'inarray' or 'function' required");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,6 @@ function smarty_function_popup($args, &$smarty_obj)
|
|||||||
if (!empty($hauto)) { echo ",HAUTO"; }
|
if (!empty($hauto)) { echo ",HAUTO"; }
|
||||||
if (!empty($vauto)) { echo ",VAUTO"; }
|
if (!empty($vauto)) { echo ",VAUTO"; }
|
||||||
echo ');" onMouseOut="nd();"';
|
echo ');" onMouseOut="nd();"';
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
/* vim: set expandtab: */
|
||||||
|
@@ -8,11 +8,11 @@
|
|||||||
* Purpose: initialize overlib
|
* Purpose: initialize overlib
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_function_popup_init($args, &$smarty_obj)
|
function smarty_function_popup_init($params, &$smarty)
|
||||||
{
|
{
|
||||||
// be sure to place overlib.js where Smarty can locate it.
|
// be sure to place overlib.js where Smarty can locate it.
|
||||||
// overlib.js came with the distribution of Smarty.
|
// overlib.js came with the distribution of Smarty.
|
||||||
extract($args);
|
extract($params);
|
||||||
echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'."\n";
|
echo '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'."\n";
|
||||||
if (empty($src)) {
|
if (empty($src)) {
|
||||||
echo '<script language="JavaScript">'."\n".'<!--'."\n";
|
echo '<script language="JavaScript">'."\n".'<!--'."\n";
|
||||||
@@ -21,7 +21,6 @@ function smarty_function_popup_init($args, &$smarty_obj)
|
|||||||
} else {
|
} else {
|
||||||
echo '<script language="JavaScript" src="'.$src.'"></script>'."\n";
|
echo '<script language="JavaScript" src="'.$src.'"></script>'."\n";
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
/* vim: set expandtab: */
|
||||||
|
@@ -23,15 +23,17 @@ function smarty_modifier_escape($string, $esc_type = 'html')
|
|||||||
|
|
||||||
case 'hex':
|
case 'hex':
|
||||||
// escape every character into hex
|
// escape every character into hex
|
||||||
for ($x=0; $x<strlen($string); $x++) {
|
for ($x=0; $x < strlen($string); $x++) {
|
||||||
$return .= '%'.bin2hex($string[$x]);
|
$return .= '%' . bin2hex($string[$x]);
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
case 'hexentity':
|
case 'hexentity':
|
||||||
for ($x=0; $x<strlen($string); $x++) {
|
for ($x=0; $x < strlen($string); $x++) {
|
||||||
$return .= '&#x'.bin2hex($string[$x]).';';
|
$return .= '&#x' . bin2hex($string[$x]) . ';';
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user