Issue obtaining IP from site visitors on Yahoo server

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Hosty
Forum Newbie
Posts: 8
Joined: Wed Sep 10, 2008 8:54 am

Issue obtaining IP from site visitors on Yahoo server

Post 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
Last edited by Hosty on Wed Sep 10, 2008 1:27 pm, edited 1 time in total.
marcth
Forum Contributor
Posts: 142
Joined: Mon Aug 25, 2008 8:16 am

Re: Issue obtaining IP from site visitors

Post by marcth »

What happens when you do a trace route on the bad IP?
User avatar
Hosty
Forum Newbie
Posts: 8
Joined: Wed Sep 10, 2008 8:54 am

Re: Issue obtaining IP from site visitors

Post 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.
marcth
Forum Contributor
Posts: 142
Joined: Mon Aug 25, 2008 8:16 am

Re: Issue obtaining IP from site visitors

Post by marcth »

Do you have a proxy server in your environment? Firewall? Load Balancer?
User avatar
Hosty
Forum Newbie
Posts: 8
Joined: Wed Sep 10, 2008 8:54 am

Re: Issue obtaining IP from site visitors

Post by Hosty »

no proxy server, no firewall. what is a load balancer?
User avatar
Hosty
Forum Newbie
Posts: 8
Joined: Wed Sep 10, 2008 8:54 am

FIX FOUND

Post 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.
marcth
Forum Contributor
Posts: 142
Joined: Mon Aug 25, 2008 8:16 am

Re: Issue obtaining IP from site visitors on Yahoo server

Post 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.
Post Reply