Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Many-many thanks to <strong>jmathai</strong> , <strong>ToonMariner</strong> , <strong>experimentX</strong> for precious advice.</p> <p>But i have got the simple solution </p> <pre><code> public function getCountryIp() { $currency = new Zend_Currency(); $countryCode = $this-&gt;getCountryFromIP(); $currencyCode = $currency-&gt;getCurrencyList($countryCode); $localCurrency = $this-&gt;currency('USD',$currencyCode[0],50); $var['currencyCode'] = $currencyCode[0]; $var['currency'] = $localCurrency; return $var; } //use to convert currency public function currency($from_Currency, $to_Currency, $amount) { $amount = urlencode($amount); $from_Currency = urlencode($from_Currency); $to_Currency = urlencode($to_Currency); $url = "http://www.google.com/ig/calculator?hl=en&amp;q=$amount$from_Currency=?$to_Currency"; $ch = curl_init(); $timeout = 0; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)"); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); $rawdata = curl_exec($ch); curl_close($ch); $data = explode('"', $rawdata); $data = explode(' ', $data['3']); $stripped = ereg_replace("[^A-Za-z0-9.\+]", "", $data['0']);//remove special char return round($stripped,3); // $var = $data['0']; // return $var; // return round($var, 8); } //get ip-address and show country code public function getCountryFromIP() { $ip = $_SERVER['REMOTE_ADDR']; $country = exec("whois $ip | grep -i country"); // Run a local whois and get the result back //$country = strtolower($country); // Make all text lower case so we can use str_replace happily // Clean up the results as some whois results come back with odd results, this should cater for most issues $country = str_replace("country:", "", "$country"); $country = str_replace("Country:", "", "$country"); $country = str_replace("Country :", "", "$country"); $country = str_replace("country :", "", "$country"); $country = str_replace("network:country-code:", "", "$country"); $country = str_replace("network:Country-Code:", "", "$country"); $country = str_replace("Network:Country-Code:", "", "$country"); $country = str_replace("network:organization-", "", "$country"); $country = str_replace("network:organization-usa", "us", "$country"); $country = str_replace("network:country-code;i:us", "us", "$country"); $country = str_replace("eu#countryisreallysomewhereinafricanregion", "af", "$country"); $country = str_replace("", "", "$country"); $country = str_replace("countryunderunadministration", "", "$country"); $country = str_replace(" ", "", "$country"); return $country; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload