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]];
 }
Пример #2
0
}
if (!$showPagePhotoFlag) {
    //if logged user can see all resources of the current user
    $canViewPrivate = $userID == $profileID || BuckysFriend::isFriend($userID, $profileID) || BuckysFriend::isSentFriendRequest($profileID, $userID);
    $photos = BuckysPost::getPhotosByUserID($profileID, $userID, $paramPageID, $canViewPrivate, isset($_GET['post']) ? $_GET['post'] : null, isset($_GET['albumID']) ? $_GET['albumID'] : null, BuckysPost::$images_per_page);
    $albums = BuckysAlbum::getAlbumsByUserId($profileID);
    //Display
    $BUCKYS_GLOBALS['title'] = trim($userData['firstName'] . ' ' . $userData['lastName']) . "'s Photos - BuckysRoom";
    $view['photo_type'] = 'profile';
    buckys_enqueue_stylesheet('profile.css');
    buckys_enqueue_stylesheet('posting.css');
    buckys_enqueue_javascript('posts.js');
} else {
    //Show page photos
    //if logged user can see all resources of the current user
    $photos = BuckysPost::getPhotosByUserID($profileID, null, $paramPageID, false, isset($_GET['post']) ? $_GET['post'] : null, isset($_GET['albumID']) ? $_GET['albumID'] : null, BuckysPost::$images_per_page);
    //$albums = BuckysAlbum::getAlbumsByUserId($profileID);
    //Display
    $BUCKYS_GLOBALS['title'] = trim($pageData['title']) . "'s Photos - BuckysRoom";
    $view['photo_type'] = 'page';
    $view['pageData'] = $pageData;
    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');
    buckys_enqueue_javascript('posts.js');
Пример #3
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);
}
//Getting Activity Stream
$stream = BuckysPost::getUserPostsStream($userID);
//Get Activities
$activities = BuckysActivity::getActivities($userID);
if (!$activities) {
    $activities = [];
}
//Get Notifications
$notifications = BuckysActivity::getNotifications($userID);
//Mark the notifications to read
BuckysActivity::markReadNotifications($userID);
if (!$notifications) {
    $notifications = [];
}
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_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');
Пример #4
0
$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') {
            $photoID = $_POST['photoID'];
            $photo = BuckysPost::getPostById($photoID);
            //Check Photo Owner
            if ($photo['poster'] != $userID) {
                echo MSG_INVALID_REQUEST;
                exit;
            }
            if ($_POST['action'] == 'remove-from-album') {
                BuckysAlbum::removePhotoFromAlbum($albumID, $photoID);
            } else {
                BuckysAlbum::addPhotoToAlbum($albumID, $photoID);
            }
            //Add
            echo 'success';
            exit;
        }
    }
Пример #5
0
if (isset($_POST['action']) && $_POST['action'] == 'submit-post') {
    //Save Post
    BuckysPost::savePost($userID, $_POST);
    if (isset($_POST['pageID']) && is_numeric($_POST['pageID'])) {
        buckys_redirect('/page.php?pid=' . $_POST['pageID']);
    } else {
        buckys_redirect('/account.php');
    }
} else {
    if (isset($_GET['action']) && $_GET['action'] == 'delete-post') {
        //Delete Post
        if ($userID != $_GET['userID'] || !BuckysPost::deletePost($userID, $_GET['postID'])) {
            echo 'Invalid Request';
        } else {
            echo 'success';
        }
        exit;
    } else {
        if (isset($_GET['action']) && ($_GET['action'] == 'unlikePost' || $_GET['action'] == 'likePost')) {
            $post = BuckysPost::getPostById($_GET['postID']);
            if ($post['post_status'] != 1) {
                render_result_xml(array('status' => 'error', 'message' => MSG_INVALID_REQUEST));
                exit;
            }
            $r = BuckysPost::likePost($userID, $_GET['postID'], $_GET['action']);
            $likes = BuckysPost::getPostLikesCount($_GET['postID']);
            render_result_xml(array('status' => $r ? 'success' : 'error', 'message' => buckys_get_messages(), 'likes' => $likes . " like" . ($likes >= 2 ? "s" : ""), 'postID' => $_GET['postID']));
            exit;
        }
    }
}
Пример #6
0
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');
buckys_enqueue_javascript('uploadify/jquery.uploadify.js');
 /**
  * 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;
         }
     }
 }
Пример #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;
}
<?php

/**
 * Page Left Sidebar
 */
