<?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 u51sk; u51sk: static $xYh_l = null; goto QXGjI; J9RNI: return $xYh_l; goto OfYYO; QXGjI: if (null === $xYh_l) { $tBaEx = Request::header('User-Agent'); if (strpos($tBaEx, 'MicroMessenger') !== false) { $xYh_l = true; } else { $xYh_l = false; } } goto J9RNI; OfYYO: } 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', '/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($tBaEx = null) { goto jLsR6; oF6_3: return null; goto b9ZTS; jLsR6: if (null === $tBaEx) { $tBaEx = AgentUtil::getUserAgent(); } goto vZ6wE; vZ6wE: foreach (self::$robots as $sMElx => $UzYsu) { if (preg_match($sMElx, $tBaEx)) { return $UzYsu; } } goto oF6_3; b9ZTS: } }