Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] file_get_cotents failed to open stream gdzię błąd
twardes
post
Post #1





Grupa: Zarejestrowani
Postów: 23
Pomógł: 0
Dołączył: 13.01.2008

Ostrzeżenie: (0%)
-----


Witam!

Mam oto taki plik który odpowiedzialny jest za pingowanie sitemapy (http://www.forumbiznesu.eu/rapidfinder.pl/tesssst.php)

  1. <?php
  2.  
  3. function sitemapSubmit($strona,$engine,$OKmessage,$NOmessage)
  4. {
  5.    
  6.    $okTag = 'OKsi';
  7.    $noTag = 'NOsi';
  8.    
  9.    $pingurl = $engine.$strona;
  10.  
  11.    $source = @file_get_contents("$pingurl");
  12.  
  13.    if ($source != false) {
  14.        
  15.        $source = strip_tags($source);
  16.        $source = "BUFOR".$source;
  17.        
  18.        $isOKmessage = stripos($source,$OKmessage);
  19.        $isNOmessage = stripos($source,$NOmessage);
  20.        
  21.        if (($isOKmessage != false)&&($isNOmessage == false)) {$submitRaport = $okTag.$OKmessage;}
  22.        if (($isOKmessage == false)&&($isNOmessage != false)) {$submitRaport = $noTag.$NOmessage;}
  23.        if (($isOKmessage == false)&&($isNOmessage == false)) {$submitRaport = $noTag.'Submission error';}
  24.  
  25.    }
  26.    
  27.    else if ($source == false) {$submitRaport = $noTag.'Engine error';}
  28.    
  29.    return array($source, $submitRaport);
  30.  
  31. }
  32.  
  33. $silnik = array(
  34.  
  35.    'goo' => array (
  36.        'nazwaEngine' => 'Google',
  37.        'engine' => 'http://www.google.com/webmasters/sitemaps/ping?sitemap=',
  38.        'OKmessage' => 'Sitemap Notification Received',
  39.        'NOmessage' => 'Bad Request'
  40.    ),
  41.  
  42.    'yah' => array (
  43.        'nazwaEngine' => 'Yahoo!',
  44.        'engine' => 'http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap=',
  45.        'OKmessage' => 'Update notification has successfully submitted',
  46.        'NOmessage' => 'The following errors were detected'
  47.    ),    
  48.  
  49.    'liv' => array (
  50.        'nazwaEngine' => 'Live Search',
  51.        'engine' => 'http://webmaster.live.com/ping.aspx?siteMap=',
  52.        'OKmessage' => 'Thanks for submitting your sitemap',
  53.        'NOmessage' => 'baddddddd'
  54.    ),
  55.  
  56.    'ask' => array (
  57.        'nazwaEngine' => 'Ask.com',
  58.        'engine' => 'http://submissions.ask.com/ping?sitemap=',
  59.        'OKmessage' => 'Your Sitemap submission was successful',
  60.        'NOmessage' => 'Your Sitemap submission was not successful'
  61.    ),
  62.  
  63.    'mor' => array (
  64.        'nazwaEngine' => 'Moreover',
  65.        'engine' => 'http://api.moreover.com/ping?u=',
  66.        'OKmessage' => 'Thank you for your ping',
  67.        'NOmessage' => 'baddddddd'
  68.    ),
  69.    
  70.    'for' => array (
  71.        'nazwaEngine' => 'ForumBiznesu.eu',
  72.        'engine' => 'http://www.forumbiznesu.eu/wordpress/submission.php?sitemap=',
  73.        'OKmessage' => 'Sitemap submission successful',
  74.        'NOmessage' => 'baddddddd'
  75.    ),
  76.  
  77. );
  78.  
  79.  
  80. $added_sitemap .= '<p>';
  81.  
  82. foreach ($silnik as $siln => $cecha )
  83. {
  84.    
  85. $nazwaEngine    = $cecha['nazwaEngine'];
  86. $engine            = $cecha['engine'];
  87. $OKmessage        = $cecha['OKmessage'];
  88. $NOmessage        = $cecha['NOmessage'];
  89.  
  90. $strona = "http://www.jakasstrona.com/sitemap.xlm";
  91.  
  92. list ($source, $submitRaport) =  sitemapSubmit($strona,$engine,$OKmessage,$NOmessage);
  93.  
  94. $statusTag = substr($submitRaport,0,4);
  95. if ($statusTag == 'OKsi') {$icon = ':-) ';}
  96. else if ($statusTag == 'NOsi') {$icon = ';-OOOOO ';}
  97. else {$icon = '';}
  98.  
  99. $submitRaport = substr($submitRaport,4);
  100.  
  101. $insert_sitemap = "\n".$icon."<b>".$nazwaEngine."</b> reported:<br /><i>".$submitRaport."</i><br />";
  102. $added_sitemap .= $insert_sitemap;
  103.  
  104. }
  105.  
  106. $added_sitemap .= '</p>';
  107.  
  108. ?>
  109.  
  110. <?=$added_sitemap?>



Jednakże z niejasnych przyczyn prawie zawszenie nie udaje się uzyskać treści http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap=http://www.jakasstrona.com/sitemap.xlm (raz na 100 zadziała)
wpisując ręcznie ten adres problemużadnego nie ma.

gdy pozbędę się operatora
@ sprzed funkcji file_get_contents() (tak wygląda plik na serwerze) widzę komunikat:
Kod
         Warning:  file_get_contents(http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap=http://www.jakasstrona.com/sitemap.xlm) function.file-get-contents: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden   in /home/twardes0/public_html/rapidfinder.pl/tesssst.php on line 11


próbowałem różnych rozwiązań ale na razie nici (domyślam się że chodzi o nagłówki http)




Proszę o wasze pomysły


--------------------
Jak założyć firmę, napisać biznes plan? - ForumBiznesu.eu
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.08.2025 - 08:06