diff --git a/inc/mod.php b/inc/mod.php index 3d0c0d83..bce9e206 100644 --- a/inc/mod.php +++ b/inc/mod.php @@ -74,12 +74,16 @@ } function modLog($action) { - global $mod; - $query = prepare("INSERT INTO `modlogs` VALUES (:id, :ip, :time, :text)"); + global $mod, $board; + $query = prepare("INSERT INTO `modlogs` VALUES (:id, :ip, :board, :time, :text)"); $query->bindValue(':id', $mod['id'], PDO::PARAM_INT); $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); $query->bindValue(':time', time(), PDO::PARAM_INT); $query->bindValue(':text', $action); + if(isset($board)) + $query->bindValue(':board', $board['id']); + else + $query->bindValue(':board', null, PDO::PARAM_NULL); $query->execute() or error(db_error($query)); } diff --git a/install.sql b/install.sql index 8dae0201..6123bc6c 100644 --- a/install.sql +++ b/install.sql @@ -105,6 +105,7 @@ INSERT INTO `boards` (`id`, `uri`, `title`, `subtitle`) VALUES CREATE TABLE IF NOT EXISTS `modlogs` ( `mod` int(11) NOT NULL, `ip` varchar(45) NOT NULL, + `board` int(11) NOT NULL, `time` int(11) NOT NULL, `text` text NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/mod.php b/mod.php index 3db8ea6d..57a8cdcb 100644 --- a/mod.php +++ b/mod.php @@ -128,9 +128,15 @@ } elseif(preg_match('/^\/log$/', $query)) { if($mod['type'] < $config['mod']['modlog']) error($config['error']['noaccess']); - $body = ''; + $boards = Array(); + $_boards = listBoards(); + foreach($_boards as &$_b) { + $boards[$_b['id']] = $_b['uri']; + } - $query = prepare("SELECT `id`,`username`,`ip`,`time`,`text` FROM `modlogs` INNER JOIN `mods` ON `mod` = `id` ORDER BY `time` DESC LIMIT :limit"); + $body = '
UserIP addressAgoAction
'; + + $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->execute() or error(db_error($query)); @@ -143,6 +149,12 @@ '' . '' . '' . + '' + : 'deleted?') + : '-') . '' . ''; } @@ -173,12 +185,17 @@ $query = prepare("DELETE FROM `pms` WHERE `id` = :id"); $query->bindValue(':id', $id, PDO::PARAM_INT); $query->execute() or error(db_error($query)); + + modLog('Deleted a PM'); + header('Location: ?/', true, $config['redirect_http']); } else { $query = prepare("UPDATE `pms` SET `unread` = 0 WHERE `id` = :id"); $query->bindValue(':id', $id, PDO::PARAM_INT); $query->execute() or error(db_error($query)); + modLog('Read a PM'); + $body = '
UserIP addressAgoBoardAction
' . $log['username'] . '' . $log['ip'] . '' . ago($log['time']) . '' . + ($log['board'] ? + (isset($boards[$log['board']]) ? + '' . sprintf($config['board_abbreviation'], $boards[$log['board']]) . '' . $log['text'] . '
From' . ($mod['type'] >= $config['mod']['editusers'] ? '' . htmlentities($pm['username']) . '' : @@ -234,6 +251,8 @@ $query->bindValue(':time', time(), PDO::PARAM_INT); $query->execute() or error(db_error($query)); + modLog('Sent a PM to ' . $to['username']); + echo Element('page.html', Array( 'config'=>$config, 'title'=>'PM sent', @@ -399,6 +418,8 @@ $query = prepare("DELETE FROM `mods` WHERE `id` = :id"); $query->bindValue(':id', $modID, PDO::PARAM_INT); $query->execute() or error(db_error($query)); + + modLog('Deleted user #' . $modID); } else { // Promote/demote if($mod['type'] < $config['mod']['promoteusers']) error($config['error']['noaccess']); @@ -436,6 +457,9 @@ $query->bindValue(':username', $_POST['username']); $query->bindValue(':id', $modID, PDO::PARAM_INT); $query->execute() or error(db_error($query)); + modLog('Edited login details for user "' . $_mod['username'] . '"'); + } else { + modLog('Changed own password'); } if(!empty($_POST['password'])) { $query = prepare("UPDATE `mods` SET `password` = :password WHERE `id` = :id"); @@ -602,6 +626,8 @@ if($mod['type'] < $config['mod']['deleteboard']) error($config['error']['noaccess']); // Delete board + modLog('Deleted board ' . sprintf($config['board_abbreviation'], $board['uri'])); + // Delete entire board directory rrmdir($board['uri'] . '/'); @@ -800,6 +826,8 @@ } $body .= 'Complete!

'; + modLog('Rebuilt everything'); + echo Element('page.html', Array( 'config'=>$config, 'title'=>'Rebuilt', @@ -1191,7 +1219,7 @@ } // Record the action - modLog("Created a ban for {$_POST['ip']} with reason {$_POST['reason']}"); + modLog('Created a ' . ($expire ? $expire . ' second' : 'permanent') . " ban for {$_POST['ip']} with " . (!empty($_POST['reason']) ? "reason \"{$_POST['reason']}\"" : 'no reason')); $query->execute() or error(db_error($query));