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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stop counter incrementing for webmaster 1

Status
Not open for further replies.

serpento

Programmer
Joined
Jun 16, 2002
Messages
92
Location
GB
I remember reading somewhere you can stop a counter incrementing for the webmaster by finding the user's IP number using $ENV{'REMOTE_ADDR'} and comparing it with the webmaster's IP number. I cannot get this to work, as every time I connect to the internet, $ENV{'REMOTE_ADDR'} has a different value. Any sugestions?
 
Here's an idea:

Have a simple text file on your server (call it "webmasters.ip") and in that file, store your ip address. Now, the scripts that increment the counter, will check to see if REMOTE_ADDR is the same as the ip in that file.

OK - no solution yet... I know - the trick is to make a new script that servers not other purpose than to alter that text file to match the $ENV{REMOTE_ADDR} of the current user. you can password protect it if you like - but only the webmaster should be able to access that script. So now, everytime you 'dial up' onto the internet, go to that script first thing - it will alter the "webmasters.ip" file and your server will recognize you from there on out - as long as your ip doesn't change (you have to re-logon for instance...).

An example of the script that alters the webmasters.ip file would be:

#============== MeetNewWebmaster.cgi ===========
use CGI;
use CGI::Carp qw/fatalsToBrowser/;

my $j = new CGI;
print $j->header();

open(FILE, ">path/to/webmasters.ip") || die $!;
print FILE $ENV{REMOTE_ADDR};
close(FILE);

print &quot;Greetings new webmaster...<br>\n&quot;;
print &quot;New ip address: $ENV{REMOTE_ADDR}<br>\n&quot;;
print &quot;You may now peruse the website<br>\n&quot;;
print &quot;without being noticed...\n&quot;;

#================= END ==========================

And the scripts that test for the IP should check the
webmasters.ip file to test against the $ENV{REMOTE_ADDR} and act based on that.

--jim
 
OOps:

This is what I typed:

the trick is to make a new script that servers not other purpose than to alter that text file to match the $ENV{REMOTE_ADDR} of the current user.

This is what I meant:

the trick is to make a new script that serves no other purpose than to alter that text file to match the $ENV{REMOTE_ADDR} of the current user.
 
Thanks, thats just what I wanted.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top