1
0
Fork 0
mirror of https://github.com/Findus23/devicedetector.net.git synced 2024-09-19 15:43:46 +02:00
devicedetector.net/public/ua.php

57 lines
1.8 KiB
PHP
Raw Normal View History

2019-04-09 20:36:39 +02:00
<?php
namespace DeviceDetectorNet;
require_once '../vendor/autoload.php';
use DeviceDetector\DeviceDetector;
2019-06-25 20:02:30 +02:00
use DeviceDetector\Parser\Client\Browser;
2019-04-09 20:36:39 +02:00
use DeviceDetector\Parser\Device\DeviceParserAbstract;
2019-06-25 20:02:30 +02:00
use DeviceDetector\Parser\OperatingSystem;
use DeviceDetector\Yaml\Symfony;
2019-04-09 20:36:39 +02:00
// 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);
$dd->setYamlParser(new Symfony());
2019-04-09 20:36:39 +02:00
$cacheloader->configureDeviceDetector($dd);
$dd->parse();
2019-04-10 12:12:22 +02:00
$icons = new IconPath($dd);
2019-04-09 20:36:39 +02:00
$data = [];
$data["isBot"] = $dd->isBot();
if ($dd->isBot()) {
$data["botInfo"] = $dd->getBot();
} else {
$data["clientInfo"] = $dd->getClient();
2019-06-25 20:02:30 +02:00
$data["browserFamily"]= Browser::getBrowserFamily($dd->getClient('short_name'));
$data["isMobileOnlyBrowser"] = Browser::isMobileOnlyBrowser($dd->getClient('short_name'));
2019-04-09 20:36:39 +02:00
$data["osInfo"] = $dd->getOs();
2019-06-25 20:02:30 +02:00
$data["osFamily"]=OperatingSystem::getOsFamily($dd->getOs('short_name'));
2019-04-10 12:12:22 +02:00
$data["device"] = $dd->getDevice();
2019-04-09 20:36:39 +02:00
$data["deviceName"] = $dd->getDeviceName();
$data["deviceBrand"] = $dd->getBrandName();
$data["model"] = $dd->getModel();
2019-04-17 21:17:42 +02:00
$data["icons"] = [
"browser" => $icons->getBrowserLogo(),
"os" => $icons->getOsLogo(),
"device" => $icons->getDeviceTypeLogo(),
"brand" => $icons->getBrandLogo()
];
2019-04-09 20:36:39 +02:00
}
header("Content-Type: application/json; charset=UTF-8");
2019-04-20 21:55:56 +02:00
echo json_encode($data,JSON_FORCE_OBJECT);
2019-04-09 20:36:39 +02:00