//Save Forum Links BuckysForumCategory::removeAllLinks($categoryID); if (isset($_POST['link_title'])) { foreach ($_POST['link_title'] as $i => $link_title) { $link_url = $_POST['link_url'][$i]; if (!$link_url || !$link_title) { continue; } BuckysForumCategory::saveCategoryLink($categoryID, $link_title, $link_url); } } buckys_redirect("/forum/category.php?id=" . $categoryID, MSG_FORUM_SAVED, MSG_TYPE_SUCCESS); } $categoryID = isset($_GET['id']) ? $_GET['id'] : null; if ($categoryID != null) { $category = BuckysForumCategory::getCategory($categoryID); //Check Permission if (!$category || !buckys_is_admin() && !buckys_is_moderator() && !buckys_is_forum_admin($category['categoryID']) && !buckys_is_forum_moderator($category['categoryID'])) { buckys_redirect('/forum', MSG_PERMISSION_DENIED, MSG_TYPE_ERROR); } } buckys_enqueue_stylesheet('sceditor/themes/default.css'); buckys_enqueue_stylesheet('forum.css'); buckys_enqueue_stylesheet('posting.css'); buckys_enqueue_stylesheet('publisher.css'); buckys_enqueue_stylesheet('uploadify.css'); buckys_enqueue_stylesheet('jquery.Jcrop.css'); buckys_enqueue_javascript('sceditor/jquery.sceditor.bbcode.js'); buckys_enqueue_javascript('uploadify/jquery.uploadify.js'); buckys_enqueue_javascript('jquery.Jcrop.js'); buckys_enqueue_javascript('edit_forum.js');
<thead> <tr> <th style="padding:0px;padding-bottom:5px;" class="titles"><?php echo $cat['categoryName']; ?> </th> <th style="padding:0px;">Last Post</th> <th style="padding:0px;" class="td-counts">Topics</th> <th style="padding:0px;" class="td-counts">Replies</th> </tr> </thead> <tbody> <?php foreach ($cat['children'] as $idx => $subCat) { $categoryDescription = BuckysForumCategory::getCategoryDescription($subCat['categoryID']); ?> <tr <?php echo $idx == count($cat['children']) - 1 ? 'class="last-tr"' : ''; ?> > <td class="first-column" style="padding-left:0px; font-size:12px;" width="50%"> <a href="/forum/category.php?id=<?php echo $subCat['categoryID']; ?> "><img src="/images/forum/icons/<?php echo $subCat['categoryID']; ?> .png" class="poster-icon"></a> <a
$topic = BuckysForumTopic::getTopic($topicID); if (!$topic) { buckys_redirect('/forum'); } //If the topic is not published(pending or suspended), only forum moderator and administrator can see this if ($topic['status'] != 'publish' && !buckys_is_forum_moderator() && $BUCKYS_GLOBALS['user']['userID'] != $topic['creatorID']) { buckys_redirect('/forum'); } $orderBy = isset($_GET['orderby']) ? $_GET['orderby'] : 'oldest'; //Getting Replies $page = isset($_GET['page']) ? $_GET['page'] : 1; $total = BuckysForumReply::getTotalNumOfReplies($topic['topicID'], 'publish'); $pagination = new Pagination($total, BuckysForumReply::$COUNT_PER_PAGE, $page); $page = $pagination->getCurrentPage(); $replies = BuckysForumReply::getReplies($topic['topicID'], 'publish', $page, $orderBy); $hierarchical = BuckysForumCategory::getCategoryHierarchical($topic['categoryID']); //Mark Forum Notifications to read if (buckys_check_user_acl(USER_ACL_REGISTERED)) { BuckysForumNotification::makeNotificationsToRead($BUCKYS_GLOBALS['user']['userID'], null, $topic['topicID']); } buckys_enqueue_javascript('jquery-migrate-1.2.0.js'); buckys_enqueue_javascript('editor/jquery.cleditor.js'); buckys_enqueue_javascript('prettyprint/run_prettify.js?skin=default&'); buckys_enqueue_javascript('forum.js'); //buckys_enqueue_javascript('editor/jquery.cleditor.bbcode.js'); buckys_enqueue_stylesheet('editor/jquery.cleditor.css'); buckys_enqueue_stylesheet('prettify.css'); buckys_enqueue_stylesheet('forum.css'); $BUCKYS_GLOBALS['headerType'] = 'forum'; $BUCKYS_GLOBALS['content'] = 'forum/topic'; $BUCKYS_GLOBALS['title'] = $topic['topicTitle'] . ' - BuckysRoomForum';
$categoryID = null; if (isset($_REQUEST['id'])) { $categoryID = buckys_escape_query_integer($_REQUEST['id']); $category = BuckysForumCategory::getCategory($_REQUEST['id']); } $keyword = isset($_REQUEST['s']) ? buckys_escape_query_string($_GET['s']) : ''; $orderBy = isset($_GET['orderby']) ? buckys_escape_query_string($_GET['orderby']) : 'popular'; switch ($orderBy) { case 'recent': $orderByStr = ' c.createdDate DESC '; break; case 'popular': default: $orderByStr = ' c.followers DESC '; break; } $page = isset($_GET['page']) ? buckys_escape_query_integer($_GET['page']) : 1; $results = BuckysForumCategory::searchCategories($keyword, $page, $orderByStr, BuckysForumCategory::$COUNT_PER_PAGE); $pagination = new Pagination($results['total'], BuckysForumCategory::$COUNT_PER_PAGE, $page); $page = $pagination->getCurrentPage(); buckys_enqueue_stylesheet('sceditor/themes/default.css'); buckys_enqueue_stylesheet('forum.css'); buckys_enqueue_stylesheet('publisher.css'); buckys_enqueue_stylesheet('uploadify.css'); buckys_enqueue_javascript('sceditor/jquery.sceditor.bbcode.js'); buckys_enqueue_javascript('uploadify/jquery.uploadify.js'); $view['action_type'] = 'create'; $TNB_GLOBALS['headerType'] = 'forum'; $TNB_GLOBALS['content'] = 'forum/search_forums'; $TNB_GLOBALS['title'] = 'Search Forums - thenewboston Forum'; require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";
/** * Unban Users * * @param mixed $ids */ public static function unbanUsers($ids) { global $db, $TNB_GLOBALS; if (!is_array($ids)) { $ids = [$ids]; } //Check the user has lready been banned or not $rows = $db->getResultsArray("SELECT * FROM " . TABLE_BANNED_USERS . " WHERE bannedID IN (" . implode(', ', $ids) . ")"); if ($rows) { foreach ($rows as $brow) { $userID = $brow['bannedUserID']; //Change User Table $db->query("UPDATE " . TABLE_USERS . " SET status=1 WHERE userID=" . $userID); //Change Posts table $db->query("UPDATE " . TABLE_POSTS . " SET post_status=1 WHERE poster=" . $userID); //Change Activities $db->query("UPDATE " . TABLE_MAIN_ACTIVITIES . " SET activityStatus=1 WHERE userID=" . $userID); //Change Messages $db->query("UPDATE " . TABLE_MESSAGES . " SET messageStatus=1 WHERE sender=" . $userID); //Fix Comments Count $query = $db->prepare("SELECT count(commentID) AS c, postID FROM " . TABLE_POSTS_COMMENTS . " WHERE commenter=%d AND commentStatus=0 GROUP BY postID", $userID); $pcRows = $db->getResultsArray($query); foreach ($pcRows as $row) { $db->query("UPDATE " . TABLE_POSTS . " SET `comments` = `comments` + " . $row['c'] . " WHERE postID=" . $row['postID']); } //Unblock Comments $db->query("UPDATE " . TABLE_POSTS_COMMENTS . " SET commentStatus=1 WHERE commenter=" . $userID); //Fix Likes Count $query = $db->prepare("SELECT count(likeID) AS c, postID FROM " . TABLE_POSTS_LIKES . " WHERE userID=%d AND likeStatus=0 GROUP BY postID", $userID); $plRows = $db->getResultsArray($query); foreach ($plRows as $row) { $db->query("UPDATE " . TABLE_POSTS . " SET `likes` = `likes` + " . $row['c'] . " WHERE postID=" . $row['postID']); } //Unblock Likes $db->query("UPDATE " . TABLE_POSTS_LIKES . " SET likeStatus=1 WHERE userID=" . $userID); //Unblock Votes for Moderator $query = $db->prepare("SELECT count(voteID) AS c, candidateID FROM " . TABLE_MODERATOR_VOTES . " WHERE voterID=%d AND voteStatus=0 GROUP BY candidateID", $userID); $vRows = $db->getResultsArray($query); foreach ($vRows as $row) { $db->query("UPDATE " . TABLE_MODERATOR_CANDIDATES . " SET `votes` = `votes` + " . $row['c'] . " WHERE candidateID=" . $row['candidateID']); } $db->query("UPDATE " . TABLE_MODERATOR_VOTES . " SET voteStatus=1 WHERE voterID=" . $userID); //Unblock Replies $query = $db->prepare("SELECT count(r.replyID), r.topicID, t.categoryID FROM " . TABLE_FORUM_REPLIES . " AS r LEFT JOIN " . TABLE_FORUM_TOPICS . " AS t ON t.topicID=r.topicID WHERE r.status='suspended' AND r.creatorID=%d GROUP BY r.topicID", $userID); $rRows = $db->getResultsArray($query); $db->query("UPDATE " . TABLE_FORUM_REPLIES . " SET `status`='publish' WHERE creatorID=" . $userID . " AND `status`='suspended'"); foreach ($rRows as $row) { $db->query("UPDATE " . TABLE_FORUM_TOPICS . " SET `replies` = `replies` + " . $row['c'] . " WHERE topicID=" . $row['topicID']); $db->query("UPDATE " . TABLE_FORUM_CATEGORIES . " SET `replies` = `replies` + " . $row['c'] . " WHERE categoryID=" . $row['categoryID']); BuckysForumTopic::updateTopicLastReplyID($row['topicID']); BuckysForumCategory::updateCategoryLastTopicID($row['categoryID']); } //unblock Topics $query = $db->prepare("SELECT count(topicID) AS tc, SUM(replies) AS rc, categoryID FROM " . TABLE_FORUM_TOPICS . " WHERE creatorID=%d AND `status`='suspended' GROUP BY categoryID", $userID); $tRows = $db->getResultsArray($query); $db->query("UPDATE " . TABLE_FORUM_TOPICS . " SET `status`='publish' WHERE creatorID=" . $userID . " AND `status`='suspended'"); foreach ($tRows as $row) { $db->query("UPDATE " . TABLE_FORUM_CATEGORIES . " SET `replies` = `replies` + " . $row['rc'] . ", `topics` = `topics` + " . $row['tc'] . " WHERE categoryID=" . $row['categoryID']); BuckysForumCategory::updateCategoryLastTopicID($row['categoryID']); } //Unblock Reply Votes $query = $db->prepare("SELECT count(voteID) AS c, objectID FROM " . TABLE_FORUM_VOTES . " WHERE voterID=%d AND voteStatus=0 GROUP BY objectID", $userID); $vRows = $db->getResultsArray($query); foreach ($vRows as $row) { $db->query("UPDATE " . TABLE_FORUM_REPLIES . " SET `votes` = `votes` + " . $row['c'] . " WHERE replyID=" . $row['objectID']); } $db->query("UPDATE " . TABLE_FORUM_VOTES . " SET voteStatus=1 WHERE voterID=" . $userID); //Unblock page section & Trade section $tradeItemIns = new BuckysTradeItem(); $tradeOfferIns = new BuckysTradeOffer(); $pageIns = new BuckysPage(); $tradeItemIns->massStatusChange($userID, BuckysTradeItem::STATUS_ITEM_ACTIVE); $tradeOfferIns->massStatusChange($userID, BuckysTradeOffer::STATUS_OFFER_ACTIVE); $pageIns->massStatusChange($userID, BuckysPage::STATUS_ACTIVE); //enable Shop Products $shopProdIns = new BuckysShopProduct(); $shopProdIns->massStatusChange($userID, BuckysShopProduct::STATUS_ACTIVE); //Remove From banned users table $db->query("DELETE FROM " . TABLE_BANNED_USERS . " WHERE bannedID=" . $brow['bannedID']); } } }
if ($_REQUEST['action'] == 'delete-forum') { $return = isset($_REQUEST['return']) ? base64_decode($_REQUEST['return']) : '/forum/moderator.php?id=' . $categoryID; //Check forum token if (!buckys_check_form_token('request')) { buckys_redirect($return, MSG_INVALID_REQUEST, MSG_TYPE_ERROR); } //Admin, Site Moderator, Category Admin and Category Moderator can't apply if (!(buckys_is_admin() || buckys_is_forum_admin($category['categoryID']))) { buckys_redirect($return, MSG_PERMISSION_DENIED, MSG_TYPE_ERROR); } //Check Password $userData = BuckysUser::getUserData($userID); if (!buckys_validate_password($_REQUEST['pwd'], $userData['password'])) { buckys_redirect($return, MSG_CURRENT_PASSWORD_NOT_CORRECT, MSG_TYPE_ERROR); } BuckysForumCategory::deleteCategory($category['categoryID']); buckys_redirect("/forum", MSG_REMOVE_FORUM_SUCCESS); } } } } } } } } } } //Admin, Site Moderator, Category Admin and Category Moderator can't apply if (!(buckys_is_admin() || buckys_is_moderator() || buckys_is_forum_admin($category['categoryID']) || buckys_is_forum_moderator($category['categoryID']))) { buckys_redirect('/forum/category.php?id=' . $categoryID, MSG_PERMISSION_DENIED, MSG_TYPE_ERROR); }
/** * Delete Topic * * @param Int $topicID * @return bool */ public static function deleteTopic($topicID) { global $db; $query = $db->prepare("SELECT * FROM " . TABLE_FORUM_TOPICS . " WHERE topicID=%d", $topicID); $topic = $db->getRow($query); if ($topic) { //Update Stats $query = "UPDATE " . TABLE_USERS_STATS . " AS us\n LEFT JOIN " . TABLE_FORUM_REPLIES . " AS r ON r.creatorID=us.userID\n SET\n us.`voteUps` = us.`voteUps` - r.`votes`,\n us.`reputation` = us.`reputation` - r.`votes`\n WHERE \n r.status='publish' AND r.topicID={$topic['topicID']} \n "; $db->query($query); //Getting Published Replies count $query = "SELECT COUNT(1) FROM " . TABLE_FORUM_REPLIES . " WHERE `status`='publish' AND topicID=" . $topic['topicID']; $publishReplies = $db->getVar($query); BuckysUser::updateStats($topic['creatorID'], 'replies', -1 * $publishReplies); BuckysUser::updateStats($topic['creatorID'], 'voteUps', -1 * $topic['votes']); //Remove Reply Votes $query = "DELETE FROM " . TABLE_FORUM_VOTES . " WHERE objectID IN (SELECT replyID FROM " . TABLE_FORUM_REPLIES . " WHERE topicID=" . $topic['topicID'] . ")"; $db->query($query); //Remove Replies $query = "DELETE FROM " . TABLE_FORUM_REPLIES . " WHERE topicID=" . $topic['topicID']; $db->query($query); //Delete Topics $query = "DELETE FROM " . TABLE_FORUM_TOPICS . " WHERE topicID=" . $topic['topicID']; $db->query($query); //Delete Frome Reports Table $query = "DELETE FROM " . TABLE_REPORTS . " WHERE objectType='topic' AND objectID=" . $topic['topicID']; $db->query($query); //Update Category Values $query = "UPDATE " . TABLE_FORUM_CATEGORIES . " SET `topics` = `topics` - 1, `replies` = `replies` - " . $publishReplies . " WHERE categoryID=" . $topic['categoryID']; $db->query($query); //If the topic status is publish, decrease user posts count if ($topic['status'] == 'publish') { $db->query("UPDATE " . TABLE_USERS . " SET `posts_count`=`posts_count` " . ($topic['votes'] > 0 ? '-' : '+') . abs($topic['votes']) . " WHERE userID=" . $topic['creatorID']); } //Update Last Topic ID of the category BuckysForumCategory::updateCategoryLastTopicID($topic['categoryID']); return true; } return false; }
public function getCategoryHierarchical($catID) { global $db; $result = array(); $cCat = BuckysForumCategory::getCategory($catID); $result[] = $cCat; while ($cCat && $cCat['parentID'] != 0) { $cCat = BuckysForumCategory::getCategory($cCat['parentID']); $result[] = $cCat; } $result = array_reverse($result); return $result; }
<?php require dirname(dirname(__FILE__)) . '/includes/bootstrap.php'; $categoryID = null; if (isset($_REQUEST['id'])) { $categoryID = buckys_escape_query_integer($_REQUEST['id']); $category = BuckysForumCategory::getCategory($_REQUEST['id']); } $keyword = isset($_REQUEST['s']) ? buckys_escape_query_string($_GET['s']) : ''; $orderBy = isset($_GET['orderby']) ? buckys_escape_query_string($_GET['orderby']) : 'recent'; switch ($orderBy) { case 'recent': $orderByStr = ' lastReplyDate DESC '; break; case 'rating': $orderByStr = ' t.votes DESC '; break; case 'replies': $orderByStr = ' t.replies DESC '; break; case 'best-match': default: $orderByStr = ' relevance DESC '; break; } $page = isset($_GET['page']) ? buckys_escape_query_integer($_GET['page']) : 1; $results = BuckysForumTopic::searchTopic($keyword, $categoryID, $page, $orderByStr, BuckysForumTopic::$COUNT_PER_PAGE); $pagination = new Pagination($results['total'], BuckysForumTopic::$COUNT_PER_PAGE, $page); $page = $pagination->getCurrentPage(); buckys_enqueue_stylesheet('sceditor/themes/default.css'); buckys_enqueue_stylesheet('forum.css');
/** * Delete Topic * * @param Int $topicID */ public function deleteTopic($topicID) { global $db; $query = $db->prepare("SELECT * FROM " . TABLE_FORUM_TOPICS . " WHERE topicID=%d", $topicID); $topic = $db->getRow($query); if ($topic) { //Getting Published Replies count $query = "SELECT COUNT(1) FROM " . TABLE_FORUM_REPLIES . " WHERE `status`='publish' AND topicID=" . $topic['topicID']; $publishReplies = $db->getVar($query); //Remove Reply Votes $query = "DELETE FROM " . TABLE_FORUM_VOTES . " WHERE objectID IN (SELECT replyID FROM " . TABLE_FORUM_REPLIES . " WHERE topicID=" . $topic['topicID'] . ")"; $db->query($query); //Remove Replies $query = "DELETE FROM " . TABLE_FORUM_REPLIES . " WHERE topicID=" . $topic['topicID']; $db->query($query); //Delete Topics $query = "DELETE FROM " . TABLE_FORUM_TOPICS . " WHERE topicID=" . $topic['topicID']; $db->query($query); //Update Category Values $query = "UPDATE " . TABLE_FORUM_CATEGORIES . " SET `topics` = `topics` - 1, `replies` = `replies` - " . $publishReplies . " WHERE categoryID=" . $topic['categoryID']; $db->query($query); //Update Last Topic ID of the category BuckysForumCategory::updateCategoryLastTopicID($topic['categoryID']); return true; } return false; }
<?php /** * Page Left Sidebar */ if (!isset($TNB_GLOBALS)) { die("Invalid Request!"); } if (buckys_is_logged_in()) { $followingCategories = BuckysForumCategory::getFollowingCategories(); } else { $followingCategories = BuckysForumCategory::getDefaultCategories(); } ?> <aside id="forum-left-bar"> <?php if (buckys_is_logged_in()) { ?> <h2 class="titles"><?php echo $TNB_GLOBALS['user']['firstName'] . " " . $TNB_GLOBALS['user']['lastName']; ?> </h2> <div class="user-thumbnail"> <a href="/profile.php?user=<?php echo $TNB_GLOBALS['user']['userID']; ?> "> <?php if (!$TNB_GLOBALS['user']['thumbnail']) { ?> <img src="<?php
/** * Check the current user is the admin(creator) of the forum * * @param int $categoryID * @return Boolean */ function buckys_is_forum_admin($categoryID) { global $db; if (!($userID = buckys_is_logged_in())) { return false; } $category = BuckysForumCategory::getCategory($categoryID); if ($category['creatorID'] != $userID) { return false; } else { return true; } }
/** * Remove Account */ public static function deleteUserAccount($userID) { global $db; $userID = intval($userID); //Fix Comments Count $query = $db->prepare("SELECT count(commentID) AS c, postID FROM " . TABLE_POSTS_COMMENTS . " WHERE commenter=%d AND commentStatus=1 GROUP BY postID", $userID); $pcRows = $db->getResultsArray($query); foreach ($pcRows as $row) { $db->query("UPDATE " . TABLE_POSTS . " SET `comments` = `comments` - " . $row['c'] . " WHERE postID=" . $row['postID']); } //Fix Likes Count $query = $db->prepare("SELECT count(likeID) AS c, postID FROM " . TABLE_POSTS_LIKES . " WHERE userID=%d AND likeStatus=1 GROUP BY postID", $userID); $plRows = $db->getResultsArray($query); foreach ($plRows as $row) { $db->query("UPDATE " . TABLE_POSTS . " SET `likes` = `likes` - " . $row['c'] . " WHERE postID=" . $row['postID']); } //Block Votes for Moderator $query = $db->prepare("SELECT count(voteID) AS c, candidateID FROM " . TABLE_MODERATOR_VOTES . " WHERE voterID=%d AND voteStatus=1 GROUP BY candidateID", $userID); $vRows = $db->getResultsArray($query); foreach ($vRows as $row) { $db->query("UPDATE " . TABLE_MODERATOR_CANDIDATES . " SET `votes` = `votes` - " . $row['c'] . " WHERE candidateID=" . $row['candidateID']); } //Block Replies $query = $db->prepare("SELECT count(r.replyID), r.topicID, t.categoryID FROM " . TABLE_FORUM_REPLIES . " AS r LEFT JOIN " . TABLE_FORUM_TOPICS . " AS t ON t.topicID=r.topicID WHERE r.status='publish' AND r.creatorID=%d GROUP BY r.topicID", $userID); $rRows = $db->getResultsArray($query); $db->query("UPDATE " . TABLE_FORUM_REPLIES . " SET `status`='suspended' WHERE creatorID=" . $userID . " AND `status`='publish'"); foreach ($rRows as $row) { $db->query("UPDATE " . TABLE_FORUM_TOPICS . " SET `replies` = `replies` - " . $row['c'] . " WHERE topicID=" . $row['topicID']); $db->query("UPDATE " . TABLE_FORUM_CATEGORIES . " SET `replies` = `replies` - " . $row['c'] . " WHERE categoryID=" . $row['categoryID']); BuckysForumTopic::updateTopicLastReplyID($row['topicID']); } //Block Topics $query = $db->prepare("SELECT count(topicID) AS tc, SUM(replies) AS rc, categoryID FROM " . TABLE_FORUM_TOPICS . " WHERE creatorID=%d AND `status`='publish' GROUP BY categoryID", $userID); $tRows = $db->getResultsArray($query); $db->query("UPDATE " . TABLE_FORUM_TOPICS . " SET `status`='suspended' WHERE creatorID=" . $userID . " AND `status`='publish'"); foreach ($tRows as $row) { $db->query("UPDATE " . TABLE_FORUM_CATEGORIES . " SET `replies` = `replies` - " . $row['rc'] . ", `topics` = `topics` - " . $row['tc'] . " WHERE categoryID=" . $row['categoryID']); BuckysForumCategory::updateCategoryLastTopicID($row['categoryID']); } //Block Reply Votes $query = $db->prepare("SELECT count(voteID) AS c, objectID FROM " . TABLE_FORUM_VOTES . " WHERE voterID=%d AND voteStatus=1 GROUP BY objectID", $userID); $vRows = $db->getResultsArray($query); foreach ($vRows as $row) { $db->query("UPDATE " . TABLE_FORUM_REPLIES . " SET `votes` = `votes` - " . $row['c'] . " WHERE replyID=" . $row['objectID']); } //Delete Reported Objects $db->query("DELETE FROM " . TABLE_REPORTS . " WHERE objectID IN (SELECT postID FROM " . TABLE_POSTS . " WHERE poster=" . $userID . ")"); $db->query("DELETE FROM " . TABLE_REPORTS . " WHERE objectID IN (SELECT topicID FROM " . TABLE_FORUM_TOPICS . " WHERE creatorID=" . $userID . ")"); $db->query("DELETE FROM " . TABLE_REPORTS . " WHERE objectID IN (SELECT replyID FROM " . TABLE_FORUM_REPLIES . " WHERE creatorID=" . $userID . ")"); //Delete From banned Users $db->query("DELETE FROM " . TABLE_BANNED_USERS . " WHERE bannedUserID=" . $userID); //Delete Activities $db->query("DELETE FROM " . TABLE_MAIN_ACTIVITIES . " WHERE userID=" . $userID); //Delete Album Photos $db->query("DELETE FROM " . TABLE_ALBUMS_PHOTOS . " WHERE album_id IN (SELECT albumID FROM " . TABLE_ALBUMS . " WHERE OWNER=" . $userID . ")"); //Delete ALbums $db->query("DELETE FROM " . TABLE_ALBUMS . " WHERE OWNER=" . $userID); //Delete Friends $db->query("DELETE FROM " . TABLE_FRIENDS . " WHERE userID=" . $userID . " OR userFriendID=" . $userID); //Delete Messages $db->query("DELETE FROM " . TABLE_MESSAGES . " WHERE userID=" . $userID . " OR sender=" . $userID); //Delete Private Messengers $db->query("DELETE FROM " . TABLE_MESSENGER_BLOCKLIST . " WHERE userID=" . $userID . " OR blockedID=" . $userID); $db->query("DELETE FROM " . TABLE_MESSENGER_BUDDYLIST . " WHERE userID=" . $userID . " OR buddyID=" . $userID); $db->query("DELETE FROM " . TABLE_MESSENGER_MESSAGES . " WHERE userID=" . $userID . " OR buddyID=" . $userID); //Delete Posts $posts = $db->getResultsArray("SELECT * FROM " . TABLE_POSTS . " WHERE poster=" . $userID); foreach ($posts as $post) { //Delete Comments $db->query("DELETE FROM " . TABLE_POSTS_COMMENTS . " WHERE postID=" . $post['postID']); //Delete Likes $db->query("DELETE FROM " . TABLE_POSTS_LIKES . " WHERE postID=" . $post['postID']); //Delete hits $db->query("DELETE FROM " . TABLE_POSTS_HITS . " WHERE postID=" . $post['postID']); } $db->query("DELETE FROM " . TABLE_POSTS . " WHERE poster=" . $userID); //Delete Pages $pageIns = new BuckysPage(); $pageIns->deletePageByUserID($userID); //Delete Trade Section which are related to this user. $tradeIns = new BuckysTradeItem(); $tradeIns->deleteItemsByUserID($userID); //Delete Shop Section which are related to this user $shopIns = new BuckysShopProduct(); $shopIns->deleteProductsByUserID($userID); //Delete Comments $db->query("DELETE FROM " . TABLE_POSTS_COMMENTS . " WHERE commenter=" . $userID); //Delete Likes $db->query("DELETE FROM " . TABLE_POSTS_LIKES . " WHERE userID=" . $userID); //Delete Page Followers $db->query("DELETE FROM " . TABLE_PAGE_FOLLOWERS . " WHERE userID=" . $userID); //Getting Removed Topics $topicIDs = $db->getResultsArray("SELECT topicID FROM " . TABLE_FORUM_TOPICS . " WHERE creatorID=" . $userID); if (!$topicIDs) { $topicIDs = [0]; } //Delete Reply Votes $db->query("DELETE FROM " . TABLE_FORUM_VOTES . " WHERE voterID=" . $userID); $db->query("DELETE FROM " . TABLE_FORUM_VOTES . " WHERE objectID IN ( SELECT replyID FROM " . TABLE_FORUM_REPLIES . " WHERE creatorID=" . $userID . " OR topicID IN (" . implode(", ", $topicIDs) . ") )"); //Delete Replies $db->query("DELETE FROM " . TABLE_FORUM_REPLIES . " WHERE creatorID=" . $userID . " OR topicID IN (" . implode(", ", $topicIDs) . ")"); //Delete Topics $db->query("DELETE FROM " . TABLE_FORUM_TOPICS . " WHERE creatorID=" . $userID); //Delete Users /*$db->query("DELETE FROM " . TABLE_USERS . " WHERE userID=" . $userID); $db->query("DELETE FROM " . TABLE_USERS_CONTACT . " WHERE userID=" . $userID); $db->query("DELETE FROM " . TABLE_USERS_EDUCATIONS . " WHERE userID=" . $userID); $db->query("DELETE FROM " . TABLE_USERS_EMPLOYMENTS . " WHERE userID=" . $userID); $db->query("DELETE FROM " . TABLE_USERS_LINKS . " WHERE userID=" . $userID); $db->query("DELETE FROM " . TABLE_USERS_TOKEN . " WHERE userID=" . $userID);*/ //Don't delete user from the database, just update the user's status $db->query("UPDATE " . TABLE_USERS . " SET `status`=" . BuckysUser::STATUS_USER_DELETED . " WHERE userID=" . $userID); //Send $bitCoinInfo = BuckysUser::getUserBitcoinInfo($userID); if ($bitCoinInfo) { $userInfo = BuckysUser::getUserBasicInfo($userID); $content = "Your " . TNB_SITE_NAME . " account has been deleted. However, you may still access your Bitcoin wallet at:\n" . "https://blockchain.info/wallet/login\n" . "Identifier: " . $bitCoinInfo['bitcoin_guid'] . "\n" . "Password: "******"\n"; //Send Email to User buckys_sendmail($userInfo['email'], $userInfo['firstName'] . ' ' . $userInfo['lastName'], TNB_SITE_NAME . ' Account has been Deleted', $content); } }
<?php require dirname(dirname(__FILE__)) . '/includes/bootstrap.php'; if (!buckys_check_user_acl(USER_ACL_REGISTERED)) { buckys_redirect('/forum', MSG_PERMISSION_DENIED, MSG_TYPE_ERROR); } if (isset($_POST['action'])) { if ($_POST['action'] == 'create-topic') { $result = BuckysForumTopic::createTopic($_POST); if ($result == 'publish' || $result == 'pending') { buckys_redirect("/forum", MSG_TOPIC_POSTED_SUCCESSFULLY . ($result == 'pending' ? ' ' . MSG_POST_IS_UNDER_PREVIEW : ''), MSG_TYPE_SUCCESS); } else { buckys_redirect("/forum/create_topic.php", $result, MSG_TYPE_ERROR); } } } $curCatID = isset($_GET['category']) ? $_GET['category'] : 0; $categories = BuckysForumCategory::getAllCategories(); buckys_enqueue_stylesheet('editor/jquery.cleditor.css'); buckys_enqueue_stylesheet('uploadify.css'); buckys_enqueue_stylesheet('forum.css'); buckys_enqueue_javascript('jquery-migrate-1.2.0.js'); buckys_enqueue_javascript('uploadify/jquery.uploadify.js'); buckys_enqueue_javascript('editor/jquery.cleditor.js'); //buckys_enqueue_javascript('editor/jquery.cleditor.bbcode.js'); $view['action_type'] = 'create'; $BUCKYS_GLOBALS['headerType'] = 'forum'; $BUCKYS_GLOBALS['content'] = 'forum/create_topic'; $BUCKYS_GLOBALS['title'] = 'Create a New Topic - BuckysRoomForum'; require DIR_FS_TEMPLATE . $BUCKYS_GLOBALS['template'] . "/" . $BUCKYS_GLOBALS['layout'] . ".php";
/** * Remove Account * */ public function deleteUserAccount($userID) { global $db; $userID = intval($userID); //Fix Comments Count $query = $db->prepare("SELECT count(commentID) as c, postID FROM " . TABLE_POSTS_COMMENTS . " WHERE commenter=%d AND commentStatus=1 GROUP BY postID", $userID); $pcRows = $db->getResultsArray($query); foreach ($pcRows as $row) { $db->query("UPDATE " . TABLE_POSTS . " SET `comments` = `comments` - " . $row['c'] . " WHERE postID=" . $row['postID']); } //Fix Likes Count $query = $db->prepare("SELECT count(likeID) as c, postID FROM " . TABLE_POSTS_LIKES . " WHERE userID=%d AND likeStatus=1 GROUP BY postID", $userID); $plRows = $db->getResultsArray($query); foreach ($plRows as $row) { $db->query("UPDATE " . TABLE_POSTS . " SET `likes` = `likes` - " . $row['c'] . " WHERE postID=" . $row['postID']); } //Block Votes for Moderator $query = $db->prepare("SELECT count(voteID) as c, candidateID FROM " . TABLE_MODERATOR_VOTES . " WHERE voterID=%d AND voteStatus=1 GROUP BY candidateID", $userID); $vRows = $db->getResultsArray($query); foreach ($vRows as $row) { $db->query("UPDATE " . TABLE_MODERATOR_CANDIDATES . " SET `votes` = `votes` - " . $row['c'] . " WHERE candidateID=" . $row['candidateID']); } //Block Replies $query = $db->prepare("SELECT count(r.replyID), r.topicID, t.categoryID FROM " . TABLE_FORUM_REPLIES . " AS r LEFT JOIN " . TABLE_FORUM_TOPICS . " AS t ON t.topicID=r.topicID WHERE r.status='publish' AND r.creatorID=%d GROUP BY r.topicID", $userID); $rRows = $db->getResultsArray($query); $db->query("UPDATE " . TABLE_FORUM_REPLIES . " SET `status`='suspended' WHERE creatorID=" . $userID . " AND `status`='publish'"); foreach ($rRows as $row) { $db->query("UPDATE " . TABLE_FORUM_TOPICS . " SET `replies` = `replies` - " . $row['c'] . " WHERE topicID=" . $row['topicID']); $db->query("UPDATE " . TABLE_FORUM_CATEGORIES . " SET `replies` = `replies` - " . $row['c'] . " WHERE categoryID=" . $row['categoryID']); BuckysForumTopic::updateTopicLastReplyID($row['topicID']); } //Block Topics $query = $db->prepare("SELECT count(topicID) as tc, SUM(replies) as rc, categoryID FROM " . TABLE_FORUM_TOPICS . " WHERE creatorID=%d AND `status`='publish' GROUP BY categoryID", $userID); $tRows = $db->getResultsArray($query); $db->query("UPDATE " . TABLE_FORUM_TOPICS . " SET `status`='suspended' WHERE creatorID=" . $userID . " AND `status`='publish'"); foreach ($tRows as $row) { $db->query("UPDATE " . TABLE_FORUM_CATEGORIES . " SET `replies` = `replies` - " . $row['rc'] . ", `topics` = `topics` - " . $row['tc'] . " WHERE categoryID=" . $row['categoryID']); BuckysForumCategory::updateCategoryLastTopicID($row['categoryID']); } //Block Reply Votes $query = $db->prepare("SELECT count(voteID) as c, objectID FROM " . TABLE_FORUM_VOTES . " WHERE voterID=%d AND voteStatus=1 GROUP BY objectID", $userID); $vRows = $db->getResultsArray($query); foreach ($vRows as $row) { $db->query("UPDATE " . TABLE_FORUM_REPLIES . " SET `votes` = `votes` - " . $row['c'] . " WHERE replyID=" . $row['objectID']); } //Delete Reported Objects $db->query("DELETE FROM " . TABLE_REPORTS . " WHERE objectID IN (SELECT postID FROM " . TABLE_POSTS . " WHERE poster=" . $userID . ")"); $db->query("DELETE FROM " . TABLE_REPORTS . " WHERE objectID IN (SELECT topicID FROM " . TABLE_FORUM_TOPICS . " WHERE creatorID=" . $userID . ")"); $db->query("DELETE FROM " . TABLE_REPORTS . " WHERE objectID IN (SELECT replyID FROM " . TABLE_FORUM_REPLIES . " WHERE creatorID=" . $userID . ")"); //Delete From banned Users $db->query("DELETE FROM " . TABLE_BANNED_USERS . " WHERE bannedUserID=" . $userID); //Delete Activities $db->query("DELETE FROM " . TABLE_ACTIVITES . " WHERE userID=" . $userID); //Delete Album Photos $db->query("DELETE FROM " . TABLE_ALBUMS_PHOTOS . " WHERE album_id IN (SELECT albumID FROM " . TABLE_ALBUMS . " WHERE owner=" . $userID . ")"); //Delete ALbums $db->query("DELETE FROM " . TABLE_ALBUMS . " WHERE owner=" . $userID); //Delete Friends $db->query("DELETE FROM " . TABLE_FRIENDS . " WHERE userID=" . $userID . " OR userFriendID=" . $userID); //Delete Messages $db->query("DELETE FROM " . TABLE_MESSAGES . " WHERE userID=" . $userID . " OR sender=" . $userID); //Delete Private Messengers $db->query("DELETE FROM " . TABLE_MESSENGER_BLOCKLIST . " WHERE userID=" . $userID . " OR blockedID=" . $userID); $db->query("DELETE FROM " . TABLE_MESSENGER_BUDDYLIST . " WHERE userID=" . $userID . " OR buddyID=" . $userID); $db->query("DELETE FROM " . TABLE_MESSENGER_MESSAGES . " WHERE userID=" . $userID . " OR buddyID=" . $userID); //Delete Posts $posts = $db->getResultsArray("SELECT * FROM " . TABLE_POSTS . " WHERE poster=" . $userID); foreach ($posts as $post) { //Delete Comments $db->query("DELETE FROM " . TABLE_POSTS_COMMENTS . " WHERE postID=" . $post['postID']); //Delete Likes $db->query("DELETE FROM " . TABLE_POSTS_LIKES . " WHERE postID=" . $post['postID']); //Delete hits $db->query("DELETE FROM " . TABLE_POSTS_HITS . " WHERE postID=" . $post['postID']); } $db->query("DELETE FROM " . TABLE_POSTS . " WHERE poster=" . $userID); //Delete Pages $pageIns = new BuckysPage(); $pageIns->deletePageByUserID($userID); //Delete Trade Section which are related to this user. $tradeIns = new BuckysTradeItem(); $tradeIns->deleteItemsByUserID($userID); //Delete Comments $db->query("DELETE FROM " . TABLE_POSTS_COMMENTS . " WHERE commenter=" . $userID); //Delete Likes $db->query("DELETE FROM " . TABLE_POSTS_LIKES . " WHERE userID=" . $userID); //Getting Removed Topics $topicIDs = $db->getResultsArray("SELECT topicID FROM " . TABLE_FORUM_TOPICS . " WHERE creatorID=" . $userID); if (!$topicIDs) { $topicIDs = array(0); } //Delete Reply Votes $db->query("DELETE FROM " . TABLE_FORUM_VOTES . " WHERE voterID=" . $userID); $db->query("DELETE FROM " . TABLE_FORUM_VOTES . " WHERE objectID IN ( SELECT replyID FROM " . TABLE_FORUM_REPLIES . " WHERE creatorID=" . $userID . " OR topicID IN (" . implode(", ", $topicIDs) . ") )"); //Delete Replies $db->query("DELETE FROM " . TABLE_FORUM_REPLIES . " WHERE creatorID=" . $userID . " OR topicID IN (" . implode(", ", $topicIDs) . ")"); //Delete Topics $db->query("DELETE FROM " . TABLE_FORUM_TOPICS . " WHERE creatorID=" . $userID); //Delete Users /*$db->query("DELETE FROM " . TABLE_USERS . " WHERE userID=" . $userID); $db->query("DELETE FROM " . TABLE_USERS_CONTACT . " WHERE userID=" . $userID); $db->query("DELETE FROM " . TABLE_USERS_EDUCATIONS . " WHERE userID=" . $userID); $db->query("DELETE FROM " . TABLE_USERS_EMPLOYMENTS . " WHERE userID=" . $userID); $db->query("DELETE FROM " . TABLE_USERS_LINKS . " WHERE userID=" . $userID); $db->query("DELETE FROM " . TABLE_USERS_TOKEN . " WHERE userID=" . $userID);*/ //Don't delete user from the database, just update the user's status $db->query("UPDATE " . TABLE_USERS . " SET `status`=" . BuckysUser::STATUS_USER_DELETED . " WHERE userID=" . $userID); }
/** * Delete Reply * * @param Int $replyID * @return bool */ public static function deleteReply($replyID) { global $db; $query = $db->prepare("SELECT * FROM " . TABLE_FORUM_REPLIES . " WHERE replyID=%d", $replyID); $reply = $db->getRow($query); if ($reply) { if ($reply['status'] == 'publish') { //Getting Topic $query = $db->prepare("SELECT * FROM " . TABLE_FORUM_TOPICS . " WHERE topicID=%d", $reply['topicID']); $topic = $db->getRow($query); //Update Replies Count For Topic $query = "UPDATE " . TABLE_FORUM_TOPICS . " SET `replies`=`replies` - 1 WHERE topicID=" . $reply['topicID']; $db->query($query); //Update Replies Count For Category $query = "UPDATE " . TABLE_FORUM_CATEGORIES . " SET `replies`=`replies` - 1 WHERE categoryID=" . $topic['categoryID']; $db->query($query); $db->query("UPDATE " . TABLE_USERS . " SET `posts_count`=`posts_count` - 1 WHERE userID=" . $reply['creatorID']); $db->query("UPDATE " . TABLE_USERS . " SET `posts_rating`=`posts_rating`" . ($reply['votes'] > 0 ? '-' : '+') . abs($reply['votes']) . " WHERE userID=" . $reply['creatorID']); //Update Stats BuckysUser::updateStats($topic['creatorID'], 'replies', -1); BuckysUser::updateStats($reply['creatorID'], 'voteUps', -1 * $reply['votes']); } //Remove Reply Votes $query = "DELETE FROM " . TABLE_FORUM_VOTES . " WHERE objectID=" . $reply['replyID']; $db->query($query); //Delete Frome Reports Table $query = "DELETE FROM " . TABLE_REPORTS . " WHERE objectType='reply' AND objectID=" . $reply['replyID']; $db->query($query); //Remove Reply $query = "DELETE FROM " . TABLE_FORUM_REPLIES . " WHERE replyID=" . $reply['replyID']; $db->query($query); BuckysForumTopic::updateTopicLastReplyID($reply['topicID']); BuckysForumCategory::updateCategoryLastTopicID($topic['categoryID']); return true; } return false; }
$video = $videoClass->getVideo($videoID); if (!$video) { buckys_redirect("/videos.php", MSG_INVALID_REQUEST, MSG_TYPE_ERROR); exit; } $categoryID = $video['categoryID']; } if ($categoryID) { $category = $videoClass->getCategory($categoryID); $categoryVideos = $videoClass->getVideos($categoryID); if (!$videoID) { $video = $categoryVideos[0]; } //Getting Forum Recent Posts $topics = BuckysForumTopic::getTopics(1, 'publish', $category['forumCategoryID'], 'lastReplyDate DESC', 10); $forumCategory = BuckysForumCategory::getCategory($category['forumCategoryID']); //Get Prev, Next Video $prevVideoId = null; $nextVideoId = null; foreach ($categoryVideos as $idx => $v) { if ($v['videoID'] == $video['videoID']) { $nextVideoId = isset($categoryVideos[$idx + 1]) ? $categoryVideos[$idx + 1]['videoID'] : null; break; } $prevVideoId = $v['videoID']; } $subjectID = $category['subjectID']; } $videoSubject = $videoClass->getSubject($subjectID); $videoCategories = $videoClass->getVideoCategories($subjectID); if (isset($video)) {