mirror of
https://github.com/Findus23/devicedetector.net.git
synced 2024-09-19 15:43:46 +02:00
50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace DeviceDetectorNet;
|
|
|
|
require_once '../vendor/autoload.php';
|
|
|
|
use DeviceDetector\DeviceDetector;
|
|
use DeviceDetector\Parser\Device\DeviceParserAbstract;
|
|
|
|
// OPTIONAL: Set version truncation to none, so full versions will be returned
|
|
// By default only minor versions will be returned (e.g. X.Y)
|
|
// for other options see VERSION_TRUNCATION_* constants in DeviceParserAbstract class
|
|
DeviceParserAbstract::setVersionTruncation(DeviceParserAbstract::VERSION_TRUNCATION_NONE);
|
|
|
|
$cacheloader = new CacheLoader();
|
|
|
|
if (!empty($_GET["ua"])) {
|
|
$userAgent = $_GET["ua"];
|
|
} else {
|
|
$userAgent = $_SERVER['HTTP_USER_AGENT'];
|
|
}
|
|
|
|
|
|
$dd = new DeviceDetector($userAgent);
|
|
|
|
$cacheloader->configureDeviceDetector($dd);
|
|
$dd->parse();
|
|
$icons = new IconPath($dd);
|
|
$data = [];
|
|
$data["isBot"] = $dd->isBot();
|
|
if ($dd->isBot()) {
|
|
$data["botInfo"] = $dd->getBot();
|
|
} else {
|
|
$data["clientInfo"] = $dd->getClient();
|
|
$data["osInfo"] = $dd->getOs();
|
|
$data["device"] = $dd->getDevice();
|
|
$data["deviceName"] = $dd->getDeviceName();
|
|
$data["deviceBrand"] = $dd->getBrandName();
|
|
$data["model"] = $dd->getModel();
|
|
$data["icons"] = [
|
|
"browser" => $icons->getBrowserLogo(),
|
|
"os" => $icons->getOsLogo(),
|
|
"device" => $icons->getDeviceTypeLogo(),
|
|
"brand" => $icons->getBrandLogo()
|
|
];
|
|
}
|
|
|
|
header("Content-Type: application/json; charset=UTF-8");
|
|
echo json_encode($data,JSON_FORCE_OBJECT);
|
|
|