<?php $birimler= array( "AED"=>"Birleşik Arap Emirlikleri Dirhemi (AED) ", "ANG"=>"Hollanda Antillean Gulden (ANG) ", "ARS"=>"Arjantin Pezosu (ARS) ", "AUD"=>"Avustralya Doları (AUD) ", "BGN"=>"Bulgar (BGN) ", "BHD"=>"Bahreyn Dinarı (BHD) ", "BND"=>"Brunei Doları (BND) ", "BOB"=>"Bolivya Para Birimi (BOB) ", "BRL"=>"Brezilya Reali (BRL) ", "BWP"=>"Botswana Pula (BWP) ", "CAD"=>"Kanada Doları (CAD) ", "CHF"=>"İsviçre Frangı (CHF) ", "CLP"=>"Şili Pezosu (CLP) ", "CNY"=>"Çince Yuan (Renminbisi) (CNY) ", "COP"=>"Kolombiya Pezosu (COP) ", "CSD"=>"Sırp Dinarı (CSD) ", "CZK"=>"Çek Koruna (CZK) ", "DKK"=>"Danimarka Kronu (DKK) ", "EEK"=>"Estonya (EEK) ", "EGP"=>"Mısır Lirası (EGP) ", "EUR"=>"Euro (EUR) ", "FJD"=>"Fiji Dili Doları (FJD) ", "GBP"=>"İngiliz Sterlini (YTL) ", "HKD"=>"Hong Kong Doları (HKD) ", "HNL"=>"Honduraslı Lempira (HNL) ", "HRK"=>"Hırvat Kunası (HRK) ", "HUF"=>"Macar (HUF) ", "IDR"=>"Endonezya Rupiahı (IDR) ", "ILS"=>"Yeni İsrail Şekeli (ILS) ", "INR"=>"Hindistan Rupisi (INR) ", "ISK"=>"İzlanda Kronu (ISK) ", "JPY"=>"Japon Yeni (JPY) ", "KRW"=>"Güney Kore Wonu (KRW) ", "KWD"=>"Kuveyt Dinarı (KWD) ", "KZT"=>"Kazak tenge (KZT) ", "LKR"=>"Sri Lankan Rupesi (LKR) ", "LTL"=>"Litvanya Litası (LTL) ", "MAD"=>"Fas Dirhemi (MAD) ", "MUR"=>"Mauritian Rupesi (Mur) ", "MXN"=>"Meksika Pezosu (MXN) ", "MYR"=>"Malezya Ringiti (MYR) ", "NOK"=>"Norveç Kronu (NOK) ", "NPR"=>"Nepal Rupisi (NPR) ", "NZD"=>"Yeni Zelanda Doları (NZD) ", "OMR"=>"Omani Rial (OMR) ", "PEN"=>"Peru Nuevo Solu (PEN) ", "PHP"=>"Filipinler Pezosu (PHP) ", "PKR"=>"Pakistan Rupesi (PKR) ", "PLN"=>"Polonya Zlotisi (PLN) ", "QAR"=>"Qatari Riyali (QAR) ", "RON"=>"Yeni Romen Leyi (RON) ", "RUB"=>"Rus Rublesi (RUB) ", "SAR"=>"Suudi Arabistan Riyali (SAR) ", "SEK"=>"İsveç Kronu (SEK) ", "SGD"=>"Singapur Doları (SGD) ", "SIT"=>"slovence Tolar (SIT) ", "SKK"=>"Slovak Korunası (SKK) ", "THB"=>"Tayland Bahtı (THB) ", "TRY"=>"Yeni Türk Lirası (YTL) ", "TTD"=>"Trinidad ve Tobago Doları (TTD) ", "TWD"=>"Yeni Tayvan Doları (TWD) ", "UAH"=>"Ukrayna Grivnası (UAH) ", "USD"=>"ABD Doları (USD) ", "VEB"=>"Venezuela Bolivarı (VEB) ", "ZAR"=>"Güney Afrika Randı (ZAR) "); /** * Converts currency using Google's Currency Converter * * @author Rochak Chauhan * * @see Currency Conversion Disclaimer * Google cannot guarantee the accuracy of the exchange rates used by the calculator. * You should confirm current rates before making any transactions that could be affected by changes in the exchange rates. * Foreign currency rates provided by Citibank N.A. and displayed under license. * Rates are for information purposes only and are subject to change without notice. * Rates for actual transactions may vary, and Citibank is not offering to enter into any transaction at any rate displayed. * NOT FOR COMMERTIAL USE */ class GoogleCurrencyConvertor{ private $rate=""; private $reverseRate=""; /** * Contructor function * * @param int $amount * @param string $currFrom * @param string $currInto * * @return resource */ public function __construct($amount, $currFrom, $currInto){ if (trim($amount)=="" ||!is_numeric($amount)) { trigger_error("Please enter a valid amount",E_USER_ERROR); } $return=array(); $gurl="http://www.google.com/search?&q=$amount+$currFrom+in+$currInto"; $html=$this->getHtmlCodeViaFopen($gurl); $pattern='/<h2 class=r(.*)\<\/h2\>/Uis'; preg_match_all($pattern,$html,$return,PREG_PATTERN_ORDER); if (isset($return[0][0])) { $rate=strip_tags($return[0][0]); $tmp=explode("=",$rate); $rate=$tmp[1]; $this->rate=$this->getIntegers($rate); $this->reverseRate=1/$this->rate; } else { $this->rate=$this->reverseRate="Google could not convert your request. Please try again."; } } /** * Function to get only integers from a string * * @param string $str * @return int */ private function getIntegers($str){ $ret=""; $str=trim($str); for ($i=0;$i<strlen($str);$i++){ $code=ord($str[$i]); if( ($code>47 && $code<58) || $code==46) { $ret.=$str[$i]; } } return $ret; } /** * Fucntion to get HTML code of a URL * * @param string $url * @return string */ function getHtmlCodeViaFopen($url){ $returnStr=""; $fp=fopen($url, "r") or die("ERROR: Failed to open $url for reading via this script."); while (!feof($fp)) { $returnStr.=fgetc($fp); } fclose($fp); return $returnStr; } /** * Function get the converter Rate * * @access public * * @return int */ function getRate(){ return $this->rate; } /** * Function get the reverse of converter Rate * * @access public * @return int * */ function getReverseRate(){ return $this->reverseRate; } } ?> <?php if(isset($_POST["hareket"]) && $_POST["hareket"]=='cevir') { $from=$_POST["from"]; $to=$_POST["to"]; $a=$_POST["a"]; } else { $a=1; } ?> <form name="form1" method="post" action=""> <input name="a" maxlength=12 size=5 value="<?php echo $a; ?>"> <select name="from"> <?php foreach($birimler as $key => $value) { ?> <option value="<?php echo $key; ?>" <?php if (!(strcmp($key,$from))) {echo 'selected="selected"';} ?>> <?php echo $value; ?></option> <? } ?> </select> <select name="to" id="to"> <?php foreach($birimler as $key => $value) { ?> <option value="<?php echo $key; ?>" <?php if (!(strcmp($key,$to))) {echo 'selected="selected"';} ?>> <?php echo $value; ?></option> <? } ?> </select> <input type="submit" name="button" id="button" value="Çevir"> <input name="hareket" type="hidden" id="hareket" value="cevir"> </form> <?php if(isset($_POST["hareket"]) && $_POST["hareket"]=='cevir') { $from=$_POST["from"]; $to=$_POST["to"]; $a=$_POST["a"]; $googleCurrencyConvertor = new GoogleCurrencyConvertor($a,$from,$to); echo $a." ".$birimler["$from"]." ".$googleCurrencyConvertor->getRate()." ".$birimler["$to"]; echo "<br>"; echo $a." ".$birimler["$to"]." ".$googleCurrencyConvertor->getReverseRate()." ".$birimler["$from"]; } ?> |
Php para birim çevirici
Kategori: Php
Yayınlanma: 15 Haziran 2009 9:17 AM +03