Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
fade2gray
Regular
Regular



Joined: Mar 26, 2006
Posts: 87
Location: UK

PostPosted: Sat Apr 22, 2006 5:46 pm Reply with quote

Essentially, I'd like to prevent my IP address from tripping the hit counter whenever I turn a page whether I'm logged in as user, admin or just browsing anonymously.

I found a piece of code that will work for a static IP, but mine is dynamic and sometimes changes if my broadband connection gets cycled.

In the header.php file, replace
Code:
include("includes/counter.php");

with
Code:
$the_ip = $_SERVER[REMOTE_ADDR];

if($the_ip != "xxx.xxx.xxx.xxx") {
     include("includes/counter.php");
}

// code credit= Humpa & chris_au.

inserting the IP address at the x's.

I guess what I'm looking for is a modification to the index.php that'll get my IP and insert it into the header.php. Is this viable one way or another?

Thanks.
 
View user's profile Send private message Visit poster's website
evaders99
Former Moderator in Good Standing



Joined: Apr 30, 2004
Posts: 3221

PostPosted: Sat Apr 22, 2006 6:14 pm Reply with quote

We can do something like

Code:


if(!stristr($the_ip,"xxx.xxx.xxx.")) {


That will take the class C part of the IP address. Depending on your ISP, you may have multiple ranges of IPs.

Another option is just not to count things when you're an admin. It does require that you remain logged in, but at least it isn't IP dependent anymore.

_________________
- Only registered users can see links on this board! Get registered or login! -

Need help? Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
fade2gray







PostPosted: Sat Apr 22, 2006 6:54 pm Reply with quote

evaders99 wrote:
That will take the class C part of the IP address. Depending on your ISP, you may have multiple ranges of IPs.

So this would work but might also exclude other users of the same ISP?


evaders99 wrote:
Another option is just not to count things when you're an admin. It does require that you remain logged in, but at least it isn't IP dependent anymore.

Yes, Dirk over at Nukies suggested I stick with this method, but I'm not the only user of this box and wanted to minimize this risk of accidents by staying logged in. I'll just have to remember to log in before browsing too deeply.

Thanks.
 
evaders99







PostPosted: Sat Apr 22, 2006 11:07 pm Reply with quote

Yes it would. Go the easy route as suggested, use the admin login Smile
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©