function userdelpost($posts, $board, $password) { // Get the threads deleted so we can clear their caches! $threads_deleted = array(); $threads_deleted = $this->mymultiarray("SELECT id,globalid FROM " . THthreads_table . " WHERE board=" . intval($board) . " " . "AND globalid IN (" . implode(",", $posts) . ") AND password='******' AND password IS NOT NULL"); if ($threads_deleted != null && count($threads_deleted) > 0) { foreach ($threads_deleted as $thread) { delimgs($this->delpost($thread['id'], true)); $this->touchreports($thread['globalid'], $board, 3); // Clear all reports for it smclearcache($board, -1, $thread['globalid']); // clear the cache } } $posts_deleted = array(); $posts_deleted = $this->myarray("SELECT id FROM " . THreplies_table . " WHERE board=" . intval($board) . " " . "AND globalid IN (" . implode(",", $posts) . ") AND password='******' AND password IS NOT NULL"); if ($posts_deleted != null && count($posts_deleted) > 0) { foreach ($posts_deleted as $post) { delimgs($this->delpost($post, false)); $this->touchreports($post, $board, 3); // Clear all reports for it } } // Return the total number of threads deleted return count($posts_deleted) + count($threads_deleted); }
if ($_SESSION['admin'] == 1) { // Let's assume this is a thread and only change if necessary $thread = $postarray['globalid']; // thread global ID for cache wiping $targetisthread = true; $targetid = $postarray['id']; // unique ID for post deletion if ($postarray['thread'] != 0) { $postdbi = new ThornPostDBI(); $fetched_thread = $postdbi->gettinfo($postarray['thread']); $thread = $fetched_thread['globalid']; $targetisthread = false; } smclearcache($board_folder, -1, $thread); // clear the associated cache for this thread smclearcache($board_folder, -1, -1); // AND the board delimgs($db->delpost($targetid, $targetisthread)); // Write to the log writelog("delete\tt:" . $postarray['globalid'] . "\tb:" . $postarray['board'], "moderator"); $message = $message . "<br />Post deletion"; } else { $message = $message . "<br /><i><b>Post deletion failed (insufficient access)</i></b>"; } } } } } $sm = sminit("popup.tpl"); $sm->assign("text", $message); $sm->assign("timeout", 5);
function purge($boardid) { $board = $this->getbinfo($boardid); $threadcount = $this->myresult("SELECT COUNT(*) FROM " . THthreads_table . " WHERE board=" . $board['id'] . " AND pin=0"); // Do we need to do anything? if ($threadcount > $board['tmax']) { // An array of imgidxes $badimgs = array(); // An array of thread IDs $threadids = array(); $targetthreads = $this->mymultiarray("SELECT * FROM " . THthreads_table . " WHERE board=" . $board['id'] . " AND pin=0 ORDER BY bump ASC LIMIT " . ($threadcount - $board['tmax'])); foreach ($targetthreads as $thread) { if ($thread['imgidx'] != 0) { // add to the images array $badimgs[] = $thread['imgidx']; } // Add to the ids array $threadids[] = $thread['id']; // Clear the reports $this->myquery("UPDATE " . THreports_table . " SET status=3 WHERE postid=" . $thread['globalid'] . " AND board=" . $board['id']); // Clear the cache smclearcache($board['id'], -1, $thread['globalid']); } // String representation of all of the thread IDs to be deleted $badthstr = implode(",", $threadids); // Retrieve the replies that are in these threads to be deleted $targetreplies = $this->mymultiarray("SELECT imgidx, globalid FROM " . THreplies_table . " WHERE board=" . $board['id'] . " AND thread in (" . $badthstr . ")"); foreach ($targetreplies as $reply) { if ($reply['imgidx'] != 0) { // add to the images array $badimgs[] = $reply['imgidx']; } // Clear the reports $this->myquery("UPDATE " . THreports_table . " set status=3 where postid=" . $reply['globalid'] . " and board=" . $board['id']); } // Delete these posts from the database $this->myquery("delete from " . THthreads_table . " where id in (" . $badthstr . ")"); $this->myquery("delete from " . THreplies_table . " where thread in (" . $badthstr . ")"); // Delete the image info from the database if (count($badimgs) > 0) { $badimgsstr = implode(",", $badimgs); // Remove extra_info sections first $extra_info_entries = $this->myarray("select extra_info from " . THimages_table . " where id in (" . $badimgsstr . ")"); if (count($extra_info_entries) > 0) { $this->myquery("delete from " . THextrainfo_table . " where id in (" . implode(",", $extra_info_entries) . ")"); } $this->myquery("delete from " . THimages_table . " where id in (" . $badimgsstr . ")"); } return $badimgs; } else { return array(); } }
$destboard_name = $db->getboardname($destboard); if ($destboard_name == null) { THdie("You can't move a thread to a board that doesn't exist!"); } // Pass the rest off to the DB $newthreadspot = $db->movethread($id, $destboard); // Check if it failed if ($newthreadspot == null) { THdie("Move failed!"); } // Clear the relevant caches smclearcache($board_id, -1, $threadid); // clear the associated cache for this thread smclearcache($board_id, -1, -1); // clear the associated cache for the original board smclearcache($destboard, -1, -1); // clear the associated cache for the target board // Write to the log $actionstring = "Move thread\t(t:" . $thread . ",ob:" . $postarray['board'] . ") => (tid:" . $newthreadspot . ",b:" . $destboard . ")"; writelog($actionstring, "moderator"); if (THuserewrite) { THdie('Thread moved.<br /><a href="' . THurl . $destboard_name . '/thread/' . $newthreadspot . '">Return to thread</a>'); } else { THdie('Thread moved.<br /><a href="' . THurl . 'drydock.php?b=' . $destboard_name . '&i=' . $newthreadspot . '">Return to thread</a>'); } } else { THdie("Invalid move thread attempt!"); } } // Some stuff might have changed after all that, so let's refetch the data $postarray = $db->getsinglepost($postid, $board_id);