paginate modlog
This commit is contained in:
parent
c7d72306ed
commit
9969e37105
69
mod.php
69
mod.php
@ -268,41 +268,68 @@
|
|||||||
'mod'=>true
|
'mod'=>true
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} elseif(preg_match('/^\/log$/', $query)) {
|
} elseif(preg_match('/^\/log(\/(\d+))?$/', $query, $match)) {
|
||||||
if(!hasPermission($config['mod']['modlog'])) error($config['error']['noaccess']);
|
if(!hasPermission($config['mod']['modlog'])) error($config['error']['noaccess']);
|
||||||
|
|
||||||
|
$page = isset($match[2]) ? $match[2] : 1;
|
||||||
|
|
||||||
$boards = Array();
|
$boards = Array();
|
||||||
$_boards = listBoards();
|
$_boards = listBoards();
|
||||||
foreach($_boards as &$_b) {
|
foreach($_boards as &$_b) {
|
||||||
$boards[$_b['id']] = $_b['uri'];
|
$boards[$_b['id']] = $_b['uri'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$body = '<table class="modlog"><tr><th>' . _('User') . '</th><th>' . _('IP address') . '</th><th>' . _('Ago') . '</th><th>' . _('Board') . '</th><th>' . _('Action') . '</th></tr>';
|
$query = prepare("SELECT `mods`.`id`,`username`,`ip`,`board`,`time`,`text` FROM `modlogs` LEFT JOIN `mods` ON `mod` = `mods`.`id` ORDER BY `time` DESC LIMIT :offset, :limit");
|
||||||
|
|
||||||
$query = prepare("SELECT `mods`.`id`,`username`,`ip`,`board`,`time`,`text` FROM `modlogs` INNER JOIN `mods` ON `mod` = `mods`.`id` ORDER BY `time` DESC LIMIT :limit");
|
|
||||||
$query->bindValue(':limit', $config['mod']['modlog_page'], PDO::PARAM_INT);
|
$query->bindValue(':limit', $config['mod']['modlog_page'], PDO::PARAM_INT);
|
||||||
|
$query->bindValue(':offset', ($page - 1) * $config['mod']['modlog_page'], PDO::PARAM_INT);
|
||||||
$query->execute() or error(db_error($query));
|
$query->execute() or error(db_error($query));
|
||||||
|
|
||||||
while($log = $query->fetch()) {
|
if(!$query->rowCount()) {
|
||||||
$log['text'] = utf8tohtml($log['text']);
|
$body = '<p class="unimportant" style="text-align:center">(Nothing to display.)</p>';
|
||||||
$log['text'] = preg_replace('/(\d+\.\d+\.\d+\.\d+)/', '<a href="?/IP/$1">$1</a>', $log['text']);
|
} else {
|
||||||
|
$body = '<table class="modlog">' .
|
||||||
|
'<tr>' .
|
||||||
|
'<th>' . _('User') . '</th>' .
|
||||||
|
'<th>' . _('IP address') . '</th>' .
|
||||||
|
'<th>' . _('Ago') . '</th>' .
|
||||||
|
'<th>' . _('Board') . '</th>' .
|
||||||
|
'<th>' . _('Action') . '</th>' .
|
||||||
|
'</tr>';
|
||||||
|
while($log = $query->fetch()) {
|
||||||
|
$log['text'] = utf8tohtml($log['text']);
|
||||||
|
$log['text'] = preg_replace('/(\d+\.\d+\.\d+\.\d+)/', '<a href="?/IP/$1">$1</a>', $log['text']);
|
||||||
|
|
||||||
$body .= '<tr>' .
|
$body .= '<tr>' .
|
||||||
'<td class="minimal"><a href="?/users/' . $log['id'] . '">' . $log['username'] . '</a></td>' .
|
'<td class="minimal">' .
|
||||||
'<td class="minimal"><a href="?/IP/' . $log['ip'] . '">' . $log['ip'] . '</a></td>' .
|
($log['username'] ?
|
||||||
'<td class="minimal">' . ago($log['time']) . '</td>' .
|
'<a href="?/new_PM/' . $log['id'] . '">' . $log['username'] . '</a>'
|
||||||
'<td class="minimal">' .
|
: '<em>deleted?</em>') .
|
||||||
($log['board'] ?
|
'</td>' .
|
||||||
(isset($boards[$log['board']]) ?
|
'<td class="minimal"><a href="?/IP/' . $log['ip'] . '">' . $log['ip'] . '</a></td>' .
|
||||||
'<a href="?/' . $boards[$log['board']] . '/' . $config['file_index'] . '">' . sprintf($config['board_abbreviation'], $boards[$log['board']]) . '</a></td>'
|
'<td class="minimal">' . ago($log['time']) . '</td>' .
|
||||||
: '<em>deleted?</em>')
|
'<td class="minimal">' .
|
||||||
: '-') .
|
($log['board'] ?
|
||||||
'<td>' . $log['text'] . '</td>' .
|
(isset($boards[$log['board']]) ?
|
||||||
'</tr>';
|
'<a href="?/' . $boards[$log['board']] . '/' . $config['file_index'] . '">' . sprintf($config['board_abbreviation'], $boards[$log['board']]) . '</a></td>'
|
||||||
|
: '<em>deleted?</em>')
|
||||||
|
: '-') .
|
||||||
|
'<td>' . $log['text'] . '</td>' .
|
||||||
|
'</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$body .= '</table>';
|
||||||
|
|
||||||
|
$query = prepare("SELECT COUNT(*) AS `count` FROM `modlogs`");
|
||||||
|
$query->execute() or error(db_error($query));
|
||||||
|
$count = $query->fetch();
|
||||||
|
|
||||||
|
$body .= '<p class="unimportant" style="text-align:center;word-wrap:break-word">';
|
||||||
|
for($x = 0; $x < $count['count'] / $config['mod']['modlog_page']; $x ++) {
|
||||||
|
$body .= '<a href="?/log/' . ($x+1) . '">[' . ($x + 1) . ']</a> ';
|
||||||
|
}
|
||||||
|
$body .= '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$body .= '</table>';
|
|
||||||
|
|
||||||
echo Element('page.html', Array(
|
echo Element('page.html', Array(
|
||||||
'config'=>$config,
|
'config'=>$config,
|
||||||
'title'=>_('Moderation log'),
|
'title'=>_('Moderation log'),
|
||||||
|
Loading…
Reference in New Issue
Block a user