• 06-11-2012, 15:02:45
    #10
    çalışan versiyonu varmı acaba sanırım sitedeki değişiklikten dolayı kodlar hata veriyor teşekkürler
  • 07-11-2012, 17:35:11
    #11
    Üyeliği durduruldu
    güzel paylaşımın için teşekkür ederim
  • 12-11-2012, 11:43:33
    #12
    Kimlik doğrulama veya yönetimden onay bekliyor.
    Madem konu hortlamış, ben de can sıkıntısına kodları çalışır hale getirip paylaşayım dedim

    <?php 
    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.mgm.gov.tr/tahmin/il-ve-ilceler.aspx?m=".$il); 
    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('#<td><em class="renkMax">(.*?)&#si', $veri, $cikti); 
    $dosya=@fopen($il.".cache.txt", "w"); 
    @fwrite($dosya,time()+60*60*$sure."#".$cikti[1][0]); 
    @fclose($dosya);  
    $yaz = $il." ".addslashes(trim(strip_tags($cikti[1][0])));   
    } 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 '°C<br />'; 
    echo havaDurumu("istanbul",1); echo '°C<br />'; 
    echo havaDurumu("izmir",1); echo '°C<br />'; 
    ?>