-
Notifications
You must be signed in to change notification settings - Fork 0
/
SpyderDetect.php
51 lines (45 loc) · 1.43 KB
/
SpyderDetect.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* Description of Spyder_Detect
*
* @author web777
*/
class SpyderDetect
{
protected static $searchBots = [
'Google' => 'GoogleBot',
'Yandex' => 'YandexBot',
'YandexImages' => 'YandexImages',
'YandexMedia' => 'YandexMedia',
'YandexBlogs' => 'YandexBlogs',
'YandexAddUrl' => 'YandexAddurl',
'YandexDirect' => 'YandexDirect',
'YandexMetrika' => 'YandexMetrika',
'YandexNews' => 'YandexNews',
'YandexCatalog' => 'YandexCatalog',
'YandexWebmaster' => 'YandexWebmaster',
'YandexPagechecker' => 'YandexPagechecker',
'YandexDyatel' => 'YandexSitelinks',
'YandexAntivirus' => 'YandexAntivirus',
'YandexMobile' => 'YandexImageResizer',
'YandexZakladki' => 'YandexZakladki',
'YandexFavicons' => 'YandexFavicons',
'YandexAdNet' => 'YandexAdNet',
'Rambler' => 'StackRamber',
'Yahoo' => 'Yahoo',
'MailRu' => 'Mail.RU_Bot',
'Bing' => 'msnbot',
];
static public function isBot($user_agent = null)
{
if (empty($user_agent)) {
$user_agent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
}
foreach (static::$searchBots as $bot => $marker) {
if (strpos(strtoupper($user_agent), strtoupper($marker)) !== false) {
return $bot;
}
}
return false;
}
}