mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 22:03:49 -07:00
feat(announcer): Block browser by checking the User-Agent
(#1764)
This commit is contained in:
parent
bf0de87679
commit
7b64b50819
1 changed files with 11 additions and 1 deletions
|
@ -138,10 +138,20 @@ if (!isset($left) || $left < 0) {
|
||||||
*
|
*
|
||||||
* @see https://github.com/HDInnovations/UNIT3D-Community-Edition/blob/c64275f0b5dcb3c4c845d5204871adfe24f359d6/app/Http/Controllers/AnnounceController.php#L177
|
* @see https://github.com/HDInnovations/UNIT3D-Community-Edition/blob/c64275f0b5dcb3c4c845d5204871adfe24f359d6/app/Http/Controllers/AnnounceController.php#L177
|
||||||
*/
|
*/
|
||||||
if (strlen((string)$_SERVER['HTTP_USER_AGENT']) > 64) {
|
$userAgent = (string)$_SERVER['HTTP_USER_AGENT'];
|
||||||
|
if (strlen($userAgent) > 64) {
|
||||||
msg_die('User-Agent must be less than 64 characters long');
|
msg_die('User-Agent must be less than 64 characters long');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Block Browser by checking the User-Agent
|
||||||
|
*
|
||||||
|
* @see https://github.com/HDInnovations/UNIT3D-Community-Edition/blob/c64275f0b5dcb3c4c845d5204871adfe24f359d6/app/Http/Controllers/AnnounceController.php#L182
|
||||||
|
*/
|
||||||
|
if (preg_match('/(Mozilla|Browser|Chrome|Safari|AppleWebKit|Opera|Links|Lynx|Bot|Unknown)/i', $userAgent)) {
|
||||||
|
msg_die('Browser disallowed');
|
||||||
|
}
|
||||||
|
|
||||||
// IP
|
// IP
|
||||||
$ip = $_SERVER['REMOTE_ADDR'];
|
$ip = $_SERVER['REMOTE_ADDR'];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue