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ı

Sorry, this file type is not permitted for security reasons Çözümü

Wordpress scriptinizde dosya yüklerken Satır x Sorry, this file type is not permitted for...

Prestashop 1.7 HTTP 500 Hatası Çözümü

Prestashop 1.7 versiyonunda kurulum sonunda 500 internal server hatası alıyor iseniz aşağıdaki...

OpenCart ERR_CONTENT_DECODING_FAILED Hatası Çözümü

OpenCart modüllerinde bazen ERR CONTENT DECODING FAILED hatası alabilirsiniz. Bu hatayı aşağıdaki...

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...

PhP Timezone Hatası Çözümü - date() It is not safe to rely on the system's timezone settings

date() It is not safe to rely on the system's timezone settings hatasının çözümü aşağıdaki...