checkIfBot()
Checks if the user-agent looks like a bot or if the ip is in the bots table.
Set $this->isBot true/false.
return nothing.
172186
protected function checkIfBot() {
    if($this->nodb) {
      return;
    }

    // BLP 2018-07-02 -- replace old logic with 'isMe()'
    if($this->isMe()) {
      return;
    }

    $this->query("select count(*) from information_schema.tables ".
                 "where (table_schema = '$this->masterdb') and (table_name = 'bots')");

    list($ok) = $this->fetchrow('num');

    if($ok == 1) {
      $agent = $this->escape($this->agent);

      $this->isBot = preg_match("~\+*https?://|Googlebot-Image|python|java|wget|nutch|perl|libwww|lwp-trivial|curl|PHP/|urllib|".
                                "GT::WWW|Snoopy|MFC_Tear_Sample|HTTP::Lite|PHPCrawl|URI::Fetch|Zend_Http_Client|".
                                "http client|PECL::HTTP~i", $this->agent)
                     || ($this->query("select ip from $this->masterdb.bots where ip='$this->ip'")) ? true : false;          
    }
  }
122426
protected function checkIP()
    {
        if (getenv("HTTP_CLIENT_IP"))
            $this->_ip = getenv("HTTP_CLIENT_IP");
        elseif (getenv("HTTP_X_FORWARDED_FOR"))
            $this->_ip = getenv("HTTP_X_FORWARDED_FOR");
        else
            $this->_ip = getenv("REMOTE_ADDR");
    }
643306
protected function checkBrowserYandexFaviconsBot()
    {
        if (stripos($this->_agent, 'YandexFavicons') !== false) {
            $aresult = explode('/', stristr($this->_agent, 'YandexFavicons'));
            if (isset($aresult[1])) {
                $aversion = explode(' ', $aresult[1]);
                $this->setVersion(str_replace(';', '', $aversion[0]));
                $this->_browser_name = self::BROWSER_YANDEXFAVICONS_BOT;
                $this->setRobot(true);
                return true;
            }
        }
        return false;
    }
818624
protected function detectRobot($userAgent)
	{
		if (preg_match('/http|bot|bingbot|googlebot|robot|spider|slurp|crawler|curl|^$/i', $userAgent))
		{
			$this->robot = true;
		}
		else
		{
			$this->robot = false;
		}

		$this->detection['robot'] = true;
	}
117499
public function robot($userAgent = null)
    {
        return $this->isRobot($userAgent)
            ? ucfirst($this->getCrawlerDetector()->getMatches())
            : false;
    }
177795
public static function isAdminIP() {
        if (!isset($_SERVER['REMOTE_ADDR']))
            return false;

        static $whiteList; if (!$whiteList) {
            $ips = ['127.0.0.1', $_SERVER['SERVER_ADDR']];

            if (!self::$defaultConfig)
                return in_array($_SERVER['REMOTE_ADDR'], $ips);

            $values = self::$defaultConfig->get('admin.ip.whitelist', []);
            if (!is_array($values)) $values = [$values];
            $whiteList = \array_keys(\array_flip(\array_merge($ips, $values)));
        }
        return in_array($_SERVER['REMOTE_ADDR'], $whiteList);
    }
399191
function DetectSymbianOS()
   {
       if (stripos($this->useragent, $this->deviceSymbian) > -1 || 
           stripos($this->useragent, $this->deviceS60) > -1 ||
           stripos($this->useragent, $this->deviceS70) > -1 || 
           stripos($this->useragent, $this->deviceS80) > -1 ||
           stripos($this->useragent, $this->deviceS90) > -1)
         return $this->true; 
      else
         return $this->false; 
   }
1141312
protected function checkBrowserGoogleBot()
    {
        if (stripos($this->_agent, 'googlebot') !== false) {
            $aresult = explode('/', stristr($this->_agent, 'googlebot'));
            $aversion = explode(' ', $aresult[1]);
            $this->setVersion(str_replace(';', '', $aversion[0]));
            $this->_browser_name = self::BROWSER_GOOGLEBOT;
            $this->setRobot(true);

            return true;
        }

        return false;
    }
709658
protected function checkBrowserYandexCatalogBot()
    {
        if (stripos($this->_agent, 'YandexCatalog') !== false) {
            $aresult = explode('/', stristr($this->_agent, 'YandexCatalog'));
            if (isset($aresult[1])) {
                $aversion = explode(' ', $aresult[1]);
                $this->setVersion(str_replace(';', '', $aversion[0]));
                $this->_browser_name = self::BROWSER_YANDEXCATALOG_BOT;
                $this->setRobot(true);
                return true;
            }
        }
        return false;
    }
1202613
def is_installed(self, bot_name):
        
        self.check_bots_ready()
        return any(b.name == bot_name for b in self.bots.values())
