• Jetzt anmelden. Es dauert nur 2 Minuten und ist kostenlos!

PHP warning in errorlog!

Fr3ddy

Mitglied
Hi,

ich benutzer das geoplugin zur lokalisierung von usern und jetzt finde ich ein bis zwei mal pro sekunde diesen fehler in meiner errorlog:

PHP Warning: file_get_contents(http://www.geoplugin.net/php.gp?ip=157.55.35.91&amp;base_currency=USD) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
in /wwwroot.wwwnew/templates/geo/geoplugin.class.php on line 105

woran liegt das bzw wieso kommt der fehler?

LG & danke
 
Das 403 habe ich ja auch verstanden, allerdings liegt der fehler wo anders, man muss seine domain noch zusätzlich bei geoplugin.com registrieren.:roll:
 
Ich glaube er hat die Lösung bereits, seine Domain wurde vom Zielserver (geoplugin.com) abgewiesen.
 
Ein direkter Aufruf ist aber möglich (sofern der Link oben stimmt).
Die Seite bleibt zwar leer, es kommt aber kein Fehler
 
Hi,

ich dachte das problem ist gelöst, leider aber doch nicht.
Diese fehlermeldungen tauchen jetzt 3 bis 4 mal in der sekunde in der logdatei auf.

Ich habe hier einen code, der die länder abfragt und ein cookie erstellt, wenn ich den entferne stoppen die fehler aber der code hat am anfang funktioniert:

PHP:
<?php
require_once('geoplugin.class.php');  
$geoplugin = new geoPlugin(); 
$geoplugin->locate(); 
$lang1 = array("AT","LT","LU","BG","NL","CZ","DK","EE","PT","FI","FR","SK","ES","HU","SE","IE","GB","DE"); //ISO 3166 
$lang2 = array("US", "");
$cookieIsSet = false;
$eloquacode = false;
$overlay = false;



    if( !isset($_COOKIE['ish_co']) || $_COOKIE['ish_co'] == '' ) { 
          
 
          if (in_array($geoplugin->countryCode, $lang1))
          {  
                 $cookieIsSet = false;
                $eloquacode = true;
                $overlay = true;
          }
              else if (in_array($geoplugin->countryCode, $lang2))
              {
                 setcookie("ish_co", "ish_in", time()+(3600*24*300));
                 $cookieIsSet = true;
                 $eloquacode = true;
          }else{
             setcookie("ish_co", "ish_in", time()+(3600*24*300));
             $cookieIsSet = true;
             $eloquacode = true;
          }
          
    } else if( $_COOKIE['ish_co'] == 'ish_in' ) {
            $cookieIsSet = true;
            $eloquacode = true;
        
    }else {
            if( $_COOKIE['ish_co'] == 'ish_out' ) {
                $cookieIsSet = true;
                $eloquacode = false;
            } 
}  
 
?>


Hier mal ein asschnitt aus meiner errorlog:

PHP:
[20-Mar-2013 15:05:58 CET] PHP Warning: file_get_contents(http://www.geoplugin.net/php.gp?ip=157.55.35.41&amp;base_currency=USD) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
 in /wwwroot.wwwnew/templates/geo/geoplugin.class.php on line 105
[20-Mar-2013 15:05:58 CET] PHP Warning: file_get_contents(http://www.geoplugin.net/php.gp?ip=157.55.35.41&amp;base_currency=USD) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
 in /wwwroot.wwwnew/templates/geo/geoplugin.class.php on line 105
[20-Mar-2013 15:05:59 CET] PHP Warning: file_get_contents(http://www.geoplugin.net/php.gp?ip=157.56.92.175&amp;base_currency=USD) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
 in /wwwroot.wwwnew/templates/geo/geoplugin.class.php on line 105
[20-Mar-2013 15:06:00 CET] PHP Warning: file_get_contents(http://www.geoplugin.net/php.gp?ip=157.55.35.91&amp;base_currency=USD) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
 in /wwwroot.wwwnew/templates/geo/geoplugin.class.php on line 105
[20-Mar-2013 15:06:00 CET] PHP Warning: file_get_contents(http://www.geoplugin.net/php.gp?ip=157.55.35.91&amp;base_currency=USD) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
 in /wwwroot.wwwnew/templates/geo/geoplugin.class.php on line 105
[20-Mar-2013 15:06:00 CET] PHP Warning: file_get_contents(http://www.geoplugin.net/php.gp?ip=65.55.24.243&amp;base_currency=USD) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
 in /wwwroot.wwwnew/templates/geo/geoplugin.class.php on line 105
[20-Mar-2013 15:06:00 CET] PHP Warning: file_get_contents(http://www.geoplugin.net/php.gp?ip=157.56.92.175&amp;base_currency=USD) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
 in /wwwroot.wwwnew/templates/geo/geoplugin.class.php on line 105
[20-Mar-2013 15:06:00 CET] PHP Warning: file_get_contents(http://www.geoplugin.net/php.gp?ip=157.55.36.49&amp;base_currency=USD) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
 in /wwwroot.wwwnew/templates/geo/geoplugin.class.php on line 105
[20-Mar-2013 15:06:00 CET] PHP Warning: file_get_contents(http://www.geoplugin.net/php.gp?ip=65.55.24.243&amp;base_currency=USD) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
 in /wwwroot.wwwnew/templates/geo/geoplugin.class.php on line 105
[20-Mar-2013 15:06:00 CET] PHP Warning: file_get_contents(http://www.geoplugin.net/php.gp?ip=157.55.36.49&amp;base_currency=USD) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
 in /wwwroot.wwwnew/templates/geo/geoplugin.class.php on line 105
[20-Mar-2013 15:06:00 CET] PHP Warning: file_get_contents(http://www.geoplugin.net/php.gp?ip=157.55.35.41&amp;base_currency=USD) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
 in /wwwroot.wwwnew/templates/geo/geoplugin.class.php on line 105
[20-Mar-2013 15:06:00 CET] PHP Warning: file_get_contents(http://www.geoplugin.net/php.gp?ip=157.56.92.175&amp;base_currency=USD) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
 in /wwwroot.wwwnew/templates/geo/geoplugin.class.php on line 105
[20-Mar-2013 15:06:01 CET] PHP Warning: file_get_contents(http://www.geoplugin.net/php.gp?ip=157.55.35.41&amp;base_currency=USD) [<a href='function.file-get-contents'>function.file-get-contents</a>]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden
 in /wwwroot.wwwnew/templates/geo/geoplugin.class.php on line 105
Und ich habe keine hanung wieso das so los feuert. -.-
 
Zuletzt bearbeitet:
Das wirst Du auch nicht loswerden, wenn Du an der Methode zum Abruf etwas änderst. geoplugin prüft offenbar regelmäßig (täglich) wer deren Service wie oft nutzt. Referrer die durch sehr viele Aufrufe einen hohen Traffic bei denen verursachen werden gesperrt. Diejenigen erhalten dann einen HTTP Status 403 vom geoplugin-Server zurück. Siehe dazu:
https://groups.google.com/forum/?fromgroups=#!topic/geoplugin/tyWuXqOx8M0

Eine Lösung wäre, dass Du diese Abrufe nicht so kurz hintereinander machst und zusätzlich die Rückgaben auch selbst bei dir speicherst. Dann musst Du nicht ständig neue Requests an den Dienst schicken.

Alternativ könntest Du dich auch an geoplugin wenden und sagen was dein Problem ist. Im besten Fall machen die dir ein Angebot wodurch Du beliebig viele Abrufe der Daten durchführen kann - kostenpflichtig. Ähnlich macht es Google selbst bei der GoogleMapAPI auch schon seit geraumer Zeit.
 
Ok, danke shcon mal.

Was ich allerdings nicht verstehe, das php script was ich geschrieben habe, macht doch nur eine abfrage an geoplugin, wenn ein nutzer auf meine websseite kommt, oder habe ich da etwas falsch verstanden?

Wenn nein, wo kommen dann die vielen anfragen her?
 
Angenommen deine Webseite besteht aus 5 Seiten. Ein Besucher ruft davon nun eine Seite auf und erzeugt eine solchen Request an den Service. Der selbe Besucher ruft danach auch die 4 anderen Seiten auf und erzeugt jeweils einen neuen Request. Insgesamt also 5 innerhalb relativ kurzer Zeit.

Jetzt kommt dazu, dass Du mehr Besucher als nur einen hast. Egal ob menschlich oder Bot - sie rufen die 5 Seiten ständig auf und führen jedes Mal diese Anfrage aus. Wenn Du an einem Tag 200 Besucher hast die 400 Seiten aufrufen hast Du 400 Requests an den Service gestartet.
 
Ich habe z.B. einen kleinen Wetter-Ticker, der von noaa Flugdaten holt. Das läuft per Cronjob jede Stunde, nachts alle 2 Stunden.
Was ich damit sagen will... Sowas ist per Cron am einfachsten, spart Ladezeiten bei dir und ist regelbar.
 
Zurück
Oben