Exemple #1
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;
        }
    }
}
 /**
  * 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;
 }
 /**
  * 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;
 }
        header('Content-type: application/xml');
        $commentsHTML = '';
        foreach ($comments as $comment) {
            $commentsHTML .= render_single_comment($comment, $userID, true);
            $lastDate = $comment['posted_date'];
        }
        $result = ['comment' => $commentsHTML];
        render_result_xml(['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 (!buckys_check_form_token('request') || !BuckysComment::deleteComment($userID, $commentID)) {
                echo 'Invalid Request';
            } else {
                header('content-type: application/xml');
                $newCount = BuckysComment::getPostCommentsCount($postID);
                render_result_xml(['commentcount' => $newCount > 1 ? $newCount . " comments" : $newCount . " comment"]);
            }
            exit;
        }
    }
}