function delete_topic($topic_id, $type) { global $db; // Delete the thread and any redirect topics if ($type == "hard") { $db->query('DELETE FROM ' . $db->prefix . 'topics WHERE id=' . $topic_id . ' OR moved_to=' . $topic_id) or error('Unable to delete topic', __FILE__, __LINE__, $db->error()); } elseif ($type == "soft") { $db->query('UPDATE ' . $db->prefix . 'topics SET soft = 1 WHERE id=' . $topic_id . ' OR moved_to=' . $topic_id) or error('Unable to soft delete topic', __FILE__, __LINE__, $db->error()); } else { $db->query('UPDATE ' . $db->prefix . 'topics SET soft = 0 WHERE id=' . $topic_id . ' OR moved_to=' . $topic_id) or error('Unable to soft delete topic', __FILE__, __LINE__, $db->error()); } // Create a list of the comment IDs in this thread $post_ids = ''; $result = $db->query('SELECT id FROM ' . $db->prefix . 'posts WHERE topic_id=' . $topic_id) or error('Unable to fetch posts', __FILE__, __LINE__, $db->error()); while ($row = $db->fetch_row($result)) { $post_ids .= $post_ids != '' ? ',' . $row[0] : $row[0]; } // Make sure we have a list of comment IDs if ($post_ids != '') { if ($type == "hard") { decrease_post_counts($post_ids); strip_search_index($post_ids); // Delete comments in topic $db->query('DELETE FROM ' . $db->prefix . 'posts WHERE topic_id=' . $topic_id) or error('Unable to delete posts', __FILE__, __LINE__, $db->error()); } else { if ($type == "soft") { $db->query('UPDATE ' . $db->prefix . 'posts SET soft = 1 WHERE topic_id=' . $topic_id) or error('Unable to soft delete comments', __FILE__, __LINE__, $db->error()); } else { $db->query('UPDATE ' . $db->prefix . 'posts SET soft = 0 WHERE topic_id=' . $topic_id) or error('Unable to soft delete comments', __FILE__, __LINE__, $db->error()); } } } if ($type != "reset") { // Delete any subscriptions for this thread $db->query('DELETE FROM ' . $db->prefix . 'topic_subscriptions WHERE topic_id=' . $topic_id) or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error()); } }
message_backstage(__('You do not have permission to access this page.', 'luna'), false, '403 Forbidden'); } } // Delete the threads and any redirect topics $db->query('DELETE FROM ' . $db->prefix . 'topics WHERE id IN(' . $topics . ') OR moved_to IN(' . $topics . ')') or error('Unable to delete topic', __FILE__, __LINE__, $db->error()); // Delete any subscriptions $db->query('DELETE FROM ' . $db->prefix . 'topic_subscriptions WHERE topic_id IN(' . $topics . ')') or error('Unable to delete subscriptions', __FILE__, __LINE__, $db->error()); // Create a list of the comment IDs in this thread and then strip the search index $result = $db->query('SELECT id FROM ' . $db->prefix . 'posts WHERE topic_id IN(' . $topics . ')') or error('Unable to fetch posts', __FILE__, __LINE__, $db->error()); $post_ids = ''; while ($row = $db->fetch_row($result)) { $post_ids .= $post_ids != '' ? ',' . $row[0] : $row[0]; } // We have to check that we actually have a list of comment IDs since we could be deleting just a redirect topic if ($post_ids != '') { decrease_post_counts($post_ids); strip_search_index($post_ids); } // Delete comments $db->query('DELETE FROM ' . $db->prefix . 'posts WHERE topic_id IN(' . $topics . ')') or error('Unable to delete posts', __FILE__, __LINE__, $db->error()); update_forum($fid); redirect('viewforum.php?id=' . $fid); } $page_title = array(luna_htmlspecialchars($luna_config['o_board_title']), __('Admin', 'luna'), __('Moderate', 'luna')); define('FORUM_ACTIVE_PAGE', 'admin'); require 'header.php'; load_admin_nav('content', 'moderate'); ?> <form method="post" action="moderate.php?fid=<?php echo $fid;