Quantcast
Channel: SA-MP Forums
Viewing all articles
Browse latest Browse all 18226

php question

$
0
0
hello all boys/girls, please do anyone know how to get Visitor's IP Address on PHP ??
i tried
PHP Code:

function GetClientIP($validate False)
{
  
$ipkeys = array(
  
'REMOTE_ADDR'
  
'HTTP_CLIENT_IP'
  
'HTTP_X_FORWARDED_FOR'
  
'HTTP_X_FORWARDED'
  
'HTTP_FORWARDED_FOR'
  
'HTTP_FORWARDED'
  
'HTTP_X_CLUSTER_CLIENT_IP'
  
);

  
$ip = array();
  foreach(
$ipkeys as $keyword){
    if( isset(
$_SERVER[$keyword]) ){
      if(
$validate){
        if(
ValidatePublicIP($_SERVER[$keyword]) ){
          
$ip[] = $_SERVER[$keyword];
        }
      }else{
        
$ip[] = $_SERVER[$keyword];
      }
    }
  }

  
$ip = ( empty($ip) ? 'Unknown' implode(", "$ip) );
  return 
$ip;

}
function 
ValidatePublicIP($ip)
{
  if(
filter_var($ipFILTER_VALIDATE_IPFILTER_FLAG_NO_PRIV_RANGE FILTER_FLAG_NO_RES_RANGE)) {
    return 
true;
  }
  else {
    return 
false;
  }


but it always returns Unknown or ::1

please some help ???

Viewing all articles
Browse latest Browse all 18226

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>