×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Bob Ray
Added: Jul 16, 2015 10:16 PM
Modified: Jul 16, 2015 10:35 PM
Views: 13
Tags: address ip real
Gets visitor's real IP address
  1. /* Original code by Mohit Madan @TheMohitMadan */
  2. function getRealIpAddr()  
  3. {  
  4.     if (!emptyempty($_SERVER['HTTP_CLIENT_IP']))  
  5.     {  
  6.         $ip=$_SERVER['HTTP_CLIENT_IP'];  
  7.     }  
  8.     elseif (!emptyempty($_SERVER['HTTP_X_FORWARDED_FOR']))  
  9.     //to check ip is pass from proxy  
  10.     {  
  11.         $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];  
  12.     }  
  13.     else  
  14.     {  
  15.         $ip=$_SERVER['REMOTE_ADDR'];  
  16.     }  
  17.     return $ip;  
  18. }