Commit realizado el 12:13:52 08-04-2024
This commit is contained in:
15
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/.helpers/constants.php
vendored
Normal file
15
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/.helpers/constants.php
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
$class = new ReflectionClass($argv[1]);
|
||||
|
||||
echo "Predefined helper constants from `{$class->getName()}`\n\n";
|
||||
|
||||
echo "| Constant | {$argv[2]} | \n|----------|----------| \n";
|
||||
|
||||
foreach( $class->getConstants() as $constant => $value ) {
|
||||
echo "| `{$class->getShortName()}::{$constant}` | {$value} | \n";
|
||||
}
|
||||
|
||||
echo "\n";
|
91
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/.mddoc.xml
vendored
Normal file
91
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/.mddoc.xml
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
<mddoc>
|
||||
<docpage target="README.md">
|
||||
|
||||
<autoloader namespace="donatj\UserAgent" type="psr4" root="src" />
|
||||
|
||||
<section title="PHP User Agent Parser">
|
||||
<text><](https://gitter.im/PhpUserAgentParser/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
]]></text>
|
||||
<badge-poser type="version"/>
|
||||
<badge-poser type="downloads"/>
|
||||
<badge-poser type="license"/>
|
||||
<badge-github-action name="donatj/phpUserAgent" workflow-file="ci.yml"/>
|
||||
<section title="What It Is">
|
||||
<text><![CDATA[
|
||||
A simple, streamlined PHP user-agent parser!
|
||||
|
||||
Licensed under the MIT license: https://www.opensource.org/licenses/mit-license.php
|
||||
]]></text>
|
||||
</section>
|
||||
<section title="Upgrading to `1.*`">
|
||||
<text><![CDATA[
|
||||
The new `1.*` release **does not break compatibility** with `0.*` and nothing need to change to upgrade. However, the global `parse_user_agent` is now deprecated; it has been replaced with the namespaced `\donatj\UserAgent\parse_user_agent` and functions exactly the same. You can easily replace any existing call to `parse_user_agent` with `\donatj\UserAgent\parse_user_agent`
|
||||
|
||||
In addition, 1.x adds a convenience object wrapper you may use should you prefer. More information on this is in the Usage section below.
|
||||
]]></text>
|
||||
</section>
|
||||
<section title="Why Use This">
|
||||
<text><![CDATA[
|
||||
You have your choice in user-agent parsers. This one detects **all modern browsers** in a very light, quick, understandable fashion.
|
||||
It is less than 200 lines of code, and consists of just three regular expressions!
|
||||
It can also correctly identify exotic versions of IE others fail on.
|
||||
|
||||
It offers 100% unit test coverage, is installable via Composer, and is very easy to use.
|
||||
]]></text>
|
||||
</section>
|
||||
<section title="What It Does Not Do">
|
||||
<text><![CDATA[
|
||||
This is not meant as a browser "knowledge engine" but rather a simple parser. Anything not adequately provided directly by the user agent string itself will simply not be provided by this.
|
||||
]]></text>
|
||||
|
||||
<section title="OS Versions">
|
||||
<text>< I created for a client if you want to poke it, I update it from time to time, but frankly if you need to *reliably detect OS Version*, using user-agent isn't the way to do it. I'd go with JavaScript.
|
||||
]]></text>
|
||||
</section>
|
||||
<section title="Undetectable Browsers">
|
||||
<text><![CDATA[
|
||||
- **Brave** - Brave is simply not differentiable from Chrome. This was a design decision on their part.
|
||||
]]></text>
|
||||
</section>
|
||||
<section title="Undetectable Platforms">
|
||||
<text><)
|
||||
]]></text>
|
||||
</section>
|
||||
</section>
|
||||
<section title="Requirements">
|
||||
<composer-requires/>
|
||||
</section>
|
||||
<section title="Installing">
|
||||
<text>PHP User Agent is available through Packagist via Composer.</text>
|
||||
<composer-install/>
|
||||
</section>
|
||||
<section title="Usage">
|
||||
<text>The classic procedural use is as simple as:</text>
|
||||
<source name="examples/procedural.php" lang="php" />
|
||||
|
||||
<text>The new object-oriented wrapper form:</text>
|
||||
<source name="examples/object-oriented.php" lang="php" />
|
||||
</section>
|
||||
<section title="Currently Detected Platforms">
|
||||
<exec cmd="php .helpers/constants.php 'donatj\UserAgent\Platforms' 'Platform'"/>
|
||||
</section>
|
||||
<section title="Currently Detected Browsers">
|
||||
<exec cmd="php .helpers/constants.php 'donatj\UserAgent\Browsers' 'Browser'"/>
|
||||
</section>
|
||||
<text><.
|
||||
]]></text>
|
||||
</section>
|
||||
</docpage>
|
||||
</mddoc>
|
22
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/LICENSE.md
vendored
Normal file
22
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/LICENSE.md
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
The MIT License
|
||||
===============
|
||||
|
||||
Copyright (c) 2013 Jesse G. Donat
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
18
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/Makefile
vendored
Normal file
18
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/Makefile
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
.PHONY: test
|
||||
test:
|
||||
./vendor/bin/phpunit --coverage-text
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
-rm tests/user_agents.json
|
||||
touch tests/user_agents.json
|
||||
|
||||
.PHONY: generate
|
||||
generate:
|
||||
php bin/user_agent_sorter.php > tests/user_agents.tmp.json && mv tests/user_agents.tmp.json tests/user_agents.dist.json
|
||||
php bin/constant_generator.php
|
||||
|
||||
.PHONY: init
|
||||
init:
|
||||
php bin/init_user_agent.php > tests/user_agents.tmp.json && mv tests/user_agents.tmp.json tests/user_agents.dist.json
|
||||
make generate
|
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use donatj\UserAgent\UserAgentParser;
|
||||
|
||||
// if you're using composer
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
$parser = new UserAgentParser();
|
||||
|
||||
// object-oriented call
|
||||
$ua = $parser->parse();
|
||||
// or
|
||||
// command style invocation
|
||||
$ua = $parser();
|
||||
|
||||
echo $ua->platform() . PHP_EOL;
|
||||
echo $ua->browser() . PHP_EOL;
|
||||
echo $ua->browserVersion() . PHP_EOL;
|
14
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/examples/procedural.php
vendored
Normal file
14
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/examples/procedural.php
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
// if you're using composer
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
// v0 style global function - @deprecated
|
||||
$uaInfo = parse_user_agent();
|
||||
// or
|
||||
// modern namespaced function
|
||||
$uaInfo = donatj\UserAgent\parse_user_agent();
|
||||
|
||||
echo $uaInfo[donatj\UserAgent\PLATFORM] . PHP_EOL;
|
||||
echo $uaInfo[donatj\UserAgent\BROWSER] . PHP_EOL;
|
||||
echo $uaInfo[donatj\UserAgent\BROWSER_VERSION] . PHP_EOL;
|
58
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/src/UserAgent/Browsers.php
vendored
Normal file
58
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/src/UserAgent/Browsers.php
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
// DO NOT EDIT THIS FILE - IT IS GENERATED BY constant_generator.php
|
||||
|
||||
namespace donatj\UserAgent;
|
||||
|
||||
interface Browsers {
|
||||
|
||||
const ADSBOT_GOOGLE = 'AdsBot-Google';
|
||||
const ANDROID_BROWSER = 'Android Browser';
|
||||
const APPLEBOT = 'Applebot';
|
||||
const BAIDUSPIDER = 'Baiduspider';
|
||||
const BINGBOT = 'bingbot';
|
||||
const BLACKBERRY_BROWSER = 'BlackBerry Browser';
|
||||
const BROWSER = 'Browser';
|
||||
const BUNJALLOO = 'Bunjalloo';
|
||||
const CAMINO = 'Camino';
|
||||
const CHROME = 'Chrome';
|
||||
const CURL = 'curl';
|
||||
const EDGE = 'Edge';
|
||||
const FACEBOOKEXTERNALHIT = 'facebookexternalhit';
|
||||
const FEEDVALIDATOR = 'FeedValidator';
|
||||
const FIREFOX = 'Firefox';
|
||||
const GOOGLEBOT = 'Googlebot';
|
||||
const GOOGLEBOT_IMAGE = 'Googlebot-Image';
|
||||
const GOOGLEBOT_VIDEO = 'Googlebot-Video';
|
||||
const HEADLESSCHROME = 'HeadlessChrome';
|
||||
const IEMOBILE = 'IEMobile';
|
||||
const IMESSAGEBOT = 'iMessageBot';
|
||||
const KINDLE = 'Kindle';
|
||||
const LYNX = 'Lynx';
|
||||
const MIDORI = 'Midori';
|
||||
const MIUIBROWSER = 'MiuiBrowser';
|
||||
const MSIE = 'MSIE';
|
||||
const MSNBOT_MEDIA = 'msnbot-media';
|
||||
const NETFRONT = 'NetFront';
|
||||
const NINTENDOBROWSER = 'NintendoBrowser';
|
||||
const OCULUSBROWSER = 'OculusBrowser';
|
||||
const OPERA = 'Opera';
|
||||
const PUFFIN = 'Puffin';
|
||||
const SAFARI = 'Safari';
|
||||
const SAILFISHBROWSER = 'SailfishBrowser';
|
||||
const SAMSUNGBROWSER = 'SamsungBrowser';
|
||||
const SILK = 'Silk';
|
||||
const SLACKBOT = 'Slackbot';
|
||||
const TELEGRAMBOT = 'TelegramBot';
|
||||
const TIZENBROWSER = 'TizenBrowser';
|
||||
const TWITTERBOT = 'Twitterbot';
|
||||
const UC_BROWSER = 'UC Browser';
|
||||
const VALVE_STEAM_TENFOOT = 'Valve Steam Tenfoot';
|
||||
const VIVALDI = 'Vivaldi';
|
||||
const WGET = 'Wget';
|
||||
const WORDPRESS = 'WordPress';
|
||||
const YANDEX = 'Yandex';
|
||||
const YANDEXBOT = 'YandexBot';
|
||||
|
||||
}
|
||||
|
42
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/src/UserAgent/Platforms.php
vendored
Normal file
42
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/src/UserAgent/Platforms.php
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
// DO NOT EDIT THIS FILE - IT IS GENERATED BY constant_generator.php
|
||||
|
||||
namespace donatj\UserAgent;
|
||||
|
||||
interface Platforms {
|
||||
|
||||
const MACINTOSH = 'Macintosh';
|
||||
const CHROME_OS = 'Chrome OS';
|
||||
const LINUX = 'Linux';
|
||||
const WINDOWS = 'Windows';
|
||||
const ANDROID = 'Android';
|
||||
const BLACKBERRY = 'BlackBerry';
|
||||
const FREEBSD = 'FreeBSD';
|
||||
const IPAD = 'iPad';
|
||||
const IPHONE = 'iPhone';
|
||||
const IPOD = 'iPod';
|
||||
const KINDLE = 'Kindle';
|
||||
const KINDLE_FIRE = 'Kindle Fire';
|
||||
const NETBSD = 'NetBSD';
|
||||
const NEW_NINTENDO_3DS = 'New Nintendo 3DS';
|
||||
const NINTENDO_3DS = 'Nintendo 3DS';
|
||||
const NINTENDO_DS = 'Nintendo DS';
|
||||
const NINTENDO_SWITCH = 'Nintendo Switch';
|
||||
const NINTENDO_WII = 'Nintendo Wii';
|
||||
const NINTENDO_WIIU = 'Nintendo WiiU';
|
||||
const OPENBSD = 'OpenBSD';
|
||||
const PLAYBOOK = 'PlayBook';
|
||||
const PLAYSTATION_3 = 'PlayStation 3';
|
||||
const PLAYSTATION_4 = 'PlayStation 4';
|
||||
const PLAYSTATION_5 = 'PlayStation 5';
|
||||
const PLAYSTATION_VITA = 'PlayStation Vita';
|
||||
const SAILFISH = 'Sailfish';
|
||||
const SYMBIAN = 'Symbian';
|
||||
const TIZEN = 'Tizen';
|
||||
const WINDOWS_PHONE = 'Windows Phone';
|
||||
const XBOX = 'Xbox';
|
||||
const XBOX_ONE = 'Xbox One';
|
||||
|
||||
}
|
||||
|
57
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/src/UserAgent/UserAgent.php
vendored
Normal file
57
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/src/UserAgent/UserAgent.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace donatj\UserAgent;
|
||||
|
||||
class UserAgent implements UserAgentInterface {
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $platform;
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $browser;
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $browserVersion;
|
||||
|
||||
/**
|
||||
* UserAgent constructor.
|
||||
*
|
||||
* @param string|null $platform
|
||||
* @param string|null $browser
|
||||
* @param string|null $browserVersion
|
||||
*/
|
||||
public function __construct( $platform, $browser, $browserVersion ) {
|
||||
$this->platform = $platform;
|
||||
$this->browser = $browser;
|
||||
$this->browserVersion = $browserVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
* @see \donatj\UserAgent\Platforms for a list of tested platforms
|
||||
*/
|
||||
public function platform() {
|
||||
return $this->platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
* @see \donatj\UserAgent\Browsers for a list of tested browsers.
|
||||
*/
|
||||
public function browser() {
|
||||
return $this->browser;
|
||||
}
|
||||
|
||||
/**
|
||||
* The version string. Formatting depends on the browser.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function browserVersion() {
|
||||
return $this->browserVersion;
|
||||
}
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace donatj\UserAgent;
|
||||
|
||||
interface UserAgentInterface {
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
* @see \donatj\UserAgent\Platforms for a list of tested platforms
|
||||
*/
|
||||
public function platform();
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
* @see \donatj\UserAgent\Browsers for a list of tested browsers.
|
||||
*/
|
||||
public function browser();
|
||||
|
||||
/**
|
||||
* The version string. Formatting depends on the browser.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function browserVersion();
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace donatj\UserAgent;
|
||||
|
||||
class UserAgentParser {
|
||||
|
||||
/**
|
||||
* Parses a user agent string into its important parts, provide an object
|
||||
*
|
||||
* @param string|null $u_agent User agent string to parse or null. Uses $_SERVER['HTTP_USER_AGENT'] on NULL
|
||||
* @return UserAgent an object with 'browser', 'browserVersion' and 'platform' methods
|
||||
* @throws \InvalidArgumentException on not having a proper user agent to parse.
|
||||
* @see \donatj\UserAgent\parse_user_agent()
|
||||
*
|
||||
*/
|
||||
public function parse( $u_agent = null ) {
|
||||
$parsed = parse_user_agent($u_agent);
|
||||
|
||||
return new UserAgent(
|
||||
$parsed[PLATFORM],
|
||||
$parsed[BROWSER],
|
||||
$parsed[BROWSER_VERSION]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a user agent string into its important parts
|
||||
*
|
||||
* @param string|null $u_agent User agent string to parse or null. Uses $_SERVER['HTTP_USER_AGENT'] on NULL
|
||||
* @return UserAgent an object with 'browser', 'browserVersion' and 'platform' methods
|
||||
* @throws \InvalidArgumentException on not having a proper user agent to parse.
|
||||
* @see \donatj\UserAgent\parse_user_agent()
|
||||
*
|
||||
*/
|
||||
public function __invoke( $u_agent = null ) {
|
||||
return $this->parse($u_agent);
|
||||
}
|
||||
|
||||
}
|
218
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/src/UserAgentParser.php
vendored
Normal file
218
wp-content/plugins/seo-by-rank-math/vendor/donatj/phpuseragentparser/src/UserAgentParser.php
vendored
Normal file
@@ -0,0 +1,218 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @author Jesse G. Donat <donatj@gmail.com>
|
||||
*
|
||||
* @link https://donatstudios.com/PHP-Parser-HTTP_USER_AGENT
|
||||
* @link https://github.com/donatj/PhpUserAgent
|
||||
*
|
||||
* @license MIT https://github.com/donatj/PhpUserAgent/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
* Parses a user agent string into its important parts
|
||||
*
|
||||
* This method is defined for backwards comparability with the old global method.
|
||||
*
|
||||
* @param string|null $u_agent User agent string to parse or null. Uses $_SERVER['HTTP_USER_AGENT'] on NULL
|
||||
* @return string[] an array with 'browser', 'version' and 'platform' keys
|
||||
* @throws \InvalidArgumentException on not having a proper user agent to parse.
|
||||
*
|
||||
* @deprecated This exists for backwards compatibility with 0.x and will likely be removed in 2.x
|
||||
* @see \donatj\UserAgent\parse_user_agent
|
||||
*/
|
||||
function parse_user_agent( $u_agent = null ) {
|
||||
return \donatj\UserAgent\parse_user_agent($u_agent);
|
||||
}
|
||||
}
|
||||
|
||||
namespace donatj\UserAgent {
|
||||
|
||||
const PLATFORM = 'platform';
|
||||
const BROWSER = 'browser';
|
||||
const BROWSER_VERSION = 'version';
|
||||
|
||||
/**
|
||||
* Parses a user agent string into its important parts
|
||||
*
|
||||
* @param string|null $u_agent User agent string to parse or null. Uses $_SERVER['HTTP_USER_AGENT'] on NULL
|
||||
* @return string[] an array with 'browser', 'version' and 'platform' keys
|
||||
* @throws \InvalidArgumentException on not having a proper user agent to parse.
|
||||
*/
|
||||
function parse_user_agent( $u_agent = null ) {
|
||||
if( $u_agent === null && isset($_SERVER['HTTP_USER_AGENT']) ) {
|
||||
$u_agent = (string)$_SERVER['HTTP_USER_AGENT'];
|
||||
}
|
||||
|
||||
if( $u_agent === null ) {
|
||||
throw new \InvalidArgumentException('parse_user_agent requires a user agent');
|
||||
}
|
||||
|
||||
$platform = null;
|
||||
$browser = null;
|
||||
$version = null;
|
||||
|
||||
$return = [ PLATFORM => &$platform, BROWSER => &$browser, BROWSER_VERSION => &$version ];
|
||||
|
||||
if( !$u_agent ) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
if( preg_match('/\((.*?)\)/m', $u_agent, $parent_matches) ) {
|
||||
preg_match_all(<<<'REGEX'
|
||||
/(?P<platform>BB\d+;|Android|Adr|Symbian|Sailfish|CrOS|Tizen|iPhone|iPad|iPod|Linux|(?:Open|Net|Free)BSD|Macintosh|
|
||||
Windows(?:\ Phone)?|Silk|linux-gnu|BlackBerry|PlayBook|X11|(?:New\ )?Nintendo\ (?:WiiU?|3?DS|Switch)|Xbox(?:\ One)?)
|
||||
(?:\ [^;]*)?
|
||||
(?:;|$)/imx
|
||||
REGEX
|
||||
, $parent_matches[1], $result);
|
||||
|
||||
$priority = [ 'Xbox One', 'Xbox', 'Windows Phone', 'Tizen', 'Android', 'FreeBSD', 'NetBSD', 'OpenBSD', 'CrOS', 'X11', 'Sailfish' ];
|
||||
|
||||
$result[PLATFORM] = array_unique($result[PLATFORM]);
|
||||
if( count($result[PLATFORM]) > 1 ) {
|
||||
if( $keys = array_intersect($priority, $result[PLATFORM]) ) {
|
||||
$platform = reset($keys);
|
||||
} else {
|
||||
$platform = $result[PLATFORM][0];
|
||||
}
|
||||
} elseif( isset($result[PLATFORM][0]) ) {
|
||||
$platform = $result[PLATFORM][0];
|
||||
}
|
||||
}
|
||||
|
||||
if( $platform == 'linux-gnu' || $platform == 'X11' ) {
|
||||
$platform = 'Linux';
|
||||
} elseif( $platform == 'CrOS' ) {
|
||||
$platform = 'Chrome OS';
|
||||
} elseif( $platform == 'Adr' ) {
|
||||
$platform = 'Android';
|
||||
} elseif( $platform === null ) {
|
||||
if(preg_match_all('%(?P<platform>Android)[:/ ]%ix', $u_agent, $result)) {
|
||||
$platform = $result[PLATFORM][0];
|
||||
}
|
||||
}
|
||||
|
||||
preg_match_all(<<<'REGEX'
|
||||
%(?P<browser>Camino|Kindle(\ Fire)?|Firefox|Iceweasel|IceCat|Safari|MSIE|Trident|AppleWebKit|
|
||||
TizenBrowser|(?:Headless)?Chrome|YaBrowser|Vivaldi|IEMobile|Opera|OPR|Silk|Midori|(?-i:Edge)|EdgA?|CriOS|UCBrowser|Puffin|
|
||||
OculusBrowser|SamsungBrowser|SailfishBrowser|XiaoMi/MiuiBrowser|YaApp_Android|
|
||||
Baiduspider|Applebot|Facebot|Googlebot|YandexBot|bingbot|Lynx|Version|Wget|curl|
|
||||
Valve\ Steam\ Tenfoot|
|
||||
NintendoBrowser|PLAYSTATION\ (?:\d|Vita)+)
|
||||
\)?;?
|
||||
(?:[:/ ](?P<version>[0-9A-Z.]+)|/[A-Z]*)%ix
|
||||
REGEX
|
||||
, $u_agent, $result);
|
||||
|
||||
// If nothing matched, return null (to avoid undefined index errors)
|
||||
if( !isset($result[BROWSER][0], $result[BROWSER_VERSION][0]) ) {
|
||||
if( preg_match('%^(?!Mozilla)(?P<browser>[A-Z0-9\-]+)([/ :](?P<version>[0-9A-Z.]+))?%ix', $u_agent, $result) ) {
|
||||
return [ PLATFORM => $platform ?: null, BROWSER => $result[BROWSER], BROWSER_VERSION => empty($result[BROWSER_VERSION]) ? null : $result[BROWSER_VERSION] ];
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
if( preg_match('/rv:(?P<version>[0-9A-Z.]+)/i', $u_agent, $rv_result) ) {
|
||||
$rv_result = $rv_result[BROWSER_VERSION];
|
||||
}
|
||||
|
||||
$browser = $result[BROWSER][0];
|
||||
$version = $result[BROWSER_VERSION][0];
|
||||
|
||||
$lowerBrowser = array_map('strtolower', $result[BROWSER]);
|
||||
|
||||
$find = function ( $search, &$key = null, &$value = null ) use ( $lowerBrowser ) {
|
||||
$search = (array)$search;
|
||||
|
||||
foreach( $search as $val ) {
|
||||
$xkey = array_search(strtolower($val), $lowerBrowser);
|
||||
if( $xkey !== false ) {
|
||||
$value = $val;
|
||||
$key = $xkey;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
$findT = function ( array $search, &$key = null, &$value = null ) use ( $find ) {
|
||||
$value2 = null;
|
||||
if( $find(array_keys($search), $key, $value2) ) {
|
||||
$value = $search[$value2];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
$key = 0;
|
||||
$val = '';
|
||||
if( $findT([ 'OPR' => 'Opera', 'Facebot' => 'iMessageBot', 'UCBrowser' => 'UC Browser', 'YaBrowser' => 'Yandex', 'YaApp_Android' => 'Yandex', 'Iceweasel' => 'Firefox', 'Icecat' => 'Firefox', 'CriOS' => 'Chrome', 'Edg' => 'Edge', 'EdgA' => 'Edge', 'XiaoMi/MiuiBrowser' => 'MiuiBrowser' ], $key, $browser) ) {
|
||||
$version = is_numeric(substr($result[BROWSER_VERSION][$key], 0, 1)) ? $result[BROWSER_VERSION][$key] : null;
|
||||
} elseif( $find('Playstation Vita', $key, $platform) ) {
|
||||
$platform = 'PlayStation Vita';
|
||||
$browser = 'Browser';
|
||||
} elseif( $find([ 'Kindle Fire', 'Silk' ], $key, $val) ) {
|
||||
$browser = $val == 'Silk' ? 'Silk' : 'Kindle';
|
||||
$platform = 'Kindle Fire';
|
||||
if( !($version = $result[BROWSER_VERSION][$key]) || !is_numeric($version[0]) ) {
|
||||
$version = $result[BROWSER_VERSION][array_search('Version', $result[BROWSER])];
|
||||
}
|
||||
} elseif( $find('NintendoBrowser', $key) || $platform == 'Nintendo 3DS' ) {
|
||||
$browser = 'NintendoBrowser';
|
||||
$version = $result[BROWSER_VERSION][$key];
|
||||
} elseif( $find('Kindle', $key, $platform) ) {
|
||||
$browser = $result[BROWSER][$key];
|
||||
$version = $result[BROWSER_VERSION][$key];
|
||||
} elseif( $find('Opera', $key, $browser) ) {
|
||||
$find('Version', $key);
|
||||
$version = $result[BROWSER_VERSION][$key];
|
||||
} elseif( $find('Puffin', $key, $browser) ) {
|
||||
$version = $result[BROWSER_VERSION][$key];
|
||||
if( strlen($version) > 3 ) {
|
||||
$part = substr($version, -2);
|
||||
if( ctype_upper($part) ) {
|
||||
$version = substr($version, 0, -2);
|
||||
|
||||
$flags = [ 'IP' => 'iPhone', 'IT' => 'iPad', 'AP' => 'Android', 'AT' => 'Android', 'WP' => 'Windows Phone', 'WT' => 'Windows' ];
|
||||
if( isset($flags[$part]) ) {
|
||||
$platform = $flags[$part];
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif( $find([ 'Applebot', 'IEMobile', 'Edge', 'Midori', 'Vivaldi', 'OculusBrowser', 'SamsungBrowser', 'Valve Steam Tenfoot', 'Chrome', 'HeadlessChrome', 'SailfishBrowser' ], $key, $browser) ) {
|
||||
$version = $result[BROWSER_VERSION][$key];
|
||||
} elseif( $rv_result && $find('Trident') ) {
|
||||
$browser = 'MSIE';
|
||||
$version = $rv_result;
|
||||
} elseif( $browser == 'AppleWebKit' ) {
|
||||
if( $platform == 'Android' ) {
|
||||
$browser = 'Android Browser';
|
||||
} elseif( strpos((string)$platform, 'BB') === 0 ) {
|
||||
$browser = 'BlackBerry Browser';
|
||||
$platform = 'BlackBerry';
|
||||
} elseif( $platform == 'BlackBerry' || $platform == 'PlayBook' ) {
|
||||
$browser = 'BlackBerry Browser';
|
||||
} else {
|
||||
$find('Safari', $key, $browser) || $find('TizenBrowser', $key, $browser);
|
||||
}
|
||||
|
||||
$find('Version', $key);
|
||||
$version = $result[BROWSER_VERSION][$key];
|
||||
} elseif( $pKey = preg_grep('/playstation \d/i', $result[BROWSER]) ) {
|
||||
$pKey = reset($pKey);
|
||||
|
||||
$platform = 'PlayStation ' . preg_replace('/\D/', '', $pKey);
|
||||
$browser = 'NetFront';
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user