-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
send unknown user agents to mysterycode.de optionally
- Loading branch information
Showing
8 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
<?php | ||
|
||
define('BLACKLIST_USER_AGENTS_HIDE_FROM_ONLINELIST', 0); | ||
define('USERS_ONLINE_SEND_UNKNOWN_USERAGENTS', 0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
files/lib/system/background/job/RegisterUnknownUserAgentBackgroundJob.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace wcf\system\background\job; | ||
|
||
use Exception; | ||
use wcf\util\HTTPRequest; | ||
use wcf\util\MessageUtil; | ||
use wcf\util\StringUtil; | ||
use function wcf\functions\exception\logThrowable; | ||
|
||
class RegisterUnknownUserAgentBackgroundJob extends AbstractBackgroundJob { | ||
/** | ||
* @var string | ||
*/ | ||
protected $userAgent; | ||
|
||
public function __construct($userAgent) { | ||
$this->userAgent = $userAgent; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function perform() { | ||
try { | ||
(new HTTPRequest('https://api.mysterycode.de/woltlab/registeruseragent.php', [], [ | ||
'userAgent' => StringUtil::trim(MessageUtil::stripCrap($this->userAgent)) | ||
]))->execute(); | ||
} | ||
catch (Exception $e) { | ||
logThrowable($e); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
files/lib/system/event/listener/SendUnknownUserAgentListener.class.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
|
||
namespace wcf\system\event\listener; | ||
|
||
use wcf\data\user\online\UserOnline; | ||
use wcf\page\AbstractPage; | ||
use wcf\system\background\BackgroundQueueHandler; | ||
use wcf\system\background\job\RegisterUnknownUserAgentBackgroundJob; | ||
use wcf\system\WCF; | ||
use wcf\util\UserUtil; | ||
|
||
class SendUnknownUserAgentListener implements IParameterizedEventListener { | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function execute($eventObj, $className, $eventName, array &$parameters) { | ||
/** @var AbstractPage $eventObj */ | ||
|
||
if (!WCF::getUser()->userID && !WCF::getSession()->spiderID && USERS_ONLINE_SEND_UNKNOWN_USERAGENTS) { | ||
$profile = new UserOnline(WCF::getUser()); | ||
$userAgent = UserUtil::getUserAgent(); | ||
|
||
if ($userAgent == $profile->getBrowser() && !preg_match('/(WoltLab (Suite|Community Framework)|WSC-Connect|shoWWelle)/', $userAgent)) { | ||
BackgroundQueueHandler::getInstance()->enqueueIn([ | ||
new RegisterUnknownUserAgentBackgroundJob($userAgent) | ||
]); | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters