public function getNewNotificationAction()
 {
     global $TNB_GLOBALS, $db;
     $data = $_POST;
     $token = isset($data['TOKEN']) ? trim($data['TOKEN']) : 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.')];
     }
     $notifications = BuckysActivity::getAppNotifications($userID, $data['page']);
     $results = [];
     foreach ($notifications as $row) {
         $item = [];
         $item['postID'] = $row['postID'];
         $item['userID'] = $row['userID'];
         $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);
         $item['userName'] = $data['firstName'] . " " . $data['lastName'];
         $item['comment_content'] = $row['comment_content'];
         $item['userThumbnail'] = THENEWBOSTON_SITE_URL . BuckysUser::getProfileIcon($data);
         $item['type'] = $row['type'];
         $item['activityType'] = $row['activityType'];
         $item['post_date'] = buckys_api_format_date($userID, $row['post_date']);
         $item['isNew'] = $row['isNew'];
         $results[] = $item;
     }
     return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ["STATUS" => "SUCCESS", "RESULT" => $results]];
 }
 /**
  * Create New Message
  * 
  * @param mixed $data
  */
 public function composeMessage($data)
 {
     global $db;
     $receivers = $data['to'];
     if (!buckys_not_null($receivers)) {
         buckys_add_message(MSG_SENDER_EMPTY_ERROR, MSG_TYPE_ERROR);
         return false;
     }
     if (trim($data['subject']) == '') {
         buckys_add_message(MSG_MESSAGE_SUBJECT_EMPTY_ERROR, MSG_TYPE_ERROR);
         return false;
     }
     if (trim($data['body']) == '') {
         buckys_add_message(MSG_MESSAGE_BODY_EMPTY_ERROR, MSG_TYPE_ERROR);
         return false;
     }
     $createdDate = date("Y-m-d H:i:s");
     if (!is_array($receivers)) {
         $receivers = array($receivers);
     }
     //Remove Duplicated Messages
     $receivers = array_unique($receivers);
     $nonFriend = array();
     $sents = array();
     $errors = array();
     $isError = false;
     foreach ($receivers as $receiver) {
         //Create A message row for Sender
         $sender = $data['userID'];
         $receiverInfo = BuckysUser::getUserBasicInfo($receiver);
         //confirm that current user and receiver is friend
         /*if(!BuckysFriend::isFriend($receiver, $sender))
           {                                
               $nonFriend[] = $receiverInfo['firstName'] . " " . $receiverInfo['lastName'];
               $isError = true;
               continue;
           }*/
         $insertData = array('userID' => $sender, 'sender' => $sender, 'receiver' => $receiver, 'subject' => $data['subject'], 'body' => $data['body'], 'status' => 'read', 'created_date' => $createdDate);
         $newId1 = $db->insertFromArray(TABLE_MESSAGES, $insertData);
         //Create A message row for receiver
         $sender = $data['userID'];
         $insertData = array('userID' => $receiver, 'sender' => $sender, 'receiver' => $receiver, 'subject' => $data['subject'], 'body' => $data['body'], 'status' => 'unread', 'created_date' => $createdDate);
         $newId2 = $db->insertFromArray(TABLE_MESSAGES, $insertData);
         $sents[] = $receiverInfo['firstName'] . ' ' . $receiverInfo['lastName'];
     }
     if (count($sents) > 0) {
         buckys_add_message(MSG_NEW_MESSAGE_SENT, MSG_TYPE_SUCCESS);
     }
     if (count($nonFriend) > 0) {
         if (count($nonFriend) > 1) {
             $msg = sprintf(MSG_COMPOSE_MESSAGE_ERROR_TO_NON_FRIENDS, implode(", ", $nonFriend));
         } else {
             $msg = sprintf(MSG_COMPOSE_MESSAGE_ERROR_TO_NON_FRIEND, $nonFriend[0]);
         }
         buckys_add_message($msg, MSG_TYPE_ERROR);
     }
     return !$isError;
 }
 /**
  * @param      $userID
  * @param      $tokenType
  * @param null $token
  * @return null|string
  */
 public static function createNewToken($userID, $tokenType, $token = null)
 {
     global $db;
     $info = BuckysUser::getUserData($userID);
     if (!$token) {
         $token = md5(mt_rand(0, 99999) . time() . mt_rand(0, 99999) . $info['email'] . mt_rand(0, 99999));
     }
     $newID = $db->insertFromArray(TABLE_USERS_TOKEN, ['userID' => $userID, 'userToken' => $token, 'tokenDate' => time(), 'tokenType' => $tokenType]);
     return $token;
 }
 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]];
 }
 /**
  * make payment
  *
  * @param mixed $buyerID
  * @param mixed $sellerID
  * @param mixed $amount
  */
 public function makePayment($buyerID, $sellerID, $amount)
 {
     $sellerBitcoinInfo = BuckysUser::getUserBitcoinInfo($sellerID);
     if ($amount <= 0 || !$sellerBitcoinInfo) {
         return false;
         //no payment
     }
     $flag = BuckysBitcoin::sendBitcoin($buyerID, $sellerBitcoinInfo['bitcoin_address'], $amount);
     buckys_get_messages();
     // this will flash the messages
     return $flag;
 }
 /**
  * Add notification for the users whose 'My post approved' set 1.
  * 
  * @param Int $ownerID
  * @param Int $topicID
  * @param Int $replyID
  */
 public function addNotificationsForPendingPost($ownerID, $topicID, $replyID = null)
 {
     global $db, $BUCKYS_GLOBALS;
     $forumSettings = BuckysUser::getUserForumSettings($ownerID);
     $activity = new BuckysActivity();
     if ($forumSettings['notifyRepliedToMyTopic']) {
         if ($replyID == null) {
             $activity->addActivity($ownerID, $topicID, 'forum', BuckysForumNotification::ACTION_TYPE_TOPIC_APPROVED, 0);
         } else {
             $activity->addActivity($ownerID, $topicID, 'forum', BuckysForumNotification::ACTION_TYPE_REPLY_APPROVED, $replyID);
         }
     }
     return true;
 }
 public function getFriendListAction()
 {
     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) {
         if ($item['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);
             if ($data['friendID']) {
                 $row = [];
                 $row['id'] = $item['userID'];
                 $row['name'] = $data['firstName'] . " " . $data['lastName'];
                 $row['description'] = $data['current_city_visibility'] ? $data['current_city'] : "";
                 $row['friendType'] = "user";
                 $row['thumbnail'] = THENEWBOSTON_SITE_URL . BuckysUser::getProfileIcon($data);
                 $results[] = $row;
             }
         }
     }
     return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ["STATUS" => "SUCCESS", "RESULT" => $results]];
 }
 public function getPendingAction()
 {
     $request = $_GET;
     $token = isset($request['TOKEN']) ? trim($request['TOKEN']) : 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.')];
     }
     $friends = BuckysFriend::getPendingRequests($userID);
     $results = [];
     foreach ($friends as $row) {
         $item = [];
         $item['id'] = $row['userID'];
         $item['name'] = $row['fullName'];
         $item['thumbnail'] = THENEWBOSTON_SITE_URL . BuckysUser::getProfileIcon($row['userID']);
         $item['description'] = $row['city'];
         $item['friendType'] = $row['status'];
         $results[] = $item;
     }
     return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ["STATUS" => "SUCCESS", "RESULT" => $results]];
 }
