bans.php

main 110 lines · 3 KB Raw
Alex Alex Commit Initial commit 01/10/2026 09:20
1<?php
2/**
3 * Public ban list.
4 *
5 * Prepared by bans.php:
6 * $bansSupported false when this engine has no readable ban tables
7 * $accountBans [name, reason, banned_at, expires_at]
8 * $nameLocks [name, reason, at]
9 * $ipBanCount number of active address bans, shown as a count only
10 */
11
12/** "3 days left", "permanent", or "expired". */
13function znote_ban_remaining(int $expires): string {
14 if ($expires <= 0) {
15 return t('bans.permanent');
16 }
17
18 $left = $expires - time();
19 if ($left <= 0) {
20 return t('bans.expired');
21 }
22
23 $days = intdiv($left, 86400);
24 $hours = intdiv($left % 86400, 3600);
25
26 if ($days > 0) {
27 return t('bans.days_left', ['n' => $days]);
28 }
29 if ($hours > 0) {
30 return t('bans.hours_left', ['n' => $hours]);
31 }
32
33 return t('bans.less_hour');
34}
35?>
36<div class="znx-acct">
37
38<div class="znx-acct-head"><?= t('bans.title') ?></div>
39
40<?php if (!$bansSupported): ?>
41
42 <div class="znx-empty-box"><?= t('bans.unsupported') ?></div>
43
44<?php else: ?>
45
46 <div class="znx-acct-info">
47 <?= t('bans.intro') ?>
48 <?php if ($ipBanCount > 0): ?>
49 <?= t('bans.ip_count', ['count' => (int)$ipBanCount]) ?>
50 <?php endif; ?>
51 </div>
52
53 <div class="znx-acct-head"><?= t('bans.accounts') ?></div>
54 <?php if ($accountBans): ?>
55 <div class="znx-acct-table-wrap">
56 <table class="znx-acct-table">
57 <tr class="yellow">
58 <td><?= t('common.character') ?></td>
59 <td><?= t('common.reason') ?></td>
60 <td><?= t('bans.banned') ?></td>
61 <td><?= t('common.status') ?></td>
62 </tr>
63 <?php foreach ($accountBans as $ban): ?>
64 <tr>
65 <td>
66 <a href="characterprofile.php?name=<?= urlencode($ban['name']) ?>">
67 <?= htmlspecialchars($ban['name'], ENT_QUOTES, 'UTF-8') ?>
68 </a>
69 </td>
70 <td><?= htmlspecialchars($ban['reason'], ENT_QUOTES, 'UTF-8') ?></td>
71 <td><?= htmlspecialchars(getClock($ban['banned_at'], true), ENT_QUOTES, 'UTF-8') ?></td>
72 <td><?= htmlspecialchars(znote_ban_remaining($ban['expires_at']), ENT_QUOTES, 'UTF-8') ?></td>
73 </tr>
74 <?php endforeach; ?>
75 </table>
76 </div>
77 <?php else: ?>
78 <div class="znx-empty-box"><?= t('bans.none') ?></div>
79 <?php endif; ?>
80
81 <div class="znx-acct-head"><?= t('bans.namelocks') ?></div>
82 <?php if ($nameLocks): ?>
83 <div class="znx-acct-table-wrap">
84 <table class="znx-acct-table">
85 <tr class="yellow">
86 <td><?= t('common.character') ?></td>
87 <td><?= t('common.reason') ?></td>
88 <td><?= t('bans.locked') ?></td>
89 </tr>
90 <?php foreach ($nameLocks as $lock): ?>
91 <tr>
92 <td>
93 <a href="characterprofile.php?name=<?= urlencode($lock['name']) ?>">
94 <?= htmlspecialchars($lock['name'], ENT_QUOTES, 'UTF-8') ?>
95 </a>
96 </td>
97 <td><?= htmlspecialchars($lock['reason'], ENT_QUOTES, 'UTF-8') ?></td>
98 <td><?= htmlspecialchars(getClock($lock['at'], true), ENT_QUOTES, 'UTF-8') ?></td>
99 </tr>
100 <?php endforeach; ?>
101 </table>
102 </div>
103 <?php else: ?>
104 <div class="znx-empty-box"><?= t('bans.no_namelocks') ?></div>
105 <?php endif; ?>
106
107<?php endif; ?>
108
109</div><!-- .znx-acct -->
110
Top