summaryrefslogtreecommitdiff
path: root/inc/mod
diff options
context:
space:
mode:
author8chan <admin@8chan.co>2015-02-25 17:21:49 -0800
committerczaks <marcin@6irc.net>2016-05-06 15:44:26 +0200
commit7911c374e86ef8fa69c4545867b9d9d3de12d5c6 (patch)
tree217ac7d32eff8acfaa6b08991dc792750edcedc3 /inc/mod
parent6dd1420f91410531bb2dac506f821d959bf74d0a (diff)
Public action logs commit (log.php)
Note: In a previous commit, I began making inc/mod/auth.php more modular with the check_login() function. Including it does NOT check mod login by default anymore like it does on vichan. You have to call check_login(). I've finally included it in inc/functions.php. If you have any custom pages that use inc/mod/auth.php, just including functions.php is enough now. =================================== Also: backports 351375185e5 (early 404)
Diffstat (limited to 'inc/mod')
-rw-r--r--inc/mod/auth.php2
-rw-r--r--inc/mod/pages.php36
2 files changed, 37 insertions, 1 deletions
diff --git a/inc/mod/auth.php b/inc/mod/auth.php
index 009e93ad..42f34196 100644
--- a/inc/mod/auth.php
+++ b/inc/mod/auth.php
@@ -130,7 +130,7 @@ function destroyCookies() {
function modLog($action, $_board=null) {
global $mod, $board, $config;
$query = prepare("INSERT INTO ``modlogs`` VALUES (:id, :ip, :board, :time, :text)");
- $query->bindValue(':id', $mod['id'], PDO::PARAM_INT);
+ $query->bindValue(':id', (isset($mod['id']) ? $mod['id'] : -1), PDO::PARAM_INT);
$query->bindValue(':ip', $_SERVER['REMOTE_ADDR']);
$query->bindValue(':time', time(), PDO::PARAM_INT);
$query->bindValue(':text', $action);
diff --git a/inc/mod/pages.php b/inc/mod/pages.php
index a90fbbd6..ca12eaf1 100644
--- a/inc/mod/pages.php
+++ b/inc/mod/pages.php
@@ -698,6 +698,42 @@ function mod_user_log($username, $page_no = 1) {
mod_page(_('Moderation log'), 'mod/log.html', array('logs' => $logs, 'count' => $count, 'username' => $username));
}
+function mod_board_log($board, $page_no = 1, $hide_names = false, $public = false) {
+ global $config;
+
+ if ($page_no < 1)
+ error($config['error']['404']);
+
+ if (!hasPermission($config['mod']['mod_board_log'], $board) && !$public)
+ error($config['error']['noaccess']);
+
+ $query = prepare("SELECT `username`, `mod`, `ip`, `board`, `time`, `text` FROM ``modlogs`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE `board` = :board ORDER BY `time` DESC LIMIT :offset, :limit");
+ $query->bindValue(':board', $board);
+ $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));
+ $logs = $query->fetchAll(PDO::FETCH_ASSOC);
+
+ if (empty($logs) && $page_no > 1)
+ error($config['error']['404']);
+
+ if (!hasPermission($config['mod']['show_ip'])) {
+ // Supports ipv4 only!
+ foreach ($logs as $i => &$log) {
+ $log['text'] = preg_replace_callback('/(?:<a href="\?\/IP\/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}">)?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})(?:<\/a>)?/', function($matches) {
+ return "xxxx";//less_ip($matches[1]);
+ }, $log['text']);
+ }
+ }
+
+ $query = prepare("SELECT COUNT(*) FROM ``modlogs`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE `board` = :board");
+ $query->bindValue(':board', $board);
+ $query->execute() or error(db_error($query));
+ $count = $query->fetchColumn();
+
+ mod_page(_('Board log'), 'mod/log.html', array('logs' => $logs, 'count' => $count, 'board' => $board, 'hide_names' => $hide_names, 'public' => $public));
+}
+
function mod_view_board($boardName, $page_no = 1) {
global $config, $mod;