function buckys_api_format_date($userID, $date, $format = 'F j, Y')
{
    global $TNB_GLOBALS;
    $timeOffset = 0;
    $userInfo = BuckysUser::getUserBasicInfo($userID);
    $timeOffset = $TNB_GLOBALS['timezone'][$userInfo['timezone']];
    $strDate = "";
    $now = time();
    $today = date("Y-m-d");
    $cToday = date("Y-m-d", strtotime($date));
    if ($cToday == $today) {
        $h = floor(($now - strtotime($date)) / 3600);
        $m = floor(($now - strtotime($date)) % 3600 / 60);
        $s = floor(($now - strtotime($date)) % 3600 % 60);
        if ($s > 40) {
            $m++;
        }
        if ($h > 0) {
            $strDate = $h . " hour" . ($h > 1 ? "s " : " ");
        }
        if ($m > 0) {
            $strDate .= $m . " minute" . ($m > 1 ? "s " : " ");
        }
        if ($strDate == "") {
            if ($s == 0) {
                $s = 1;
            }
            $strDate .= $s . " second" . ($s > 1 ? "s " : " ");
        }
        $strDate .= "ago";
    } else {
        $strDate = date($format, strtotime($date) + $timeOffset * 60 * 60);
        //        $strDate = date("F j, Y h:i A", strtotime($date));
    }
    return $strDate;
}
 /**
  * Remove page followers when removing page
  *
  * @param mixed $pageID
  */
 public function removeAllFollowersByPageID($pageID)
 {
     global $db;
     if (!is_numeric($pageID)) {
         return;
     }
     //Getting Followers
     $query = $db->prepare("SELECT userID FROM " . TABLE_PAGES . " WHERE pageID=%d", $pageID);
     $pageCreatorId = $db->getVar($query);
     //Getting Followers
     $query = $db->prepare("SELECT count(*) FROM " . TABLE_PAGE_FOLLOWERS . " WHERE pageID=%d", $pageID);
     $followers = $db->getVar($query);
     if ($followers > 0) {
         BuckysUser::updateStats($pageCreatorId, 'pageFollowers', -1 * $followers);
     }
     $query = sprintf("DELETE FROM %s WHERE pageID=%d", TABLE_PAGE_FOLLOWERS, $pageID);
     $db->query($query);
     return;
 }
