function ConvertCurrency($FROM, $INTO, $AMOUNT) { global $conversionarray; $data = array('amount' => $AMOUNT, 'from' => $FROM, 'to' => $INTO); if ($FROM == $INTO) { return $AMOUNT; } $CURRENCIES = CurrenciesList(); $rate = findconversionrate($FROM, $INTO); if ($rate == 0) { $conversion = googleconvert($AMOUNT, $FROM, $INTO); $conversionarray[1][] = array('from' => $FROM, 'to' => $INTO, 'rate' => $conversion); buildcache($conversionarray[1]); return $AMOUNT * $conversion; } else { return $AMOUNT * $rate; } }
function converter_call($post_data = true, $data = array()) { global $system; include $include_path . 'converter.inc.php'; // get convertion data if ($post_data) { global $_REQUEST; $amount = $_REQUEST['amount']; $from = $_REQUEST['from']; $to = $_REQUEST['to']; } else { $amount = $data['amount']; $from = $data['from']; $to = $data['to']; } $amount = $system->input_money($amount); $CURRENCIES = CurrenciesList(); $conversion = ConvertCurrency($from, $to, $amount); // construct string echo $amount . ' ' . $CURRENCIES[$from] . ' = ' . $system->print_money_nosymbol($conversion, true) . ' ' . $CURRENCIES[$to]; }
<?php /*************************************************************************** * copyright : (C) 2008 - 2014 WeBid * site : http://www.webidsupport.com/ ***************************************************************************/ /*************************************************************************** * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. Although none of the code may be * sold. If you have been sold this script, get a refund. ***************************************************************************/ include 'common.php'; include $include_path . 'converter.inc.php'; $CURRENCIES = CurrenciesList(); $conversion = ' '; if (isset($_POST['action']) && $_POST['action'] == 'convert') { // Convert $from = is_numeric($_POST['from']) ? $_POST['from'] : 0; $to = is_numeric($_POST['to']) ? $_POST['to'] : 0; $amount = is_numeric($_POST['amount']) ? $_POST['amount'] : 0; $conversion = ConvertCurrency($from, $to, $amount); // construct string $conversion = $system->print_money_nosymbol($amount) . ' ' . $CURRENCIES[$from] . ' = ' . $system->print_money_nosymbol($conversion, true) . ' |' . $CURRENCIES[$to]; } foreach ($CURRENCIES as $k => $v) { $fromselected = false; $toselected = false; if ($k == $system->SETTINGS['currency']) { $fromselected = true;