Kodları lütfen aşağıdaki butonları kullanarak renklendirin. Örnek: <php> echo "Selam Dünya"; </php>
Yardım
karakter kaldı

Php ile dosya import ederken sorgulama

merhabalar,
hava durumu için aşağıdaki sistemi kullanıyorum fakat arada bir düzenleme yaptıklarında sayfa açılmıyor ve hata veriyor benim aklıma şöyle bir özüm geldi dosya gelmediği durumlarda güncelleniyor diye bir yazmasın. Asıl sorum bu dosyayı belli bir zaman gelmediği zaman sonra yazmasını nasıl yapabilirim. şimdiden herkese teşekkür ederim :)

$html = implode('', file('http://www.dmi.gov.tr/tahmin/il-ve-ilceler.aspx?m=ADANA'));

//1---------
$gun1Baslangic = strpos($html,"thmGun1",0);
$gun1Baslangic = strpos($html,"\">",$gun1Baslangic);
$gun1Bitis = strpos($html,"</",$gun1Baslangic);
$gun1 = substr($html,$gun1Baslangic+2,$gun1Bitis-$gun1Baslangic-2);

$gun1 = mb_convert_encoding($gun1,"ISO-8859-9","UTF-8");
$gun1 = str_replace(" Ocak",".01",$gun1);
$gun1 = str_replace(" Subat",".02",$gun1);
$gun1 = str_replace(" Mart",".03",$gun1);
$gun1 = str_replace(" Nisan",".04",$gun1);
$gun1 = str_replace(" Mayis",".05",$gun1);
$gun1 = str_replace(" Haziran",".06",$gun1);
$gun1 = str_replace(" Temmuz",".07",$gun1);
$gun1 = str_replace(" Agustos",".08",$gun1);
$gun1 = str_replace(" Eylül",".09",$gun1);
$gun1 = str_replace(" Ekim",".10",$gun1);
$gun1 = str_replace(" Kasim",".11",$gun1);
$gun1 = str_replace(" Aralik",".12",$gun1);

$gun1 = str_replace(" Pazartesi",".".date("Y"),$gun1);
$gun1 = str_replace(" Sali",".".date("Y"),$gun1);
$gun1 = str_replace(" Çarsamba",".".date("Y"),$gun1);
$gun1 = str_replace(" Persembe",".".date("Y"),$gun1);
$gun1 = str_replace(" Cumartesi",".".date("Y"),$gun1);
$gun1 = str_replace(" Cuma",".".date("Y"),$gun1);
$gun1 = str_replace(" Pazar",".".date("Y"),$gun1);

$thmmin1Baslangic = strpos($html,"thmMin1",0);
$thmmin1Baslangic = strpos($html,"\">",$thmmin1Baslangic);
$thmmin1Bitis = strpos($html,"</",$thmmin1Baslangic);
$thmmin1 = substr($html,$thmmin1Baslangic+2,$thmmin1Bitis-$thmmin1Baslangic-2);

$thmmax1Baslangic = strpos($html,"thmMax1",0);
$thmmax1Baslangic = strpos($html,"\">",$thmmax1Baslangic);
$thmmax1Bitis = strpos($html,"</",$thmmax1Baslangic);
$thmmax1 = substr($html,$thmmax1Baslangic+2,$thmmax1Bitis-$thmmax1Baslangic-2);

$thmhadise1Baslangic = strpos($html,"imgHadise1",0);
$thmhadise1Baslangic = strpos($html,"src=\"",$thmhadise1Baslangic);
$thmhadise1Bitis = strpos($html,"alt=",$thmhadise1Baslangic);
$thmhadise1 = substr($html,$thmhadise1Baslangic+5,$thmhadise1Bitis-$thmhadise1Baslangic-7);
$imgthmhadise1="<img src=\"http://www.dmi.gov.tr/tahmin/".$thmhadise1."\" width=\"20\">";

//2---------
$gun2Baslangic = strpos($html,"thmGun2",0);
$gun2Baslangic = strpos($html,"\">",$gun2Baslangic);
$gun2Bitis = strpos($html,"</",$gun2Baslangic);
$gun2 = substr($html,$gun2Baslangic+2,$gun2Bitis-$gun2Baslangic-2);

