Файл: vendor/whichbrowser/parser/src/Analyser/Header/Useragent/Bot.php
Строк: 30
<?php
namespace WhichBrowserAnalyserHeaderUseragent;
use WhichBrowserConstants;
use WhichBrowserData;
trait Bot
{
private function &detectBot($ua)
{
/* Detect bots based on url in the UA string */
if (preg_match('/+https?:///iu', $ua)) {
$this->data->browser->reset();
$this->data->os->reset();
$this->data->engine->reset();
$this->data->device->reset();
$this->data->device->type = ConstantsDeviceType::BOT;
}
/* Detect bots based on common markers */
if (preg_match('/(?:Bot|Robot|Spider|Crawler)([/);]|$)/iu', $ua) && !preg_match('/CUBOT/iu', $ua)) {
$this->data->browser->reset();
$this->data->os->reset();
$this->data->engine->reset();
$this->data->device->reset();
$this->data->device->type = ConstantsDeviceType::BOT;
}
/* Detect based on a predefined list or markers */
if ($bot = DataApplications::identifyBot($ua)) {
$this->data->browser = $bot;
$this->data->os->reset();
$this->data->engine->reset();
$this->data->device->reset();
$this->data->device->type = ConstantsDeviceType::BOT;
}
return $this;
}
}