Example #11
0
    buckys_redirect('/index.php');
}
//Getting UserData from Id
$userData = BuckysUser::getUserLinks($userID);
if (isset($_POST['action'])) {
    //Check the user id is same with the current logged user id
    if ($_POST['userID'] != $userID) {
        echo 'Invalid Request!';
        exit;
    }
    //Save Address
    if ($_POST['action'] == 'save_links') {
        $data = array();
        for ($i = 0; $i < count($_POST['title']); $i++) {
            $data[] = array('title' => $_POST['title'][$i], 'url' => $_POST['url'][$i], 'visibility' => $_POST['visibility'][$i]);
        }
        //Update User Phone numbers
        if (BuckysUser::updateUserLinks($userID, $data)) {
            echo 'Success';
        } else {
            echo $db->getLastError();
        }
        exit;
    }
}
buckys_enqueue_stylesheet('account.css');
buckys_enqueue_stylesheet('info.css');
buckys_enqueue_javascript('info.js');
$BUCKYS_GLOBALS['content'] = 'info_links';
$BUCKYS_GLOBALS['title'] = "Info Links - BuckysRoom";
require DIR_FS_TEMPLATE . $BUCKYS_GLOBALS['template'] . "/" . $BUCKYS_GLOBALS['layout'] . ".php";
        echo $subCat['categoryID'];
        ?>
"
                                    style="font-weight:bold;"><?php 
        echo $subCat['categoryName'];
        ?>
</a> <br/> <span
                                    style="color:#999999;font-size:11px;"><?php 
        echo $categoryDescription;
        ?>
</span>
                            </td>
                            <td>
                                <?php 
        if ($subCat['lastTopicID'] > 0) {
            echo '<a href="/profile.php?user='******'lastPosterID'] . '"><img src="' . BuckysUser::getProfileIcon($subCat['lastPosterID']) . '" class="poster-icon" /></a>';
            echo "<a href='/forum/topic.php?id=" . $subCat['lastTopicID'] . "'>";
            if (strlen($subCat['lastPostTitle']) > 200) {
                echo substr($subCat['lastPostTitle'], 0, 195) . "...";
            } else {
                echo $subCat['lastPostTitle'];
            }
            echo "</a><br />";
            ?>
                                    <a style="font-weight:bold;"
                                        href="/profile.php?user=<?php 
            echo $subCat['lastPosterID'];
            ?>
