Add TINYIB_AUTOHIDE
This commit is contained in:
parent
fbea1d4140
commit
cff26e609d
9 changed files with 44 additions and 10 deletions
|
@ -506,6 +506,7 @@ if (!isset($_GET['delete']) && !isset($_GET['manage']) && (isset($_POST['name'])
|
|||
if ($report_post) {
|
||||
$report = array('ip' => $post['ip'], 'post' => $post['id']);
|
||||
insertReport($report);
|
||||
checkAutoHide($post);
|
||||
}
|
||||
|
||||
if ($post['moderated'] == '1') {
|
||||
|
@ -638,6 +639,7 @@ EOF;
|
|||
|
||||
$report = array('ip' => remoteAddress(), 'post' => $post['id']);
|
||||
insertReport($report);
|
||||
checkAutoHide($post);
|
||||
|
||||
fancyDie(__('Post reported.'), $go_back);
|
||||
// Check if the request is to delete a post and/or its associated image
|
||||
|
|
|
@ -360,7 +360,15 @@ function postsInThreadByID($id, $moderated_only = true) {
|
|||
$compClause->add(new SimpleWhereClause(POST_ID, '=', $id, INTEGER_COMPARISON));
|
||||
$compClause->add(new SimpleWhereClause(POST_PARENT, '=', $id, INTEGER_COMPARISON));
|
||||
|
||||
$rows = $GLOBALS['db']->selectWhere(POSTS_FILE, $compClause, -1, new OrderBy(POST_ID, ASCENDING, INTEGER_COMPARISON));
|
||||
if ($moderated_only) {
|
||||
$compClause2 = new AndWhereClause();
|
||||
$compClause2->add($compClause);
|
||||
$compClause2->add(new SimpleWhereClause(POST_MODERATED, '>', 0, INTEGER_COMPARISON));
|
||||
} else {
|
||||
$compClause2 = $compClause;
|
||||
}
|
||||
|
||||
$rows = $GLOBALS['db']->selectWhere(POSTS_FILE, $compClause2, -1, new OrderBy(POST_ID, ASCENDING, INTEGER_COMPARISON));
|
||||
return convertPostsToSQLStyle($rows);
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@ function postByID($id) {
|
|||
}
|
||||
|
||||
function threadExistsByID($id) {
|
||||
$result = pdoQuery("SELECT COUNT(*) FROM " . TINYIB_DBPOSTS . " WHERE id = ? AND parent = 0 AND moderated = 1", array($id));
|
||||
$result = pdoQuery("SELECT COUNT(*) FROM " . TINYIB_DBPOSTS . " WHERE id = ? AND parent = 0 AND moderated > 0", array($id));
|
||||
return $result->fetchColumn() != 0;
|
||||
}
|
||||
|
||||
|
@ -177,13 +177,13 @@ function lockThreadByID($id, $setlock) {
|
|||
}
|
||||
|
||||
function countThreads() {
|
||||
$result = pdoQuery("SELECT COUNT(*) FROM " . TINYIB_DBPOSTS . " WHERE parent = 0 AND moderated = 1");
|
||||
$result = pdoQuery("SELECT COUNT(*) FROM " . TINYIB_DBPOSTS . " WHERE parent = 0 AND moderated > 0");
|
||||
return (int)$result->fetchColumn();
|
||||
}
|
||||
|
||||
function allThreads() {
|
||||
$threads = array();
|
||||
$results = pdoQuery("SELECT * FROM " . TINYIB_DBPOSTS . " WHERE parent = 0 AND moderated = 1 ORDER BY stickied DESC, bumped DESC");
|
||||
$results = pdoQuery("SELECT * FROM " . TINYIB_DBPOSTS . " WHERE parent = 0 AND moderated > 0 ORDER BY stickied DESC, bumped DESC");
|
||||
while ($row = $results->fetch()) {
|
||||
$threads[] = $row;
|
||||
}
|
||||
|
@ -191,13 +191,13 @@ function allThreads() {
|
|||
}
|
||||
|
||||
function numRepliesToThreadByID($id) {
|
||||
$result = pdoQuery("SELECT COUNT(*) FROM " . TINYIB_DBPOSTS . " WHERE parent = ? AND moderated = 1", array($id));
|
||||
$result = pdoQuery("SELECT COUNT(*) FROM " . TINYIB_DBPOSTS . " WHERE parent = ? AND moderated > 0", array($id));
|
||||
return (int)$result->fetchColumn();
|
||||
}
|
||||
|
||||
function postsInThreadByID($id, $moderated_only = true) {
|
||||
$posts = array();
|
||||
$results = pdoQuery("SELECT * FROM " . TINYIB_DBPOSTS . " WHERE (id = ? OR parent = ?)" . ($moderated_only ? " AND moderated = 1" : "") . " ORDER BY id ASC", array($id, $id));
|
||||
$results = pdoQuery("SELECT * FROM " . TINYIB_DBPOSTS . " WHERE (id = ? OR parent = ?)" . ($moderated_only ? " AND moderated > 0" : "") . " ORDER BY id ASC", array($id, $id));
|
||||
while ($row = $results->fetch(PDO::FETCH_ASSOC)) {
|
||||
$posts[] = $row;
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ function imagesInThreadByID($id, $moderated_only = true) {
|
|||
|
||||
function postsByHex($hex) {
|
||||
$posts = array();
|
||||
$results = pdoQuery("SELECT * FROM " . TINYIB_DBPOSTS . " WHERE file_hex = ? AND moderated = 1 LIMIT 1", array($hex));
|
||||
$results = pdoQuery("SELECT * FROM " . TINYIB_DBPOSTS . " WHERE file_hex = ? AND moderated > 0 LIMIT 1", array($hex));
|
||||
while ($row = $results->fetch(PDO::FETCH_ASSOC)) {
|
||||
$posts[] = $row;
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ function deletePostByID($id) {
|
|||
function trimThreads() {
|
||||
$limit = (int)TINYIB_MAXTHREADS;
|
||||
if ($limit > 0) {
|
||||
$results = pdoQuery("SELECT id FROM " . TINYIB_DBPOSTS . " WHERE parent = 0 AND moderated = 1 ORDER BY stickied DESC, bumped DESC LIMIT 100 OFFSET " . $limit);
|
||||
$results = pdoQuery("SELECT id FROM " . TINYIB_DBPOSTS . " WHERE parent = 0 AND moderated > 0 ORDER BY stickied DESC, bumped DESC LIMIT 100 OFFSET " . $limit);
|
||||
/*
|
||||
old mysql, sqlite3: SELECT id FROM $table ORDER BY bumped LIMIT $limit,100
|
||||
mysql, postgresql, sqlite3: SELECT id FROM $table ORDER BY bumped LIMIT 100 OFFSET $limit
|
||||
|
|
|
@ -186,7 +186,7 @@ function numRepliesToThreadByID($id) {
|
|||
|
||||
function postsInThreadByID($id, $moderated_only = true) {
|
||||
$posts = array();
|
||||
$result = sqlite_fetch_all(sqlite_query($GLOBALS["db"], "SELECT * FROM " . TINYIB_DBPOSTS . " WHERE id = " . $id . " OR parent = " . $id . " ORDER BY id ASC"), SQLITE_ASSOC);
|
||||
$result = sqlite_fetch_all(sqlite_query($GLOBALS["db"], "SELECT * FROM " . TINYIB_DBPOSTS . " WHERE (id = " . $id . " OR parent = " . $id . ")" . ($moderated_only ? " AND moderated > 0" : "") . " ORDER BY id ASC"), SQLITE_ASSOC);
|
||||
foreach ($result as $post) {
|
||||
$posts[] = $post;
|
||||
}
|
||||
|
|
|
@ -218,7 +218,7 @@ function numRepliesToThreadByID($id) {
|
|||
function postsInThreadByID($id, $moderated_only = true) {
|
||||
global $db;
|
||||
$posts = array();
|
||||
$result = $db->query("SELECT * FROM " . TINYIB_DBPOSTS . " WHERE id = " . $id . " OR parent = " . $id . " ORDER BY id ASC");
|
||||
$result = $db->query("SELECT * FROM " . TINYIB_DBPOSTS . " WHERE (id = " . $id . " OR parent = " . $id . ")" . ($moderated_only ? " AND moderated > 0" : "") . " ORDER BY id ASC");
|
||||
while ($post = $result->fetchArray()) {
|
||||
$posts[] = $post;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,9 @@ if (!defined('TINYIB_MANAGECAPTCHA')) {
|
|||
if (!defined('TINYIB_REPORT')) {
|
||||
define('TINYIB_REPORT', false);
|
||||
}
|
||||
if (!defined('TINYIB_AUTOHIDE')) {
|
||||
define('TINYIB_AUTOHIDE', 0);
|
||||
}
|
||||
if (!defined('TINYIB_REQMOD')) {
|
||||
define('TINYIB_REQMOD', '');
|
||||
}
|
||||
|
|
|
@ -345,6 +345,20 @@ function checkMessageSize() {
|
|||
}
|
||||
}
|
||||
|
||||
function checkAutoHide($post) {
|
||||
if (TINYIB_AUTOHIDE <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$reports = reportsByPost($post['id']);
|
||||
if (count($reports) >= TINYIB_AUTOHIDE) {
|
||||
approvePostByID($post['id'], 0);
|
||||
|
||||
$parent_id = $post['parent'] == TINYIB_NEWTHREAD ? $post['id'] : $post['parent'];
|
||||
threadUpdated($parent_id);
|
||||
}
|
||||
}
|
||||
|
||||
function manageCheckLogIn($requireKey) {
|
||||
$account = array();
|
||||
$loggedin = false;
|
||||
|
|
|
@ -741,6 +741,12 @@ function rebuildIndexes() {
|
|||
function rebuildThread($id) {
|
||||
$id = intval($id);
|
||||
|
||||
$post = postByID($id);
|
||||
if ($post['moderated'] == 0) {
|
||||
@unlink('res/' . $id . '.html');
|
||||
return;
|
||||
}
|
||||
|
||||
$posts = postsInThreadByID($id);
|
||||
if (count($posts) == 0) {
|
||||
@unlink('res/' . $id . '.html');
|
||||
|
|
|
@ -28,6 +28,7 @@ define('TINYIB_CAPTCHA', ''); // Reduce spam by requiring users to pass
|
|||
define('TINYIB_REPORTCAPTCHA', ''); // Reduce invalid reports by requiring users to pass a CAPTCHA when reporting: simple / hcaptcha / recaptcha ['' to disable]
|
||||
define('TINYIB_MANAGECAPTCHA', ''); // Improve security by requiring users to pass a CAPTCHA when logging in to the management panel: simple / hcaptcha / recaptcha ['' to disable]
|
||||
define('TINYIB_REPORT', false); // Allow users to report posts
|
||||
define('TINYIB_AUTOHIDE', 0); // Amount of reports which will cause a post to be hidden until it is approved [0 to disable]
|
||||
define('TINYIB_REQMOD', ''); // Require moderation before displaying posts: files / all ['' to disable]
|
||||
define('TINYIB_AUTOREFRESH', 30); // Delay (in seconds) between attempts to refresh a thread automatically [0 to disable]
|
||||
define('TINYIB_CLOUDFLARE', false); // Only enable when the site is served via Cloudflare to identify IP addresses correctly
|
||||
|
|
Loading…
Reference in a new issue