|
»Forumlar »D?k?manlar
»Cacheli hava durumu botu
https://seditio.com.tr/eski1/forums.php?m=posts&q=1679 |
| Author: Kaan, Posted: 2011-12-08 23:29 GMT. |
|
: hp]<?php #Coded By: Cyclone #E-mail: Cyclone.ugur [ at ] windowslive.com #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 />'; ?> 1 saat'i a??nca g?ncellemiyor mu ? E?er g?ncellemiyorsa : hp]<?php function havaDurumu($il,$sure) { $klasor = "havadurumu_temp/"; $dosya=@fopen($klasor.$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($klasor.$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 />'; ?> havadurumu_temp diye klasor olu?tur. chmod yaz?labilir yap |
| Powered by Seditio | Print version |