PDA       
     
 

:


1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87

IP .


    artuska 19.02.2007 - 12:47
!

, , , .
, "" :

PHP
  1.  
  2. function get_user_ip()
  3. {
  4. $strRemoteIP = $_SERVER['REMOTE_ADDR'];
  5.  
  6. if (!$strRemoteIP) { $strRemoteIP = urldecode(getenv('HTTP_CLIENTIP'));}
  7.  
  8. if (getenv('HTTP_X_FORWARDED_FOR')) { $strIP = getenv('HTTP_X_FORWARDED_FOR'); }
  9. elseif (getenv('HTTP_X_FORWARDED')) { $strIP = getenv('HTTP_X_FORWARDED'); }
  10. elseif (getenv('HTTP_FORWARDED_FOR')) { $strIP = getenv('HTTP_FORWARDED_FOR'); }
  11. elseif (getenv('HTTP_FORWARDED')) { $strIP = getenv('HTTP_FORWARDED'); }
  12. else { $strIP = $_SERVER['REMOTE_ADDR']; }
  13.  
  14. if ($strRemoteIP != $strIP) { $strIP = $strRemoteIP.", ".$strIP; }
  15.  
  16. return $strIP;
  17. }
  18.  


.

! . , - - . $_SERVER['REMOTE_ADDR'] ( , ) , !!!

, . ?
. - , .

, !!!

clapping.gif


    vasa_c 19.02.2007 - 12:57
, , IP . , , . IP http-. HTTP_X_FORWARDED_FOR . , , , .


    cage 19.02.2007 - 13:11
, -... , ! ,


    artuska 19.02.2007 - 13:25
to cage:

- , ?
- - , , - CTRL+R, !!! , , , 15 , ...


    cage 19.02.2007 - 13:32
, , -, -,
... , ))))))




    artuska 19.02.2007 - 13:46
, - !!! , ? _=,____!!!

, . - )


    PHPLion 23.02.2007 - 03:41
- ...
4,5



    Nikitian 13.07.2009 - 22:14
