Jump to content


Photo

Use PHP to discern users(browsers) from bots/crawlers? **SOLVED**


  • Please log in to reply
3 replies to this topic

#1 bpops

bpops
  • Members
  • PipPipPip
  • Advanced Member
  • 232 posts

Posted 04 August 2006 - 02:39 AM

I'm working on a counter from my site, and the problem I'm having is that the Google ads are checking my page and incrementing the counter.

Is there a way to check if the requester is a bot/crawler or a user with a browser?

I don't care what the browser is or anything like that, I just don't want bots counting on my counter.

Thanks in advance!

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 04 August 2006 - 02:43 AM

You could try checking the $_SERVER['USER_AGENT'] variable.

#3 bpops

bpops
  • Members
  • PipPipPip
  • Advanced Member
  • 232 posts

Posted 04 August 2006 - 02:59 AM

ok so I figured out that this variable returns "Mediapartners-Google/2.1" with Google Ads.. so I suppose I can just ignore all these requests.

Thanks so much thorpe, and you too nethnet (from my other post). 
You guys have just made me very happy. I've spent hours upon hours this past week trying to figure out why my counter was incrementing more than I was hitting the pages, and now I know how to fix it!!  :)

#4 nethnet

nethnet
  • Members
  • PipPipPip
  • Advanced Member
  • 284 posts
  • LocationPhiladelphia, PA, USA

Posted 04 August 2006 - 03:03 AM

I'm glad I could help (at least with the first part) :)
"Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep."  --Scott Adams

Current project: nethnet.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users