public function getListAction()
 {
     $request = $_GET;
     $token = isset($request['TOKEN']) ? trim($request['TOKEN']) : null;
     $lastDate = isset($request['lastDate']) ? $request['lastDate'] : null;
     if (!$token) {
         return ['STATUS_CODE' => STATUS_CODE_BAD_REQUEST, 'DATA' => buckys_api_get_error_result('Api token should not be blank')];
     }
     if (!($userID = BuckysUsersToken::checkTokenValidity($token, "api"))) {
         return ['STATUS_CODE' => STATUS_CODE_UNAUTHORIZED, 'DATA' => buckys_api_get_error_result('Api token is not valid.')];
     }
     $stream = BuckysPost::getUserPostsStream($userID, $lastDate);
     //Format Result Data
     $result = [];
     foreach ($stream as $post) {
         if ($post['pageID'] != BuckysPost::INDEPENDENT_POST_PAGE_ID) {
             $pageIns = new BuckysPage();
             $pageData = $pageIns->getPageByID($post['pageID']);
         }
         $pagePostFlag = false;
         if (isset($pageData)) {
             $pagePostFlag = true;
         }
         $item = [];
         $item['articleId'] = $post['postID'];
         $item['posterId'] = $post['poster'];
         $item['articleImage'] = "";
         $item['articleVideo'] = "";
         $item['articleVideoId'] = "";
         if ($pagePostFlag) {
             $item['posterName'] = $pageData['title'];
             $item['posterThumbnail'] = buckys_not_null($pageData['logo']) ? THENEWBOSTON_SITE_URL . DIR_WS_PHOTO . "users/" . $pageData['userID'] . "/resized/" . $pageData['logo'] : THENEWBOSTON_SITE_URL . DIR_WS_IMAGE . "newPagePlaceholder.jpg";
         } else {
             $item['posterName'] = $post['posterFullName'];
             $item['posterThumbnail'] = THENEWBOSTON_SITE_URL . BuckysUser::getProfileIcon($post['poster']);
         }
         $item['postedDate'] = buckys_api_format_date($userID, $post['post_date']);
         $item['purePostedDate'] = $post['post_date'];
         $item['articleContent'] = $post['content'];
         if ($post['type'] == 'video') {
             $item['articleVideo'] = $post['youtube_url'];
             $item['articleVideoId'] = buckys_get_youtube_video_id($post['youtube_url']);
         } else {
             if ($post['type'] == 'image') {
                 $item['articleImage'] = THENEWBOSTON_SITE_URL . DIR_WS_PHOTO . 'users/' . $post['poster'] . '/resized/' . $post['image'];
             }
         }
         $item['articleLikes'] = $post['likes'];
         $item['articleComments'] = $post['comments'];
         $item['isLiked'] = !$post['likeID'] ? "no" : "yes";
         $result[] = $item;
     }
     return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ["STATUS" => "SUCCESS", "RESULT" => $result]];
 }
 public function getListAction()
 {
     global $TNB_GLOBALS, $db;
     $data = $_POST;
     $keyword = isset($data['keyword']) ? $data['keyword'] : null;
     $token = isset($data['TOKEN']) ? trim($data['TOKEN']) : null;
     $sort = "pop";
     $page = isset($data['page']) ? $data['page'] : null;
     if (!$token) {
         return ['STATUS_CODE' => STATUS_CODE_BAD_REQUEST, 'DATA' => buckys_api_get_error_result('Api token should not be blank')];
     }
     if (!($userID = BuckysUsersToken::checkTokenValidity($token, "api"))) {
         return ['STATUS_CODE' => STATUS_CODE_UNAUTHORIZED, 'DATA' => buckys_api_get_error_result('Api token is not valid.')];
     }
     //Search Results
     $searchIns = new BuckysSearch();
     $pageIns = new BuckysPage();
     $pageFollowerIns = new BuckysPageFollower();
     $db_results = $searchIns->search($keyword, BuckysSearch::SEARCH_TYPE_USER_AND_PAGE, $sort, $page);
     $results = [];
     foreach ($db_results as $item) {
         $row = [];
         if ($item['type'] == "user") {
             //User
             $row['type'] = "user";
             //Getting Detail Information
             $query = $db->prepare("SELECT \n                                u.firstName, \n                                u.lastName, \n                                u.userID, \n                                u.thumbnail, \n                                u.current_city, \n                                u.current_city_visibility,\n                                f.friendID \n                          FROM \n                                " . TABLE_USERS . " AS u\n                          LEFT JOIN " . TABLE_FRIENDS . " AS f ON f.userID=%d AND f.userFriendID=u.userID AND f.status='1'\n                          WHERE u.userID=%d", $userID, $item['userID']);
             $data = $db->getRow($query);
             $row['id'] = $item['userID'];
             $row['title'] = $data['firstName'] . " " . $data['lastName'];
             $row['description'] = $data['current_city_visibility'] ? $data['current_city'] : "";
             $row['isFriend'] = !$data['friendID'] ? 'no' : 'yes';
             $row['image'] = THENEWBOSTON_SITE_URL . BuckysUser::getProfileIcon($data);
         } else {
             $row['type'] = "page";
             //Page
             $pageData = $pageIns->getPageByID($item['pageID']);
             $followerCount = $pageFollowerIns->getNumberOfFollowers($item['pageID']);
             $row['id'] = $item['pageID'];
             $row['title'] = $pageData['title'];
             $row['description'] = number_format($followerCount) . " follower" . ($followerCount > 1 ? "s" : "");
             $row['isFollowed'] = BuckysPageFollower::isFollower($userID, $pageData['pageID']) ? 'yes' : 'no';
             $row['image'] = THENEWBOSTON_SITE_URL . (!$pageData['logo'] ? DIR_WS_IMAGE . "newPagePlaceholder.jpg" : DIR_WS_PHOTO . "users/" . $pageData['userID'] . "/resized/" . $pageData['logo']);
         }
         $results[] = $row;
     }
     return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ["STATUS" => "SUCCESS", "RESULT" => $results]];
 }
 /**
  * Check relations if it has already followed the page
  *
  * @param integer $pageID
  * @param integer $userID
  * @return bool
  */
 public function hasRelationInFollow($pageID, $userID)
 {
     global $db;
     $pageIns = new BuckysPage();
     if (!is_numeric($pageID) || !is_numeric($userID)) {
         return false;
     }
     // failed
     $pageData = $pageIns->getPageByID($pageID);
     if ($pageData['userID'] == $userID) {
         //It means you are the owner of this page.
         //            return true;
     }
     $query = sprintf("SELECT * FROM %s WHERE pageID=%d AND userID=%d", TABLE_PAGE_FOLLOWERS, $pageID, $userID);
     if ($db->getRow($query)) {
         return true;
     } else {
         return false;
     }
 }