"><?php 
            echo $subCat['lastPosterName'];
            ?>

                <?php 
    foreach ($tradeList as $tradeData) {
        $myPrefix = '';
        $theirPrefix = '';
        if ($tradeData['sellerID'] == $view['myID']) {
            //I'm seller for this tradeData
            $myPrefix = 'seller';
            $theirPrefix = 'buyer';
        } else {
            //I'm buyer for this tradeData
            $myPrefix = 'buyer';
            $theirPrefix = 'seller';
        }
        $userIns = new BuckysUser();
        $tradeData['theirBasicInfo'] = $userIns->getUserBasicInfo($tradeData[$theirPrefix . 'ID']);
        $myTrackingNumber = $tradeData[$myPrefix . 'TrackingNo'];
        $theirTrackingNumber = $tradeData[$theirPrefix . 'TrackingNo'];
        // $myItemImage = fn_buckys_get_item_first_image_thumb($tradeData[$myPrefix . 'ItemImages']);
        // $theirItemImage = fn_buckys_get_item_first_image_thumb($tradeData[$theirPrefix . 'ItemImages']);
        $myItemImage = fn_buckys_get_item_first_image_normal($tradeData[$myPrefix . 'ItemImages']);
        $theirItemImage = fn_buckys_get_item_first_image_normal($tradeData[$theirPrefix . 'ItemImages']);
        $sendMessageLink = '/messages_compose.php?to=' . $tradeData[$theirPrefix . 'ID'];
        $dateCreated = date('n/j/y', strtotime($tradeData['tradeCreatedDate']));
        $myItemLink = '/trade/view.php?id=' . $tradeData[$myPrefix . 'ItemID'];
        $theirItemLink = '/trade/view.php?id=' . $tradeData[$theirPrefix . 'ItemID'];
        $totalRating = 'No';
        $positiveRating = '';
        if (isset($tradeData[$theirPrefix . 'TotalRating']) && $tradeData[$theirPrefix . 'TotalRating'] > 0) {
            $totalRating = $tradeData[$theirPrefix . 'TotalRating'];
<?php

if (!isset($TNB_GLOBALS)) {
    die("Invalid Request!");
}
$feedbackList = $view['feedback'];
$userIns = new BuckysUser();
if (!$view['myRatingInfo']) {
    $view['myRatingInfo'] = [];
}
?>

<section id="main_section">

    <?php 
buckys_get_panel('trade_top_search');
?>

    <section id="feedback-left-panel">
        <?php 
$myInfo = $userIns->getUserBasicInfo($view['myID']);
$myData = BuckysUser::getUserData($view['myID']);
$totalRating = 'No';
$positiveRating = '';
if ($view['myRatingInfo']['totalRating'] != '' && $view['myRatingInfo']['totalRating'] > 0) {
    $totalRating = $view['myRatingInfo']['totalRating'];
    if (is_numeric($view['myRatingInfo']['positiveRating'])) {
        $positiveRating = number_format($view['myRatingInfo']['positiveRating'] / $totalRating * 100, 2, '.', '') . '% Positive';
    }
}
?>
        ?>
                        Posts on <?php 
        echo $userData['firstName'];
        ?>
's Profile
                    <?php 
    }
    ?>

                </h3>
                <a href="/profile.php?user=<?php 
    echo $userID;
    ?>
"><img
                        src="<?php 
    echo BuckysUser::getProfileIcon($userID);
    ?>
" class="postIcons"/></a>

                <div class="new-post-row">
                    <form method="post" id="newpostform" action="/manage_post.php">
                        <div id="new-post-nav">
                            <a href="#" class="post-text selected">Text</a> <span>|</span> <a href="#"
                                class="post-image">Photo</a> <span>|</span> <a href="#" class="post-video">Video</a>
                        </div>
                        <textarea name="content" class="newPost" placeholder="Create a new post..."></textarea>

                        <div id="new-video-url">
                            <label style="font-weight:bold;font-size:11px;" for="video-url">YouTube URL:</label> <input
                                type="text" name="youtube_url" id="youtube_url" class="input" value=""/></div>
                        <div class='privacy-row'>
 /**
  * @param $userID
  * @param $commentID
  * @return bool
  */
 public static function deleteComment($userID, $commentID)
 {
     global $db;
     $query = $db->prepare("SELECT c.commentID, c.postID FROM " . TABLE_COMMENTS . " AS c LEFT JOIN " . TABLE_POSTS . " AS p ON p.postID=c.postID WHERE c.commentID=%s AND (c.commenter=%s OR p.poster=%s)", $commentID, $userID, $userID);
     $row = $db->getRow($query);
     if (!$row) {
         return false;
     } else {
         $cID = $row['commentID'];
         $postID = $row['postID'];
         $db->query('DELETE FROM ' . TABLE_COMMENTS . " WHERE commentID=" . $cID);
         //Remove Activity
         $db->query('DELETE FROM ' . TABLE_MAIN_ACTIVITIES . " WHERE actionID=" . $cID);
         //Remove From Report
         $db->query('DELETE FROM ' . TABLE_REPORTS . " WHERE objectType='comment' AND objectID=" . $cID);
         //Update comments on the posts table
         $query = $db->prepare('UPDATE ' . TABLE_POSTS . ' SET `comments`=`comments` - 1 WHERE postID=%d', $postID);
         $db->query($query);
         $postData = BuckysPost::getPostById($postID);
         //Update User Stats
         BuckysUser::updateStats($postData['poster'], 'comments', -1);
         return true;
     }
 }
 /**
  * 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;
 }
Example #18
0
<?php

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);
}
$albumID = isset($_REQUEST['albumID']) ? $_REQUEST['albumID'] : '';
if (!$albumID || !BuckysAlbum::checkAlbumOwner($albumID, $userID)) {
    buckys_redirect("/photo_albums.php", MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
}
//Getting UserData from Id
$userData = BuckysUser::getUserData($profileID);
//Getting Album
$album = BuckysAlbum::getAlbum($albumID);
//Getting Photos
$myphotos = BuckysPost::getPhotosByUserID($userID, $userID, BuckysPost::INDEPENDENT_POST_PAGE_ID, true);
$albumPhotos = BuckysAlbum::getPhotos($albumID);
//Getting Album Photos
if (isset($_POST['action'])) {
    //Create New Album
    if ($_POST['action'] == 'save-album') {
        //If the album title is empty, throw error
        //If the album title is empty, throw error
        if (trim($_POST['album_name']) == '') {
            buckys_redirect('/photo_album_edit.php?albumID=' . $_POST['albumID'], MSG_ALBUM_TITLE_EMPTY, MSG_TYPE_ERROR);
        }
        BuckysAlbum::updateAlbum($_POST['albumID'], trim($_POST['album_name']), $_POST['visibility'], $_POST['photos']);
        buckys_redirect("/photo_album_edit.php?albumID=" . $_POST['albumID'], MSG_ALBUM_UPDATED);
    } else {
        if ($_POST['action'] == 'remove-from-album' || $_POST['action'] == 'add-to-album') {
                            if ($isAjax) {
                                $resultXML = ['status' => 'error', 'message' => $db->getLastError()];
                                render_result_xml($resultXML);
                            } else {
                                buckys_redirect($return, $db->getLastError(), MSG_TYPE_ERROR);
                            }
                        }
                    }
                }
            }
        }
    }
    exit;
}
//Getting UserData from Id
$userData = BuckysUser::getUserData($userID);
$page = isset($_GET['page']) ? $_GET['page'] : 1;
if ($type == 'all') {
    $totalCount = BuckysFriend::getNumberOfFriends($userID);
} else {
    if ($type == 'pending') {
        $totalCount = BuckysFriend::getNumberOfPendingRequests($userID);
    } else {
        if ($type == 'requested') {
            $totalCount = BuckysFriend::getNumberOfReceivedRequests($userID);
        }
    }
}
//Init Pagination Class
$pagination = new Pagination($totalCount, BuckysFriend::$COUNT_PER_PAGE, $page);
$page = $pagination->getCurrentPage();
/**
* Load Private Messenger
* 
*/
function loadMessenger()
{
    global $db, $userID;
    //Getting Friends from the Buddy List
    $messengerSettings = BuckysUser::getUserBasicInfo($userID);
    $uIDs = array();
    //Return HTML
    ob_start();
    ?>
    <div id="private_messenger_main_wrap">
        <div class="box_nav_row">
            <a href="#" class="close_box_link">&nbsp;</a>
<!--            <a href="#" class="minimize_box_link">&nbsp;</a>-->
        </div>
        <h2>Private Messenger</h2>
        <div class="chat_user_list" id="private_messenger_buddies_list">
            <?php 
    echo BuckysPrivateMessenger::getUserListHTML($userID, $uIDs);
    ?>
        </div>
        <div class="below_chat_user_list <?php 
    if ($messengerSettings['messenger_privacy'] == 'all') {
        ?>
add-user-to-buddylist-hidden<?php 
    }
    ?>
" id="add-user-to-buddylist">
            <form name="adduserform" id="adduserform">
                <h2>Add Friends</h2>
                <span id="add-user-to-buddylist-inputholder">
                    <input type="text" class="input below_chat_user_list_input" id="add-user-to-buddylist-input" />                
                    <input type="submit" value="Add" class="redButton" />
                </span>
<!--                <div id="selected-users-list"></div>-->
                <div class="clear"></div>
                <?php 
    echo render_loading_wrapper();
    ?>
            </form>
        </div>
        <div class="below_chat_user_list" id="messenger_btn_box">             
            <span><input type="button" id="settings_messenger_btn" class="redButton" value="Settings"></span>
        </div>
    </div>
    <?php 
    BuckysPrivateMessenger::updateConversationList($userID, $uIDs);
    $convList = isset($_SESSION['converation_list']) ? $_SESSION['converation_list'] : array();
    ?>
    <div id="private_messenger_conversation_wrap" <?php 
    if (!buckys_not_null($convList)) {
        ?>
style="display: none;"<?php 
    }
    ?>
>                            
        <div class="box_nav_row">
            <a href="#" class="close_box_link">&nbsp;</a>
            <a href="#" class="minimize_box_link">&nbsp;</a>            
            <div href="#" class="options_link" id="private-messenger-options-link">
                Options
                <ul>
                    <li><a href="#" id="pm-box-clear-history-link">Clear history</a></li>
                    <li><a href="#" id="pm-box-block-user-link">Block User</a></li>
                </ul>
            </div>            
        </div>
        <div id="private_messenger_conversation_lft">
            <div id="private_messenger_opened_chats"> 
                <?php 
    foreach ($convList as $i => $uID) {
        $tUInfo = BuckysUser::getUserBasicInfo($uID);
        ?>
<a href="#" data-id="<?php 
        echo $uID;
        ?>
" <?php 
        if ($i == 0) {
            ?>
class="actived"<?php 
        }
        ?>
 data-encrypted="<?php 
        echo buckys_encrypt_id($uID);
        ?>
"><?php 
        echo $tUInfo['firstName'] . " " . $tUInfo['lastName'];
        ?>
 <span title="close" class="close-conversation">X</span></a><?php 
    }
    ?>
                         
            </div>                    
        </div>        
        <div id="private_messenger_conversation_rgt">
            <?php 
    foreach ($convList as $i => $uID) {
        $tUInfo = BuckysUser::getUserBasicInfo($uID);
        ?>
                <div class="private_messenger_conversation_contr" <?php 
        if ($i > 0) {
            ?>
style="display: none;"<?php 
        }
        ?>
 id="private_messenger_conversation_contr<?php 
        echo $uID;
        ?>
">
                    <?php 
        echo BuckysPrivateMessenger::getMessagesHTML($userID, $uID, 'all');
        ?>
                </div>
            <?php 
    }
    ?>
              
            <div id="private_messenger_send_message_contr">
                <form name="newmessageform" id="newmessageform" action="" method="post">
                    <input class="under_private_message_conversation_area_input" id="new_private_message" class="input" type="text" />
                </form>
            </div>
        </div>        
        <div class="clear"></div>
    </div>    
    <?php 
    $html = ob_get_contents();
    ob_end_clean();
    return $html;
}
 public function deleteAccountAction()
 {
     $data = $_POST;
     $token = isset($data['TOKEN']) ? trim($data['TOKEN']) : 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.')];
     }
     $current = BuckysUser::getUserData($userID);
     if (!buckys_validate_password($data['password'], $current['password'])) {
         return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => buckys_api_get_error_result('Current password is incorrect.')];
     } else {
         if (BuckysUser::deleteUserAccount($userID)) {
             return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ['STATUS' => 'SUCCESS']];
         } else {
             return ['STATUS_CODE' => STATUS_CODE_UNAUTHORIZED, 'DATA' => buckys_api_get_error_result('There was an error to saving your information.')];
         }
     }
     exit;
 }
    <?php 