$gun2 = mb_convert_encoding($gun2,"ISO-8859-9","UTF-8");
$gun2 = str_replace(" Ocak",".01",$gun2);
$gun2 = str_replace(" Subat",".02",$gun2);
$gun2 = str_replace(" Mart",".03",$gun2);
$gun2 = str_replace(" Nisan",".04",$gun2);
$gun2 = str_replace(" Mayis",".05",$gun2);
$gun2 = str_replace(" Haziran",".06",$gun2);
$gun2 = str_replace(" Temmuz",".07",$gun2);
$gun2 = str_replace(" Agustos",".08",$gun2);
$gun2 = str_replace(" Eylül",".09",$gun2);
$gun2 = str_replace(" Ekim",".10",$gun2);
$gun2 = str_replace(" Kasim",".11",$gun2);
$gun2 = str_replace(" Aralik",".12",$gun2);

$gun2 = str_replace(" Pazartesi",".".date("Y"),$gun2);
$gun2 = str_replace(" Sali",".".date("Y"),$gun2);
$gun2 = str_replace(" Çarsamba",".".date("Y"),$gun2);
$gun2 = str_replace(" Persembe",".".date("Y"),$gun2);
$gun2 = str_replace(" Cumartesi",".".date("Y"),$gun2);
$gun2 = str_replace(" Cuma",".".date("Y"),$gun2);
$gun2 = str_replace(" Pazar",".".date("Y"),$gun2);

$thmmin2Baslangic = strpos($html,"thmMin2",0);
$thmmin2Baslangic = strpos($html,"\">",$thmmin2Baslangic);
$thmmin2Bitis = strpos($html,"</",$thmmin2Baslangic);
$thmmin2 = substr($html,$thmmin2Baslangic+2,$thmmin2Bitis-$thmmin2Baslangic-2);

$thmmax2Baslangic = strpos($html,"thmMax2",0);
$thmmax2Baslangic = strpos($html,"\">",$thmmax2Baslangic);
$thmmax2Bitis = strpos($html,"</",$thmmax2Baslangic);
$thmmax2 = substr($html,$thmmax2Baslangic+2,$thmmax2Bitis-$thmmax2Baslangic-2);

$thmhadise2Baslangic = strpos($html,"imgHadise2",0);
$thmhadise2Baslangic = strpos($html,"src=\"",$thmhadise2Baslangic);
$thmhadise2Bitis = strpos($html,"alt=",$thmhadise2Baslangic);
$thmhadise2 = substr($html,$thmhadise2Baslangic+5,$thmhadise2Bitis-$thmhadise2Baslangic-7);
$imgthmhadise2="<img src=\"http://www.dmi.gov.tr/tahmin/".$thmhadise2."\" width=\"20\">";

//3---------
$gun3Baslangic = strpos($html,"thmGun3",0);
$gun3Baslangic = strpos($html,"\">",$gun3Baslangic);
$gun3Bitis = strpos($html,"</",$gun3Baslangic);
$gun3 = substr($html,$gun3Baslangic+2,$gun3Bitis-$gun3Baslangic-2);

$gun3 = mb_convert_encoding($gun3,"ISO-8859-9","UTF-8");
$gun3 = str_replace(" Ocak",".01",$gun3);
$gun3 = str_replace(" Subat",".02",$gun3);
$gun3 = str_replace(" Mart",".03",$gun3);
$gun3 = str_replace(" Nisan",".04",$gun3);
$gun3 = str_replace(" Mayis",".05",$gun3);
$gun3 = str_replace(" Haziran",".06",$gun3);
$gun3 = str_replace(" Temmuz",".07",$gun3);
$gun3 = str_replace(" Agustos",".08",$gun3);
$gun3 = str_replace(" Eylül",".09",$gun3);
$gun3 = str_replace(" Ekim",".10",$gun3);
$gun3 = str_replace(" Kasim",".11",$gun3);
$gun3 = str_replace(" Aralik",".12",$gun3);

$gun3 = str_replace(" Pazartesi",".".date("Y"),$gun3);
$gun3 = str_replace(" Sali",".".date("Y"),$gun3);
$gun3 = str_replace(" Çarsamba",".".date("Y"),$gun3);
$gun3 = str_replace(" Persembe",".".date("Y"),$gun3);
$gun3 = str_replace(" Cumartesi",".".date("Y"),$gun3);
$gun3 = str_replace(" Cuma",".".date("Y"),$gun3);
$gun3 = str_replace(" Pazar",".".date("Y"),$gun3);

