Switch to DeviceDetector library.

This commit is contained in:
Buster "Silver Eagle" Neece 2020-12-17 22:57:23 -06:00
parent 58b9781b20
commit 80bf66a337
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
5 changed files with 352 additions and 265 deletions

View File

@ -1,171 +1,171 @@
{
"name": "azuracast/azuracast",
"description": "The AzuraCast self-hosted web radio station management suite.",
"license": "Apache-2.0",
"type": "project",
"require": {
"php": ">=7.4",
"ext-PDO": "*",
"ext-fileinfo": "*",
"ext-gd": "*",
"ext-iconv": "*",
"ext-intl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-redis": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"ext-xmlwriter": "*",
"azuracast/azuraforms": "dev-master",
"azuracast/nowplaying": "dev-master",
"bacon/bacon-qr-code": "^2.0",
"beberlei/doctrineextensions": "^1.2",
"brick/math": "^0.9",
"composer/ca-bundle": "^1.2",
"doctrine/annotations": "^1.6",
"doctrine/data-fixtures": "^1.3",
"doctrine/dbal": "^2.8",
"doctrine/migrations": "^3.0",
"doctrine/orm": "~2.6",
"gettext/gettext": "^4.4",
"guzzlehttp/guzzle": "^7.0",
"guzzlehttp/oauth-subscriber": "^0.4.0",
"http-interop/http-factory-guzzle": "^1.0",
"james-heinrich/getid3": "dev-master",
"jhofm/flysystem-iterator": "^2.1",
"laminas/laminas-config": "^3.3",
"league/flysystem": "^1.0",
"league/flysystem-aws-s3-v3": "^1.0",
"league/flysystem-cached-adapter": "^1.0",
"league/mime-type-detection": "^1.5",
"league/plates": "^3.1",
"lstrojny/fxmlrpc": "dev-master",
"maxmind-db/reader": "~1.0",
"mezzio/mezzio-session": "^1.3",
"mezzio/mezzio-session-cache": "^1.4",
"mnapoli/silly-php-di": "^1.2",
"mobiledetect/mobiledetectlib": "^2.8",
"monolog/monolog": "^2",
"myclabs/deep-copy": "^1.10",
"nesbot/carbon": "^2.36",
"ocramius/doctrine-batch-utils": "^2.0",
"overtrue/phplint": "^2.0",
"php-di/php-di": "^6.0",
"php-di/slim-bridge": "^3.0",
"psr/http-factory": "^1.0",
"psr/simple-cache": "^1.0",
"ramsey/uuid": "^4.0",
"rlanvin/php-ip": "^2.0",
"slim/http": "^1.1",
"slim/slim": "^4.2",
"spatie/flysystem-dropbox": "^1.2",
"spomky-labs/otphp": "^10.0",
"studio24/rotate": "^1.0",
"supervisorphp/supervisor": "dev-master",
"symfony/cache": "^5.2",
"symfony/console": "^5",
"symfony/event-dispatcher": "^5",
"symfony/finder": "^5",
"symfony/lock": "^5.1",
"symfony/messenger": "^5",
"symfony/process": "^5",
"symfony/property-access": "^5",
"symfony/redis-messenger": "^5",
"symfony/serializer": "^5",
"symfony/validator": "^5",
"voku/portable-utf8": "^5.4",
"wikimedia/composer-merge-plugin": "dev-feature/composer-v2",
"zircote/swagger-php": "^3"
},
"require-dev": {
"codeception/codeception": "^4.0",
"codeception/module-asserts": "^1.1",
"codeception/module-cli": "^1.0",
"codeception/module-doctrine2": "^1.0",
"codeception/module-phpbrowser": "^1.0",
"codeception/module-rest": "^1.0",
"filp/whoops": "^2",
"mockery/mockery": "^1.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-doctrine": "^0.12",
"phpunit/php-timer": "^5.0",
"phpunit/phpunit": "^9.2",
"roave/security-advisories": "dev-master",
"slevomat/coding-standard": "^6.4",
"softcreatr/jsonpath": "^0.7.2",
"squizlabs/php_codesniffer": "^3.5",
"symfony/var-dumper": "^5.1"
},
"replace": {
"symfony/polyfill-php71": "1.99",
"symfony/polyfill-php72": "1.99",
"symfony/polyfill-php73": "1.99",
"symfony/polyfill-php74": "1.99",
"symfony/polyfill-iconv": "1.99",
"symfony/polyfill-intl-grapheme": "1.99",
"symfony/polyfill-intl-normalizer": "1.99",
"symfony/polyfill-mbstring": "1.99"
},
"repositories": [
{
"type": "git",
"url": "https://github.com/mcaskill/composer-merge-plugin.git"
}
],
"scripts": {
"cleanup-and-test": [
"@phpcbf",
"@dev-test"
"name": "azuracast/azuracast",
"description": "The AzuraCast self-hosted web radio station management suite.",
"license": "Apache-2.0",
"type": "project",
"require": {
"php": ">=7.4",
"ext-PDO": "*",
"ext-fileinfo": "*",
"ext-gd": "*",
"ext-iconv": "*",
"ext-intl": "*",
"ext-json": "*",
"ext-mbstring": "*",
"ext-redis": "*",
"ext-simplexml": "*",
"ext-xml": "*",
"ext-xmlwriter": "*",
"azuracast/azuraforms": "dev-master",
"azuracast/nowplaying": "dev-master",
"bacon/bacon-qr-code": "^2.0",
"beberlei/doctrineextensions": "^1.2",
"brick/math": "^0.9",
"composer/ca-bundle": "^1.2",
"doctrine/annotations": "^1.6",
"doctrine/data-fixtures": "^1.3",
"doctrine/dbal": "^2.8",
"doctrine/migrations": "^3.0",
"doctrine/orm": "~2.6",
"gettext/gettext": "^4.4",
"guzzlehttp/guzzle": "^7.0",
"guzzlehttp/oauth-subscriber": "^0.4.0",
"http-interop/http-factory-guzzle": "^1.0",
"james-heinrich/getid3": "dev-master",
"jhofm/flysystem-iterator": "^2.1",
"laminas/laminas-config": "^3.3",
"league/flysystem": "^1.0",
"league/flysystem-aws-s3-v3": "^1.0",
"league/flysystem-cached-adapter": "^1.0",
"league/mime-type-detection": "^1.5",
"league/plates": "^3.1",
"lstrojny/fxmlrpc": "dev-master",
"matomo/device-detector": "^4.0",
"maxmind-db/reader": "~1.0",
"mezzio/mezzio-session": "^1.3",
"mezzio/mezzio-session-cache": "^1.4",
"mnapoli/silly-php-di": "^1.2",
"monolog/monolog": "^2",
"myclabs/deep-copy": "^1.10",
"nesbot/carbon": "^2.36",
"ocramius/doctrine-batch-utils": "^2.0",
"overtrue/phplint": "^2.0",
"php-di/php-di": "^6.0",
"php-di/slim-bridge": "^3.0",
"psr/http-factory": "^1.0",
"psr/simple-cache": "^1.0",
"ramsey/uuid": "^4.0",
"rlanvin/php-ip": "^2.0",
"slim/http": "^1.1",
"slim/slim": "^4.2",
"spatie/flysystem-dropbox": "^1.2",
"spomky-labs/otphp": "^10.0",
"studio24/rotate": "^1.0",
"supervisorphp/supervisor": "dev-master",
"symfony/cache": "^5.2",
"symfony/console": "^5",
"symfony/event-dispatcher": "^5",
"symfony/finder": "^5",
"symfony/lock": "^5.1",
"symfony/messenger": "^5",
"symfony/process": "^5",
"symfony/property-access": "^5",
"symfony/redis-messenger": "^5",
"symfony/serializer": "^5",
"symfony/validator": "^5",
"voku/portable-utf8": "^5.4",
"wikimedia/composer-merge-plugin": "dev-feature/composer-v2",
"zircote/swagger-php": "^3"
},
"require-dev": {
"codeception/codeception": "^4.0",
"codeception/module-asserts": "^1.1",
"codeception/module-cli": "^1.0",
"codeception/module-doctrine2": "^1.0",
"codeception/module-phpbrowser": "^1.0",
"codeception/module-rest": "^1.0",
"filp/whoops": "^2",
"mockery/mockery": "^1.0",
"phpstan/phpstan": "^0.12",
"phpstan/phpstan-doctrine": "^0.12",
"phpunit/php-timer": "^5.0",
"phpunit/phpunit": "^9.2",
"roave/security-advisories": "dev-master",
"slevomat/coding-standard": "^6.4",
"softcreatr/jsonpath": "^0.7.2",
"squizlabs/php_codesniffer": "^3.5",
"symfony/var-dumper": "^5.1"
},
"replace": {
"symfony/polyfill-php71": "1.99",
"symfony/polyfill-php72": "1.99",
"symfony/polyfill-php73": "1.99",
"symfony/polyfill-php74": "1.99",
"symfony/polyfill-iconv": "1.99",
"symfony/polyfill-intl-grapheme": "1.99",
"symfony/polyfill-intl-normalizer": "1.99",
"symfony/polyfill-mbstring": "1.99"
},
"repositories": [
{
"type": "git",
"url": "https://github.com/mcaskill/composer-merge-plugin.git"
}
],
"dev-test": [
"@phplint",
"@phpstan",
"@phpcs",
"@codeception-no-coverage"
"scripts": {
"cleanup-and-test": [
"@phpcbf",
"@dev-test"
],
"dev-test": [
"@phplint",
"@phpstan",
"@phpcs",
"@codeception-no-coverage"
],
"phplint": "phplint",
"phpstan": "phpstan analyze",
"phpcs": "phpcs",
"phpcbf": "phpcbf",
"codeception": "codecept run --no-interaction --coverage --coverage-xml --fail-fast",
"codeception-no-coverage": "codecept run --no-interaction",
"ci-import-locales": [
"bin/console locale:import"
]
},
"authors": [
{
"name": "Buster Neece",
"email": "buster@busterneece.com"
}
],
"phplint": "phplint",
"phpstan": "phpstan analyze",
"phpcs": "phpcs",
"phpcbf": "phpcbf",
"codeception": "codecept run --no-interaction --coverage --coverage-xml --fail-fast",
"codeception-no-coverage": "codecept run --no-interaction",
"ci-import-locales": [
"bin/console locale:import"
]
},
"authors": [
{
"name": "Buster Neece",
"email": "buster@busterneece.com"
"autoload": {
"psr-4": {
"App\\": "src"
}
},
"bin": [
"bin/console"
],
"config": {
"preferred-install": "dist",
"discard-changes": true,
"sort-packages": true
},
"prefer-stable": true,
"minimum-stability": "dev",
"extra": {
"merge-plugin": {
"include": [
"plugins/*/composer.json"
],
"recurse": true,
"replace": true,
"ignore-duplicates": false,
"merge-dev": true,
"merge-extra": false,
"merge-extra-deep": false,
"merge-scripts": false
}
}
],
"autoload": {
"psr-4": {
"App\\": "src"
}
},
"bin": [
"bin/console"
],
"config": {
"preferred-install": "dist",
"discard-changes": true,
"sort-packages": true
},
"prefer-stable": true,
"minimum-stability": "dev",
"extra": {
"merge-plugin": {
"include": [
"plugins/*/composer.json"
],
"recurse": true,
"replace": true,
"ignore-duplicates": false,
"merge-dev": true,
"merge-extra": false,
"merge-extra-deep": false,
"merge-scripts": false
}
}
}

209
composer.lock generated
View File

@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "e308b78d2f128f2a11789a205aefae53",
"content-hash": "152d1c444de811053c2d92c6b87881ab",
"packages": [
{
"name": "aws/aws-sdk-php",
"version": "3.168.3",
"version": "3.171.1",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "49ef1f905388c8185012c9651b80941b8f2a218d"
"reference": "01407effc918634048346d8bd6513b2db0d07ad8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/49ef1f905388c8185012c9651b80941b8f2a218d",
"reference": "49ef1f905388c8185012c9651b80941b8f2a218d",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/01407effc918634048346d8bd6513b2db0d07ad8",
"reference": "01407effc918634048346d8bd6513b2db0d07ad8",
"shasum": ""
},
"require": {
@ -92,9 +92,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.168.3"
"source": "https://github.com/aws/aws-sdk-php/tree/3.171.1"
},
"time": "2020-12-11T19:12:18+00:00"
"time": "2020-12-17T19:16:51+00:00"
},
{
"name": "azuracast/azuraforms",
@ -2377,12 +2377,12 @@
"source": {
"type": "git",
"url": "https://github.com/JamesHeinrich/getID3.git",
"reference": "475a5291509471d6b087d62b139c60be6fbdd5d1"
"reference": "f199994d797754cac398c35240732ba235f5c2fa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/JamesHeinrich/getID3/zipball/475a5291509471d6b087d62b139c60be6fbdd5d1",
"reference": "475a5291509471d6b087d62b139c60be6fbdd5d1",
"url": "https://api.github.com/repos/JamesHeinrich/getID3/zipball/f199994d797754cac398c35240732ba235f5c2fa",
"reference": "f199994d797754cac398c35240732ba235f5c2fa",
"shasum": ""
},
"require": {
@ -2437,7 +2437,7 @@
"issues": "https://github.com/JamesHeinrich/getID3/issues",
"source": "https://github.com/JamesHeinrich/getID3/tree/master"
},
"time": "2020-12-09T16:21:59+00:00"
"time": "2020-12-15T15:18:21+00:00"
},
{
"name": "jhofm/flysystem-iterator",
@ -3212,6 +3212,75 @@
},
"time": "2020-11-23T14:42:43+00:00"
},
{
"name": "matomo/device-detector",
"version": "4.0.2",
"source": {
"type": "git",
"url": "https://github.com/matomo-org/device-detector.git",
"reference": "20572bbf8607cfc2f91a11fc75e9a3c6592bdc7a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/matomo-org/device-detector/zipball/20572bbf8607cfc2f91a11fc75e9a3c6592bdc7a",
"reference": "20572bbf8607cfc2f91a11fc75e9a3c6592bdc7a",
"shasum": ""
},
"require": {
"mustangostang/spyc": "*",
"php": ">=7.2"
},
"replace": {
"piwik/device-detector": "self.version"
},
"require-dev": {
"matthiasmullie/scrapbook": "@stable",
"mayflower/mo4-coding-standard": "dev-master#275cb9d",
"phpstan/phpstan": "^0.12.52",
"phpunit/phpunit": "^8.5.8",
"psr/cache": "^1.0.1",
"psr/simple-cache": "^1.0.1",
"symfony/yaml": "^5.1.7"
},
"suggest": {
"doctrine/cache": "Can directly be used for caching purpose",
"ext-yaml": "Necessary for using the Pecl YAML parser"
},
"type": "library",
"autoload": {
"psr-4": {
"DeviceDetector\\": ""
},
"exclude-from-classmap": [
"Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL-3.0-or-later"
],
"authors": [
{
"name": "The Matomo Team",
"email": "hello@matomo.org",
"homepage": "https://matomo.org/team/"
}
],
"description": "The Universal Device Detection library, that parses User Agents and detects devices (desktop, tablet, mobile, tv, cars, console, etc.), clients (browsers, media players, mobile apps, feed readers, libraries, etc), operating systems, devices, brands and models.",
"homepage": "https://matomo.org",
"keywords": [
"devicedetection",
"parser",
"useragent"
],
"support": {
"forum": "http://forum.matomo.org/",
"issues": "https://github.com/matomo-org/device-detector/issues",
"source": "https://github.com/matomo-org/piwik",
"wiki": "https://dev.matomo.org/"
},
"time": "2020-12-07T09:40:38+00:00"
},
{
"name": "maxmind-db/reader",
"version": "v1.8.0",
@ -3515,62 +3584,6 @@
},
"time": "2018-04-05T08:53:27+00:00"
},
{
"name": "mobiledetect/mobiledetectlib",
"version": "2.8.34",
"source": {
"type": "git",
"url": "https://github.com/serbanghita/Mobile-Detect.git",
"reference": "6f8113f57a508494ca36acbcfa2dc2d923c7ed5b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/serbanghita/Mobile-Detect/zipball/6f8113f57a508494ca36acbcfa2dc2d923c7ed5b",
"reference": "6f8113f57a508494ca36acbcfa2dc2d923c7ed5b",
"shasum": ""
},
"require": {
"php": ">=5.0.0"
},
"require-dev": {
"phpunit/phpunit": "~4.8.35||~5.7"
},
"type": "library",
"autoload": {
"classmap": [
"Mobile_Detect.php"
],
"psr-0": {
"Detection": "namespaced/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Serban Ghita",
"email": "serbanghita@gmail.com",
"homepage": "http://mobiledetect.net",
"role": "Developer"
}
],
"description": "Mobile_Detect is a lightweight PHP class for detecting mobile devices. It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.",
"homepage": "https://github.com/serbanghita/Mobile-Detect",
"keywords": [
"detect mobile devices",
"mobile",
"mobile detect",
"mobile detector",
"php mobile detect"
],
"support": {
"issues": "https://github.com/serbanghita/Mobile-Detect/issues",
"source": "https://github.com/serbanghita/Mobile-Detect/tree/2.8.34"
},
"time": "2019-09-18T18:44:20+00:00"
},
{
"name": "monolog/monolog",
"version": "2.2.0",
@ -3728,6 +3741,56 @@
},
"time": "2020-07-31T21:01:56+00:00"
},
{
"name": "mustangostang/spyc",
"version": "0.6.3",
"source": {
"type": "git",
"url": "git@github.com:mustangostang/spyc.git",
"reference": "4627c838b16550b666d15aeae1e5289dd5b77da0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/mustangostang/spyc/zipball/4627c838b16550b666d15aeae1e5289dd5b77da0",
"reference": "4627c838b16550b666d15aeae1e5289dd5b77da0",
"shasum": ""
},
"require": {
"php": ">=5.3.1"
},
"require-dev": {
"phpunit/phpunit": "4.3.*@dev"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "0.5.x-dev"
}
},
"autoload": {
"files": [
"Spyc.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "mustangostang",
"email": "vlad.andersen@gmail.com"
}
],
"description": "A simple YAML loader/dumper class for PHP",
"homepage": "https://github.com/mustangostang/spyc/",
"keywords": [
"spyc",
"yaml",
"yml"
],
"time": "2019-09-10T13:16:29+00:00"
},
{
"name": "myclabs/deep-copy",
"version": "1.10.2",
@ -9866,16 +9929,16 @@
},
{
"name": "phpstan/phpstan",
"version": "0.12.62",
"version": "0.12.63",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan.git",
"reference": "632393159335bbbdd7ca07d19b3ad50d76aa7fd8"
"reference": "c97ec4754bd53099a06c24847bd2870b99966b6a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/632393159335bbbdd7ca07d19b3ad50d76aa7fd8",
"reference": "632393159335bbbdd7ca07d19b3ad50d76aa7fd8",
"url": "https://api.github.com/repos/phpstan/phpstan/zipball/c97ec4754bd53099a06c24847bd2870b99966b6a",
"reference": "c97ec4754bd53099a06c24847bd2870b99966b6a",
"shasum": ""
},
"require": {
@ -9906,7 +9969,7 @@
"description": "PHPStan - PHP Static Analysis Tool",
"support": {
"issues": "https://github.com/phpstan/phpstan/issues",
"source": "https://github.com/phpstan/phpstan/tree/0.12.62"
"source": "https://github.com/phpstan/phpstan/tree/0.12.63"
},
"funding": [
{
@ -9922,7 +9985,7 @@
"type": "tidelift"
}
],
"time": "2020-12-13T13:59:38+00:00"
"time": "2020-12-15T16:37:16+00:00"
},
{
"name": "phpstan/phpstan-doctrine",

View File

@ -5,6 +5,7 @@ namespace App\Controller\Api\Stations;
use App\Entity;
use App\Http\Response;
use App\Http\ServerRequest;
use App\Service\DeviceDetector;
use App\Service\IpGeolocation;
use App\Utilities\Csv;
use Carbon\CarbonImmutable;
@ -19,10 +20,13 @@ class ListenersController
protected IpGeolocation $geoLite;
public function __construct(EntityManagerInterface $em, IpGeolocation $geoLite)
protected DeviceDetector $deviceDetector;
public function __construct(EntityManagerInterface $em, IpGeolocation $geoLite, DeviceDetector $deviceDetector)
{
$this->em = $em;
$this->geoLite = $geoLite;
$this->deviceDetector = $deviceDetector;
}
/**
@ -127,7 +131,6 @@ class ListenersController
}
}
$detect = new Mobile_Detect();
$locale = $request->getAttribute('locale');
$format = $params['format'] ?? 'json';
@ -153,7 +156,7 @@ class ListenersController
(string)$listener['listener_ip'],
Entity\Listener::getListenerSeconds($listener['intervals']),
(string)$listener['listener_user_agent'],
$detect->isMobile($listener['listener_user_agent']) ? 'true' : 'false',
$this->isMobile($listener['listener_user_agent']) ? 'true' : 'false',
];
if ('success' === $location['status']) {
@ -182,7 +185,7 @@ class ListenersController
$api = new Entity\Api\Listener();
$api->ip = (string)$listener['listener_ip'];
$api->user_agent = (string)$listener['listener_user_agent'];
$api->is_mobile = $detect->isMobile($listener['listener_user_agent']);
$api->is_mobile = $this->isMobile($listener['listener_user_agent']);
$api->connected_on = (int)$listener['timestamp_start'];
$api->connected_time = Entity\Listener::getListenerSeconds($listener['intervals']);
$api->location = $this->geoLite->getLocationInfo($listener['listener_ip'], $locale);
@ -192,4 +195,10 @@ class ListenersController
return $response->withJson($listeners);
}
protected function isMobile(string $userAgent): bool
{
$dd = $this->deviceDetector->parse($userAgent);
return $dd->isMobile();
}
}

View File

@ -7,6 +7,7 @@ use App\Entity;
use App\Environment;
use App\Exception;
use App\Radio\AutoDJ;
use App\Service\DeviceDetector;
use Carbon\CarbonImmutable;
use Carbon\CarbonInterface;
use Doctrine\ORM\EntityManagerInterface;
@ -17,16 +18,20 @@ class StationRequestRepository extends Repository
{
protected StationMediaRepository $mediaRepo;
protected DeviceDetector $deviceDetector;
public function __construct(
EntityManagerInterface $em,
Serializer $serializer,
Environment $environment,
LoggerInterface $logger,
StationMediaRepository $mediaRepo
StationMediaRepository $mediaRepo,
DeviceDetector $deviceDetector
) {
parent::__construct($em, $serializer, $environment, $logger);
$this->mediaRepo = $mediaRepo;
$this->deviceDetector = $deviceDetector;
}
public function submit(
@ -37,7 +42,9 @@ class StationRequestRepository extends Repository
string $userAgent
): int {
// Forbid web crawlers from using this feature.
if ($this->isCrawler($userAgent)) {
$dd = $this->deviceDetector->parse($userAgent);
if ($dd->isBot()) {
throw new Exception(__('Search engine crawlers are not permitted to use this feature.'));
}
@ -100,26 +107,6 @@ class StationRequestRepository extends Repository
return $record->getId();
}
protected function isCrawler(string $userAgent): bool
{
$userAgent = strtolower($userAgent);
// phpcs:disable Generic.Files.LineLength
$crawlers_agents = strtolower(
'Bloglines subscriber|Dumbot|Sosoimagespider|QihooBot|FAST-WebCrawler|Superdownloads Spiderman|LinkWalker|msnbot|ASPSeek|WebAlta Crawler|Lycos|FeedFetcher-Google|Yahoo|YoudaoBot|AdsBot-Google|Googlebot|Scooter|Gigabot|Charlotte|eStyle|AcioRobot|GeonaBot|msnbot-media|Baidu|CocoCrawler|Google|Charlotte t|Yahoo! Slurp China|Sogou web spider|YodaoBot|MSRBOT|AbachoBOT|Sogou head spider|AltaVista|IDBot|Sosospider|Yahoo! Slurp|Java VM|DotBot|LiteFinder|Yeti|Rambler|Scrubby|Baiduspider|accoona'
);
// phpcs:enable
$crawlers = explode('|', $crawlers_agents);
foreach ($crawlers as $crawler) {
if (strpos($userAgent, trim($crawler)) !== false) {
return true;
}
}
return false;
}
/**
* Check if the song is already enqueued as a request.
*

View File

@ -0,0 +1,28 @@
<?php
namespace App\Service;
use DeviceDetector\Cache\CacheInterface;
use DeviceDetector\Cache\PSR6Bridge;
use Psr\Cache\CacheItemPoolInterface;
use Symfony\Component\Cache\Adapter\ProxyAdapter;
class DeviceDetector
{
protected CacheInterface $cache;
public function __construct(CacheItemPoolInterface $cache)
{
$wrappedCache = new ProxyAdapter($cache, 'device.');
$this->cache = new PSR6Bridge($wrappedCache);
}
public function parse(string $userAgent): \DeviceDetector\DeviceDetector
{
$dd = new \DeviceDetector\DeviceDetector($userAgent);
$dd->setCache($this->cache);
$dd->parse();
return $dd;
}
}