} } render_result_xml($data); exit; } } else { if (isset($_GET['action']) && $_GET['action'] == 'delete') { //Delete this topic $userID = buckys_is_logged_in(); $topicID = isset($_GET['id']) ? get_secure_integer($_GET['id']) : null; if (isset($topicID)) { $forumTopicIns = new BuckysForumTopic(); $forumData = $forumTopicIns->getTopic($topicID); if (isset($forumData) && $forumData['creatorID'] == $userID) { //then you can delete this one. $forumTopicIns->deleteTopic($topicID); buckys_redirect('/forum', MSG_TOPIC_REMOVED_SUCCESSFULLY, MSG_TYPE_SUCCESS); } else { //You don't have permission buckys_redirect('/forum/topic.php?id=' . $topicID, MSG_PERMISSION_DENIED, MSG_TYPE_ERROR); } } } else { if (isset($_GET['action']) && $_GET['action'] == 'move-topic') { //Delete this topic if (!buckys_check_user_acl(USER_ACL_MODERATOR)) { buckys_redirect('/forum', MSG_PERMISSION_DENIED, MSG_TYPE_ERROR); } $userID = buckys_is_logged_in(); $topicID = isset($_GET['id']) ? buckys_escape_query_integer($_GET['id']) : null; $catID = isset($_GET['category']) ? buckys_escape_query_integer($_GET['category']) : null;
/** * Delete Objects * * @param Array $ids * @param String $objectType * @param String $modeartorType */ public function deleteObjects($ids, $objectType, $moderatorType) { global $db; if (!is_array($ids)) { $ids = array($ids); } $ids = $db->escapeInput($ids); $query = $db->prepare("SELECT * FROM " . TABLE_REPORTS . " WHERE objectType=%s AND reportID in (" . implode(", ", $ids) . ")", $objectType); $rows = $db->getResultsArray($query); foreach ($rows as $row) { if ($row['objectType'] == 'post') { $post = $db->getRow("SELECT * FROM " . TABLE_POSTS . " WHERE postID=" . $row['objectID']); BuckysPost::deletePost($post['poster'], $post['postID']); } else { if ($row['objectType'] == 'comment') { //Getting Data $comment = $db->getRow("SELECT * FROM " . TABLE_POSTS_COMMENTS . " WHERE commentID=" . $row['objectID']); BuckysComment::deleteComment($comment['commenter'], $comment['commentID']); } else { if ($row['objectType'] == 'message') { //Delete Message $db->query("DELETE FROM " . TABLE_MESSAGES . " WHERE messageID=" . $row['objectID']); } else { if ($row['objectType'] == 'topic') { //Delete Topic BuckysForumTopic::deleteTopic($row['objectID']); } else { if ($row['objectType'] == 'reply') { //Delete Topic BuckysForumReply::deleteReply($row['objectID']); } } } } } //Delete the row on the report table $db->query("DELETE FROM " . TABLE_REPORTS . " WHERE reportID=" . $row['reportID']); } return; }
/** * Delete Objects * * @param Array $ids */ public static function deleteObjects($ids) { global $db; if (!is_array($ids)) { $ids = [$ids]; } $ids = $db->escapeInput($ids); $query = $db->prepare("SELECT * FROM " . TABLE_REPORTS . " WHERE reportID IN (" . implode(", ", $ids) . ")"); $rows = $db->getResultsArray($query); foreach ($rows as $row) { if ($row['objectType'] == 'post') { $post = $db->getRow("SELECT * FROM " . TABLE_POSTS . " WHERE postID=" . $row['objectID']); BuckysPost::deletePost($post['poster'], $post['postID']); } else { if ($row['objectType'] == 'comment') { //Getting Data $comment = $db->getRow("SELECT * FROM " . TABLE_POSTS_COMMENTS . " WHERE commentID=" . $row['objectID']); BuckysComment::deleteComment($comment['commenter'], $comment['commentID']); } else { if ($row['objectType'] == 'video_comment') { //Getting Data $comment = $db->getRow("SELECT * FROM " . TABLE_VIDEO_COMMENTS . " WHERE commentID=" . $row['objectID']); BuckysVideo::deleteVideoComment($comment['commentID']); } else { if ($row['objectType'] == 'message') { //Delete Message $db->query("DELETE FROM " . TABLE_MESSAGES . " WHERE messageID=" . $row['objectID']); } else { if ($row['objectType'] == 'topic') { //Delete Topic BuckysForumTopic::deleteTopic($row['objectID']); } else { if ($row['objectType'] == 'reply') { //Delete Topic BuckysForumReply::deleteReply($row['objectID']); } else { if ($row['objectType'] == 'shop_item') { //Delete Shop Product $shopProdIns = new BuckysShopProduct(); $shopProdIns->removeProductByUserID($row['objectID'], $row['reportedID']); } else { if ($row['objectType'] == 'trade_item') { //Delete Trade Item $tradeItemIns = new BuckysTradeItem(); $tradeItemIns->removeItemByUserID($row['objectID'], $row['reportedID']); } } } } } } } } //Delete the row on the report table $db->query("DELETE FROM " . TABLE_REPORTS . " WHERE reportID=" . $row['reportID']); } return; }
/** * @param $userID * @param $categoryID */ public static function blockUser($userID, $categoryID) { global $db; //Getting Users Topics and Replies $query = $db->prepare("SELECT * FROM " . TABLE_FORUM_TOPICS . " WHERE creatorID=%d AND categoryID=%d", $userID, $categoryID); $topics = $db->getResultsArray($query); foreach ($topics as $row) { BuckysForumTopic::deleteTopic($row['topicID']); } $query = $db->prepare("SELECT r.replyID FROM " . TABLE_FORUM_REPLIES . " AS r LEFT JOIN " . TABLE_FORUM_TOPICS . " AS t ON t.topicID=r.topicID WHERE r.creatorID=%d AND t.categoryID=%d", $userID, $categoryID); $replies = $db->getResultsArray($query); foreach ($replies as $row) { BuckysForumReply::deleteReply($row['replyID']); } //Block User $query = $db->prepare("INSERT INTO " . TABLE_FORUM_BLOCKED_USRES . "(userID, categoryID, blockedDate)VALUES(%d, %d, %s)", $userID, $categoryID, date("Y-m-d H:i:s")); $db->query($query); }
/** * @param $categoryID */ public static function deleteCategory($categoryID) { global $db; //Delete Category Links $query = $db->prepare("DELETE FROM " . TABLE_FORUM_CATEGORIES_LINKS . " WHERE categoryID=%d", $categoryID); $db->query($query); //Remove Followers $query = $db->prepare("DELETE FROM " . TABLE_FORUM_FOLLOWERS . " WHERE categoryID=%d", $categoryID); $db->query($query); //Remove Moderators $query = $db->prepare("DELETE FROM " . TABLE_FORUM_MODERATORS . " WHERE categoryID=%d", $categoryID); $db->query($query); //Remove Blocked Users $query = $db->prepare("DELETE FROM " . TABLE_FORUM_BLOCKED_USRES . " WHERE categoryID=%d", $categoryID); $db->query($query); //Remove Topics $query = $db->prepare("SELECT topicID FROM " . TABLE_FORUM_TOPICS . " WHERE categoryID=%d", $categoryID); $topics = $db->getResultsArray($query); foreach ($topics as $tRow) { BuckysForumTopic::deleteTopic($tRow['topicID']); } //Remove Forum $query = $db->prepare("DELETE FROM " . TABLE_FORUM_CATEGORIES . " WHERE categoryID=%d", $categoryID); $db->query($query); return; }