$thmmin3Baslangic = strpos($html,"thmMin3",0);
$thmmin3Baslangic = strpos($html,"\">",$thmmin3Baslangic);
$thmmin3Bitis = strpos($html,"</",$thmmin3Baslangic);
$thmmin3 = substr($html,$thmmin3Baslangic+2,$thmmin3Bitis-$thmmin3Baslangic-2);

$thmmax3Baslangic = strpos($html,"thmMax3",0);
$thmmax3Baslangic = strpos($html,"\">",$thmmax3Baslangic);
$thmmax3Bitis = strpos($html,"</",$thmmax3Baslangic);
$thmmax3 = substr($html,$thmmax3Baslangic+2,$thmmax3Bitis-$thmmax3Baslangic-2);

$thmhadise3Baslangic = strpos($html,"imgHadise3",0);
$thmhadise3Baslangic = strpos($html,"src=\"",$thmhadise3Baslangic);
$thmhadise3Bitis = strpos($html,"alt=",$thmhadise3Baslangic);
$thmhadise3 = substr($html,$thmhadise3Baslangic+5,$thmhadise3Bitis-$thmhadise3Baslangic-7);
$imgthmhadise3="<img src=\"http://www.dmi.gov.tr/tahmin/".$thmhadise3."\" width=\"20\">";

//4---------
$gun4Baslangic = strpos($html,"thmGun4",0);
$gun4Baslangic = strpos($html,"\">",$gun4Baslangic);
$gun4Bitis = strpos($html,"</",$gun4Baslangic);
$gun4 = substr($html,$gun4Baslangic+2,$gun4Bitis-$gun4Baslangic-2);

$gun4 = mb_convert_encoding($gun4,"ISO-8859-9","UTF-8");
$gun4 = str_replace(" Ocak",".01",$gun4);
$gun4 = str_replace(" Subat",".02",$gun4);
$gun4 = str_replace(" Mart",".03",$gun4);
$gun4 = str_replace(" Nisan",".04",$gun4);
$gun4 = str_replace(" Mayis",".05",$gun4);
$gun4 = str_replace(" Haziran",".06",$gun4);
$gun4 = str_replace(" Temmuz",".07",$gun4);
$gun4 = str_replace(" Agustos",".08",$gun4);
$gun4 = str_replace(" Eylül",".09",$gun4);
$gun4 = str_replace(" Ekim",".10",$gun4);
$gun4 = str_replace(" Kasim",".11",$gun4);
$gun4 = str_replace(" Aralik",".12",$gun4);

$gun4 = str_replace(" Pazartesi",".".date("Y"),$gun4);
$gun4 = str_replace(" Sali",".".date("Y"),$gun4);
$gun4 = str_replace(" Çarsamba",".".date("Y"),$gun4);
$gun4 = str_replace(" Persembe",".".date("Y"),$gun4);
$gun4 = str_replace(" Cumartesi",".".date("Y"),$gun4);
$gun4 = str_replace(" Cuma",".".date("Y"),$gun4);
$gun4 = str_replace(" Pazar",".".date("Y"),$gun4);

$thmmin4Baslangic = strpos($html,"thmMin4",0);
$thmmin4Baslangic = strpos($html,"\">",$thmmin4Baslangic);
$thmmin4Bitis = strpos($html,"</",$thmmin4Baslangic);
$thmmin4 = substr($html,$thmmin4Baslangic+2,$thmmin4Bitis-$thmmin4Baslangic-2);

$thmmax4Baslangic = strpos($html,"thmMax4",0);
$thmmax4Baslangic = strpos($html,"\">",$thmmax4Baslangic);
$thmmax4Bitis = strpos($html,"</",$thmmax4Baslangic);
$thmmax4 = substr($html,$thmmax4Baslangic+2,$thmmax4Bitis-$thmmax4Baslangic-2);

$thmhadise4Baslangic = strpos($html,"imgHadise4",0);
$thmhadise4Baslangic = strpos($html,"src=\"",$thmhadise4Baslangic);
$thmhadise4Bitis = strpos($html,"alt=",$thmhadise4Baslangic);
$thmhadise4 = substr($html,$thmhadise4Baslangic+5,$thmhadise4Bitis-$thmhadise4Baslangic-7);
$imgthmhadise4="<img src=\"http://www.dmi.gov.tr/tahmin/".$thmhadise4."\" width=\"20\">";

//5---------
$gun5Baslangic = strpos($html,"thmGun5",0);
$gun5Baslangic = strpos($html,"\">",$gun5Baslangic);
$gun5Bitis = strpos($html,"</",$gun5Baslangic);
$gun5 = substr($html,$gun5Baslangic+2,$gun5Bitis-$gun5Baslangic-2);

