paginate ban list
This commit is contained in:
parent
7101fa540b
commit
f0412b0814
@ -826,6 +826,8 @@
|
|||||||
|
|
||||||
// How many actions to show per page in the moderation log
|
// How many actions to show per page in the moderation log
|
||||||
$config['mod']['modlog_page'] = 350;
|
$config['mod']['modlog_page'] = 350;
|
||||||
|
// How many bans to show per page in the ban list
|
||||||
|
$config['mod']['banlist_page'] = 350;
|
||||||
|
|
||||||
// Maximum number of results to display for a search, per board
|
// Maximum number of results to display for a search, per board
|
||||||
$config['mod']['search_results'] = 75;
|
$config['mod']['search_results'] = 75;
|
||||||
|
@ -246,7 +246,7 @@ function mod_ban() {
|
|||||||
header('Location: ?/', true, $config['redirect_http']);
|
header('Location: ?/', true, $config['redirect_http']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function mod_bans() {
|
function mod_bans($page_no = 1) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (!hasPermission($config['mod']['view_banlist']))
|
if (!hasPermission($config['mod']['view_banlist']))
|
||||||
@ -272,23 +272,27 @@ function mod_bans() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($config['mod']['view_banexpired']) {
|
if ($config['mod']['view_banexpired']) {
|
||||||
$query = prepare("SELECT `bans`.*, `username` FROM `bans` LEFT JOIN `mods` ON `mod` = `mods`.`id` ORDER BY (`expires` IS NOT NULL AND `expires` < :time), `set` DESC");
|
$query = prepare("SELECT `bans`.*, `username` FROM `bans` LEFT JOIN `mods` ON `mod` = `mods`.`id` ORDER BY (`expires` IS NOT NULL AND `expires` < :time), `set` DESC LIMIT :offset, :limit");
|
||||||
$query->bindValue(':time', time(), PDO::PARAM_INT);
|
|
||||||
$query->execute() or error(db_error($query));
|
|
||||||
} else {
|
} else {
|
||||||
// Filter out expired bans
|
// Filter out expired bans
|
||||||
$query = prepare("SELECT `bans`.*, `username` FROM `bans` INNER JOIN `mods` ON `mod` = `mods`.`id` WHERE `expires` = 0 OR `expires` > :time ORDER BY `set` DESC");
|
$query = prepare("SELECT `bans`.*, `username` FROM `bans` INNER JOIN `mods` ON `mod` = `mods`.`id` WHERE `expires` = 0 OR `expires` > :time ORDER BY `set` DESC LIMIT :offset, :limit");
|
||||||
$query->bindValue(':time', time(), PDO::PARAM_INT);
|
|
||||||
$query->execute() or error(db_error($query));
|
|
||||||
}
|
}
|
||||||
|
$query->bindValue(':time', time(), PDO::PARAM_INT);
|
||||||
|
$query->bindValue(':limit', $config['mod']['modlog_page'], PDO::PARAM_INT);
|
||||||
|
$query->bindValue(':offset', ($page_no - 1) * $config['mod']['modlog_page'], PDO::PARAM_INT);
|
||||||
|
$query->execute() or error(db_error($query));
|
||||||
$bans = $query->fetchAll(PDO::FETCH_ASSOC);
|
$bans = $query->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
|
$query = prepare("SELECT COUNT(*) FROM `bans`");
|
||||||
|
$query->execute() or error(db_error($query));
|
||||||
|
$count = $query->fetchColumn(0);
|
||||||
|
|
||||||
foreach ($bans as &$ban) {
|
foreach ($bans as &$ban) {
|
||||||
if (filter_var($ban['ip'], FILTER_VALIDATE_IP) !== false)
|
if (filter_var($ban['ip'], FILTER_VALIDATE_IP) !== false)
|
||||||
$ban['real_ip'] = true;
|
$ban['real_ip'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
mod_page('Ban list', 'mod/ban_list.html', array('bans' => $bans));
|
mod_page('Ban list', 'mod/ban_list.html', array('bans' => $bans, 'count' => $count));
|
||||||
}
|
}
|
||||||
|
|
||||||
function mod_delete($board, $post) {
|
function mod_delete($board, $post) {
|
||||||
|
1
mod.php
1
mod.php
@ -40,6 +40,7 @@ $pages = array(
|
|||||||
'!^/IP/([\w.:]+)$!' => 'ip', // view ip address
|
'!^/IP/([\w.:]+)$!' => 'ip', // view ip address
|
||||||
'!^/IP/([\w.:]+)/remove_note/(\d+)$!' => 'ip_remove_note', // remove note from ip address
|
'!^/IP/([\w.:]+)/remove_note/(\d+)$!' => 'ip_remove_note', // remove note from ip address
|
||||||
'!^/bans$!' => 'bans', // ban list
|
'!^/bans$!' => 'bans', // ban list
|
||||||
|
'!^/bans/(\d+)$!' => 'bans', // ban list
|
||||||
|
|
||||||
'!^/(\w+)/delete/(\d+)$!' => 'delete', // delete post
|
'!^/(\w+)/delete/(\d+)$!' => 'delete', // delete post
|
||||||
|
|
||||||
|
@ -72,3 +72,12 @@
|
|||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if count > bans|count %}
|
||||||
|
<p class="unimportant" style="text-align:center;word-wrap:break-word">
|
||||||
|
{% for i in range(0, count / config.mod.modlog_page) %}
|
||||||
|
<a href="?/bans/{{ i + 1 }}">[{{ i + 1 }}]</a>
|
||||||
|
{% endfor %}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user