Files
CLOAK/mdetect.php
T
2026-06-14 14:00:24 +08:00

27 lines
709 B
PHP
Executable File

<?php
require_once dirname(__FILE__) . '/Mobile-Detect/src/MobileDetect.php';
$detect = new \Detection\MobileDetect;
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
if($deviceType == 'tablet') {
$patterns = $detect::getTabletDevices();
} elseif($deviceType == 'phone') {
$patterns = $detect::getPhoneDevices();
} elseif($deviceType == 'computer') {
$patterns = "";
$model = "PC";
}
if($patterns) {
foreach ($patterns as $brand => $pattern) {
if (preg_match('/' . $pattern . '/i', $_SERVER['HTTP_USER_AGENT'], $matches)) {
$model = $brand . ' ' . $matches[1];
break;
}
}
}
echo $model;