mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-27 17:00:52 +01:00
Added needed "board" column to modlogs (see commit comment for required SQL query)
This commit is contained in:
parent
c77e78cb9c
commit
959541d505
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
34
mod.php
34
mod.php
@ -128,9 +128,15 @@
|
||||
} elseif(preg_match('/^\/log$/', $query)) {
|
||||
if($mod['type'] < $config['mod']['modlog']) error($config['error']['noaccess']);
|
||||
|
||||
$body = '<table class="modlog"><tr><th>User</th><th>IP address</th><th>Ago</th><th>Action</th></tr>';
|
||||
$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 = '<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` 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 @@
|
||||
'<td class="minimal"><a href="?/users/' . $log['id'] . '">' . $log['username'] . '</a></td>' .
|
||||
'<td class="minimal"><a href="?/IP/' . $log['ip'] . '">' . $log['ip'] . '</a></td>' .
|
||||
'<td class="minimal">' . ago($log['time']) . '</td>' .
|
||||
'<td class="minimal">' .
|
||||
($log['board'] ?
|
||||
(isset($boards[$log['board']]) ?
|
||||
'<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>';
|
||||
}
|
||||
@ -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 = '<form action="" method="post"><table><th>From</th><td>' .
|
||||
($mod['type'] >= $config['mod']['editusers'] ?
|
||||
'<a href="?/users/' . $pm['sender'] . '">' . htmlentities($pm['username']) . '</a>' :
|
||||
@ -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!</p></div>';
|
||||
|
||||
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));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user