From d970baa5d87e446904ca66be999f8feba553a7a2 Mon Sep 17 00:00:00 2001 From: 8chan Date: Wed, 25 Feb 2015 17:21:49 -0800 Subject: [PATCH] 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. --- boards.php | 1 - create.php | 1 - inc/8chan-mod-pages.php | 3 ++- inc/functions.php | 8 ++++++-- inc/mod/auth.php | 2 +- inc/mod/pages.php | 6 +++--- install.sql | 1 + log.php | 24 ++++++++++++++++++++++++ mod.php | 1 - post.php | 6 ++++-- templates/mod/log.html | 16 ++++++++++++---- templates/mod/settings.html | 3 ++- tools/inc/cli.php | 1 - 13 files changed, 55 insertions(+), 18 deletions(-) create mode 100644 log.php diff --git a/boards.php b/boards.php index fb90c771..86eb69fd 100644 --- a/boards.php +++ b/boards.php @@ -1,7 +1,6 @@ bindValue(':title', $title); $query->bindValue(':subtitle', $subtitle); $query->bindValue(':uri', $b); $query->bindValue(':indexed', !isset($_POST['meta_noindex'])); $query->bindValue(':public_bans', isset($_POST['public_bans'])); + $query->bindValue(':public_logs', (int)$_POST['public_logs']); $query->bindValue(':8archive', isset($_POST['8archive'])); $query->execute() or error(db_error($query)); diff --git a/inc/functions.php b/inc/functions.php index 44666b83..2470a4a6 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -20,6 +20,7 @@ require_once 'inc/events.php'; require_once 'inc/api.php'; require_once 'inc/bans.php'; require_once 'inc/lib/gettext/gettext.inc'; +require_once 'inc/mod/auth.php'; // the user is not currently logged in as a moderator $mod = false; @@ -433,7 +434,8 @@ function setupBoard($array) { 'uri' => $array['uri'], 'title' => $array['title'], 'subtitle' => $array['subtitle'], - 'indexed' => $array['indexed'] + 'indexed' => $array['indexed'], + 'public_logs' => $array['public_logs'] ); // older versions @@ -1152,7 +1154,7 @@ function deletePost($id, $error_if_doesnt_exist=true, $rebuild_after=true) { return true; } -function clean() { +function clean($pid = false) { global $board, $config; $offset = round($config['max_pages']*$config['threads_per_page']); @@ -1163,6 +1165,7 @@ function clean() { while ($post = $query->fetch(PDO::FETCH_ASSOC)) { deletePost($post['id'], false, false); + if ($pid) modLog("Automatically deleting thread #{$post['id']} due to new thread #{$pid}"); } // Bump off threads with X replies earlier, spam prevention method @@ -1175,6 +1178,7 @@ function clean() { while ($post = $query->fetch(PDO::FETCH_ASSOC)) { if ($post['reply_count'] < $config['early_404_replies']) { deletePost($post['thread_id'], false, false); + if ($pid) modLog("Automatically deleting thread #{$post['thread_id']} due to new thread #{$pid} (early 404 is set, #{$post['thread_id']} had {$post['reply_count']} replies)"); } } } diff --git a/inc/mod/auth.php b/inc/mod/auth.php index 0ee7acb9..196690f4 100644 --- a/inc/mod/auth.php +++ b/inc/mod/auth.php @@ -81,7 +81,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 44c69695..8deddbae 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -669,13 +669,13 @@ function mod_user_log($username, $page_no = 1) { mod_page(_('Board log'), 'mod/log.html', array('logs' => $logs, 'count' => $count, 'username' => $username)); } -function mod_board_log($board, $page_no = 1) { +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)) + 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"); @@ -702,7 +702,7 @@ function mod_board_log($board, $page_no = 1) { $query->execute() or error(db_error($query)); $count = $query->fetchColumn(); - mod_page(_('Board log'), 'mod/log.html', array('logs' => $logs, 'count' => $count, 'board' => $board)); + 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) { diff --git a/install.sql b/install.sql index e76dbe00..da1a276b 100644 --- a/install.sql +++ b/install.sql @@ -67,6 +67,7 @@ CREATE TABLE IF NOT EXISTS `boards` ( `subtitle` tinytext, `indexed` boolean default true, `public_bans` boolean default true, + `public_logs` tinyint(1) default 0, `8archive` boolean default false, `sfw` boolean default false, PRIMARY KEY (`uri`) diff --git a/log.php b/log.php new file mode 100644 index 00000000..6f003914 --- /dev/null +++ b/log.php @@ -0,0 +1,24 @@ + &$file) { if (!in_array($file['extension'], $config['allowed_ext']) && !in_array($file['extension'], $config['allowed_ext_files'])) error($config['error']['unknownext']); @@ -883,7 +885,7 @@ elseif (isset($_POST['post'])) { $build_pages = range(1, $config['max_pages']); if ($post['op']) - clean(); + clean($pid); event('post-after', $post); diff --git a/templates/mod/log.html b/templates/mod/log.html index 5a306833..0ec81afd 100644 --- a/templates/mod/log.html +++ b/templates/mod/log.html @@ -10,10 +10,14 @@ {% if log.username %} - {% if not mod|hasPermission(config.mod.modlog) %} - {{ log.username|e }} + {% if hide_names %} + hidden {% else %} - {{ log.username|e }} + {% if not mod|hasPermission(config.mod.modlog) %} + {{ log.username|e }} + {% else %} + {{ log.username|e }} + {% endif %} {% endif %} {% elseif log.mod == -1 %} system @@ -48,7 +52,11 @@ {% if count > logs|count %}

