<?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 OA7yb; vaNRm: if (null === $BKUDz) { $uWoZZ = Request::header('User-Agent'); if (strpos($uWoZZ, 'MicroMessenger') !== false) { $BKUDz = true; } else { $BKUDz = false; } } goto e9DCY; e9DCY: return $BKUDz; goto yJGEX; OA7yb: static $BKUDz = null; goto vaNRm; yJGEX: } 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($uWoZZ = null) { goto rO6CN; rO6CN: if (null === $uWoZZ) { $uWoZZ = AgentUtil::getUserAgent(); } goto tKoPP; tKoPP: foreach (self::$robots as $Q9mGn => $rWBzm) { if (preg_match($Q9mGn, $uWoZZ)) { return $rWBzm; } } goto I1ff_; I1ff_: return null; goto XIHgz; XIHgz: } }