<?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 e1S2o; XsFOh: return $FZRLw; goto bWwgB; e1S2o: static $FZRLw = null; goto nt0gQ; nt0gQ: if (null === $FZRLw) { $Ur5iO = Request::header('User-Agent'); if (strpos($Ur5iO, 'MicroMessenger') !== false) { $FZRLw = true; } else { $FZRLw = false; } } goto XsFOh; bWwgB: } 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($Ur5iO = null) { goto B7Wqq; B7Wqq: if (null === $Ur5iO) { $Ur5iO = AgentUtil::getUserAgent(); } goto eHZSM; eHZSM: foreach (self::$robots as $lwMrL => $VpAi3) { if (preg_match($lwMrL, $Ur5iO)) { return $VpAi3; } } goto H2Ro5; H2Ro5: return null; goto EtLdL; EtLdL: } }