public function getNotificationCountAction() { $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.')]; } $newMessageCount = BuckysMessage::getNumOfNewMessages($userID); $newNotificationCount = BuckysActivity::getNumberOfNotifications($userID); $friendRequestCount = BuckysFriend::getNumberOfReceivedRequests($userID); $results = []; $results['new_message'] = $newMessageCount; $results['new_notification'] = $newNotificationCount; $results['friend_request'] = $friendRequestCount; return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ["STATUS" => "SUCCESS", "RESULT" => $results]]; }
echo $totalFriendsCount != 1 ? 's' : ''; ?> <a href="/friends.php?user=<?php echo $userData['userID']; ?> " class="view-all">(view all)</a></h3> <?php foreach ($friends as $row) { render_profile_link($row, 'friendThumbnails'); } ?> </div> <br/> <?php if ($userID == $profileID || BuckysFriend::isFriend($userID, $profileID)) { ?> <div class="info-box"> <h3> <?php if ($userID == $profileID) { ?> New Post <?php } else { ?> Posts on <?php echo $userData['firstName']; ?> 's Profile <?php
//Check Friend Request if ($fid = BuckysFriend::isSentFriendRequest($userID, $row['userID'])) { ?> <a href="/myfriends.php?action=delete&friendID=<?php echo $row['userID']; echo buckys_get_token_param(); ?> &return=<?php echo base64_encode("/profile.php?user="******" data-type="buckys-ajax-link">Delete Friend Request</a> <br/> <?php } else { if ($fid = BuckysFriend::isSentFriendRequest($row['userID'], $userID)) { ?> <a href="/myfriends.php?action=accept&friendID=<?php echo $row['userID']; echo buckys_get_token_param(); ?> &return=<?php echo base64_encode("/profile.php?user="******" data-type="buckys-ajax-link">Approve Friend Request</a> <br/> <a href="/myfriends.php?action=decline&friendID=<?php echo $row['userID']; echo buckys_get_token_param(); ?>
//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 if ($postID) { BuckysActivity::markReadNotifications($userID, $postID); } buckys_enqueue_stylesheet('profile.css'); buckys_enqueue_stylesheet('posting.css'); buckys_enqueue_stylesheet('uploadify.css'); buckys_enqueue_stylesheet('jquery.Jcrop.css'); buckys_enqueue_stylesheet('publisher.css');
echo $userID; ?> " class="accountSubLinks">View All</a> <br/> <h6>Information</h6> <a href="/info_basic.php" class="accountSubLinks">Basic Info</a> <br/> <a href="/info_contact.php" class="accountSubLinks">Contact</a> <br/> <a href="/info_education.php" class="accountSubLinks">Education</a> <br/> <a href="/info_employment.php" class="accountSubLinks">Employment</a> <br/> <a href="/info_links.php" class="accountSubLinks">Links</a> <br/> <h6>Friends</h6> <a href="/myfriends.php" class="accountSubLinks">All</a> <br/> <?php $newFriendRequestsNum = BuckysFriend::getNewFriendRequests($userID); ?> <a href="/myfriends.php?type=requested" class="accountSubLinks<?php echo $newFriendRequestsNum > 0 ? 'Bold' : ''; ?> ">Requests<?php echo $newFriendRequestsNum > 0 ? ' (' . $newFriendRequestsNum . ')' : ''; ?> </a> <br/> <a href="/myfriends.php?type=pending" class="accountSubLinks">Pending</a> <br/> <!-- <a href="/moderator.php" class="accountLinks">Vote</a> --> <?php ?>
/** * Like Post * * @param int $userID * @param int $postID * @param $action * @param bool $checkToken * @return bool|int|null|string */ public static function likePost($userID, $postID, $action, $checkToken = true) { global $db; $post = BuckysPost::getPostById($postID); if ($checkToken && !buckys_check_form_token('request')) { buckys_add_message(MSG_INVALID_REQUEST, MSG_TYPE_ERROR); return false; } if (!$post || $post['poster'] == $userID) { buckys_add_message(MSG_INVALID_REQUEST, MSG_TYPE_ERROR); return false; } if ($post['visibility'] == 0 && !BuckysFriend::isFriend($userID, $post['poster'])) { buckys_add_message(MSG_INVALID_REQUEST, MSG_TYPE_ERROR); return false; } if (!BuckysUsersDailyActivity::checkUserDailyLimit($userID, 'likes')) { buckys_add_message(sprintf(MSG_DAILY_LIKES_LIMIT_EXCEED_ERROR, USER_DAILY_LIMIT_LIKES), MSG_TYPE_ERROR); return false; } //Check already like it or not $query = $db->prepare("SELECT likeID FROM " . TABLE_POSTS_LIKES . " WHERE userID=%s AND postID=%s", $userID, $postID); $likeId = $db->getVar($query); if ($action == 'likePost') { if ($likeId) { buckys_add_message(MSG_ALREADY_LIKED_POST, MSG_TYPE_ERROR); return false; } BuckysUsersDailyActivity::addLikes($userID); //Like This post $rs = $db->insertFromArray(TABLE_POSTS_LIKES, ['userID' => $userID, 'postID' => $postID]); //Update likes on the posts table $query = $db->prepare('UPDATE ' . TABLE_POSTS . ' SET `likes`=`likes` + 1 WHERE postID=%d', $postID); $db->query($query); //Add Activity $activityId = BuckysActivity::addActivity($userID, $postID, 'post', 'like', $rs); //Add Notification BuckysActivity::addNotification($post['poster'], $activityId, BuckysActivity::NOTIFICATION_TYPE_LIKE_POST); //Increase Hits BuckysHit::addHit($postID, $userID); //Update User Stats BuckysUser::updateStats($post['poster'], 'likes', 1); return $rs; } else { if ($action == 'unlikePost') { if (!$likeId) { buckys_add_message(MSG_INVALID_REQUEST, MSG_TYPE_ERROR); return false; } BuckysUsersDailyActivity::addLikes($userID); $query = $db->prepare("DELETE FROM " . TABLE_POSTS_LIKES . " WHERE userID=%s AND postID=%s", $userID, $postID); $db->query($query); //Update likes on the posts table $query = $db->prepare('UPDATE ' . TABLE_POSTS . ' SET `likes`=`likes` - 1 WHERE postID=%d', $postID); $db->query($query); //Increase Hits BuckysHit::removeHit($postID, $userID); //Update User Stats BuckysUser::updateStats($post['poster'], 'likes', -1); return true; } } }
public function deleteAction() { $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.')]; } if (BuckysFriend::delete($userID, $data['friendId'])) { 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 send your message.')]; } }
/** * Like Post * * * @param int $userID * @param int $postID */ public function likePost($userID, $postID, $action) { global $db; $post = BuckysPost::getPostById($postID); if (!$post || $post['poster'] == $userID) { buckys_add_message(MSG_INVALID_REQUEST, MSG_TYPE_ERROR); return false; } if ($post['visibility'] == 0 && !BuckysFriend::isFriend($userID, $post['poster'])) { buckys_add_message(MSG_INVALID_REQUEST, MSG_TYPE_ERROR); return false; } //Check already like it or not $query = $db->prepare("SELECT likeID FROM " . TABLE_POSTS_LIKES . " WHERE userID=%s AND postID=%s", $userID, $postID); $likeId = $db->getVar($query); if ($action == 'likePost') { if ($likeId) { buckys_add_message(MSG_ALREADY_LIKED_POST, MSG_TYPE_ERROR); return false; } //Like This post $rs = $db->insertFromArray(TABLE_POSTS_LIKES, array('userID' => $userID, 'postID' => $postID)); //Update likes on the posts table $query = $db->prepare('UPDATE ' . TABLE_POSTS . ' SET `likes`=`likes` + 1 WHERE postID=%d', $postID); $db->query($query); //Add Activity BuckysActivity::addActivity($userID, $postID, 'post', 'like', $rs); //Increase Hits BuckysHit::addHit($postID, $userID); return $rs; } else { if ($action == 'unlikePost') { if (!$likeId) { buckys_add_message(MSG_INVALID_REQUEST, MSG_TYPE_ERROR); return false; } $query = $db->prepare("DELETE FROM " . TABLE_POSTS_LIKES . " WHERE userID=%s AND postID=%s", $userID, $postID); $db->query($query); //Update likes on the posts table $query = $db->prepare('UPDATE ' . TABLE_POSTS . ' SET `likes`=`likes` - 1 WHERE postID=%d', $postID); $db->query($query); //Increase Hits BuckysHit::removeHit($postID, $userID); return true; } } }
<?php require dirname(__FILE__) . '/includes/bootstrap.php'; //If the user is not logged in, exit; if (!($userID = buckys_is_logged_in())) { echo MSG_INVALID_REQUEST; exit; } $friends = BuckysFriend::searchFriends($userID, $_REQUEST['term']); $result = array(); foreach ($friends as $row) { $result[] = array("id" => $row['userID'], 'label' => $row['fullName'], 'value' => $row['fullName']); } echo json_encode($result); exit;
if (trim($comment) == '') { echo MSG_COMMENT_EMPTY; exit; } //if Post Id was not set, show error if (!$postID) { echo MSG_INVALID_REQUEST; exit; } //Check the post id is correct if (!BuckysPost::checkPostID($postID)) { echo MSG_POST_NOT_EXIST; exit; } $post = BuckysPost::getPostById($postID); if ($post['visibility'] == 0 && $userID != $post['poster'] && !BuckysFriend::isFriend($userID, $post['poster'])) { //Only Friends can leave comments to private post echo MSG_INVALID_REQUEST; exit; } //If error, show it if (!($commentID = BuckysComment::saveComments($userID, $postID, $comment))) { echo $db->getLastError(); exit; } else { //Show Results header('Content-type: application/xml'); $newComment = BuckysComment::getComment($commentID); $newCount = BuckysComment::getPostCommentsCount($postID); render_result_xml(array('newcomment' => render_single_comment($newComment, $userID, true), 'count' => $newCount > 1 ? $newCount . " comments" : $newCount . " comment")); exit;
public function declineFriendRequestAction() { global $db; $data = $_POST; $token = isset($data['TOKEN']) ? trim($data['TOKEN']) : null; $friendID = isset($data['friendID']) ? $data['friendID'] : 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.')]; } if (!isset($friendID) || !BuckysUser::checkUserID($friendID)) { return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => buckys_api_get_error_result(MSG_INVALID_REQUEST)]; } if (BuckysFriend::decline($userID, $friendID)) { return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ['STATUS' => "SUCCESS", "MESSAGE" => MSG_FRIEND_REQUEST_DECLINED]]; } else { return ['STATUS_CODE' => STATUS_CODE_UNAUTHORIZED, 'DATA' => buckys_api_get_error_result($db->getLastError())]; } }
</span> <span class="dropDownNotificationList"> <?php render_footer_link_content('my', $notificationsList); ?> </span> </span> <?php } else { echo '<span class="notificationLinks inactive-notify no-data" id="my-notifications-icon"><span class="notification-count">0</span><span class="dropDownNotificationList"><span class="nodata">Nothing to see here</span></span></span>'; } ?> <!-- Start Friend Request Notification --> <?php $objFriend = new BuckysFriend(); $friendRequestsNum = $objFriend->getNewFriendRequests($userID); if ($friendRequestsNum > 0) { $friendRequests = $objFriend->getReceivedRequests($userID); ?> <span class="notificationLinks" id="friend-notifications-icon"> <span class="dropDownNotificationList"> <?php render_footer_link_content('friend', $friendRequests); ?> </span> </span> <?php } else { echo '<span class="notificationLinks inactive-notify no-data" id="friend-notifications-icon"><span class="dropDownNotificationList"><a href="/myfriends.php?type=requested" class="nodata">No one wants to be your friend</a></span></span>'; }
foreach ($notificationsList as $row) { echo BuckysActivity::getActivityHTML($row, $userID); } ?> <a class="view-detail-links" href="/account.php"> View All Notifications </a> </span> </span> <?php } ?> <!-- Start Friend Request Notification --> <?php $objFriend = new BuckysFriend(); $friendRequestsNum = $objFriend->getNewFriendRequests($BUCKYS_GLOBALS['user']['userID']); if ($friendRequestsNum > 0) { $friendRequests = $objFriend->getReceivedRequests($BUCKYS_GLOBALS['user']['userID']); ?> <span class="notificationLinks" id="friend-notifications-icon"> <span class="dropDownNotificationList"> <?php foreach ($friendRequests as $row) { ?> <span class="singleNotificationListItem"> <img src="<?php echo BuckysUser::getProfileIcon($row); ?> " class="dropDownNotificationImages" /> <span class="redBold"><?php
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_check_user_acl(USER_ACL_ADMINISTRATOR)) { 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); $friends = BuckysFriend::getAllFriends($profileID, 1, 18, true); $totalFriendsCount = BuckysFriend::getNumberOfFriends($profileID); $posts = BuckysPost::getPostsByUserID($profileID, $userID, BuckysPost::INDEPENDENT_POST_PAGE_ID, $canViewPrivate, isset($_GET['post']) ? $_GET['post'] : null, null, $postType); buckys_enqueue_stylesheet('account.css'); buckys_enqueue_stylesheet('profile.css'); buckys_enqueue_stylesheet('posting.css'); buckys_enqueue_stylesheet('publisher.css'); buckys_enqueue_stylesheet('uploadify.css'); buckys_enqueue_stylesheet('jquery.Jcrop.css'); buckys_enqueue_javascript('uploadify/jquery.uploadify.js'); buckys_enqueue_javascript('jquery.Jcrop.js'); buckys_enqueue_javascript('jquery.color.js'); buckys_enqueue_javascript('posts.js'); buckys_enqueue_javascript('add_post.js'); buckys_enqueue_javascript('account.js'); $TNB_GLOBALS['content'] = 'profile'; //Page title
} else { //Check Friend Request if ($fid = BuckysFriend::isSentFriendRequest($userID, $profileID)) { ?> <a href="/myfriends.php?action=delete&friendID=<?php echo $profileID; echo buckys_get_token_param(); ?> &return=<?php echo base64_encode("/profile.php?user="******">Delete Friend Request</a> <br/> <?php } else { if ($fid = BuckysFriend::isSentFriendRequest($profileID, $userID)) { ?> <a href="/myfriends.php?action=accept&friendID=<?php echo $profileID; echo buckys_get_token_param(); ?> &return=<?php echo base64_encode("/profile.php?user="******">Approve Friend Request</a> <br/> <a href="/myfriends.php?action=decline&friendID=<?php echo $profileID; echo buckys_get_token_param(); ?> &return=<?php
require dirname(__FILE__) . '/includes/bootstrap.php'; //Getting Current User ID $userID = buckys_is_logged_in(); //Getting User ID from Parameter $profileID = isset($_GET['user']) ? intval($_GET['user']) : 0; //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'); } $page = isset($_GET['page']) ? $_GET['page'] : 1; $totalCount = BuckysFriend::getNumberOfFriends($profileID); $pagination = new Pagination($totalCount, BuckysFriend::$COUNT_PER_PAGE, $page); $page = $pagination->getCurrentPage(); //Get Friends $friends = BuckysFriend::getAllFriends($profileID, $page, BuckysFriend::$COUNT_PER_PAGE); buckys_enqueue_stylesheet('profile.css'); buckys_enqueue_stylesheet('posting.css'); buckys_enqueue_stylesheet('friends.css'); $BUCKYS_GLOBALS['content'] = 'friends'; if ($userData) { $BUCKYS_GLOBALS['title'] = trim($userData['firstName'] . ' ' . $userData['lastName']) . "'s Friends - BuckysRoom"; } //if logged user can see all resources of the current user require DIR_FS_TEMPLATE . $BUCKYS_GLOBALS['template'] . "/" . $BUCKYS_GLOBALS['layout'] . ".php";
$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(); if ($type == 'all') { $friends = BuckysFriend::getAllFriends($userID, $page, BuckysFriend::$COUNT_PER_PAGE); } else { if ($type == 'pending') { $friends = BuckysFriend::getPendingRequests($userID, $page, BuckysFriend::$COUNT_PER_PAGE); } else { if ($type == 'requested') { $friends = BuckysFriend::getReceivedRequests($userID, $page, BuckysFriend::$COUNT_PER_PAGE); } } } buckys_enqueue_stylesheet('account.css'); buckys_enqueue_stylesheet('friends.css'); buckys_enqueue_javascript('friends.js'); $TNB_GLOBALS['content'] = 'myfriends'; $TNB_GLOBALS['title'] = "My Friends - " . TNB_SITE_NAME; //if logged user can see all resources of the current user require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";
if (!isset($_GET['userID']) || !BuckysUser::checkUserID($userID)) { buckys_redirect('/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR); } //Ban User BuckysBanUser::banUser($_GET['userID']); buckys_redirect('/index.php', MSG_BAN_USER); exit; } //Getting User ID from Parameter $profileID = isset($_GET['user']) ? intval($_GET['user']) : 0; //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_check_user_acl(USER_ACL_ADMINISTRATOR)) { buckys_redirect('/index.php'); } //if logged user can see all resources of the current user $canViewPrivate = $userID == $profileID || BuckysFriend::isFriend($userID, $profileID) || BuckysFriend::isSentFriendRequest($profileID, $userID); $friends = BuckysFriend::getAllFriends($profileID, 1, 18, true); $posts = BuckysPost::getPostsByUserID($profileID, $userID, BuckysPost::INDEPENDENT_POST_PAGE_ID, $canViewPrivate, isset($_GET['post']) ? $_GET['post'] : null); buckys_enqueue_stylesheet('profile.css'); buckys_enqueue_stylesheet('posting.css'); buckys_enqueue_javascript('posts.js'); $BUCKYS_GLOBALS['content'] = 'profile'; //Page title $BUCKYS_GLOBALS['title'] = $userData['firstName'] . ' ' . $userData['lastName'] . ' - BuckysRoom'; require DIR_FS_TEMPLATE . $BUCKYS_GLOBALS['template'] . "/" . $BUCKYS_GLOBALS['layout'] . ".php";