741264
protected static function checkBotIPv6($UserIP = false, $Bot_IPv6_List = false)
    {
        if (false === $Bot_IPv6_List)
        {
            return false;
        }
        // Check if IP present
        if ($UserIP === false)
        {
            if (\Environment::get('remoteAddr'))
            {
                if (strpos(\Environment::get('remoteAddr'), ',') !== false) //first IP
                {
                    $UserIP =  trim(substr(\Environment::get('remoteAddr'), 0, strpos(\Environment::get('remoteAddr'), ',')));
                }
                else
                {
                    $UserIP = trim(\Environment::get('remoteAddr'));
                }
            }
            else
            {
                return false; // No IP, no search.
            }
        }
        // search user IP in bot-ip-list-ipv6
        if (file_exists($Bot_IPv6_List))
        {
            $source = file($Bot_IPv6_List);
            foreach ($source as $line)
            {
                if ($line[0] === '#') 
                {
                	continue;
                }
                $lineleft = explode("#", $line); // Abtrennen IP von Bemerkung
                $network = explode("/", trim($lineleft[0]));

                if (!isset($network[1]))
                {
                    $network[1] = 128;
                }
                if (static::checkIp6InNetwork($UserIP,$network[0],$network[1]))
                {
                    return true; // IP found
                }
            }
        }
        // search for user bot IP-filter definitions in localconfig.php
        if ( isset($GLOBALS['BOTDETECTION']['BOT_IPV6']) )
        {
            foreach ($GLOBALS['BOTDETECTION']['BOT_IPV6'] as $lineleft)
            {
                $network = explode("/", trim($lineleft));
                if (!isset($network[1]))
                {
                    $network[1] = 128;
                }
                if (static::checkIp6InNetwork($UserIP,$network[0],$network[1]))
                {
                    return true; // IP found
                }
            }
        }
        return false;
    }
594235
protected function checkBrowserMSNBot()
    {
        if (stripos($this->_agent, "msnbot") !== false) {
            $aresult = explode("/", stristr($this->_agent, "msnbot"));
            $aversion = explode(" ", $aresult[1]);
            $this->setVersion(str_replace(";", "", $aversion[0]));
            $this->_browser_name = self::BROWSER_MSNBOT;
            $this->setRobot(true);

            return true;
        }

        return false;
    }
552060
def _is_bot(user_agent):
    """"""
    bot_list = [
                'http://www.baidu.com/search/spider.html',
                'python-requests',
                'http://ltx71.com/',
                'http://drupal.org/',
                'www.sogou.com',
                'http://search.msn.com/msnbot.htm',
                'semantic-visions.com crawler',
               ]
    for bot in bot_list:
        if re.search(re.escape(bot), user_agent):
            return True
    return False
83913
protected function checkBrowserYandexWebmasterBot()
    {
        if (stripos($this->_agent, 'YandexWebmaster') !== false) {
            $aresult = explode('/', stristr($this->_agent, 'YandexWebmaster'));
            if (isset($aresult[1])) {
                $aversion = explode(' ', $aresult[1]);
                $this->setVersion(str_replace(';', '', $aversion[0]));
                $this->_browser_name = self::BROWSER_YANDEXWEBMASTER_BOT;
                $this->setRobot(true);
                return true;
            }
        }
        return false;
    }
738903
public static function checkRobot()
    {
        static $robot = null;
        if($robot !== null) {
            return $robot;
        }
        
        $spiders  = 'bot|crawl|spider|slurp|sohu-search|lycos|robozilla';
        $browsers = 'MSIE|Netscape|Opera|Konqueror|Mozilla';
        $agent    = @$_SERVER['HTTP_USER_AGENT'];
        
        if(strpos($agent, 'http://') === false && preg_match("/($browsers)/i", $agent)) {
            $robot = false;
        } elseif(preg_match("/($spiders)/i", $agent)) {
            $robot = 'UnknowSpider';
            
            $botList = [
                'GoogleBot',
                'mediapartners-google',
                'BaiduSpider',
                '360Spider',
                'msnbot',
                'bingbot',
                'yodaobot',
                'yahoo! slurp',
                'yahoo! slurp china',
                'iaskspider',
                'Sogou web spider',
                'Sogou push spider',
                'YisouSpider'
            ];
            
            foreach ($botList as $bot) {
                if(false !== stripos($agent, $bot)) {
                    $robot = $bot;
                    break;
                }
            }
        } else {
            $robot = false;
        }
        
        return $robot;
    }
1266385
private function isExceptionFromBot()
    {
        $ignored_bots = $this->config->get('sneaker.ignored_bots');

        $agent = array_key_exists('HTTP_USER_AGENT', $_SERVER)
                    ? strtolower($_SERVER['HTTP_USER_AGENT'])
                    : null;

        if (is_null($agent)) {
            return false;
        }

        foreach ($ignored_bots as $bot) {
            if ((strpos($agent, $bot) !== false)) {
                return true;
            }
        }

        return false;
    }
1212941
async def is_bot(self):
        
        if self._bot is None:
            self._bot = (await self.get_me()).bot

        return self._bot