$gun5 = mb_convert_encoding($gun5,"ISO-8859-9","UTF-8");
$gun5 = str_replace(" Ocak",".01",$gun5);
$gun5 = str_replace(" Subat",".02",$gun5);
$gun5 = str_replace(" Mart",".03",$gun5);
$gun5 = str_replace(" Nisan",".04",$gun5);
$gun5 = str_replace(" Mayis",".05",$gun5);
$gun5 = str_replace(" Haziran",".06",$gun5);
$gun5 = str_replace(" Temmuz",".07",$gun5);
$gun5 = str_replace(" Agustos",".08",$gun5);
$gun5 = str_replace(" Eylül",".09",$gun5);
$gun5 = str_replace(" Ekim",".10",$gun5);
$gun5 = str_replace(" Kasim",".11",$gun5);
$gun5 = str_replace(" Aralik",".12",$gun5);

$gun5 = str_replace(" Pazartesi",".".date("Y"),$gun5);
$gun5 = str_replace(" Sali",".".date("Y"),$gun5);
$gun5 = str_replace(" Çarsamba",".".date("Y"),$gun5);
$gun5 = str_replace(" Persembe",".".date("Y"),$gun5);
$gun5 = str_replace(" Cumartesi",".".date("Y"),$gun5);
$gun5 = str_replace(" Cuma",".".date("Y"),$gun5);
$gun5 = str_replace(" Pazar",".".date("Y"),$gun5);

$thmmin5Baslangic = strpos($html,"thmMin5",0);
$thmmin5Baslangic = strpos($html,"\">",$thmmin5Baslangic);
$thmmin5Bitis = strpos($html,"</",$thmmin5Baslangic);
$thmmin5 = substr($html,$thmmin5Baslangic+2,$thmmin5Bitis-$thmmin5Baslangic-2);

$thmmax5Baslangic = strpos($html,"thmMax5",0);
$thmmax5Baslangic = strpos($html,"\">",$thmmax5Baslangic);
$thmmax5Bitis = strpos($html,"</",$thmmax5Baslangic);
$thmmax5 = substr($html,$thmmax5Baslangic+2,$thmmax5Bitis-$thmmax5Baslangic-2);

$thmhadise5Baslangic = strpos($html,"imgHadise5",0);
$thmhadise5Baslangic = strpos($html,"src=\"",$thmhadise5Baslangic);
$thmhadise5Bitis = strpos($html,"alt=",$thmhadise5Baslangic);
$thmhadise5 = substr($html,$thmhadise5Baslangic+5,$thmhadise5Bitis-$thmhadise5Baslangic-7);
$imgthmhadise5="<img src=\"http://www.dmi.gov.tr/tahmin/".$thmhadise5."\" width=\"20\">";
+0
-0
Cevaba KatılıyorumKatılmıyorum
Cevap Yaz Yorum Yaz Arşivime Ekle Takip Et

Doğru Cevap

  • siyahbeyaz adlı üyenin fotoğrafı
    9 yıl önce yazılmış
    9 yıl önce güncellenmiş
    472 cevap - 20 soru
    cron job diye arat. googleden.. cron job linuxta calısan bir uygulama. windowstaki karşılıgı zamanlanmış görevler. diye gecer. istedigin süreler icinde sunucu sana o dosyayı webbrowser olarak calıstırmasını saglayabilrsin. yada ziyaretci girdiginde güncelleme yapmasını istiyorsann söyle bir fikir sunabilirim..


    &lt;?php
    $saat = date(&quot;G&quot;);

    if($saat &gt;= 12 || $saat &lt;= 13) // saat 12:00 dan büyük ve 13:00 dan küçükse bir güncelleme yapsın..
    include(&quot;havadurumuguncelle.php&quot;);
    elseif($saat &gt;=15 || $saat &lt;=16)
    ... gibi. buradaki mantıkca cok amatörce eger sitenize cok kullanıcı giriyorsa her defasında veritabanına yada sisteme yüklenmek mantıklı degil.. saglam ve temiz birsey istiyorsan


    dedigim cronjob olayını yap.
    bir digeri ise verileri veritabanında yada bir txt veya bir xml icinde sakla. her defasında php ile ordan okut. cronjob ile oraya upload et..

Cevaplar

Hiç cevap bulunamadı.