post.php: use IpBlacklistService to check for spam ips via DNS

This commit is contained in:
Zankaria 2025-04-24 00:58:10 +02:00
parent 9cfcf6e536
commit d210f408dc

View File

@ -8,7 +8,7 @@ require_once 'inc/bootstrap.php';
use Vichan\{Context, WebDependencyFactory}; use Vichan\{Context, WebDependencyFactory};
use Vichan\Data\Driver\{LogDriver, HttpDriver}; use Vichan\Data\Driver\{LogDriver, HttpDriver};
use Vichan\Data\ReportQueries; use Vichan\Data\ReportQueries;
use Vichan\Service\{RemoteCaptchaQuery, SecureImageCaptchaQuery}; use Vichan\Service\{IpBlacklistService, RemoteCaptchaQuery, SecureImageCaptchaQuery};
use Vichan\Functions\{Format, IP}; use Vichan\Functions\{Format, IP};
/** /**
@ -373,7 +373,10 @@ if (isset($_POST['delete'])) {
} }
} }
checkDNSBL(); $blacklist = $context->get(IpBlacklistService::class)->isIpBlacklisted($_SERVER['REMOTE_ADDR']);
if ($blacklist !== false) {
error(\sprintf($config['error']['dnsbl'], $blacklist));
}
// Check if board exists // Check if board exists
if (!openBoard($_POST['board'])) if (!openBoard($_POST['board']))
@ -468,7 +471,10 @@ if (isset($_POST['delete'])) {
} }
} }
checkDNSBL(); $blacklist = $context->get(IpBlacklistService::class)->isIpBlacklisted($_SERVER['REMOTE_ADDR']);
if ($blacklist !== false) {
error(\sprintf($config['error']['dnsbl'], $blacklist));
}
// Check if board exists // Check if board exists
if (!openBoard($_POST['board'])) if (!openBoard($_POST['board']))
@ -661,7 +667,10 @@ if (isset($_POST['delete'])) {
(!isset($_SERVER['HTTP_REFERER']) || !preg_match($config['referer_match'], rawurldecode($_SERVER['HTTP_REFERER'])))) (!isset($_SERVER['HTTP_REFERER']) || !preg_match($config['referer_match'], rawurldecode($_SERVER['HTTP_REFERER']))))
error($config['error']['referer']); error($config['error']['referer']);
checkDNSBL(); $blacklist = $context->get(IpBlacklistService::class)->isIpBlacklisted($_SERVER['REMOTE_ADDR']);
if ($blacklist !== false) {
error(\sprintf($config['error']['dnsbl'], $blacklist));
}
if ($post['mod'] = isset($_POST['mod']) && $_POST['mod']) { if ($post['mod'] = isset($_POST['mod']) && $_POST['mod']) {