Kullanımı ve Kurulumu:
Kodları notdefterine kopyalayıp doviz.php diye kaydetin.
<?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/onlinekur.asp" );
if ( $vd ) {
$vd = implode("", $vd);
$vd = CropSt( $vd, "<font color=\"#800000\">USD</font>", 90);
$vd = CropSt( $vd, "<b>Alış </b>");
$alis = GetRoE($vd);
$vd = trim(CropSt($vd, "<b>Satış </b>" ));
$satis = GetRoE($vd);
}
// T.C. Merkez Bankası
$tcmb_today = @file("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ırımcı Köşesi - Superonline
$yatirimci = @file("http://www.borsadan.com/doviz.asp");
if ( $yatirimci ) {
$yatirimci = implode("", $yatirimci);
$yatirimci = CropSt( $yatirimci, '<td class="data">ABD Doları</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");
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
/*
*/
?>
<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>Anlık Döviz Kurları</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ış</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ış</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ı</b></font></td>
</tr>
<tr>
<td width="110"><font face="Verdana">Döviz Alış</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ış</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ış</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ış</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ırımcıKöş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ış</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ış</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üşü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ı</b></font></td>
</tr>
<tr>
<td width="110"><font face="Verdana">Döviz Alış</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ış</font></td>
<td align="right"><font face="Verdana"><?php echo number_format($koc_satis, 0, ",","."); ?> TL</font></td>
</tr>
<?php
}
?>
</table>
</center>
</body>
</html>