summaryrefslogtreecommitdiff
path: root/post.php
diff options
context:
space:
mode:
authorFredrick Brennan <admin@8chan.co>2015-04-03 14:56:28 +0800
committerczaks <marcin@6irc.net>2016-05-06 16:39:20 +0200
commit505adffcdca1c1141b7b46f862b7939f2f4acf45 (patch)
tree114147c8a811183561a227cce875140bc4ac364e /post.php
parentab02a4272514410fc053ced9c17a26bc0c8f1cf4 (diff)
Cyclical threads ♺
Diffstat (limited to 'post.php')
-rw-r--r--post.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/post.php b/post.php
index 0d3292bb..98aefe05 100644
--- a/post.php
+++ b/post.php
@@ -265,7 +265,7 @@ if (isset($_POST['delete'])) {
//Check if thread exists
if (!$post['op']) {
- $query = prepare(sprintf("SELECT `sticky`,`locked`,`sage`,`slug` FROM ``posts_%s`` WHERE `id` = :id AND `thread` IS NULL LIMIT 1", $board['uri']));
+ $query = prepare(sprintf("SELECT `sticky`,`locked`,`cycle`,`sage`,`slug` FROM ``posts_%s`` WHERE `id` = :id AND `thread` IS NULL LIMIT 1", $board['uri']));
$query->bindValue(':id', $post['thread'], PDO::PARAM_INT);
$query->execute() or error(db_error());
@@ -867,6 +867,15 @@ if (isset($_POST['delete'])) {
$post['slug'] = slugify($post);
insertFloodPost($post);
+
+ // Handle cyclical threads
+ if (!$post['op'] && isset($thread['cycle']) && $thread['cycle']) {
+ // Query is a bit weird due to "This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'" (MariaDB Ver 15.1 Distrib 10.0.17-MariaDB, for Linux (x86_64))
+ $query = prepare(sprintf('DELETE FROM ``posts_%s`` WHERE `thread` = :thread AND `id` NOT IN (SELECT `id` FROM (SELECT `id` FROM ``posts_%s`` WHERE `thread` = :thread ORDER BY `id` DESC LIMIT :limit) i)', $board['uri'], $board['uri']));
+ $query->bindValue(':thread', $post['thread']);
+ $query->bindValue(':limit', $config['cycle_limit'], PDO::PARAM_INT);
+ $query->execute() or error(db_error($query));
+ }
if (isset($post['antispam_hash'])) {
incrementSpamHash($post['antispam_hash']);