示例#4
0
<?php

require dirname(__FILE__) . '/includes/bootstrap.php';
//Getting Current User ID
$userID = buckys_is_logged_in();
$pageIns = new BuckysPage();
$pageFollowerIns = new BuckysPageFollower();
$paramPageID = isset($_GET['pid']) ? intval($_GET['pid']) : null;
$pageData = $pageIns->getPageByID($paramPageID);
//If the parameter is null, goto homepage
if (!buckys_not_null($pageData)) {
    buckys_redirect('/index.php');
}
$page = isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : 1;
$totalCount = $pageFollowerIns->getNumberOfFollowers($pageData['pageID']);
$pagination = new Pagination($totalCount, BuckysPageFollower::COUNT_PER_PAGE, $page);
$page = $pagination->getCurrentPage();
//Get Friends
$view['followers'] = $pageFollowerIns->getFollowers($pageData['pageID'], $page, BuckysPageFollower::COUNT_PER_PAGE);
$view['pageData'] = $pageData;
buckys_enqueue_stylesheet('profile.css');
buckys_enqueue_stylesheet('friends.css');
buckys_enqueue_stylesheet('account.css');
buckys_enqueue_stylesheet('stream.css');
buckys_enqueue_stylesheet('posting.css');
buckys_enqueue_stylesheet('uploadify.css');
buckys_enqueue_stylesheet('jquery.Jcrop.css');
buckys_enqueue_stylesheet('page.css');
buckys_enqueue_javascript('uploadify/jquery.uploadify.js');
buckys_enqueue_javascript('jquery.Jcrop.js');
buckys_enqueue_javascript('jquery.color.js');
</a>
        <br/> <a href="/myfriends.php?type=pending" class="accountSubLinks">Pending</a> <br/>

        <!-- <a href="/moderator.php" class="accountLinks">Vote</a> -->

        <?php 
    ?>
        <h6>Page Manager</h6>
        <!-- <a href="/follows.php?user=<?php 
    echo $userID;
    ?>
