MyBB Community Forums

Full Version: Spider by hostname
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How can i add spiders by ip ptr insteat of USER_AGENT?
The easiest, but not necessarily the best, way to accomplish this would be to:

1. Add the spider IP address to the User Agent String field in the Spiders/Bots list.

2. Edit ./inc/class_session.php and find:

if(my_strpos(my_strtolower($this->useragent), my_strtolower($spider['useragent'])) !== false)

and replace with:

if(my_strpos(my_strtolower($this->useragent), my_strtolower($spider['useragent'])) !== false || get_ip() == $spider['useragent'])

With this method it allows both useragent and IP address validation.
(2012-09-01, 02:46 PM)Nathan Malcolm Wrote: [ -> ]The easiest, but not necessarily the best, way to accomplish this would be to:

1. Add the spider IP address to the User Agent String field in the Spiders/Bots list.

2. Edit ./inc/class_session.php and find:

if(my_strpos(my_strtolower($this->useragent), my_strtolower($spider['useragent'])) !== false)

and replace with:

if(my_strpos(my_strtolower($this->useragent), my_strtolower($spider['useragent'])) !== false || get_ip() == $spider['useragent'])

With this method it allows both useragent and IP address validation.

Ok, knowing the file i can properly drive this,

So if i want to use the ptr i must just do

if(my_strpos(my_strtolower($this->useragent), my_strtolower($spider['useragent'])) !== false || preg_match("/" . $spider['useragent'] . "/i",gethostbyaddr(get_ip())

assuming $spider is an array with the spider data

Thanks Smile