Skip to content

Commit

Permalink
+ If spider checks are enabled, we'll still want to apply a generic t…
Browse files Browse the repository at this point in the history
…est to we::$user['possibly_robot'], to catch any possible unnamed bots. (Class-System.php)
  • Loading branch information
Nao committed Mar 5, 2014
1 parent dd59b61 commit ca3053c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions core/app/Class-System.php
Expand Up @@ -216,17 +216,19 @@ protected static function init_user()
if (isset($_COOKIE[$cookiename]))
$_COOKIE[$cookiename] = '';

// At the very least, try to guess whether this user agent is unlikely to be human!
$wild_guess = (strpos(self::$ua, 'Mozilla') === false && strpos(self::$ua, 'Opera') === false) || preg_match('~(?:bot|slurp|crawl|spider)~', strtolower(self::$ua));

// Do we perhaps think this is a search robot? Check every five minutes just in case...
if ((!empty($settings['spider_mode']) || !empty($settings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300))
{
loadSource('ManageSearchEngines');
$user['possibly_robot'] = SpiderCheck();
$user['possibly_robot'] = SpiderCheck() || $wild_guess;
}
elseif (!empty($settings['spider_mode']))
$user['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
// If we haven't turned on proper spider hunts then have a guess!
$user['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : false;
else
$user['possibly_robot'] = (strpos(self::$ua, 'Mozilla') === false && strpos(self::$ua, 'Opera') === false) || preg_match('~(?:bot|slurp|crawl|spider)~', strtolower(self::$ua));
$user['possibly_robot'] = $wild_guess;
}

// Figure out the new time offset.
Expand Down

0 comments on commit ca3053c

Please sign in to comment.