<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Illuminate\Support\Facades\Request; use Jenssegers\Agent\Facades\Agent; use ModStart\Core\Exception\BizException; class AgentUtil { public static function getUserAgent() { return Request::header('User-Agent'); } public static function device() { if (self::isMobile()) { return 'mobile'; } return 'pc'; } public static function isWechat() { goto tFaTg; s00IY: return $Ggf1e; goto RYyg_; tFaTg: static $Ggf1e = null; goto baL56; baL56: if (null === $Ggf1e) { $Wo0pX = Request::header('User-Agent'); if (strpos($Wo0pX, 'MicroMessenger') !== false) { $Ggf1e = true; } else { $Ggf1e = false; } } goto s00IY; RYyg_: } public static function isMobile() { return Agent::isPhone() || Agent::isTablet(); } public static function isPC() { return !Agent::isPhone() && !Agent::isTablet(); } private static $robots = array('/googlebot/i' => 'Google', '/baiduspider/i' => 'Baidu', '/360spider/i' => '360', '/sogou/i' => 'Sogou', '/bingbot/i' => 'Bing', '/bytespider/i' => 'TouTiao', '/crawler/i' => 'Other', '/spider/i' => 'Other', '/(?:^|[\\W])\\w*bot([\\W\\s]|$)/i' => 'Other', '/detector/i' => 'Other', '/(curl|python|java|node-fetch|http-client|msray-plus|guzzlehttp|wget|okhttp)/i' => 'Other', '/(ows.eu|researchscan|github|LogStatistic|Dataprovider|facebook)/i' => 'Other'); public static function detectRobot($Wo0pX = null) { goto z4UbA; z4UbA: if (null === $Wo0pX) { $Wo0pX = AgentUtil::getUserAgent(); } goto OwmQc; PcfOb: return null; goto bHb8n; OwmQc: foreach (self::$robots as $mY5v7 => $ScvW1) { if (preg_match($mY5v7, $Wo0pX)) { return $ScvW1; } } goto PcfOb; bHb8n: } }