/** * Delete page by PageID * * @param integer $userID * @param integer $pageID */ public function deletePageByID($pageID, $userID = null) { global $db; $postIns = new BuckysPost(); $pageFollowerIns = new BuckysPageFollower(); //Get Page info & related posts belonged to this page. $pageData = $this->getPageByID($pageID); if (!$pageData) { return false; } if (!empty($userID) && $pageData['userID'] != $userID) { return false; // You don't have permission to delete this page } $postList = $postIns->getPostsByPageID($pageData['pageID']); //Delete related posts if (is_array($postList) && count($postList) > 0) { foreach ($postList as $postData) { $postIns->deletePost($pageData['userID'], $postData['postID']); } } //Delete page $query = sprintf("DELETE FROM %s WHERE pageID=%d", TABLE_PAGES, $pageID); $db->query($query); //Delete followers $pageFollowerIns->removeAllFollowersByPageID($pageID); return true; }
if (!($userID = buckys_is_logged_in())) { buckys_redirect('/index.php', MSG_NOT_LOGGED_IN_USER, MSG_TYPE_ERROR); } //Action Process if (isset($_POST['action']) && $_POST['action'] == 'submit-post') { //Save Post BuckysPost::savePost($userID, $_POST); if (isset($_POST['pageID']) && is_numeric($_POST['pageID'])) { buckys_redirect('/page.php?pid=' . $_POST['pageID']); } else { buckys_redirect('/account.php'); } } else { if (isset($_GET['action']) && $_GET['action'] == 'delete-post') { //Delete Post if ($userID != $_GET['userID'] || !BuckysPost::deletePost($userID, $_GET['postID'])) { echo 'Invalid Request'; } else { echo 'success'; } exit; } else { if (isset($_GET['action']) && ($_GET['action'] == 'unlikePost' || $_GET['action'] == 'likePost')) { $post = BuckysPost::getPostById($_GET['postID']); if ($post['post_status'] != 1) { render_result_xml(array('status' => 'error', 'message' => MSG_INVALID_REQUEST)); exit; } $r = BuckysPost::likePost($userID, $_GET['postID'], $_GET['action']); $likes = BuckysPost::getPostLikesCount($_GET['postID']); render_result_xml(array('status' => $r ? 'success' : 'error', 'message' => buckys_get_messages(), 'likes' => $likes . " like" . ($likes >= 2 ? "s" : ""), 'postID' => $_GET['postID']));
require dirname(__FILE__) . '/includes/bootstrap.php'; //Getting Current User ID if (!($userID = buckys_is_logged_in())) { buckys_redirect('/index.php', MSG_NOT_LOGGED_IN_USER, MSG_TYPE_ERROR); } //Getting UserData from Id $userData = BuckysUser::getUserData($userID); if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; if ($action == 'set-profile-photo') { BuckysUser::updateUserProfilePhoto($userID, $_REQUEST['photoID']); buckys_redirect('/photo_manage.php'); } else { if ($action == 'delete-photo') { if (!BuckysPost::deletePost($userID, $_REQUEST['photoID'])) { buckys_redirect('/photo_manage.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR); } else { buckys_redirect('/photo_manage.php', MSG_PHOTO_REMOVED, MSG_TYPE_SUCCESS); } } else { if ($action == 'remove-profile-photo') { BuckysUser::updateUserFields($userID, ['thumbnail' => '']); buckys_redirect('/photo_manage.php'); } } } } //Getting Album ID $albumID = isset($_REQUEST['albumID']) ? $_REQUEST['albumID'] : null; //Getting Current Page
/** * 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; }