开发者

2 IP are stored for a visitor : PROXY?

开发者 https://www.devze.com 2022-12-29 18:01 出处:网络
on my database i\'ve decided to store IP of the visitors who answoers to polls. It\'s all working, but there开发者_运维百科 is only 2 cases where not only 1 IP is stored, but there is 2 SAME ip for th

on my database i've decided to store IP of the visitors who answoers to polls. It's all working, but there开发者_运维百科 is only 2 cases where not only 1 IP is stored, but there is 2 SAME ip for the same visitor

MySQL output (i replaced 2 numbers by XX)

10.188.XX.129, 10.188.XX.129

Here's the script to recieve the IP of the visitor :

    <?php 
 function realip() {
     if (isset($_SERVER)) {
   if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
    $realip = $_SERVER["HTTP_X_FORWARDED_FOR"];
   } elseif (isset($_SERVER["HTTP_CLIENT_IP"])) {
    $realip = $_SERVER["HTTP_CLIENT_IP"];
   } else {
    $realip = $_SERVER["REMOTE_ADDR"];
   }

     } else {
   if ( getenv( 'HTTP_X_FORWARDED_FOR' ) ) {
    $realip = getenv( 'HTTP_X_FORWARDED_FOR' );
   } elseif ( getenv( 'HTTP_CLIENT_IP' ) ) {
    $realip = getenv( 'HTTP_CLIENT_IP' );
   } else {
    $realip = getenv( 'REMOTE_ADDR' );
   }
     }
     return $realip;
  }
?>

my question is : 99.9% of the time, only 1 IP is stored on MYSQL. I have 2 cases in mySQL database (example on my post) where 2 IP are stored on 1 row of mySQL : does it means that the visitors were using PROXY ? Thanks


ahhh well, figured it out at last.
you store IP address not in the int column nor even in varchar(15), but something like varchar(255). So, anything can be stored. So, you store anything but IP address.

well. If you want to store an IP address there is only one available in your script - a $_SERVER["REMOTE_ADDR"] one.

There can be some use of realip() function's result, but it should be used with precautions and knowledge, and - most important part - not instead of IP address, but only in addition to it, as some supplemental info.

0

精彩评论

暂无评论...
验证码 换一张
取 消