Source for file calc.module.php
Documentation is available at calc.module.php
* Module is used for calculating simple math expressions.
* - !calc abs(sqrt(4*25)/10-20)
* @author Jector <no.one.on@gmail.com>
* @todo add more functions
* Contains available functions for calculating (sqrt, abs, etc) ...
$this->commands->addCommand($this, 'calc', array('calculate'));
$this->funcs = implode('|',array('abs','sqrt','pow','round','ceil','floor','rand','sin','cos','tan','asin','acos','atan','rad2deg','pi','log10','log','log2','exp','decoct','dechex','decbin','bindec','octdec'));
* @param string $params calculatin string
if (preg_match("/^([0-9\s\-\+\(\)\*\/%\.,]+|{$this->funcs})+$/ i",$params))
$err=@eval('$ret = '.$params.';');
$ret = 'Calculating error. Check your expression.';
$ret = 'Invalid chars in input calc string. Check your expression';
$this->commands->sendMsg($uin, strtr($params, "\r\n"," "). ' = '. $ret);
|