<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Util; use Illuminate\Support\Facades\Request; use Jenssegers\Agent\Facades\Agent; 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 peLB7; peLB7: static $z42ES = null; goto KrsNz; KrsNz: if (null === $z42ES) { $J4KQL = Request::header('User-Agent'); if (strpos($J4KQL, 'MicroMessenger') !== false) { $z42ES = true; } else { $z42ES = false; } } goto mXPNk; mXPNk: return $z42ES; goto DYuMd; DYuMd: } 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]*/i' => 'Other', '/Detector/' => 'Other', '/YandexImages/i' => 'Other', '/CensysInspect/i' => 'Other', '/GoogleOther/i' => 'Other', '/duckduckgo\\.com/i' => 'Other', '/Dataprovider\\.com/i' => 'Other', '/NetcraftSurveyAgent/i' => 'Other', '/Scrapy/i' => 'Other', '/linkfluence/i' => 'Other', '/github\\-camo/i' => 'Other', '/msray/i' => 'Other', '/InternetMeasurement/i' => 'Other', '/Vue\\-Telescope/i' => 'Other', '/2ip\\.io/i' => 'Other', '/facebookexternalhit/i' => 'Other', '/Wordupindexinfo/i' => 'Other', '/researchscan/i' => 'Other', '/woorankreview/i' => 'Other', '/Avant Browser/i' => 'Other', '/Wget\\/\\d+/i' => 'Other', '/python\\-(http|requests|urllib)/i' => 'Other', '/curl\\/\\d+\\.\\d+\\./i' => 'Other', '/Java\\/\\d+\\.\\d+\\./i' => 'Other', '/Ruby/i' => 'Other', '/aiohttp/i' => 'Other', '/cpp\\-httplib/i' => 'Other', '/node\\-fetch/i' => 'Other', '/Go\\-http\\-client/i' => 'Other', '/okhttp/i' => 'Other', '/GuzzleHttp/i' => 'Other', '/Apache\\-HttpClient/i' => 'Other'); public static function detectRobot($J4KQL = null) { goto cxWMi; cxWMi: if (null === $J4KQL) { $J4KQL = AgentUtil::getUserAgent(); } goto mjrYQ; mjrYQ: foreach (self::$robots as $OrDMz => $fuFRG) { if (preg_match($OrDMz, $J4KQL)) { return $fuFRG; } } goto A6mMD; A6mMD: return null; goto u8dAv; u8dAv: } }