-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserAgent.php
More file actions
44 lines (38 loc) · 1.24 KB
/
UserAgent.php
File metadata and controls
44 lines (38 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/*******************************************************************************
* Copyright (c) 2022. Ankio. All Rights Reserved.
******************************************************************************/
/**
* Package: library\useragent
* Class UserAgent
* Created By ankio.
* Date : 2023/7/13
* Time : 21:08
* Description :
*/
namespace library\useragent;
use cleanphp\base\Request;
class UserAgent
{
static function parse($ua): array
{
$Os = Os::get($ua);
$OsImg = self::img("os/", $Os['code'], $Os['title']);
$OsName = $Os['title'];
$Browser = Browser::get($ua);
$BrowserImg = self::img("browser/", $Browser['code'], $Browser['title']);
$BrowserName = $Browser['title'];
return [
$OsName,
$OsImg,
$BrowserName,
$BrowserImg
];
}
private static function img($type, $name, $title) {
$size = "18px";
$url_img = Request::getAddress()."/" ;
$img = "<img nogallery class='icon-ua' src='" . $url_img . $type . $name . ".svg' title='" . $title . "' alt='" . $title . "' height='" . $size . "' style='vertical-align:-2px;margin-right:0.3rem;margin-left:0.3rem' />";
return $img;
}
}