diff --git a/inc/config.php b/inc/config.php
index 03df743d..d56e4344 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -235,6 +235,8 @@
$config['mod']['ip_recentposts'] = 5;
// How many posts to display on the reports page
$config['mod']['recent_reports'] = 5;
+ // How many actions to show per page in the moderation log
+ $config['mod']['modlog_page'] = 350;
// Probably best not to change these:
if(!defined('JANITOR')) {
@@ -310,6 +312,8 @@
$config['mod']['deleteusers'] = ADMIN;
// Create a user
$config['mod']['createusers'] = ADMIN;
+ // View the moderation log
+ $config['mod']['modlog'] = ADMIN;
// Mod links (full HTML)
// Correspond to above permission directives
diff --git a/mod.php b/mod.php
index 13879292..34b36ad8 100644
--- a/mod.php
+++ b/mod.php
@@ -90,9 +90,12 @@
if($mod['type'] >= $config['mod']['view_banlist']) {
$fieldset['Administration'] .= '
Ban list';
}
- if($mod['type'] >= $config['mod']['manageusers']) {
+ if($mod['type'] >= $config['mod']['manageusers']) {
$fieldset['Administration'] .= 'Manage users';
}
+ if($mod['type'] >= $config['mod']['modlog']) {
+ $fieldset['Administration'] .= 'Moderation log';
+ }
if($mod['type'] >= $config['mod']['show_config']) {
$fieldset['Administration'] .= 'Show configuration';
}
@@ -112,7 +115,40 @@
//,'mod'=>true /* All 'mod' does, at this point, is put the "Return to dashboard" link in. */
)
);
+ } elseif(preg_match('/^\/log$/', $query)) {
+ if($mod['type'] < $config['mod']['modlog']) error($config['error']['noaccess']);
+
+ $body = 'User | IP address | Ago | Action |
';
+
+ $query = prepare("SELECT `id`,`username`,`ip`,`time`,`text` FROM `modlogs` INNER JOIN `mods` ON `mod` = `id` ORDER BY `time` DESC LIMIT :limit");
+ $query->bindValue(':limit', $config['mod']['modlog_page'], PDO::PARAM_INT);
+ $query->execute() or error(db_error($query));
+
+ while($log = $query->fetch()) {
+ $log['text'] = htmlentities($log['text']);
+ $log['text'] = preg_replace('/(\d+\.\d+\.\d+\.\d+)/', '$1', $log['text']);
+
+
+ $body .= '' .
+ '' . $log['username'] . ' | ' .
+ '' . $log['ip'] . ' | ' .
+ '' . ago($log['time']) . ' | ' .
+ '' . $log['text'] . ' | ' .
+ '
';
+ }
+
+ $body .= '
';
+
+ echo Element('page.html', Array(
+ 'index'=>$config['root'],
+ 'title'=>'Moderation log',
+ 'body'=>$body,
+ 'mod'=>true
+ )
+ );
} elseif(preg_match('/^\/users$/', $query)) {
+ if($mod['type'] < $config['mod']['manageusers']) error($config['error']['noaccess']);
+
$body = '