Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions web/pages/admin.edit.ban.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,15 @@ function emitEditBanToastAndRedirect(string $kind, string $title, string $body,
$_POST['steam'] = \SteamID\SteamID::toSteam2($rawSteam);
}

if ($error === 0 && empty($_POST['ip']) && $postBanType === BanType::Ip) {
// Didn't type an IP
$error++;
$validationErrors['ip'] = 'You must type an IP';
} elseif ($error === 0 && $postBanType === BanType::Ip && !filter_var($_POST['ip'], FILTER_VALIDATE_IP)) {
$error++;
$validationErrors['ip'] = 'You must type a valid IP';
if ($postBanType === BanType::Ip) {
if ($error === 0 && empty($_POST['ip'])) {
// Didn't type an IP
$error++;
$validationErrors['ip'] = 'You must type an IP';
} elseif ($error === 0 && !filter_var($_POST['ip'], FILTER_VALIDATE_IP)) {
$error++;
$validationErrors['ip'] = 'You must type a valid IP';
}
}

// Didn't type a custom reason
Expand All @@ -209,6 +211,11 @@ function emitEditBanToastAndRedirect(string $kind, string $title, string $body,
PruneBans();

if ($error == 0) {
// Re-read from POST so PHPStan does not carry the narrowed type
// inferred by the validation branches above into this independent
// duplicate-check block. The value is identical at runtime.
$postBanType = BanType::tryFrom((int) $_POST['type']) ?? BanType::Steam;

// Check if the new steamid is already banned. Surface the
// conflicting bid so the admin can investigate the OTHER
// active row that's blocking this edit (mirrors the same
Expand Down
Loading