{% for i in range(0, (count - 1) / config.mod.modlog_page) %} - [{{ i + 1 }}] + {% if public %} + [{{ i + 1 }}] + {% else %} + [{{ i + 1 }}] + {% endif %} {% endfor %}

{% endif %} diff --git a/templates/mod/settings.html b/templates/mod/settings.html index 4d4b5b28..9427cd9e 100644 --- a/templates/mod/settings.html +++ b/templates/mod/settings.html @@ -36,7 +36,6 @@ {% trans %}Automatically convert ... to …{% endtrans %} {% trans %}No index{% endtrans %}
{% trans %}Hide from boards index
and do not index in search engines{% endtrans %}
{% trans %}Archive my board on 8archive.moe{% endtrans %}
{% trans %}This archives your board on 8archive.moe if you opt in{% endtrans %} - {% trans %}Public bans{% endtrans %}
{% trans %}Displays your bans for the public{% endtrans %} {% trans %}[code] tags{% endtrans %} {% trans %}Oekaki{% endtrans %} {% trans %}Format math between [tex]{% endtrans %} @@ -48,6 +47,8 @@ {% trans %}Allow posters to post via the Tor onion router{% endtrans %}
Disabling this is evil, but if you really care about "ban evasion", here you go. {% trans %}Enable CAPTCHA{% endtrans %}
Users must solve a CAPTCHA in order to post.
This is not ReCAPTCHA, it is custom to 8chan.
{% trans %}Enable CAPTCHA for thread creation only{% endtrans %}
Users must solve a CAPTCHA in order to create new threads,
but do not have to solve a CAPTCHA in order to post replies.
+ {% trans %}Public bans{% endtrans %}
{% trans %}Displays your bans for the public{% endtrans %} + {% trans %}Public action log{% endtrans %}
{% trans %}Displays all actions to the public{% endtrans %} diff --git a/tools/inc/cli.php b/tools/inc/cli.php index f3e8824f..95d51573 100644 --- a/tools/inc/cli.php +++ b/tools/inc/cli.php @@ -39,7 +39,6 @@ if(!getenv('TINYBOARD_PATH')) { putenv('TINYBOARD_PATH=' . getcwd()); require 'inc/functions.php'; -require 'inc/mod/auth.php'; $mod = Array( 'id' => -1,