Page 1 of 1

Issue obtaining IP from site visitors on Yahoo server

Posted: Wed Sep 10, 2008 9:11 am
by Hosty
I record the name, IP and time/date of each person who logs into my site in a flat (or text) file. I do this as a quick reference to IPs that I may need to ban... I have some bad eggs!

Code: Select all

 
<?
$un = $_POST['username'];
$ipMain = $_SERVER['REMOTE_ADDR'];
$time = date("M j Y h:i A");
 
$ourFileName = "mainrecord.txt";
$fh = fopen($ourFileName, 'a') or die("can't open file");
$stringData = "$ipMain \n$time :: $un \n\n";
fwrite($fh, $stringData);
fclose($fh);
?>
 
Problem? I get the same IP number for every visitor. Why? What am I doing wrong?

THANKS for any help.
Hosty

Re: Issue obtaining IP from site visitors

Posted: Wed Sep 10, 2008 9:15 am
by marcth
What happens when you do a trace route on the bad IP?

Re: Issue obtaining IP from site visitors

Posted: Wed Sep 10, 2008 9:24 am
by Hosty
It traces back to "my" server (yahoo/geo).

Edit: although it's not my IP number, and my flat file has this same IP number for everyone who logs in, except the final sub of numbers changes randomly to 128, 129 or 130. (xxx.xxx.xxx.128)

Edit 2: also, I should mention this worked fine for 2 days, then started repeating the IPs. I changed no code during that time, so I'm assuming yahoo did something... I am just stumped.

Re: Issue obtaining IP from site visitors

Posted: Wed Sep 10, 2008 9:47 am
by marcth
Do you have a proxy server in your environment? Firewall? Load Balancer?

Re: Issue obtaining IP from site visitors

Posted: Wed Sep 10, 2008 10:00 am
by Hosty
no proxy server, no firewall. what is a load balancer?

FIX FOUND

Posted: Wed Sep 10, 2008 1:26 pm
by Hosty
$SERVER["REMOTE_ADDR"]; Problem? I get the same IP number for every visitor (yahoo.com's IP). Why? What am I doing wrong?
after looking all over, i did

phpinfo()

in a test.php file and found that yahoo has a different code for IP addresses of my website visitors:

$_SERVER["HTTP_YAHOOREMOTEIP"];

i replaced $_SERVER["REMOTE_ADDR"]; in my file and BAM she worked like a charm.

Re: Issue obtaining IP from site visitors on Yahoo server

Posted: Thu Sep 11, 2008 6:23 am
by marcth
If you work in a clustered server environment, say 2 or 3 servers that handle PHP request, the load balancer is responsible for forwarding a request to the least busy server.