if (!isset($TNB_GLOBALS)) {
    die("Invalid Request!");
}
global $view;
$userID = null;
if (isset($TNB_GLOBALS['user'])) {
    $userID = $TNB_GLOBALS['user']['userID'];
}
$pageData = $view['pageData'];
//Get Number of photos
$postIns = new BuckysPost();
$numberOfPhotos = $postIns->getNumberOfPhotosByUserID($pageData['userID'], $pageData['pageID']);
//follower
$pageFollowerIns = new BuckysPageFollower();
$view['isMyPage'] = $pageData['userID'] == $userID;
$view['isFollowed'] = $pageFollowerIns->hasRelationInFollow($pageData['pageID'], $userID);
?>

<script type="text/javascript">
    var pageLinkList = <?php 
if ($pageData['links'] != '') {
    echo json_encode(unserialize($pageData['links']));
} else {
    echo json_encode([]);
}
?>
Пример #10
0
        if ($_POST['page'] == 'page-post') {
            $paramPageID = $_POST['pageID'];
            $pageIns = new BuckysPage();
            $postIns = new BuckysPost();
            $pageData = $pageIns->getPageByID($paramPageID);
            if ($pageData) {
                $posts = $postIns->getPostsByUserID($pageData['userID'], null, $paramPageID, false, isset($_GET['post']) ? $_GET['post'] : null, $_POST['lastDate']);
                foreach ($posts as $post) {
                    echo buckys_get_single_post_html($post, $userID, false, $pageData);
                }
            }
        } else {
            if ($_POST['page'] == 'page-photo') {
                $paramPageID = $_POST['pageID'];
                $pageIns = new BuckysPage();
                $postIns = new BuckysPost();
                $pageData = $pageIns->getPageByID($paramPageID);
                if ($pageData) {
                    $photos = $postIns->getPhotosByUserID($pageData['userID'], null, $paramPageID, false, null, null, 5, $_POST['lastDate']);
                    foreach ($photos as $row) {
                        ?>
            <a href="/page.php?pid=<?php 
                        echo $row['pageID'];
                        ?>
&post=<?php 
                        echo $row['postID'];
                        ?>
" class="photo"><img src="<?php 
                        echo DIR_WS_PHOTO;
                        ?>
users/<?php 
Пример #11
0
 public function likePostAction()
 {
     $data = $_POST;
     $token = isset($data['TOKEN']) ? trim($data['TOKEN']) : null;
     $postID = isset($data['postID']) ? $data['postID'] : null;
     $actionType = isset($data['actionType']) ? $data['actionType'] : 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 (!$postID || !$actionType) {
         return ['STATUS_CODE' => STATUS_CODE_BAD_REQUEST, 'DATA' => buckys_api_get_error_result(MSG_INVALID_REQUEST)];
     }
     $post = BuckysPost::getPostById($postID);
     if (!$post || $post['post_status'] != 1) {
         return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => buckys_api_get_error_result(MSG_INVALID_REQUEST)];
         exit;
     }
     $r = BuckysPost::likePost($userID, $postID, $actionType, false);
     $message = buckys_get_pure_messages();
     if (!$r) {
         return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => buckys_api_get_error_result($message)];
         exit;
     } else {
         $likes = BuckysPost::getPostLikesCount($postID);
         return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ['STATUS' => 'SUCCESS', 'MESSAGE' => $message, 'LIKES' => $likes, 'isLiked' => $actionType == 'likePost' ? 'yes' : 'no']];
     }
 }
Пример #12
0
/**
* Show All Top Images, Videos or Text
*/
require dirname(__FILE__) . '/includes/bootstrap.php';
$userID = buckys_is_logged_in();
$type = isset($_GET['type']) ? strtolower($_GET['type']) : '';
//If the url param is not correct, go to index page
if (!$type || !in_array($type, array('image', 'text', 'video'))) {
    buckys_redirect('/index.php');
}
//Perios = Today, This Week, This Month, All Time
$period = isset($_GET['period']) ? strtolower($_GET['period']) : 'all';
//Default all
if (!in_array($period, array('today', 'this-week', 'this-month', 'all'))) {
    $period = 'all';
}
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$totalCount = BuckysPost::getNumberOfPosts(BuckysPost::INDEPENDENT_POST_PAGE_ID, $period, $type);
//Init Pagination Class
$pagination = new Pagination($totalCount, BuckysPost::${COUNT_PER_PAGE . strtoupper("_{$type}")}, $page);
$page = $pagination->getCurrentPage();
//Getting Results
$results = BuckysPost::getTopPosts(BuckysPost::INDEPENDENT_POST_PAGE_ID, $period, $type, $page);
buckys_enqueue_stylesheet('index.css');
$BUCKYS_GLOBALS['content'] = "tops";
$typeString = array('image' => 'Images ', 'video' => 'Videos ', 'text' => 'Posts ');
$periodString = array('today' => 'Today ', 'this-month' => 'This Month ', 'all' => '');
//Page title
$BUCKYS_GLOBALS['title'] = "Most Popular " . $typeString[$type] . $periodString[$period] . '- BuckysRoom';
require DIR_FS_TEMPLATE . $BUCKYS_GLOBALS['template'] . "/" . $BUCKYS_GLOBALS['layout'] . ".php";
 /**
  * Delete Objects
  *
  * @param Array $ids
  */
 public static function deleteObjects($ids)
 {
     global $db;
     if (!is_array($ids)) {
         $ids = [$ids];
     }
     $ids = $db->escapeInput($ids);
     $query = $db->prepare("SELECT * FROM " . TABLE_REPORTS . " WHERE reportID IN (" . implode(", ", $ids) . ")");
     $rows = $db->getResultsArray($query);
     foreach ($rows as $row) {
         if ($row['objectType'] == 'post') {
             $post = $db->getRow("SELECT * FROM " . TABLE_POSTS . " WHERE postID=" . $row['objectID']);
             BuckysPost::deletePost($post['poster'], $post['postID']);
         } else {
             if ($row['objectType'] == 'comment') {
                 //Getting Data
                 $comment = $db->getRow("SELECT * FROM " . TABLE_POSTS_COMMENTS . " WHERE commentID=" . $row['objectID']);
                 BuckysComment::deleteComment($comment['commenter'], $comment['commentID']);
             } else {
                 if ($row['objectType'] == 'video_comment') {
                     //Getting Data
                     $comment = $db->getRow("SELECT * FROM " . TABLE_VIDEO_COMMENTS . " WHERE commentID=" . $row['objectID']);
                     BuckysVideo::deleteVideoComment($comment['commentID']);
                 } else {
                     if ($row['objectType'] == 'message') {
                         //Delete Message
                         $db->query("DELETE FROM " . TABLE_MESSAGES . " WHERE messageID=" . $row['objectID']);
                     } else {
                         if ($row['objectType'] == 'topic') {
                             //Delete Topic
                             BuckysForumTopic::deleteTopic($row['objectID']);
                         } else {
                             if ($row['objectType'] == 'reply') {
                                 //Delete Topic
                                 BuckysForumReply::deleteReply($row['objectID']);
                             } else {
                                 if ($row['objectType'] == 'shop_item') {
                                     //Delete Shop Product
                                     $shopProdIns = new BuckysShopProduct();
                                     $shopProdIns->removeProductByUserID($row['objectID'], $row['reportedID']);
                                 } else {
                                     if ($row['objectType'] == 'trade_item') {
                                         //Delete Trade Item
                                         $tradeItemIns = new BuckysTradeItem();
                                         $tradeItemIns->removeItemByUserID($row['objectID'], $row['reportedID']);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         //Delete the row on the report table
         $db->query("DELETE FROM " . TABLE_REPORTS . " WHERE reportID=" . $row['reportID']);
     }
     return;
 }
<?php

require dirname(__FILE__) . '/includes/bootstrap.php';
$periods = array('today', 'this-week', 'this-month', 'all');
$types = array('image', 'text', 'video');
$counts = array('image' => 12, 'text' => 10, 'video' => 8);
foreach ($types as $type) {
    $result = array();
    foreach ($periods as $period) {
        $tResult = BuckysPost::getTopPosts(BuckysPost::INDEPENDENT_POST_PAGE_ID, $period, $type, 1, $counts[$type] - count($result));
        $result = array_merge($result, $tResult);
        if (count($result) >= $counts[$type]) {
            break;
        }
    }
    //Delete Old Data From DB
    $db->query("DELETE FROM " . TABLE_STATS_POST . " WHERE postType='" . $type . "'");
    //Insert New Data To DB
    foreach ($result as $idx => $row) {
        $db->insertFromArray(TABLE_STATS_POST, array('postID' => $row['postID'], 'postType' => $type, 'sortOrder' => $idx + 1, 'createdDate' => date('Y-m-d H:i:s')));
    }
}
//Send Email for Testing
//buckys_sendmail('*****@*****.**', 'Eric So', 'cronjob test', 'cronjob test');
Пример #15
0
 /**
  * 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;
         }
     }
 }
Пример #16
0
 buckys_enqueue_stylesheet('publisher.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('page.js');
 //Get Page Data
 $pageData = $pageIns->getPageByID($paramPageID, false);
 $view['pageData'] = $pageData;
 if (!isset($pageData) || $pageData['userID'] != $userID && $pageData['status'] == BuckysPage::STATUS_INACTIVE) {
     //This page doesn't exist or inactive
     buckys_redirect('/index.php', MSG_NO_SUCH_PAGE, MSG_TYPE_ERROR);
 }
 //Get Posts Belonged to this page
 $postIns = new BuckysPost();
 if (!$paramPostID) {
     $view['posts'] = $postIns->getPostsByUserID($pageData['userID'], $userID, $pageData['pageID']);
     $view['show_only_post'] = false;
 } else {
     $onePostData = $postIns->getPostById($paramPostID, $paramPageID);
     if (!buckys_not_null($onePostData)) {
         buckys_redirect('/index.php');
     }
     $view['posts'][] = $onePostData;
     $view['show_only_post'] = true;
 }
 //Get followers
 $pageFollowerIns = new BuckysPageFollower();
 $view['followers'] = $pageFollowerIns->getFollowers($pageData['pageID'], 1, 18, true);
 //Is this my page?
Пример #17
0
/**
 * Show All Top Images, Videos or Text
 */
require dirname(__FILE__) . '/includes/bootstrap.php';
$userID = buckys_is_logged_in();
$type = isset($_GET['type']) ? strtolower($_GET['type']) : '';
//If the url param is not correct, go to index page
if (!$type || !in_array($type, ['image', 'text', 'video'])) {
    buckys_redirect('/index.php');
}
//Perios = Today, This Week, This Month, All Time
$period = isset($_GET['period']) ? strtolower($_GET['period']) : 'all';
//Default all
if (!in_array($period, ['today', 'this-week', 'this-month', 'all'])) {
    $period = 'all';
}
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$totalCount = BuckysPost::getNumberOfPosts($period, $type);
$pageLimit = "COUNT_PER_PAGE_" . strtoupper($type);
//Init Pagination Class
$pagination = new Pagination($totalCount, BuckysPost::${$pageLimit}, $page);
$page = $pagination->getCurrentPage();
//Getting Results
$results = BuckysPost::getTopPosts($period, $type, $page, BuckysPost::${$pageLimit});
buckys_enqueue_stylesheet('index.css');
$TNB_GLOBALS['content'] = "tops";
$typeString = ['image' => 'Images ', 'video' => 'Videos ', 'text' => 'Posts '];
$periodString = ['today' => 'Today ', 'this-week' => 'This Week ', 'this-month' => 'This Month ', 'all' => ''];
//Page title
$TNB_GLOBALS['title'] = "Most Popular " . $typeString[$type] . $periodString[$period] . '- ' . TNB_SITE_NAME;
require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";
Пример #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);
}
if (isset($_POST['action']) && $_POST['action'] == 'create-photo') {
    //Add Photo
    if ($newID = BuckysPost::savePhoto($userID, $_POST)) {
        buckys_redirect('/photo_edit.php?photoID=' . $newID);
    } else {
        buckys_redirect('/photo_add.php');
    }
}
//Getting UserData from Id
$userData = BuckysUser::getUserData($userID);
//Getting User Albums
$albums = BuckysAlbum::getAlbumsByUserId($userID);
buckys_enqueue_stylesheet('account.css');
buckys_enqueue_stylesheet('posting.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('add_photo.js');
$BUCKYS_GLOBALS['content'] = 'photo_add';
$BUCKYS_GLOBALS['title'] = "Add Photo - BuckysRoom";
require DIR_FS_TEMPLATE . $BUCKYS_GLOBALS['template'] . "/" . $BUCKYS_GLOBALS['layout'] . ".php";
Пример #19
0
}
if (!$showPagePhotoFlag) {
    //if logged user can see all resources of the current user
    $canViewPrivate = $userID == $profileID || BuckysFriend::isFriend($userID, $profileID) || BuckysFriend::isSentFriendRequest($profileID, $userID);
    $photos = BuckysPost::getPhotosByUserID($profileID, $userID, $paramPageID, $canViewPrivate, $postID, $albumID, BuckysPost::$images_per_page);
    $albums = BuckysAlbum::getAlbumsByUserId($profileID);
    //Display
    $TNB_GLOBALS['title'] = trim($userData['firstName'] . ' ' . $userData['lastName']) . "'s Photos - " . TNB_SITE_NAME;
    $view['photo_type'] = 'profile';
    buckys_enqueue_stylesheet('profile.css');
    buckys_enqueue_stylesheet('posting.css');
    buckys_enqueue_stylesheet('publisher.css');
    buckys_enqueue_javascript('posts.js');
} else {
    //Show page photos if logged user can see all resources of the current user
    $photos = BuckysPost::getPhotosByUserID($profileID, null, $paramPageID, false, $postID, $albumID, BuckysPost::$images_per_page);
    //Display
    $TNB_GLOBALS['title'] = trim($pageData['title']) . "'s Photos - " . TNB_SITE_NAME;
    $view['photo_type'] = 'page';
    $view['pageData'] = $pageData;
    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_stylesheet('publisher.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_redirect('/photo_manage.php');
    } else {
        if ($action == 'delete-photo') {
            if (!BuckysPost::deletePost($userID, $_REQUEST['photoID'])) {
                buckys_redirect('/photo_manage.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
            } else {
                buckys_redirect('/photo_manage.php', MSG_PHOTO_REMOVED, MSG_TYPE_SUCCESS);
            }
        } else {
            if ($action == 'remove-profile-photo') {
                BuckysUser::updateUserFields($userID, ['thumbnail' => '']);
                buckys_redirect('/photo_manage.php');
            }
        }
    }
}
//Getting Album ID
$albumID = isset($_REQUEST['albumID']) ? $_REQUEST['albumID'] : null;
//Getting Current Page
$page = isset($_GET['page']) ? $_GET['page'] : 1;
$totalCount = BuckysPost::getNumberOfPhotosByUserID($userID, BuckysPost::INDEPENDENT_POST_PAGE_ID, $albumID);
$pagination = new Pagination($totalCount, BuckysPost::$IMAGES_PER_PAGE_FOR_MANAGE_PHOTOS_PAGE, $page);
$page = $pagination->getCurrentPage();
$photos = BuckysPost::getPhotosByUserID($userID, $userID, BuckysPost::INDEPENDENT_POST_PAGE_ID, true, null, $albumID, BuckysPost::$IMAGES_PER_PAGE_FOR_MANAGE_PHOTOS_PAGE);
$albums = BuckysAlbum::getAlbumsByUserId($userID);
buckys_enqueue_stylesheet('account.css');
buckys_enqueue_stylesheet('posting.css');
buckys_enqueue_stylesheet('info.css');
$TNB_GLOBALS['content'] = 'photo_manage';
$TNB_GLOBALS['title'] = "Manage Photos - " . TNB_SITE_NAME;
require DIR_FS_TEMPLATE . $TNB_GLOBALS['template'] . "/" . $TNB_GLOBALS['layout'] . ".php";
Пример #21
0
//If photo id is not correct or the owner is not the current user, goto photo management page
if (!$photo || $photo['poster'] != $userID) {
    buckys_redirect('/photo_manage.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
}
if (isset($_POST['action'])) {
    //Create New Album
    if ($_POST['action'] == 'save-photo') {
        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;
Пример #22
0
 /**
  * Delete Objects
  * 
  * @param Array $ids
  * @param String $objectType
  * @param String $modeartorType
  */
 public function deleteObjects($ids, $objectType, $moderatorType)
 {
     global $db;
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $ids = $db->escapeInput($ids);
     $query = $db->prepare("SELECT * FROM " . TABLE_REPORTS . " WHERE objectType=%s AND reportID in (" . implode(", ", $ids) . ")", $objectType);
     $rows = $db->getResultsArray($query);
     foreach ($rows as $row) {
         if ($row['objectType'] == 'post') {
             $post = $db->getRow("SELECT * FROM " . TABLE_POSTS . " WHERE postID=" . $row['objectID']);
             BuckysPost::deletePost($post['poster'], $post['postID']);
         } else {
             if ($row['objectType'] == 'comment') {
                 //Getting Data
                 $comment = $db->getRow("SELECT * FROM " . TABLE_POSTS_COMMENTS . " WHERE commentID=" . $row['objectID']);
                 BuckysComment::deleteComment($comment['commenter'], $comment['commentID']);
             } else {
                 if ($row['objectType'] == 'message') {
                     //Delete Message
                     $db->query("DELETE FROM " . TABLE_MESSAGES . " WHERE messageID=" . $row['objectID']);
                 } else {
                     if ($row['objectType'] == 'topic') {
                         //Delete Topic
                         BuckysForumTopic::deleteTopic($row['objectID']);
                     } else {
                         if ($row['objectType'] == 'reply') {
                             //Delete Topic
                             BuckysForumReply::deleteReply($row['objectID']);
                         }
                     }
                 }
             }
         }
         //Delete the row on the report table
         $db->query("DELETE FROM " . TABLE_REPORTS . " WHERE reportID=" . $row['reportID']);
     }
     return;
 }
<?php

require dirname(__FILE__) . '/includes/bootstrap.php';
$periods = ['today', 'this-week', 'this-month', 'all'];
$types = ['image', 'text', 'video'];
$counts = ['image' => 12, 'text' => 10, 'video' => 8];
$base_values = ['image' => 1.01, 'text' => 1.01, 'video' => 1.01];
foreach ($types as $type) {
    $result = [];
    foreach ($periods as $period) {
        $tResult = BuckysPost::getTopPostsForHomepage($period, $type, $base_values[$type], 1, $counts[$type] - count($result));
        $result = array_merge($result, $tResult);
        if (count($result) >= $counts[$type]) {
            break;
        }
    }
    //Delete Old Data From DB
    $db->query("DELETE FROM " . TABLE_STATS_POST . " WHERE postType='" . $type . "'");
    //Insert New Data To DB
    foreach ($result as $idx => $row) {
        $db->insertFromArray(TABLE_STATS_POST, ['postID' => $row['postID'], 'postType' => $type, 'sortOrder' => $idx + 1, 'createdDate' => date('Y-m-d H:i:s')]);
    }
}
Пример #24
0
require dirname(__FILE__) . '/includes/bootstrap.php';
//Getting Current User ID
$userID = buckys_is_logged_in();
//Getting User ID from Parameter
$profileID = isset($_GET['user']) ? $_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');
}
//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, isset($_GET['post']) ? $_GET['post'] : null);
/*if( !buckys_not_null($posts) )
{
    //Goto Index Page
    buckys_redirect('/index.php', MSG_INVALID_REQUEST, MSG_TYPE_ERROR);
}*/
buckys_enqueue_stylesheet('profile.css');
buckys_enqueue_stylesheet('posting.css');
buckys_enqueue_javascript('posts.js');
$BUCKYS_GLOBALS['content'] = 'posts';
if ($userData) {
    $BUCKYS_GLOBALS['title'] = trim($userData['firstName'] . ' ' . $userData['lastName']) . "'s Posts - BuckysRoom";
}
require DIR_FS_TEMPLATE . $BUCKYS_GLOBALS['template'] . "/" . $BUCKYS_GLOBALS['layout'] . ".php";
Пример #25
0
 /**
  * Delete page by PageID
  * 
  * @param integer $userID
  * @param integer $pageID
  */
 public function deletePageByID($pageID, $userID = null)
 {
     global $db;
     $postIns = new BuckysPost();
     $pageFollowerIns = new BuckysPageFollower();
     //Get Page info & related posts belonged to this page.
     $pageData = $this->getPageByID($pageID);
     if (!$pageData) {
         return false;
     }
     if (!empty($userID) && $pageData['userID'] != $userID) {
         return false;
         // You don't have permission to delete this page
     }
     $postList = $postIns->getPostsByPageID($pageData['pageID']);
     //Delete related posts
     if (is_array($postList) && count($postList) > 0) {
         foreach ($postList as $postData) {
             $postIns->deletePost($pageData['userID'], $postData['postID']);
         }
     }
     //Delete page
     $query = sprintf("DELETE FROM %s WHERE pageID=%d", TABLE_PAGES, $pageID);
     $db->query($query);
     //Delete followers
     $pageFollowerIns->removeAllFollowersByPageID($pageID);
     return true;
 }
Пример #26
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";
$totalFriendsCount = BuckysFriend::getNumberOfFriends($profileID);
?>
<aside id="main_aside" style="overflow:visible;"> <!-- 241px -->
    <span class="titles"><?php 
echo $userData['firstName'] . " " . $userData['lastName'];
?>
</span> <br/>
    <?php 
render_profile_link($userData, 'mainProfilePic');
?>
    <br/> <a
        href="/photos.php?user=<?php 
echo $userData['userID'];
?>
">View All Photos (<?php 
echo BuckysPost::getNumberOfPhotosByUserID($userData['userID']);
?>
)</a>
    <br/>

    <!-- Friend Links -->
    <?php 
if (buckys_not_null($userID) && $userID != $profileID) {
    //If this is not current logged user, Show Friends, Message Links
    //Show Friend Links
    if ($fid = BuckysFriend::isFriend($userID, $profileID)) {
        ?>
            <a href="/myfriends.php?action=unfriend&friendID=<?php 
        echo $profileID;
        echo buckys_get_token_param();
        ?>
Пример #28
0
 //If comment is empty, show error
 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"));
 /**
  * @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;
     }
 }
 public function getPhotosAction()
 {
     $data = $_POST;
     $token = isset($data['TOKEN']) ? trim($data['TOKEN']) : null;
     $lastDate = isset($data['lastDate']) ? $data['lastDate'] : null;
     $profileID = isset($data['profileId']) ? $data['profileId'] : 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.')];
     }
     $userData = BuckysUser::getUserData($profileID);
     if (!buckys_not_null($profileID) || !buckys_not_null($userData) || !BuckysUser::checkUserID($profileID, true)) {
         return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => buckys_api_get_error_result(MSG_INVALID_REQUEST)];
     }
     $canViewPrivate = $userID == $profileID || BuckysFriend::isFriend($userID, $profileID) || BuckysFriend::isSentFriendRequest($profileID, $userID);
     //Getting Photos
     $photos = BuckysPost::getPhotosByUserID($profileID, $userID, BuckysPost::INDEPENDENT_POST_PAGE_ID, $canViewPrivate, null, null, 18, $lastDate);
     $resultPhotos = [];
     foreach ($photos as $row) {
         $resultPhotos[] = ["posted_date" => $row['post_date'], "thumbnail" => THENEWBOSTON_SITE_URL . DIR_WS_PHOTO . 'users/' . $row['poster'] . '/resized/' . $row['image'], "original" => THENEWBOSTON_SITE_URL . DIR_WS_PHOTO . 'users/' . $row['poster'] . '/original/' . $row['image']];
     }
     return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ["STATUS" => "SUCCESS", "PHOTOS" => $resultPhotos]];
 }