PhP İle IP Adresi Öğrenme

Aşağıdaki php kodu ziyaretçinin standart olan ip adresini alır:

echo $_SERVER['REMOTE_ADDR'];

Aşağıdaki fonksiyon ise gerçek ip adresini alır:

function GetIP(){
    if(getenv("HTTP_CLIENT_IP")) {
         $ip = getenv("HTTP_CLIENT_IP");
     } elseif(getenv("HTTP_X_FORWARDED_FOR")) {
         $ip = getenv("HTTP_X_FORWARDED_FOR");
         if (strstr($ip, ',')) {
             $tmp = explode (',', $ip);
             $ip = trim($tmp[0]);
         }
     } else {
     $ip = getenv("REMOTE_ADDR");
     }
    return $ip;
}

$ip_adresi = GetIP();

echo GetIP();

Bu cevap yeterince yardımcı oldu mu?

Daha Fazlası

Wordpress open_basedir restriction in effect Hatası Çözümü

Warning file_exists() open_basedir restriction in effect hatasını aşağıdaki şekilde çözerek...

Yandex Mail POP IMAP SMTP Ayarları

Pop: pop.yandex.ru Port: 995 (SSL gerektirir) 110 (SSL gerektirmez)Smtp: smtp.yandex.ru Port: 465...

Wordpress 4.2 Güncelleme Sonrası Notice: register_sidebar was called incorrectly hatası

Merhaba değerli müşterilerimiz,Wordpress 4.1 den 4.2 ye geçişlerde güncelleme sonrası bazı...

Opencart startup.php on line 89 Hatası Çözümü

İlgili hata opencart ın open_basedir yapısı ile sorun yaşamasından yani dizin yolunu...