, :
get_ip()
functionget_ip()
{
global$REMOTE_ADDR;
global$HTTP_X_FORWARDED_FOR,$HTTP_X_FORWARDED,$HTTP_FORWARDED_FOR,$HTTP_FORWARDED;
global$HTTP_VIA,$HTTP_X_COMING_FROM,$HTTP_COMING_FROM;
global$HTTP_SERVER_VARS,$HTTP_ENV_VARS;
//Getsomeserver/environmentvariablesvalues
if(empty($REMOTE_ADDR))
{
if(!empty($_SERVER)&&isset($_SERVER['REMOTE_ADDR']))
{
$REMOTE_ADDR=$_SERVER['REMOTE_ADDR'];
}
elseif(!empty($_ENV)&&isset($_ENV['REMOTE_ADDR']))
{
$REMOTE_ADDR=$_ENV['REMOTE_ADDR'];
}
elseif(!empty($HTTP_SERVER_VARS)&&isset($HTTP_SERVER_VARS['REMOTE_ADDR']))
{
$REMOTE_ADDR=$HTTP_SERVER_VARS['REMOTE_ADDR'];
}
elseif(!empty($HTTP_ENV_VARS)&&isset($HTTP_ENV_VARS['REMOTE_ADDR']))
{
$REMOTE_ADDR=$HTTP_ENV_VARS['REMOTE_ADDR'];
}
elseif(@getenv('REMOTE_ADDR'))
{
$REMOTE_ADDR=getenv('REMOTE_ADDR');
}
}//endif
if(empty($HTTP_X_FORWARDED_FOR))
{
if(!empty($_SERVER)&&isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
$HTTP_X_FORWARDED_FOR=$_SERVER['HTTP_X_FORWARDED_FOR'];
}
elseif(!empty($_ENV)&&isset($_ENV['HTTP_X_FORWARDED_FOR']))
{
$HTTP_X_FORWARDED_FOR=$_ENV['HTTP_X_FORWARDED_FOR'];
}
elseif(!empty($HTTP_SERVER_VARS)&&isset($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']))
{
$HTTP_X_FORWARDED_FOR=$HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'];
}
elseif(!empty($HTTP_ENV_VARS)&&isset($HTTP_ENV_VARS['HTTP_X_FORWARDED_FOR']))
{
$HTTP_X_FORWARDED_FOR=$HTTP_ENV_VARS['HTTP_X_FORWARDED_FOR'];
}
elseif(@getenv('HTTP_X_FORWARDED_FOR'))
{
$HTTP_X_FORWARDED_FOR=getenv('HTTP_X_FORWARDED_FOR');
}
}//endif
if(empty($HTTP_X_FORWARDED))
{
if(!empty($_SERVER)&&isset($_SERVER['HTTP_X_FORWARDED']))
{
$HTTP_X_FORWARDED=$_SERVER['HTTP_X_FORWARDED'];
}
elseif(!empty($_ENV)&&isset($_ENV['HTTP_X_FORWARDED']))
{
$HTTP_X_FORWARDED=$_ENV['HTTP_X_FORWARDED'];
}
elseif(!empty($HTTP_SERVER_VARS)&&isset($HTTP_SERVER_VARS['HTTP_X_FORWARDED']))
{
$HTTP_X_FORWARDED=$HTTP_SERVER_VARS['HTTP_X_FORWARDED'];
}
elseif(!empty($HTTP_ENV_VARS)&&isset($HTTP_ENV_VARS['HTTP_X_FORWARDED']))
{
$HTTP_X_FORWARDED=$HTTP_ENV_VARS['HTTP_X_FORWARDED'];
}
elseif(@getenv('HTTP_X_FORWARDED'))
{
$HTTP_X_FORWARDED=getenv('HTTP_X_FORWARDED');
}
}//endif
if(empty($HTTP_FORWARDED_FOR))
{
if(!empty($_SERVER)&&isset($_SERVER['HTTP_FORWARDED_FOR']))
{
$HTTP_FORWARDED_FOR=$_SERVER['HTTP_FORWARDED_FOR'];
}
elseif(!empty($_ENV)&&isset($_ENV['HTTP_FORWARDED_FOR']))
{
$HTTP_FORWARDED_FOR=$_ENV['HTTP_FORWARDED_FOR'];
}
elseif(!empty($HTTP_SERVER_VARS)&&isset($HTTP_SERVER_VARS['HTTP_FORWARDED_FOR']))
{
$HTTP_FORWARDED_FOR=$HTTP_SERVER_VARS['HTTP_FORWARDED_FOR'];
}
elseif(!empty($HTTP_ENV_VARS)&&isset($HTTP_ENV_VARS['HTTP_FORWARDED_FOR']))
{
$HTTP_FORWARDED_FOR=$HTTP_ENV_VARS['HTTP_FORWARDED_FOR'];
}
elseif(@getenv('HTTP_FORWARDED_FOR'))
{
$HTTP_FORWARDED_FOR=getenv('HTTP_FORWARDED_FOR');
}
}//endif
if(empty($HTTP_FORWARDED))
{
if(!empty($_SERVER)&&isset($_SERVER['HTTP_FORWARDED']))
{
$HTTP_FORWARDED=$_SERVER['HTTP_FORWARDED'];
}
elseif(!empty($_ENV)&&isset($_ENV['HTTP_FORWARDED']))
{
$HTTP_FORWARDED=$_ENV['HTTP_FORWARDED'];
}
elseif(!empty($HTTP_SERVER_VARS)&&isset($HTTP_SERVER_VARS['HTTP_FORWARDED']))
{
$HTTP_FORWARDED=$HTTP_SERVER_VARS['HTTP_FORWARDED'];
}
elseif(!empty($HTTP_ENV_VARS)&&isset($HTTP_ENV_VARS['HTTP_FORWARDED']))
{
$HTTP_FORWARDED=$HTTP_ENV_VARS['HTTP_FORWARDED'];
}
elseif(@getenv('HTTP_FORWARDED'))
{
$HTTP_FORWARDED=getenv('HTTP_FORWARDED');
}
}//endif
if(empty($HTTP_VIA))
{
if(!empty($_SERVER)&&isset($_SERVER['HTTP_VIA']))
{
$HTTP_VIA=$_SERVER['HTTP_VIA'];
}
elseif(!empty($_ENV)&&isset($_ENV['HTTP_VIA']))
{
$HTTP_VIA=$_ENV['HTTP_VIA'];
}
elseif(!empty($HTTP_SERVER_VARS)&&isset($HTTP_SERVER_VARS['HTTP_VIA']))
{
$HTTP_VIA=$HTTP_SERVER_VARS['HTTP_VIA'];
}
elseif(!empty($HTTP_ENV_VARS)&&isset($HTTP_ENV_VARS['HTTP_VIA']))
{
$HTTP_VIA=$HTTP_ENV_VARS['HTTP_VIA'];
}
elseif(@getenv('HTTP_VIA'))
{
$HTTP_VIA=getenv('HTTP_VIA');
}
}//endif
if(empty($HTTP_X_COMING_FROM))
{
if(!empty($_SERVER)&&isset($_SERVER['HTTP_X_COMING_FROM']))
{
$HTTP_X_COMING_FROM=$_SERVER['HTTP_X_COMING_FROM'];
}
elseif(!empty($_ENV)&&isset($_ENV['HTTP_X_COMING_FROM']))
{
$HTTP_X_COMING_FROM=$_ENV['HTTP_X_COMING_FROM'];
}
elseif(!empty($HTTP_SERVER_VARS)&&isset($HTTP_SERVER_VARS['HTTP_X_COMING_FROM']))
{
$HTTP_X_COMING_FROM=$HTTP_SERVER_VARS['HTTP_X_COMING_FROM'];
}
elseif(!empty($HTTP_ENV_VARS)&&isset($HTTP_ENV_VARS['HTTP_X_COMING_FROM']))
{
$HTTP_X_COMING_FROM=$HTTP_ENV_VARS['HTTP_X_COMING_FROM'];
}
elseif(@getenv('HTTP_X_COMING_FROM'))
{
$HTTP_X_COMING_FROM=getenv('HTTP_X_COMING_FROM');
}
}//endif
if(empty($HTTP_COMING_FROM))
{
if(!empty($_SERVER)&&isset($_SERVER['HTTP_COMING_FROM']))
{
$HTTP_COMING_FROM=$_SERVER['HTTP_COMING_FROM'];
}
elseif(!empty($_ENV)&&isset($_ENV['HTTP_COMING_FROM']))
{
$HTTP_COMING_FROM=$_ENV['HTTP_COMING_FROM'];
}
elseif(!empty($HTTP_COMING_FROM)&&isset($HTTP_SERVER_VARS['HTTP_COMING_FROM']))
{
$HTTP_COMING_FROM=$HTTP_SERVER_VARS['HTTP_COMING_FROM'];
}
elseif(!empty($HTTP_ENV_VARS)&&isset($HTTP_ENV_VARS['HTTP_COMING_FROM']))
{
$HTTP_COMING_FROM=$HTTP_ENV_VARS['HTTP_COMING_FROM'];
}
elseif(@getenv('HTTP_COMING_FROM'))
{
$HTTP_COMING_FROM=getenv('HTTP_COMING_FROM');
}
}//endif
//Getsthedefaultipsentbytheuser

if(!empty($REMOTE_ADDR))
{
$direct_ip=$REMOTE_ADDR;
}
//Getstheproxyipsentbytheuser
$proxy_ip='';
if(!empty($HTTP_X_FORWARDED_FOR))$proxy_ip=$HTTP_X_FORWARDED_FOR;
elseif(!empty($HTTP_X_FORWARDED))$proxy_ip=$HTTP_X_FORWARDED;
elseif(!empty($HTTP_FORWARDED_FOR))$proxy_ip=$HTTP_FORWARDED_FOR;
elseif(!empty($HTTP_FORWARDED))$proxy_ip=$HTTP_FORWARDED;
elseif(!empty($HTTP_VIA))$proxy_ip=$HTTP_VIA;
elseif(!empty($HTTP_X_COMING_FROM))$proxy_ip=$HTTP_X_COMING_FROM;
elseif(!empty($HTTP_COMING_FROM))$proxy_ip=$HTTP_COMING_FROM;
//ReturnsthetrueIPifithasbeenfound,elseFALSE
if(empty($proxy_ip))
{
//TrueIPwithoutproxy
return$direct_ip;
}
else
{
$is_ip=ereg('^([0-9]{1,3}\.){3,3}[0-9]{1,3}',$proxy_ip,$regs);
if($is_ip&&(count($regs)>0))
{
//TrueIPbehindaproxy
return$regs[0];
}
else
{
//Can'tdefineIP:thereisaproxybutwedon'thave
//informationaboutthetrueIP
returnFALSE;
}
}//endif...else...
}

, , .. )


    gooder 14.07.2009 - 10:08
Nikitian
)


    nnov 6.06.2010 - 19:23
, , ip
echo ? sad.gif
!



    Nikitian 27.08.2010 - 17:35
(nnov @ 6.06.2010 - 15:23)
, , ip
echo ? sad.gif
!

:
echo get_ip();