更新完善网页逻辑,工具迁移至html逻辑
This commit is contained in:
1 parent
c3bfce7afb
commit
646754c04d
26 files changed
+1606
-167
No files matched your search
@@ -115,6 +115,75 @@ function home_quote(): string
|
||||
return $lines[array_rand($lines)];
|
||||
}
|
||||
|
||||
/** 首页访客信息(hero 信息模式):IP 与浏览器/系统/内核由服务端解析 UA 提供,屏幕/语言由前端补齐 */
|
||||
function visitor_brief(): array
|
||||
{
|
||||
$ip = trim((string)($_SERVER['REMOTE_ADDR'] ?? ''));
|
||||
if ($ip === '' || !filter_var($ip, FILTER_VALIDATE_IP)) {
|
||||
$ip = '未知';
|
||||
}
|
||||
$ua = (string)($_SERVER['HTTP_USER_AGENT'] ?? '');
|
||||
$browser = '未知';
|
||||
$kernel = '未知';
|
||||
$os = '未知';
|
||||
if ($ua !== '') {
|
||||
// 浏览器 / 内核
|
||||
if (strpos($ua, 'MicroMessenger') !== false) {
|
||||
$browser = '微信内置浏览器';
|
||||
$kernel = 'WebKit';
|
||||
} elseif (preg_match('/Edg\/([\d.]+)/', $ua, $m)) {
|
||||
$browser = 'Edge ' . $m[1];
|
||||
$kernel = 'Blink';
|
||||
} elseif (preg_match('/OPR\/([\d.]+)/', $ua, $m)) {
|
||||
$browser = 'Opera ' . $m[1];
|
||||
$kernel = 'Blink';
|
||||
} elseif (strpos($ua, 'Firefox/') !== false) {
|
||||
$browser = 'Firefox';
|
||||
$kernel = 'Gecko';
|
||||
if (preg_match('/Firefox\/([\d.]+)/', $ua, $m)) $browser .= ' ' . $m[1];
|
||||
} elseif (preg_match('/(?:Chrome|CriOS)\/([\d.]+)/', $ua, $m)) {
|
||||
$browser = 'Chrome ' . $m[1];
|
||||
$kernel = 'Blink';
|
||||
} elseif (strpos($ua, 'Safari/') !== false) {
|
||||
$browser = 'Safari';
|
||||
$kernel = 'WebKit';
|
||||
if (preg_match('/Version\/([\d.]+)/', $ua, $m)) $browser .= ' ' . $m[1];
|
||||
}
|
||||
if ($kernel === '未知') {
|
||||
if (strpos($ua, 'Gecko/') !== false) $kernel = 'Gecko';
|
||||
elseif (strpos($ua, 'AppleWebKit/') !== false) $kernel = 'WebKit';
|
||||
}
|
||||
// 操作系统
|
||||
if (strpos($ua, 'Windows NT 10.0') !== false) {
|
||||
$os = 'Windows 10 / 11';
|
||||
} elseif (strpos($ua, 'Windows NT 6.3') !== false) {
|
||||
$os = 'Windows 8.1';
|
||||
} elseif (strpos($ua, 'Windows NT 6.2') !== false) {
|
||||
$os = 'Windows 8';
|
||||
} elseif (strpos($ua, 'Windows NT 6.1') !== false) {
|
||||
$os = 'Windows 7';
|
||||
} elseif (strpos($ua, 'Windows NT 5.1') !== false) {
|
||||
$os = 'Windows XP';
|
||||
} elseif (strpos($ua, 'Windows Phone') !== false) {
|
||||
$os = 'Windows Phone';
|
||||
} elseif (strpos($ua, 'Android') !== false) {
|
||||
$os = 'Android';
|
||||
if (preg_match('/Android ([\d.]+)/', $ua, $m)) $os .= ' ' . $m[1];
|
||||
} elseif (strpos($ua, 'iPad') !== false || strpos($ua, 'iPhone') !== false || strpos($ua, 'iPod') !== false) {
|
||||
$os = 'iOS';
|
||||
if (preg_match('/OS ([\d_]+)/', $ua, $m)) $os .= ' ' . str_replace('_', '.', $m[1]);
|
||||
} elseif (strpos($ua, 'Mac OS X') !== false) {
|
||||
$os = 'macOS';
|
||||
if (preg_match('/Mac OS X ([\d_]+)/', $ua, $m)) $os .= ' ' . str_replace('_', '.', $m[1]);
|
||||
} elseif (strpos($ua, 'CrOS') !== false) {
|
||||
$os = 'ChromeOS';
|
||||
} elseif (strpos($ua, 'Linux') !== false) {
|
||||
$os = 'Linux';
|
||||
}
|
||||
}
|
||||
return ['ip' => $ip, 'browser' => $browser, 'os' => $os, 'kernel' => $kernel];
|
||||
}
|
||||
|
||||
/** 图标值是否属于图片(dataURL / http / 常见图片扩展 / 相对路径) */
|
||||
function icon_is_image(string $raw): bool
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user