function getGoogleCurrency($currency_from, $currency_to) { $url = "http://www.google.com/ig/calculator?hl=en&q=1+{$currency_from}=?{$currency_to}"; $res = JTheFactoryHelper::remote_read_url($url); $matches = array(); if (preg_match('/lhs:\\s*"([^"]*)"\\s*,rhs:\\s*"([^"]*)"\\s*,error:\\s*"([^"]*)"/', $res, $matches)) { $error = $matches[3]; $rate = $matches[2]; if ($error) { return false; } return floatval(substr($rate, 0, strpos($rate, " "))); } else { return false; } }
/** * Field related Tasks / Admin Section */ function Main() { $MyApp = JTheFactoryApplication::getInstance(); $filename = $MyApp->getIniValue('version_root') . '/' . APP_EXTENSION . ".xml"; $doc = JTheFactoryHelper::remote_read_url($filename); $xml = JFactory::getXML($doc, false); $view = $this->getView('main'); if (version_compare(COMPONENT_VERSION, (string) $xml->latestversion) >= 0) { $view->assign('isnew_version', false); } else { $view->assign('isnew_version', true); } $view->assign('latestversion', (string) $xml->latestversion); $view->assign('versionhistory', (string) $xml->versionhistory); $view->assign('downloadlink', (string) $xml->downloadlink); $view->assign('aboutfactory', html_entity_decode((string) $xml->aboutfactory)); $view->assign('otherproducts', html_entity_decode((string) $xml->otherproducts)); $view->assign('build', (string) $xml->build); $view->display(); }