botun özelliklerine geçmek gerekirse
cachelidir bu sayede sizin ve karşı sitenin serverini kasmaz belirli aralıklarla günceller(opsiyonel olarak süre değiştirilebilir)
işim olduğu için acele ile yazdım, hataları olabilir bildirirseniz düzeltebilirim
<?php
#Coded By: Cyclone
#Last Updated: 02.06.2009
function havaDurumu($il,$sure) {
$dosya=@fopen($il.".cache.txt", "r");
$data=@fread($dosya, 1024);
$bol = explode("#", $data);
@fclose($dosya);
if($bol[0] < time() || !$dosya) {
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,"http://www.havadurumu.com.tr/turkiye/".$il."_hava_durumu/");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com.tr");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
$veri = curl_exec($ch);
curl_close($ch);
preg_match_all("#<span class=\"style3\">(.*?)</span>#si", $veri, $cikti);
$dosya=@fopen($il.".cache.txt", "w");
@fwrite($dosya,time()+60*60*$sure."#".$cikti[1][1]);
@fclose($dosya);
$yaz = $il." ".addslashes(trim(strip_tags($cikti[1][1])));
} else
$yaz = $il." ". addslashes(trim(strip_tags($bol[1])));
return $yaz;
}
// --- örnek kullanım ---
// echo havaDurumu("il adı",cache süresi);
echo havaDurumu("Ankara",1); echo '<br />';
echo havaDurumu("istanbul",1); echo '<br />';
echo havaDurumu("izmir",1); echo '<br />';
?>veya eklentiden indirebilirsiniz