$moderators = BuckysForumModerator::getForumModerators($category['categoryID']);
?>

    <h4>Moderators</h4>
    <table class="moderators">
        <tr>
            <td style="width: 35px;">
                <a href="/profile.php?user=<?php 
echo !$category['creatorID'] ? TNB_USER_ID : $category['creatorID'];
?>
">
                    <img
                        src="<?php 
echo BuckysUser::getProfileIcon(!$category['creatorID'] ? TNB_USER_ID : $category['creatorID']);
?>
"
                        class="poster-icon"/> </a>
            </td>
            <td>
                <a href="/profile.php?user=<?php 
echo !$category['creatorID'] ? TNB_USER_ID : $category['creatorID'];
?>
">
                    <b><?php 
echo buckys_get_user_name(!$category['creatorID'] ? TNB_USER_ID : $category['creatorID']);
?>
</b>
                </a><br/> <span>Administrator</span>
            </td>
<?php

require dirname(__FILE__) . '/includes/bootstrap.php';
//Getting Current User ID
$userID = buckys_is_logged_in();
//Getting User ID from Parameter
$profileID = get_secure_integer($_GET['user']);
$postID = buckys_escape_query_integer(isset($_GET['post']) ? $_GET['post'] : null);
//If the parameter is null, goto homepage
if (!$profileID) {
    buckys_redirect('/index.php');
}
//Getting UserData from Id
$userData = BuckysUser::getUserData($profileID);
//Goto Homepage if the userID is not correct
if (!buckys_not_null($userData) || !BuckysUser::checkUserID($profileID, true)) {
    buckys_redirect('/index.php');
}
$postType = isset($_GET['type']) ? $_GET['type'] : 'all';
if (!in_array($postType, ['all', 'user', 'friends'])) {
    $postType = 'all';
}
//if logged user can see all resources of the current user
$canViewPrivate = $userID == $profileID || BuckysFriend::isFriend($userID, $profileID) || BuckysFriend::isSentFriendRequest($profileID, $userID);
$posts = BuckysPost::getPostsByUserID($profileID, $userID, BuckysPost::INDEPENDENT_POST_PAGE_ID, $canViewPrivate, $postID, null, $postType);
/*if( !buckys_not_null($posts) )
{
    //Goto Index Page
    buckys_redirect('/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
}*/
//Mark the notifications to read
Example #24
0
        if ($photo['poster'] != $userID) {
            buckys_redirect('/photo_manage.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
        }
        //Update Photo Caption and Privacy
        BuckysPost::updatePhoto($userID, $_POST);
        //Change user profile image
        if ($_POST['photo_visibility'] == 2) {
            if (!$photo['is_profile']) {
                BuckysPost::createProfileImage($photo, $_POST);
            }
            //Update profile image with old one
            BuckysUser::updateUserFields($userID, array('thumbnail' => $photo['image']));
        } else {
            if ($userData['thumbnail'] == $photo['image']) {
                //If it was a profile image and now it is not, remove it from the profile image
                BuckysUser::updateUserFields($userID, array('thumbnail' => ''));
            }
        }
        //Save Album
        if (isset($_POST['album']) && $_POST['album'] != '' && isset($albums[$_POST['album']])) {
            BuckysAlbum::addPhotoToAlbum($_POST['album'], $photo['postID']);
        }
        buckys_redirect('/photo_edit.php?photoID=' . $photo['postID'], MSG_PHOTO_UPDATED, MSG_TYPE_SUCCESS);
        exit;
    }
}
$set_profile = isset($_GET['set_profile']) ? $_GET['set_profile'] : null;
buckys_enqueue_stylesheet('account.css');
buckys_enqueue_stylesheet('posting.css');
buckys_enqueue_stylesheet('jquery.Jcrop.css');
buckys_enqueue_javascript('jquery.Jcrop.js');
        <div class="offer-received">
            <?php 
