1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
detector.php
См. документацию.
1<?php
2
9
10namespace Bitrix\Main\Web\UserAgent;
11
13{
17 public function detectBrowser(?string $userAgent): Browser
18 {
19 $browser = $this->getKnownAgent($userAgent);
20
21 if ($browser === null)
22 {
23 if (ini_get('browscap') != '')
24 {
25 $info = get_browser($userAgent);
26
27 if ($info)
28 {
29 $deviceType = $this->getDeviceType($info);
30 $browser = new Browser($info->browser, $info->platform, $deviceType);
31 }
32 }
33 }
34
35 if ($browser === null)
36 {
37 $browser = new Browser();
38 }
39
40 $browser->setUserAgent($userAgent);
41
42 return $browser;
43 }
44
45 protected function getKnownAgent(?string $userAgent)
46 {
47 if ($userAgent !== null)
48 {
49 if (str_contains($userAgent, 'Bitrix24.Disk'))
50 {
51 if (str_contains($userAgent, 'Windows'))
52 {
53 $platform = 'Windows';
54 }
55 elseif (str_contains($userAgent, 'Linux'))
56 {
57 $platform = 'Linux';
58 }
59 else
60 {
61 $platform = 'macOS';
62 }
63
64 return new Browser('Bitrix24.Disk', $platform, DeviceType::DESKTOP);
65 }
66
67 if (str_contains($userAgent, 'BitrixDesktop'))
68 {
69 if (str_contains($userAgent, 'Windows'))
70 {
71 $platform = 'Windows';
72 }
73 elseif (str_contains($userAgent, 'Mac OS'))
74 {
75 $platform = 'macOS';
76 }
77 else
78 {
79 $platform = 'Linux';
80 }
81
82 return new Browser('Bitrix24.Desktop', $platform, DeviceType::DESKTOP);
83 }
84
85 if (str_contains($userAgent, 'BitrixMobile') || str_contains($userAgent, 'Bitrix24/'))
86 {
87 if (str_contains($userAgent, 'iPhone') || str_contains($userAgent, 'iPad') || str_contains($userAgent, 'Darwin'))
88 {
89 $device = (str_contains($userAgent, 'iPad') ? DeviceType::TABLET : DeviceType::MOBILE_PHONE);
90 return new Browser('Bitrix24.Mobile', 'iOS', $device);
91 }
92
93 $device = (str_contains($userAgent, 'Tablet') ? DeviceType::TABLET : DeviceType::MOBILE_PHONE);
94 return new Browser('Bitrix24.Mobile', 'Android', $device);
95 }
96
97 if (str_contains($userAgent, 'CardDavBitrix24'))
98 {
99 return new Browser('Bitrix24.DAV', 'Android', DeviceType::MOBILE_PHONE);
100 }
101 }
102 return null;
103 }
104
105 protected function getDeviceType($info)
106 {
107 if ($info->istablet)
108 {
109 $deviceType = DeviceType::TABLET;
110 }
111 elseif ($info->ismobiledevice)
112 {
113 $deviceType = DeviceType::MOBILE_PHONE;
114 }
115 elseif ($info->device_type == 'TV Device')
116 {
117 $deviceType = DeviceType::TV;
118 }
119 elseif ($info->device_type == 'Desktop')
120 {
121 $deviceType = DeviceType::DESKTOP;
122 }
123 else
124 {
125 $deviceType = DeviceType::UNKNOWN;
126 }
127
128 return $deviceType;
129 }
130}
getKnownAgent(?string $userAgent)
Определения detector.php:45
getDeviceType($info)
Определения detector.php:105
detectBrowser(?string $userAgent)
Определения detector.php:17
if($NS['step']==6) if( $NS[ 'step']==7) if(COption::GetOptionInt('main', 'disk_space', 0) > 0) $info
Определения backup.php:924
$platform
Определения settings.php:7
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393