Example #1
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;
}
Example #2
0
        header('Content-type: application/xml');
        $commentsHTML = '';
        foreach ($comments as $comment) {
            $commentsHTML .= render_single_comment($comment, $userID, true);
            $lastDate = $comment['posted_date'];
        }
        $result = array('comment' => $commentsHTML);
        render_result_xml(array('comment' => $commentsHTML, 'lastdate' => $lastDate, 'hasmore' => $commentsHTML != '' && BuckysComment::hasMoreComments($postID, $lastDate) ? 'yes' : 'no'));
    }
} else {
    if ($_GET['action']) {
        //Delete Post
        if ($_GET['action'] == 'delete-comment') {
            if (!$userID) {
                echo MSG_INVALID_REQUEST;
                exit;
            }
            $postID = $_GET['postID'];
            $commentID = $_GET['commentID'];
            $cUserID = $_GET['userID'];
            if (!BuckysComment::deleteComment($userID, $commentID)) {
                echo 'Invalid Request';
            } else {
                header('content-type: application/xml');
                $newCount = BuckysComment::getPostCommentsCount($postID);
                render_result_xml(array('commentcount' => $newCount > 1 ? $newCount . " comments" : $newCount . " comment"));
            }
            exit;
        }
    }
}
        echo $row['ownerID'];
        ?>
">
                                        <?php 
        echo $row['ownerName'];
        ?>
                                    </a>
                                </div>
                                <div class="td td-content">
                                    <?php 
        switch ($row['objectType']) {
            case 'post':
                echo '<a href="/posts.php?user='******'ownerID'] . '&post=' . $row['objectID'] . '">Post - ' . $row['objectID'] . '</a>';
                break;
            case 'comment':
                $tPost = BuckysComment::getPost($row['objectID']);
                echo '<a href="/posts.php?user='******'poster'] . '&post=' . $tPost['postID'] . '">Comment - ' . $row['objectID'] . '</a>';
                break;
            case 'video_comment':
                echo '<a href="/videos.php?video=' . BuckysVideo::getVideoIDByCommentID($row['objectID']) . '">Video Comment - ' . $row['objectID'] . '</a>';
                break;
            case 'topic':
                echo '<a href="/forum/topic.php?id=' . $row['objectID'] . '">Forum Topic - ' . $row['objectID'] . '</a>';
                break;
            case 'message':
                echo '<a href="/messages_read.php?message=' . $row['objectID'] . '">Message - ' . $row['objectID'] . '</a>';
                break;
            case 'reply':
                echo '<a href="/forum/topic.php?id=' . BuckysForumReply::getForumID($row['objectID']) . '">Forum Reply - ' . $row['objectID'] . '</a>';
                break;
            case 'trade_item':
 /**
  * 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;
 }
 /**
  * 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;
 }