diff options
| author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-08-29 12:10:12 +0000 |
|---|---|---|
| committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2005-08-29 12:10:12 +0000 |
| commit | 96d2531821c13a5962b09a5b130d93c8d8b8a987 (patch) | |
| tree | e257a4b90d1aadbfaec3763eefa1bf58dcab2af6 /wp-inst/wp-content/smarty-plugins/function.math.php | |
| parent | 04d51d5f3493a358f75449ac08425310978e5b24 (diff) | |
| download | wordpress-mu-96d2531821c13a5962b09a5b130d93c8d8b8a987.tar.gz wordpress-mu-96d2531821c13a5962b09a5b130d93c8d8b8a987.tar.xz wordpress-mu-96d2531821c13a5962b09a5b130d93c8d8b8a987.zip | |
Removed Smarty stuff
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@249 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-inst/wp-content/smarty-plugins/function.math.php')
| -rw-r--r-- | wp-inst/wp-content/smarty-plugins/function.math.php | 83 |
1 files changed, 0 insertions, 83 deletions
diff --git a/wp-inst/wp-content/smarty-plugins/function.math.php b/wp-inst/wp-content/smarty-plugins/function.math.php deleted file mode 100644 index 0439107..0000000 --- a/wp-inst/wp-content/smarty-plugins/function.math.php +++ /dev/null @@ -1,83 +0,0 @@ -<?php -/** - * Smarty plugin - * @package Smarty - * @subpackage plugins - */ - - -/** - * Smarty {math} function plugin - * - * Type: function<br> - * Name: math<br> - * Purpose: handle math computations in template<br> - * @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: */ - -?> |
