feat: initial commit
This commit is contained in:
Executable
+27
@@ -0,0 +1,27 @@
|
||||
<?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;
|
||||
Reference in New Issue
Block a user