CodeIgniter Forums

Full Version: Detecting Bot using Codeigniter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is there any class or helper in CI for detecting and blocking bad bots? i have some pages that i don't want be visible by bot,
i know i can use robot.txt but some bots can read that,...
I don't believe so. The only way really to detect would be the visitors (bot) IP and/or user agent string, both of which can easily be changed and are unreliable. If you have some pages that shouldn't be visible by someone (anyone), they should be behind a login, otherwise everything is considered public. What are you trying to prevent bots from seeing?
in fact in my application any user get some point when one of him/his articles viewed by some one, so one user can get many point by using a bot,
For bots which are behaving properly, you can use the user_agent library:
http://www.codeigniter.com/user_guide/li...::is_robot

$this->agent->is_robot() or $this->agent->is_robot('name_of_bot')

As already mentioned, though, when someone wants to create a bot which misbehaves, more than likely they're going to make it difficult for you to detect that bot, as well.