} else {
                //no permission
                //permission error
                buckys_redirect('/forum', MSG_PERMISSION_DENIED, MSG_TYPE_ERROR);
            }
        }
    }
} else {
    if (isset($_GET['action']) && $_GET['action'] == 'delete') {
        //Delete post_reply
        $userID = buckys_is_logged_in();
        $replyID = isset($_GET['replyID']) ? get_secure_integer($_GET['replyID']) : null;
        $replyData = $forumReplyIns->getReplyByID($replyID);
        if ($replyData && $replyData['creatorID'] == $userID && $replyData['topicID'] == $topicID) {
            //then you can delete this one
            $forumReplyIns->deleteReply($replyID);
            buckys_redirect("/forum/topic.php?id=" . $topicID, MSG_REPLY_REMOVED_SUCCESSFULLY, MSG_TYPE_SUCCESS);
        } else {
            echo MSG_PERMISSION_DENIED;
        }
        exit;
    } else {
        if (isset($_GET['action']) && $_GET['action'] == 'edit') {
            //edit post_reply
            $forumReplyIns = new BuckysForumReply();
            $userID = buckys_is_logged_in();
            $replyID = isset($_GET['replyID']) ? get_secure_integer($_GET['replyID']) : null;
            $replyData = $forumReplyIns->getReplyByID($replyID);
            if ($replyData && $replyData['creatorID'] == $userID && $replyData['topicID'] == $topicID) {
                //then you can edit this one
                $view['replyData'] = $replyData;
 /**
  * @param $userID
  * @param $categoryID
  */
 public static function blockUser($userID, $categoryID)
 {
     global $db;
     //Getting Users Topics and Replies
     $query = $db->prepare("SELECT * FROM " . TABLE_FORUM_TOPICS . " WHERE creatorID=%d AND categoryID=%d", $userID, $categoryID);
     $topics = $db->getResultsArray($query);
     foreach ($topics as $row) {
         BuckysForumTopic::deleteTopic($row['topicID']);
     }
     $query = $db->prepare("SELECT r.replyID FROM " . TABLE_FORUM_REPLIES . " AS r LEFT JOIN " . TABLE_FORUM_TOPICS . " AS t ON t.topicID=r.topicID WHERE r.creatorID=%d AND t.categoryID=%d", $userID, $categoryID);
     $replies = $db->getResultsArray($query);
     foreach ($replies as $row) {
         BuckysForumReply::deleteReply($row['replyID']);
     }
     //Block User
     $query = $db->prepare("INSERT INTO " . TABLE_FORUM_BLOCKED_USRES . "(userID, categoryID, blockedDate)VALUES(%d, %d, %s)", $userID, $categoryID, date("Y-m-d H:i:s"));
     $db->query($query);
 }
Exemplo n.º 3
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;
 }
 /**
  * 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;
 }