Compare commits
1 commit
74349cc701
...
67b464cc47
Author | SHA1 | Date | |
---|---|---|---|
Michael | 67b464cc47 |
|
@ -69,7 +69,7 @@ function blockbot_init_1()
|
|||
}
|
||||
|
||||
if (empty($parts)) {
|
||||
logger::debug('Known frontend found', $logdata);
|
||||
Logger::debug('Known frontend found', $logdata);
|
||||
if ($isCrawler) {
|
||||
blockbot_save('badly-parsed-agents', $_SERVER['HTTP_USER_AGENT']);
|
||||
}
|
||||
|
@ -77,22 +77,22 @@ function blockbot_init_1()
|
|||
}
|
||||
|
||||
if (blockbot_is_crawler($parts)) {
|
||||
logger::debug('Crawler found', $logdata);
|
||||
Logger::debug('Crawler found', $logdata);
|
||||
blockbot_reject();
|
||||
}
|
||||
|
||||
if (blockbot_is_searchbot($parts)) {
|
||||
logger::debug('Search bot found', $logdata);
|
||||
Logger::debug('Search bot found', $logdata);
|
||||
blockbot_reject();
|
||||
}
|
||||
|
||||
if (blockbot_is_unwanted($parts)) {
|
||||
logger::debug('Uncategorized unwanted agent found', $logdata);
|
||||
Logger::debug('Uncategorized unwanted agent found', $logdata);
|
||||
blockbot_reject();
|
||||
}
|
||||
|
||||
if (blockbot_is_security_checker($parts)) {
|
||||
logger::debug('Security checker found', $logdata);
|
||||
Logger::debug('Security checker found', $logdata);
|
||||
if (!DI::config()->get('blockbot', 'security_checker')) {
|
||||
blockbot_reject();
|
||||
}
|
||||
|
@ -100,49 +100,49 @@ function blockbot_init_1()
|
|||
}
|
||||
|
||||
if (blockbot_is_social_media($parts)) {
|
||||
logger::debug('Social media service found', $logdata);
|
||||
Logger::debug('Social media service found', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockbot_is_fediverse_client($parts)) {
|
||||
logger::debug('Fediverse client found', $logdata);
|
||||
Logger::debug('Fediverse client found', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockbot_is_feed_reader($parts)) {
|
||||
logger::debug('Feed reader found', $logdata);
|
||||
Logger::debug('Feed reader found', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockbot_is_fediverse_tool($parts)) {
|
||||
logger::debug('Fediverse tool found', $logdata);
|
||||
Logger::debug('Fediverse tool found', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockbot_is_service_agent($parts)) {
|
||||
logger::debug('Service agent found', $logdata);
|
||||
Logger::debug('Service agent found', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockbot_is_monitor($parts)) {
|
||||
logger::debug('Monitoring service found', $logdata);
|
||||
Logger::debug('Monitoring service found', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockbot_is_validator($parts)) {
|
||||
logger::debug('Validation service found', $logdata);
|
||||
Logger::debug('Validation service found', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockbot_is_good_tool($parts)) {
|
||||
logger::debug('Uncategorized helpful service found', $logdata);
|
||||
Logger::debug('Uncategorized helpful service found', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
// Needs to be checked at the end, since other services might use these libraries
|
||||
if (blockbot_is_http_library($parts)) {
|
||||
blockbot_check_login_attempt($_SERVER['REQUEST_URI'], $logdata);
|
||||
logger::debug('HTTP Library found', $logdata);
|
||||
Logger::debug('HTTP Library found', $logdata);
|
||||
if (!DI::config()->get('blockbot', 'http_libraries')) {
|
||||
blockbot_reject();
|
||||
}
|
||||
|
@ -156,12 +156,12 @@ function blockbot_init_1()
|
|||
|
||||
if (!$isCrawler) {
|
||||
blockbot_save('good-agents', $_SERVER['HTTP_USER_AGENT']);
|
||||
logger::debug('Non-bot user agent detected', $logdata);
|
||||
Logger::debug('Non-bot user agent detected', $logdata);
|
||||
return;
|
||||
}
|
||||
|
||||
blockbot_save('bad-agents', $_SERVER['HTTP_USER_AGENT']);
|
||||
logger::notice('Blocked bot', $logdata);
|
||||
Logger::notice('Blocked bot', $logdata);
|
||||
blockbot_reject();
|
||||
}
|
||||
|
||||
|
@ -182,7 +182,7 @@ function blockbot_save($database, $userAgent)
|
|||
function blockbot_check_login_attempt(string $url, array $logdata)
|
||||
{
|
||||
if (in_array(trim(parse_url($url, PHP_URL_PATH), '/'), ['login', 'lostpass', 'register'])) {
|
||||
logger::debug('Login attempt detected', $logdata);
|
||||
Logger::debug('Login attempt detected', $logdata);
|
||||
blockbot_reject();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue