<?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 HdM30; S5k2Q: if (null === $XGfHy) { $vz4sA = Request::header('User-Agent'); if (strpos($vz4sA, 'MicroMessenger') !== false) { $XGfHy = true; } else { $XGfHy = false; } } goto G3FHp; HdM30: static $XGfHy = null; goto S5k2Q; G3FHp: return $XGfHy; goto mfSaw; mfSaw: } 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($vz4sA = null) { goto wiwMW; wiwMW: if (null === $vz4sA) { $vz4sA = AgentUtil::getUserAgent(); } goto arMrI; arMrI: foreach (self::$robots as $IYVOQ => $ScKKo) { if (preg_match($IYVOQ, $vz4sA)) { return $ScKKo; } } goto pgEWr; pgEWr: return null; goto qB7IN; qB7IN: } }