Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Static IPs in PHP

Status
Not open for further replies.

rossmcl

Programmer
Apr 18, 2000
128
Hi,

I use the following code to store the IP address of a visitor to my site. It worked perfectly...until I recently changed ISP.

This new ISP doesnt give me a static IP address. So I am wondering, does anyone know of a cunning way in PHP so that when I enter my website, it doesnt store my IP details and skey my visitor numbers. Can I use IPCONFIG in php or something . . . hmm, I am not sure if this is possible, but would really appreciate if any php experts have a cunning ploy!

Much appreciated as always
Rossmcl

===

<?php

$filename = "VisitorsDetailsBlog.txt";
$handle = fopen ($filename, "a+");
$todaydate = date("Y-m-d H:i:s");
$visitorInfo = $HTTP_SERVER_VARS['REMOTE_ADDR'];
$url = $_SERVER['REQUEST_URI'];
$test = $_SERVER[HTTP_REFERER];


if ($visitorInfo == "212.126.131.105")
{
//do nothing
}
else
{
fwrite($handle, "\r\n" . $todaydate . ' ' . $visitorInfo . ' ' . $test . ' ' . $url);
}
fclose( $handle );


?>

 
You could try using php sessions
where only you have a particular session value. Then you can check the value of it for the one you have and only if it doesn't contain your value will the ip be captured.
 
I would use a variant of smashing's idea. But instead of sessions, I would create a script that is not linked-to by any other part of your site.

That script is designed to do only one thing -- set a cookie on your browser. Something with a long life before it expires.

Then have your visitor-counter check for that cookie. If it exists, the counter will not record your visit.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thanks for the ultra-fast reponses.

One question - how do you add cookies?

(sorry, I am not an PHP or internet programmer)

Rossmcl

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top