if (isset($offerReceived) && count($offerReceived) > 0) {
    ?>

                <div class="top-header-cont">
                    <div class="n1">My Item</div>
                    <div class="n2">Their Item</div>
                    <div class="n3">Actions</div>
                    <div class="clear"></div>
                </div>


                <?php 
    foreach ($offerReceived as $offerData) {
        $userIns = new BuckysUser();
        $offerData['basicInfo'] = $userIns->getUserBasicInfo($offerData['offeredUserID']);
        // $myItemImage = fn_buckys_get_item_first_image_thumb($offerData['targetImages']);
        // $offeredItemImage = fn_buckys_get_item_first_image_thumb($offerData['offeredImages']);
        $myItemImage = fn_buckys_get_item_first_image_normal($offerData['targetImages']);
        $offeredItemImage = fn_buckys_get_item_first_image_normal($offerData['offeredImages']);
        $sendMessageLink = '/messages_compose.php?to=' . $offerData['offeredUserID'];
        $theirID = $offerData['offeredUserID'];
        $dateOffered = date('n/j/y H:i', strtotime($offerData['offerCreatedDate']));
        $strTimeLeft = '';
        if (strtotime($offerData['targetExpiryDate']) > strtotime($offerData['offeredExpiryDate'])) {
            $strTimeLeft = fn_buckys_get_item_time_left($offerData['offeredExpiryDate']);
        } else {
            $strTimeLeft = fn_buckys_get_item_time_left($offerData['targetExpiryDate']);
        }
        $targetItemLink = '/trade/view.php?id=' . $offerData['targetItemID'];
    buckys_redirect('/index.php');
}
//Getting UserData from Id
$userData = BuckysUser::getUserEmploymentHistory($userID);
if (isset($_POST['action'])) {
    //Check the user id is same with the current logged user id
    if ($_POST['userID'] != $userID) {
        echo 'Invalid Request!';
        exit;
    }
    //Save Address
    if ($_POST['action'] == 'save_employment') {
        $data = [];
        for ($i = 0; $i < count($_POST['employer']); $i++) {
            $data[] = ['employer' => $_POST['employer'][$i], 'start' => $_POST['from'][$i], 'end' => $_POST['to'][$i], 'visibility' => $_POST['visibility'][$i]];
        }
        //Update User Phone numbers
        if (BuckysUser::updateUserEmploymentHistory($userID, $data)) {
            echo 'Success';
        } else {
            echo $db->getLastError();
        }
        exit;
    }
}
buckys_enqueue_stylesheet('account.css');
buckys_enqueue_stylesheet('info.css');
buckys_enqueue_javascript('info.js');
$TNB_GLOBALS['content'] = 'info_employment';
$TNB_GLOBALS['title'] = "Employment History - " . TNB_SITE_NAME;
require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";
<?php

require dirname(__FILE__) . '/includes/bootstrap.php';
if (!($userID = buckys_is_logged_in())) {
    buckys_redirect('/index.php', MSG_NOT_LOGGED_IN_USER, MSG_TYPE_ERROR);
}
$view = [];
//Save Shipping info
$tradeUserIns = new BuckysTradeUser();
if (isset($_POST['action']) && $_POST['action'] == 'saveNotifyInfo') {
    $result = BuckysUser::saveUserNotificationSettings($userID, $_POST);
    if ($result === true) {
        buckys_redirect('/notify.php', MSG_NOTIFICATION_SETTINGS_SAVED);
    } else {
        buckys_redirect('/notify.php', $result, MSG_TYPE_ERROR);
    }
}
//Get offer_received info
$view['trade_user_info'] = $tradeUserIns->getUserByID($userID);
$userNotifyInfo = BuckysUser::getUserNotificationSettings($userID);
if (empty($view['trade_user_info'])) {
    buckys_redirect('/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
}
buckys_enqueue_stylesheet('account.css');
buckys_enqueue_stylesheet('info.css');
$TNB_GLOBALS['content'] = 'notify';
$TNB_GLOBALS['title'] = 'Notification Settings - ' . TNB_SITE_NAME;
require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";
Example #28
0
<?php

require dirname(__FILE__) . '/includes/bootstrap.php';
if (!($userID = buckys_is_logged_in())) {
    buckys_redirect('/index.php', MSG_NOT_LOGGED_IN_USER, MSG_TYPE_ERROR);
}
$view = array();
//Save Shipping info
$tradeUserIns = new BuckysTradeUser();
if (isset($_POST['action']) && $_POST['action'] == 'saveNotifyInfo') {
    $result = BuckysUser::saveUserNotificationSettings($userID, $_POST);
    if ($result === true) {
        buckys_redirect('/notify.php', MSG_NOTIFICATION_SETTINGS_SAVED);
    } else {
        buckys_redirect('/notify.php', $result, MSG_TYPE_ERROR);
    }
}
//Get offer_received info
$view['trade_user_info'] = $tradeUserIns->getUserByID($userID);
$forumNotifyInfo = BuckysUser::getUserForumSettings($userID);
if (empty($view['trade_user_info'])) {
    buckys_redirect('/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
}
buckys_enqueue_stylesheet('account.css');
buckys_enqueue_stylesheet('info.css');
$BUCKYS_GLOBALS['content'] = 'notify';
$BUCKYS_GLOBALS['title'] = 'Notification Settings - BuckysRoom';
require DIR_FS_TEMPLATE . $BUCKYS_GLOBALS['template'] . "/" . $BUCKYS_GLOBALS['layout'] . ".php";
}
$bitcoinClass = new BuckysBitcoin();
//Create Wallet if it is not created
$bitcoinInfo = BuckysUser::getUserBitcoinInfo($userID);
if (!$bitcoinInfo) {
    $bitcoinInfo = $bitcoinClass->createWallet($TNB_GLOBALS['user']['userID'], $TNB_GLOBALS['user']['email']);
}
if (isset($_POST['action']) && $_POST['action'] == 'send-bitcoins') {
    //Check Token
    if (!buckys_check_form_token()) {
        buckys_redirect("/wallet.php", MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
    }
    $toAddress = $_POST['receiver'];
    $amount = doubleval($_POST['amount']);
    $password = $_POST['password'];
    $user = BuckysUser::getUserData($TNB_GLOBALS['user']['userID']);
    $is_error = false;
    if (!$password || !buckys_validate_password($password, $user['password'])) {
        buckys_redirect("/wallet.php", MSG_CURRENT_PASSWORD_NOT_CORRECT, MSG_TYPE_ERROR);
    }
    if (!$toAddress) {
        buckys_redirect("/wallet.php", MSG_ENTER_BITCOINS_ADDRESS_OF_RECIPIENT, MSG_TYPE_ERROR);
    }
    if (!$amount || $amount <= 0) {
        buckys_redirect("/wallet.php", MSG_INVALID_BITCOIN_AMOUNT, MSG_TYPE_ERROR);
    }
    if (!$is_error) {
        $bitcoinClass->sendBitcoin($userID, $toAddress, $amount);
    }
    buckys_redirect("/wallet.php");
}
<?php

require dirname(__FILE__) . '/includes/bootstrap.php';
//If the user is not logged in, redirect to the index page
if (!($userID = buckys_is_logged_in())) {
    buckys_redirect('/index.php');
}
if (isset($_GET['to'])) {
    $receiver = BuckysUser::getUserData($_GET['to']);
}
if (isset($_GET['reply'])) {
    $replyTo = BuckysMessage::getMessage($_GET['reply']);
}
if (isset($_POST['action'])) {
    //Check the user id is same with the current logged user id
    if ($_POST['userID'] != $userID) {
        echo 'Invalid Request!';
        exit;
    }
    //Save Address
    if ($_POST['action'] == 'compose_message') {
        //Show Results
        header('Content-type: application/xml');
        if (!BuckysMessage::composeMessage($_POST)) {
            render_result_xml(['status' => 'error', 'message' => buckys_get_messages()]);
        } else {
            render_result_xml(['status' => 'success', 'message' => buckys_get_messages()]);
        }
        exit;
    }
}