/** * Stores math information * * @param array $expr Data * * @return none */ private function _calc($expr) { try { $expr = str_replace(',', '.', $expr); $val = Math\calc($expr); return $val; } catch (Exception $e) { return $e->getMessage(); //return false; } }
/** * CallConverter * * @param object $parent The object that's calling the module * @param array $data Data * @param array $extra Extra data such as regexps * * @return none */ public function callConverter($parent, $data, $extra) { extract($extra); if (class_exists('Math')) { try { $regexp['amount'] = Math\calc(str_replace(',', '.', $regexp['amount'])); } catch (Exception $e) { } } $fromCurrency = strtolower($regexp['FromCurrency']); $toCurrency = strtolower($regexp['ToCurrency']); $amount = $regexp['amount']; $extraData = array_merge($extra, array('parent' => $parent, 'origFrom' => $fromCurrency, 'origTo' => $toCurrency, 'origAmount' => $amount, 'fromCurrency' => $fromCurrency, 'toCurrency' => $toCurrency, 'amount' => $amount)); if ($fromCurrency == $toCurrency) { return; } if ($fromCurrency == "btc") { //$this->parent->privmsg($replyto, "API closed down for BTC, pm jny about a new BTC api pls."); $this->mtgoxCurrency($extraData); } else { $this->yahooCurrency($extraData); } }