" class="accountLinks">Groups</a> -->
        <a href="/page_add.php" class="accountSubLinks">Create New Page</a><br/>
        <?php 
    //Get my created pages link
    $pageIns = new BuckysPage();
    $pageList = $pageIns->getPagesByUserId($userID);
    if (count($pageList) > 0) {
        foreach ($pageList as $pageD) {
            echo sprintf('<a href="/page.php?pid=%d" class="accountSubLinks">%s</a><br/>', $pageD['pageID'], $pageD['title']);
        }
    }
    ?>

        <!-- Control Panel-->
        <?php 
    if (buckys_check_user_acl(USER_ACL_MODERATOR)) {
        ?>
            <?php 
        $reportedItems = BuckysReport::getReportedObjectCount();
        $pendingAds = BuckysAds::getPendingAdsCount();
 /**
  * Save Post
  *
  * @param $userID
  * @param mixed $data
  * @return bool|int|null|string
  */
 public static function savePhoto($userID, $data)
 {
     global $db, $TNB_GLOBALS;
     //Check the Photo File Name
     if (!isset($data['file']) || strpos($data['file'], "../") !== false || !file_exists(DIR_FS_PHOTO_TMP . $data['file'])) {
         buckys_add_message(MSG_FILE_UPLOAD_ERROR, MSG_TYPE_ERROR);
         return false;
     }
     $data['pageID'] = isset($data['pageID']) && is_numeric($data['pageID']) ? $data['pageID'] : BuckysPost::INDEPENDENT_POST_PAGE_ID;
     // Validate the file type
     $fileParts = pathinfo($data['file']);
     if (!in_array(strtolower($fileParts['extension']), $TNB_GLOBALS['imageTypes'])) {
         buckys_add_message(MSG_INVALID_PHOTO_TYPE, MSG_TYPE_ERROR);
         return false;
     }
     //Validate File Size
     list($width, $height, $type, $attr) = getimagesize(DIR_FS_PHOTO_TMP . $data['file']);
     if ($width * $height > MAX_IMAGE_WIDTH * MAX_IMAGE_HEIGHT) {
         buckys_add_message(MSG_PHOTO_MAX_SIZE_ERROR, MSG_TYPE_ERROR);
         return false;
     }
     //Checking File Size and move it from the tmp folder to the user photo folder and resize it.
     if ($data['post_visibility'] == 2) {
         //Calc Ratio using real image width
         $ratio = floatval($width / $data['width']);
         $sourceWidth = ($data['x2'] - $data['x1']) * $ratio;
         BuckysPost::moveFileFromTmpToUserFolder($userID, $data['file'], PROFILE_IMAGE_WIDTH, PROFILE_IMAGE_HEIGHT, $data['x1'] * $ratio, $data['y1'] * $ratio, $sourceWidth, $sourceWidth);
         if ($data['pageID'] == BuckysPost::INDEPENDENT_POST_PAGE_ID) {
             //Update User Profile Field
             BuckysUser::updateUserFields($userID, ['thumbnail' => $data['file']]);
             $is_profile = 1;
         } else {
             //Update Page Profile field
             $pageIns = new BuckysPage();
             $pageIns->updateData($data['pageID'], ['logo' => $data['file']]);
             $is_profile = 1;
         }
     } else {
         if ($width > MAX_POST_IMAGE_WIDTH) {
             $height = $height * (MAX_POST_IMAGE_WIDTH / $width);
             $width = MAX_POST_IMAGE_WIDTH;
         }
         if ($height > MAX_POST_IMAGE_HEIGHT) {
             $width = $width * (MAX_POST_IMAGE_HEIGHT / $height);
             $height = MAX_POST_IMAGE_HEIGHT;
         }
         //Create normal image
         BuckysPost::moveFileFromTmpToUserFolder($userID, $data['file'], $width, $height, 0, 0);
         $is_profile = 0;
     }
     $now = date('Y-m-d H:i:s');
     $newId = $db->insertFromArray(TABLE_POSTS, ['poster' => $userID, 'pageID' => $data['pageID'], 'profileID' => $data['profileID'], 'content' => $data['content'], 'type' => 'image', 'post_date' => $now, 'image' => $data['file'], 'visibility' => $data['post_visibility'] > 0 ? 1 : 0, 'is_profile' => $is_profile]);
     if (!$newId) {
         buckys_add_message($db->getLastError(), MSG_TYPE_ERROR);
         return false;
     }
     //Assign Photo to Album
     if (isset($data['album']) && $data['album'] != '') {
         if (!BuckysAlbum::checkAlbumOwner($data['album'], $userID)) {
             buckys_add_message(MSG_INVALID_ALBUM_ID, MSG_TYPE_ERROR);
         } else {
             BuckysAlbum::addPhotoToAlbum($data['album'], $newId);
         }
     }
     buckys_add_message(MSG_PHOTO_UPLOADED_SUCCESSFULLY);
     return $newId;
 }
示例#7
0
<?php

if (!isset($BUCKYS_GLOBALS)) {
    die("Invalid Request!");
}
$userIns = new BuckysUser();
$pageIns = new BuckysPage();
$pageFollowerIns = new BuckysPageFollower();
$searcuResult = $view['search_result'];
?>

<script type="text/javascript">
    
</script>

<section id="main_section">
    
    <?php 
buckys_get_panel('top_search');
?>
    
    
    <section id="main_content" class="search-result-panel">
            
            <?php 
render_result_messages();
?>
            
            <div class="search-result-list">
                <?php 
if (count($searcuResult) > 0) {
示例#8
0
function buckys_get_single_post_html($post, $userID, $isPostPage = false, $pageData = null)
{
    ob_start();
    if ($post['pageID'] != BuckysPost::INDEPENDENT_POST_PAGE_ID) {
        $pageIns = new BuckysPage();
        $pageData = $pageIns->getPageByID($post['pageID']);
    }
    $pagePostFlag = false;
    if (isset($pageData)) {
        $pagePostFlag = true;
    }
    ?>
    <div class="post-item" id=<?php 
    echo $post['postID'];
    ?>
>
            
                <?php 
    if ($pagePostFlag) {
        ?>
                    <?php 
        render_pagethumb_link($pageData, 'postIcons');
        ?>
                <?php 
    } else {
        ?>
                    <a href="/profile.php?user=<?php 
        echo $post['poster'];
        ?>
" class="poster-thumb"><img src="<?php 
        echo BuckysUser::getProfileIcon($post['poster']);
        ?>
" class="postIcons" /></a>
                <?php 
    }
    ?>
            
            <div class="post-content">
                
                <?php 
    if ($pagePostFlag) {
        ?>
                    <div class="post-author"><a href="page.php?pid=<?php 
        echo $pageData['pageID'];
        ?>
"><b><?php 
        echo $pageData['title'];
        ?>
</b></a></div>
                <?php 
    } else {
        ?>
                    <div class="post-author"><a href="profile.php?user=<?php 
        echo $post['poster'];
        ?>
"><b><?php 
        echo $post['posterFullName'];
        ?>
</b></a></div>
                <?php 
    }
    ?>
                
                
                <?php 
    echo buckys_process_post_content($post, $pageData);
    ?>
                <div class="post-date">
                    <span class="lft">
                        <?php 
    if (buckys_not_null($userID) && $post['poster'] != $userID) {
        ?>
                        <a href='/manage_post.php?action=<?php 
        echo buckys_not_null($post['likeID']) ? 'unlikePost' : 'likePost';
        ?>
&postID=<?php 
        echo $post['postID'];
        ?>
' class="like-post-link"><?php 
        echo buckys_not_null($post['likeID']) ? 'Unlike' : 'Like';
        ?>
</a> &middot;
                        <?php 
    }
    ?>
                        <?php 
    if (buckys_not_null($userID) && $post['poster'] == $userID) {
        ?>
                        <a href='/manage_post.php?action=delete-post&userID=<?php 
        echo $userID;
        ?>
&postID=<?php 
        echo $post['postID'];
        ?>
' class="remove-post-link">Delete</a> &middot;
                        <?php 
    }
    ?>
                        <span><?php 
    echo buckys_format_date($post['post_date']);
    ?>
</span>
                        <?php 
    if (buckys_not_null($userID) && $post['poster'] != $userID && !$post['reportID']) {
        ?>
                        &middot; <a href="/report_object.php" data-type="post" data-id="<?php 
        echo $post['postID'];
        ?>
" data-idHash="<?php 
        echo buckys_encrypt_id($post['postID']);
        ?>
" class="report-link">Report</a>
                        <?php 
    }
    ?>
                    </span>
                    <span class="rgt">
                        <?php 
    echo $post['visibility'] ? 'Public' : 'Private';
    ?>
                    </span>
                    <div class="clear"></div>
                </div>
                <div class="post-like-comment"> 
                    <?php 
    if ($pagePostFlag) {
        ?>
                        
                        <a href="/page.php?pid=<?php 
        echo $pageData['pageID'];
        ?>
&post=<?php 
        echo $post['postID'];
        ?>
" class="usersThatLiked likes-link"><?php 
        echo $post['likes'] > 1 ? $post['likes'] . " likes" : $post['likes'] . " like";
        ?>
 </a>
                        &middot;
                        <a href="/page.php?pid=<?php 
        echo $pageData['pageID'];
        ?>
&post=<?php 
        echo $post['postID'];
        ?>
" class="usersThatLiked"><?php 
        echo $post['comments'] > 1 ? $post['comments'] . " comments" : $post['comments'] . " comment";
        ?>
 </a>
                        
                    <?php 
    } else {
        ?>
                        <a href="/posts.php?user=<?php 
        echo $post['poster'];
        ?>
&post=<?php 
        echo $post['postID'];
        ?>
" class="usersThatLiked likes-link"><?php 
        echo $post['likes'] > 1 ? $post['likes'] . " likes" : $post['likes'] . " like";
        ?>
 </a>
                        &middot;
                        <a href="/posts.php?user=<?php 
        echo $post['poster'];
        ?>
&post=<?php 
        echo $post['postID'];
        ?>
" class="usersThatLiked"><?php 
        echo $post['comments'] > 1 ? $post['comments'] . " comments" : $post['comments'] . " comment";
        ?>
 </a>
                    <?php 
    }
    ?>
                </div>
                <?php 
    if ($post['likes'] > 0) {
        $likedUsers = BuckysPost::getLikedUsers($post['postID']);
        ?>
                <div class="liked-users">
                    <ul>
                        <?php 
        foreach ($likedUsers as $l) {
            ?>
                        <li><a href="/profile.php?user=<?php 
            echo $l['userID'];
            ?>
"><img src="<?php 
            echo BuckysUser::getProfileIcon($l);
            ?>
"> <span><?php 
            echo $l['firstName'] . " " . $l['lastName'];
            ?>
</span></a></li>
                        <?php 
        }
        ?>
                        <?php 
        if ($post['likes'] > 30) {
            ?>
                        <li class="more-likes">+ <?php 
            echo $post['likes'] - count($likedUsers);
            ?>
 more</li>
                        <?php 
        }
        ?>
                    </ul>                    
                </div>
                <?php 
    }
    ?>
                <?php 
    if (buckys_not_null($userID)) {
        ?>
                <div class="post-new-comment"> 
                    <a href="/profile.php?user=<?php 
        echo $userID;
        ?>
"><img src="<?php 
        echo BuckysUser::getProfileIcon($userID);
        ?>
" class="replyToPostIcons" /></a>
                    <form method="post" class="postcommentform" name="postcommentform" action="">
                        <input type="text" class="input" name="comment" placeholder="Write a comment...">
                        <input type="hidden" name="postID" value="<?php 
        echo $post['postID'];
        ?>
" />
                        <input type="submit" value="Post Comment" id="submit_post_reply" class="redButton" />
                        <?php 
        render_loading_wrapper();
        ?>
                    </form>
                </div>
                <?php 
    }
    ?>
                <?php 
    $comments = BuckysComment::getPostComments($post['postID']);
    echo render_post_comments($comments, $userID);
    if (count($comments) > 0 && BuckysComment::hasMoreComments($post['postID'], $comments[count($comments) - 1]['posted_date'])) {
        ?>
                                
                <a href="#" class="show-more-comments" data-last-date="<?php 
        echo $comments[count($comments) - 1]['posted_date'];
        ?>
" data-post-id="<?php 
        echo $post['postID'];
        ?>
">view more</a>
                <?php 
    }
    ?>
            </div>
            <input type="hidden" class="post-created-date" value="<?php 
    echo $post['post_date'];
    ?>
" />
        </div>    
    <?php 
    $html = ob_get_contents();
    ob_end_clean();
    return $html;
}
 /**
  * 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']);
         }
     }
 }
示例#10
0
 /**
  * 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);
 }
示例#11
0
<?php

require dirname(__FILE__) . '/includes/bootstrap.php';
$userID = buckys_is_logged_in();
//Read Parameters (common)
$paramAction = 'view';
if (isset($_REQUEST['action'])) {
    $paramAction = get_secure_string($_REQUEST['action']);
}
$pageIns = new BuckysPage();
$pageFollowerIns = new BuckysPageFollower();
//Capture Ajax requests (such as save title, ... here)
if (is_numeric($userID)) {
    switch ($paramAction) {
        //============ Update About Content By Ajax =================//
        case 'updateAbout':
            $paramPageID = get_secure_integer($_REQUEST['pageID']);
            $paramContent = get_secure_string($_REQUEST['content']);
            $pageData = $pageIns->getPageByID($paramPageID);
            if ($pageData && $pageData['userID'] == $userID) {
                $data['about'] = $paramContent;
                $pageIns->updateData($paramPageID, $data);
                echo json_encode(['success' => 1, 'msg' => MSG_CONTENT_UPDATED_SUCCESS, 'content' => $paramContent, 'content_display' => render_enter_to_br($paramContent)]);
            } else {
                if (empty($pageData)) {
                    //No such page exists
                    echo json_encode(['success' => 0, 'msg' => MSG_NO_SUCH_PAGE]);
                } else {
                    //You don't have permission to update content
                    echo json_encode(['success' => 0, 'msg' => MSG_NO_PERMISSION_TO_EDIT_PAGE]);
                }
    /**
     * @param $row
     * @param $userID
     * @return string
     */
    public static function getActivityHTML($row, $userID)
    {
        ob_start();
        $user = BuckysUser::getUserBasicInfo($row['userID']);
        $owner = BuckysUser::getUserBasicInfo($row['poster']);
        $pagePostFlag = false;
        if ($row['pageID'] != BuckysPost::INDEPENDENT_POST_PAGE_ID) {
            $pageIns = new BuckysPage();
            $pageData = $pageIns->getPageByID($row['pageID']);
        }
        if (isset($pageData)) {
            $pagePostFlag = true;
        }
        if ($pagePostFlag) {
            $objectLink = "/page.php?pid=" . $row['pageID'] . "&post=" . $row['objectID'];
            $authorLink = '/page.php?pid=' . $row['pageID'];
        } else {
            $objectLink = "/posts.php?user="******"&post=" . $row['objectID'];
            $authorLink = '/profile.php?user='******'poster'];
        }
        if ($row['activityType'] == 'like') {
            ?>
            <div class="activityComment">
                <?php 
            render_profile_link($user, 'replyToPostIcons');
            ?>
                <span>
                    <a href="/profile.php?user=<?php 
            echo $row['userID'];
            ?>
"
                        class="userName"><?php 
            echo $user['firstName'] . " " . $user['lastName'];
            ?>
</a>
                    liked <?php 
            echo $row['poster'] == $userID ? 'your' : "<a href='/profile.php?user="******"' class=\"userName\">" . $owner['firstName'] . " " . $owner['lastName'] . "'s</a>";
            ?>
                    <?php 
            switch ($row['type']) {
                case "image":
                    echo "<a href='" . $objectLink . "'>photo</a>";
                    break;
                case "video":
                    echo "<a href='" . $objectLink . "'>video</a>";
                    break;
                case "text":
                default:
                    echo "<a href='" . $objectLink . "'>post</a> ";
                    if (strlen(buckys_trunc_content($row['content'], 60)) > 0) {
                        echo '&#8220;' . buckys_trunc_content($row['content'], 60) . '&#8221;';
                    }
                    break;
            }
            ?>
                </span>
            </div>
            
            <?php 
        } else {
            if ($row['activityType'] == 'comment') {
                ?>
            <div class="activityComment">                
                <?php 
                render_profile_link($user, 'replyToPostIcons');
                ?>
                <span>
                    <a href="/profile.php?user=<?php 
                echo $row['userID'];
                ?>
"
                        class="userName"><?php 
                echo $user['firstName'] . " " . $user['lastName'];
                ?>
</a>
                    left a comment on 
                    <?php 
                if ($row['poster'] == $userID) {
                    echo 'your';
                } else {
                    if ($row['poster'] == $row['userID']) {
                        //Getting User Data
                        $tUinfo = BuckysUser::getUserBasicInfo($row['userID']);
                        switch (strtolower($tUinfo['gender'])) {
                            case 'male':
                                echo 'his';
                                break;
                            case 'female':
                                echo 'her';
                                break;
                                break;
                                echo 'their';
                                break;
                        }
                    } else {
                        echo "<a href='/profile.php?user="******"' class=\"userName\">" . $owner['firstName'] . " " . $owner['lastName'] . "'s</a>";
                    }
                }
                ?>
 
                    <?php 
                switch ($row['type']) {
                    case "image":
                        echo "<a href='" . $objectLink . "'>photo</a>";
                        break;
                    case "video":
                        echo "<a href='" . $objectLink . "'>video</a>";
                        break;
                    case "text":
                    default:
                        echo "<a href='" . $objectLink . "'>post</a> ";
                        break;
                }
                if (strlen(buckys_trunc_content($row['comment_content'], 25)) > 0) {
                    echo ': &#8220;' . buckys_trunc_content($row['comment_content'], 25) . '&#8221;';
                }
                ?>
                    
                </span>
            </div>
            <?php 
            }
        }
        $html = ob_get_contents();
        ob_end_clean();
        return $html;
    }
示例#13
0
<?php

require dirname(__FILE__) . '/includes/bootstrap.php';
$userID = buckys_is_logged_in();
$popularImages = BuckysPost::getPostsFromStats('image');
$popularPosts = BuckysPost::getPostsFromStats('text');
$popularVideos = BuckysPost::getPostsFromStats('video');
$popularPages = BuckysPage::getPopularPagesForHomepage();
$recentTopics = BuckysForumTopic::getTopics(1, 'publish', null, 'lastReplyDate DESC, t.createdDate DESC', 5);
$recentTradeItems = BuckysTradeItem::getRecentItems(3);
buckys_enqueue_stylesheet('index.css');
$BUCKYS_GLOBALS['content'] = "home";
$BUCKYS_GLOBALS['title'] = "BuckysRoom - The Worlds Most Popular Open Source Social Network";
require DIR_FS_TEMPLATE . $BUCKYS_GLOBALS['template'] . "/" . $BUCKYS_GLOBALS['layout'] . ".php";
    }
    if (!$_POST['pageName']) {
        buckys_redirect("/page_add.php", MSG_PAGE_NAME_EMPTY, MSG_TYPE_ERROR);
    }
    if (!$_POST['file']) {
        buckys_redirect("/page_add.php", MSG_PAGE_LOGO_EMPTY, MSG_TYPE_ERROR);
    }
    if (!isset($_POST['file']) || strpos($_POST['file'], "../") !== false || !file_exists(DIR_FS_PHOTO_TMP . $_POST['file'])) {
        buckys_redirect("/page_add.php", MSG_FILE_UPLOAD_ERROR, MSG_TYPE_ERROR);
    }
    $fileParts = pathinfo($_POST['file']);
    if (!in_array(strtolower($fileParts['extension']), $TNB_GLOBALS['imageTypes'])) {
        buckys_redirect("/page_add.php", MSG_INVALID_PHOTO_TYPE, MSG_TYPE_ERROR);
        return false;
    }
    $pageClass = new BuckysPage();
    if ($pageID = $pageClass->addPage($userID, $_POST)) {
        buckys_add_message(MSG_PAGE_CREATED_SUCCESSFULLY, MSG_TYPE_SUCCESS);
        buckys_redirect("/page.php?pid=" . $pageID);
    } else {
        buckys_redirect("/page_add.php");
    }
}
buckys_enqueue_stylesheet('account.css');
buckys_enqueue_stylesheet('uploadify.css');
buckys_enqueue_stylesheet('jquery.Jcrop.css');
buckys_enqueue_stylesheet('posting.css');
buckys_enqueue_stylesheet('page.css');
buckys_enqueue_javascript('uploadify/jquery.uploadify.js');
buckys_enqueue_javascript('jquery.Jcrop.js');
buckys_enqueue_javascript('jquery.color.js');
 /**
  * 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);
     }
 }