PDA

Orijinalini görmek için tıklayınız : Php ile döviz kuru alma


aŞk-ı LâL
03 Ekim 2008, 18:25
HAZIRKODLAR
Script Adý : PHP ile Döviz Kuru Alma
Telif : bbokeer
Kategori : Php
Hit : 2230

<?php
function CropSt($st, $what, $len=100) {
$start = strpos( $st, $what );
$st = substr( $st, $start+strlen($what), $len );
return $st;
}
function GetRoE($st, $endsep = " TL") {
$end = strpos( $st, $endsep);
$st = substr( $st, 0, $end);
$st = ereg_replace( ",", "", $st );
return (int)$st;
}
function SaveStringToFile($filename, $text) {
$file = @fopen($filename, "w");
if ( $file ) {
fputs($file, $text);
fclose($file);
}
}
// VillaDöviz
$vd = @file( "http://www.villadoviz.com/ (http://www.villadoviz.com/)" );
if ( $vd ) {
$vd = implode("", $vd);
$vd = CropSt( $vd, "<font color=\"#800000\">USD</font>", 90);
$vd = CropSt( $vd, "<b>Al&yacute;&thorn; </b>");
$alis = GetRoE($vd);
$vd = trim(CropSt($vd, "<b>Sat&yacute;&thorn; </b>" ));
$satis = GetRoE($vd);
}
// T.C. Merkez Bankas&yacute;
$tcmb_today = @file("http://www.tcmb.gov.tr/kurlar/today.html (http://www.tcmb.gov.tr/kurlar/today.html)");
if ( $tcmb_today ) {
$tcmb_today = implode("", $tcmb_today);
$tcm_today = ereg_replace("\r", "", $tcmb_today);
$start = strpos($tcmb_today, "ABD DOLARI");
$tcmb_today = trim(substr($tcmb_today, $start+14, 70));
while ( ereg( "[ ]{2,}", $tcmb_today)>0 )
$tcmb_today = ereg_replace( "[ ]{2,}", " ", $tcmb_today );
/* while ( strpos($tcmb_today, " ")>0 )
$tcmb_today = ereg_replace(" ", " ", $tcmb_today); */
$tcmb_today = explode( " ", $tcmb_today );
$doviz_alis = (int)ereg_replace( ",", "", $tcmb_today[0] );
$doviz_satis = (int)ereg_replace( ",", "", $tcmb_today[1] );
$efektif_alis = (int)ereg_replace( ",", "", $tcmb_today[2] );
$efektif_satis = (int)ereg_replace( ",", "", $tcmb_today[3] );
}
// Yat&yacute;r&yacute;mc&yacute; Kö&thorn;esi - Superonline
$yatirimci = @file("http://www.borsadan.com/doviz.asp (http://www.borsadan.com/doviz.asp)");
if ( $yatirimci ) {
$yatirimci = implode("", $yatirimci);
$yatirimci = CropSt( $yatirimci, '<td class="data">ABD Dolar&yacute;</td>', 300);
SaveStringToFile("sol.txt", "SOL\n\n".$yatirimci);
$yatirimci = strip_tags($yatirimci);
$yatirimci = ereg_replace( ",", "", trim($yatirimci) );
$yatirimci = ereg_replace( "\t|\n|\r", " ", $yatirimci );
while ( ereg( "[ ]{2,}", $yatirimci)>0 )
$yatirimci = ereg_replace( "[ ]{2,}", " ", $yatirimci );
$yatirimci = explode( " ", $yatirimci );
$y_alis = (int)$yatirimci[0];
$y_satis = (int)$yatirimci[1];
$y_endusuk = (int)$yatirimci[2];
$y_enyuksek = (int)$yatirimci[3];
$y_saat = $yatirimci[4];
}
// KOÇ Bank
$koc = @file("http://www.kocbank.com.tr/_index/index_main.asp (http://www.kocbank.com.tr/_index/index_main.asp)");
if ( $koc ) {
$koc = implode("", $koc);
$koc = CropSt( $koc, ' USD:', 265);
$koc = CropSt( $koc, '<font face="Arial, Helvetica, sans-serif" size="1">',151);
$koc = strip_tags($koc);
$koc = ereg_replace( "\.", "", trim($koc) );
$koc = ereg_replace( "\t|\n|\r", " ", $koc );
while ( ereg( "[ ]{2,}", $koc)>0 )
$koc = ereg_replace( "[ ]{2,}", " ", $koc );
$koc = explode( " ", $koc );
$koc_alis = (int)$koc[0];
$koc_satis = (int)$koc[1];
} else
echo "HATA";
?>
<?php
/*
******************* ÖRNEK SAYFA *************************
*/
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso8859-9">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
<title></title>
</head>
<body bgcolor="#FEECDD">
<center>
<table border="0" width="300" cellspacing="1" cellpadding="1">
<?php
if ( $vd ) {
?>
<tr bgcolor="#FF8000">
<td colspan="2" align="center"><font face="Verdana"color="#FFFFFF"><b>VillaDöviz</b></font></td>
</tr>
<tr>
<td width="110"><font face="Verdana">$USD Al&yacute;&thorn;</font></td>
<td align="right"><font face="Verdana"><?php echo number_format($alis, 0, ",", ".");?>TL</font></td>
</tr>
<tr>
<td><font face="Verdana">$USD Sat&yacute;&thorn;</font></td>
<td align="right"><font face="Verdana"><?php echo number_format($satis, 0, ",",".");?> TL</font></td>
</tr>
<tr>
<td colspan="2"><hr></td>
</tr>
<?php
}
if ( $tcmb_today ) {
?>
<tr bgcolor="#FF8000">
<td colspan="2" align="center"><font face="Verdana" color="#FFFFFF"><b>MerkezBankas&yacute;</b></font></td>
</tr>
<tr>
<td width="110"><font face="Verdana">Döviz Al&yacute;&thorn;</font></td>
<td align="right"><font face="Verdana"><?php echo number_format($doviz_alis, 0, ",",".");?> TL</font></td>
</tr>
<tr>
<td><font face="Verdana">Döviz Sat&yacute;&thorn;</font></td>
<td align="right"><font face="Verdana"><?php echo number_format($doviz_satis, 0, ",",".");?> TL</font></td>
</tr>
<tr>
<td><font face="Verdana">Efektif Al&yacute;&thorn;</font></td>
<td align="right"><font face="Verdana"><?php echo number_format($efektif_alis, 0, ",",".");?> TL</font></td>
</tr>
<tr>
<td><font face="Verdana">Efektif Sat&yacute;&thorn;</font></td>
<td align="right"><font face="Verdana"><?php echo number_format($efektif_satis, 0,",", ".");?> TL</font></td>
</tr>
<tr>
<td colspan="2"><hr></td>
</tr>
<?php
}
if ( $yatirimci ) {
?>
<tr bgcolor="#FF8000">
<td colspan="2" align="center"><font face="Verdana" color="#FFFFFF"><b>Yat&yacute;r&yacute;mc&yacute;K ö&thorn;esi - Superonline</b></font> <font face="Verdana" color="#FFFFFF" size="1">(<?php echo$y_saat; ?>)</font></td>
</tr>
<tr>
<td width="110"><font face="Verdana">Döviz Al&yacute;&thorn;</font></td>
<td align="right"><font face="Verdana"><?php echo number_format($y_alis, 0, ",", ".");?> TL</font></td>
</tr>
<tr>
<td><font face="Verdana">Döviz Sat&yacute;&thorn;</font></td>
<td align="right"><font face="Verdana"><?php echo number_format($y_satis, 0, ",", ".");?> TL</font></td>
</tr>
<tr>
<td><font face="Verdana">En Dü&thorn;ük</font></td>
<td align="right"><font face="Verdana"><?php echo number_format($y_endusuk, 0, ",","."); ?> TL</font></td>
</tr>
<tr>
<td><font face="Verdana">En Yüksek</font></td>
<td align="right"><font face="Verdana"><?php echo number_format($y_enyuksek, 0, ",","."); ?> TL</font></td>
</tr>
<?php
}
if ( $koc ) {
?>
<tr bgcolor="#FF8000">
<td colspan="2" align="center"><font face="Verdana" color="#FFFFFF"><b>KoçBankas&yacute;</b></font></td>
</tr>
<tr>
<td width="110"><font face="Verdana">Döviz Al&yacute;&thorn;</font></td>
<td align="right"><font face="Verdana"><?php echo number_format($koc_alis, 0, ",","."); ?> TL</font></td>
</tr>
<tr>
<td><font face="Verdana">Döviz Sat&yacute;&thorn;</font></td>
<td align="right"><font face="Verdana"><?php echo number_format($koc_satis, 0, ",","."); ?> TL</font></td>
</tr>
<?php
}
?>
</table>
</center>
</body>
</html>




alintidir