added unban xd

This commit is contained in:
Lain Iwakura 2025-06-16 03:12:45 +03:00
parent 71dd22c304
commit da3dc76280
No known key found for this signature in database
GPG Key ID: C7C18257F2ADC6F8

View File

@ -45,6 +45,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$error = "Username already banned"; $error = "Username already banned";
} }
} }
} elseif ($_POST['action'] === 'preventive_unban') {
$stmt = $db->prepare('DELETE FROM banned_usernames WHERE username = ?');
$stmt->execute([$username]);
$success = "Username $username has been preventively unbanned";
} }
} }
} }
@ -121,6 +125,36 @@ $users = $stmt->fetchAll(PDO::FETCH_ASSOC);
</form> </form>
</div> </div>
<h2>Preventively Banned Usernames</h2>
<table class="admin-table">
<thead>
<tr>
<th>Username</th>
<th>Banned At</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
$stmt = $db->query('SELECT username, created_at FROM banned_usernames ORDER BY created_at DESC');
$banned_usernames = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($banned_usernames as $banned): ?>
<tr>
<td><?= htmlspecialchars($banned['username']) ?></td>
<td><?= $banned['created_at'] ?></td>
<td>
<form method="post" style="display:inline">
<input type="hidden" name="username" value="<?= htmlspecialchars($banned['username']) ?>">
<input type="hidden" name="action" value="preventive_unban">
<button type="submit" class="unban-btn">Unban</button>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<h2>Users</h2>
<table class="admin-table"> <table class="admin-table">
<thead> <thead>
<tr> <tr>