X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=wwwroot%2Fsmarty%2FSmarty-2.6.10%2Flibs%2Fplugins%2Ffunction.math.php;fp=wwwroot%2Fsmarty%2FSmarty-2.6.10%2Flibs%2Fplugins%2Ffunction.math.php;h=0000000000000000000000000000000000000000;hb=e034221efbc7970ec58be22d7517fd3c503dc903;hp=544f5c6a8a0b719cc06dcd3827d8e4a576b13991;hpb=c6f21b69e8210bdd0e80cf87f1c2f06dfc848a75;p=mirrors%2FKyberia-bloodline.git diff --git a/wwwroot/smarty/Smarty-2.6.10/libs/plugins/function.math.php b/wwwroot/smarty/Smarty-2.6.10/libs/plugins/function.math.php deleted file mode 100644 index 544f5c6..0000000 --- a/wwwroot/smarty/Smarty-2.6.10/libs/plugins/function.math.php +++ /dev/null @@ -1,83 +0,0 @@ - - * Name: math
- * Purpose: handle math computations in template
- * @link http://smarty.php.net/manual/en/language.function.math.php {math} - * (Smarty online manual) - * @param array - * @param Smarty - * @return string - */ -function smarty_function_math($params, &$smarty) -{ - // be sure equation parameter is present - if (empty($params['equation'])) { - $smarty->trigger_error("math: missing equation parameter"); - return; - } - - $equation = $params['equation']; - - // make sure parenthesis are balanced - if (substr_count($equation,"(") != substr_count($equation,")")) { - $smarty->trigger_error("math: unbalanced parenthesis"); - return; - } - - // match all vars in equation, make sure all are passed - preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]+)!",$equation, $match); - $allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10', - 'max','min','pi','pow','rand','round','sin','sqrt','srand','tan'); - - foreach($match[1] as $curr_var) { - if ($curr_var && !in_array($curr_var, array_keys($params)) && !in_array($curr_var, $allowed_funcs)) { - $smarty->trigger_error("math: function call $curr_var not allowed"); - return; - } - } - - foreach($params as $key => $val) { - if ($key != "equation" && $key != "format" && $key != "assign") { - // make sure value is not empty - if (strlen($val)==0) { - $smarty->trigger_error("math: parameter $key is empty"); - return; - } - if (!is_numeric($val)) { - $smarty->trigger_error("math: parameter $key: is not numeric"); - return; - } - $equation = preg_replace("/\b$key\b/",$val, $equation); - } - } - - eval("\$smarty_math_result = ".$equation.";"); - - if (empty($params['format'])) { - if (empty($params['assign'])) { - return $smarty_math_result; - } else { - $smarty->assign($params['assign'],$smarty_math_result); - } - } else { - if (empty($params['assign'])){ - printf($params['format'],$smarty_math_result); - } else { - $smarty->assign($params['assign'],sprintf($params['format'],$smarty_math_result)); - } - } -} - -/* vim: set expandtab: */ - -?>