예제 #1
0
 /**
  * Delete a comment
  * @param int $PostID
  */
 public static function delete($PostID)
 {
     $QueryID = G::$DB->get_query_id();
     // Get page, pageid
     G::$DB->query("SELECT Page, PageID FROM comments WHERE ID = {$PostID}");
     if (!G::$DB->has_results()) {
         // no such comment?
         G::$DB->set_query_id($QueryID);
         return false;
     }
     list($Page, $PageID) = G::$DB->next_record();
     // get number of pages
     G::$DB->query("\n\t\t\tSELECT\n\t\t\t\tCEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Pages,\n\t\t\t\tCEIL(SUM(IF(ID <= {$PostID}, 1, 0)) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page\n\t\t\tFROM comments\n\t\t\tWHERE Page = '{$Page}'\n\t\t\t\tAND PageID = {$PageID}\n\t\t\tGROUP BY PageID");
     if (!G::$DB->has_results()) {
         // the comment $PostID was probably not posted on $Page
         G::$DB->set_query_id($QueryID);
         return false;
     }
     list($CommPages, $CommPage) = G::$DB->next_record();
     // $CommPages = number of pages in the thread
     // $CommPage = which page the post is on
     // These are set for cache clearing.
     G::$DB->query("\n\t\t\tDELETE FROM comments\n\t\t\tWHERE ID = {$PostID}");
     G::$DB->query("\n\t\t\tDELETE FROM comments_edits\n\t\t\tWHERE Page = '{$Page}'\n\t\t\t\tAND PostID = {$PostID}");
     G::$DB->query("\n\t\t\tDELETE FROM users_notify_quoted\n\t\t\tWHERE Page = '{$Page}'\n\t\t\t\tAND PostID = {$PostID}");
     Subscriptions::flush_subscriptions($Page, $PageID);
     Subscriptions::flush_quote_notifications($Page, $PageID);
     //We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
     $ThisCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
     $LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
     for ($i = $ThisCatalogue; $i <= $LastCatalogue; ++$i) {
         G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $i);
     }
     G::$Cache->delete_value($Page . '_comments_' . $PageID);
     if ($Page == 'collages') {
         // On collages, we also need to clear the collage key (collage_$CollageID), because it has the comments in it... (why??)
         G::$Cache->delete_value("collage_{$PageID}");
     }
     G::$DB->set_query_id($QueryID);
     return true;
 }
예제 #2
0
            //Merge it
        } else {
            $Forum = $Part1 + $Part2 + $Part3;
            //Merge it
        }
        $Cache->cache_value("forums_{$ForumID}", array($Forum, '', 0, $Stickies), 0);
        //Update the forum root
        $Cache->begin_transaction('forums_list');
        $Cache->update_row($ForumID, array('NumPosts' => '+1', 'LastPostID' => $PostID, 'LastPostAuthorID' => $LoggedUser['ID'], 'LastPostTopicID' => $TopicID, 'LastPostTime' => $SQLTime, 'Title' => $ThreadInfo['Title'], 'IsLocked' => $ThreadInfo['IsLocked'], 'IsSticky' => $ThreadInfo['IsSticky']));
        $Cache->commit_transaction(0);
    } else {
        //If there's no cache, we have no data, and if there's no data
        $Cache->delete_value('forums_list');
    }
    //This calculates the block of 500 posts that this one will fall under
    $CatalogueID = floor((POSTS_PER_PAGE * ceil($ThreadInfo['Posts'] / POSTS_PER_PAGE) - POSTS_PER_PAGE) / THREAD_CATALOGUE);
    //Insert the post into the thread catalogue (block of 500 posts)
    $Cache->begin_transaction("thread_{$TopicID}" . "_catalogue_{$CatalogueID}");
    $Cache->insert('', array('ID' => $PostID, 'AuthorID' => $LoggedUser['ID'], 'AddedTime' => $SQLTime, 'Body' => $Body, 'EditedUserID' => 0, 'EditedTime' => '0000-00-00 00:00:00', 'Username' => $LoggedUser['Username']));
    $Cache->commit_transaction(0);
    //Update the thread info
    $Cache->begin_transaction("thread_{$TopicID}" . '_info');
    $Cache->update_row(false, array('Posts' => '+1', 'LastPostAuthorID' => $LoggedUser['ID']));
    $Cache->commit_transaction(0);
    //Increment this now to make sure we redirect to the correct page
    $ThreadInfo['Posts']++;
}
Subscriptions::flush_subscriptions('forums', $TopicID);
Subscriptions::quote_notify($Body, $PostID, 'forums', $TopicID);
header("Location: forums.php?action=viewthread&threadid={$TopicID}&page=" . ceil($ThreadInfo['Posts'] / $PerPage));
die;
예제 #3
0
if (!is_number($CollageID) || !$CollageID) {
    error(404);
}
$DB->query("\n\tSELECT Name, CategoryID, UserID\n\tFROM collages\n\tWHERE ID = '{$CollageID}'");
list($Name, $CategoryID, $UserID) = $DB->next_record(MYSQLI_NUM, false);
if (!check_perms('site_collages_delete') && $UserID !== $LoggedUser['ID']) {
    error(403);
}
$Reason = trim($_POST['reason']);
if (!$Reason) {
    error('You must enter a reason!');
}
$DB->query("\n\tSELECT GroupID\n\tFROM collages_torrents\n\tWHERE CollageID = '{$CollageID}'");
while (list($GroupID) = $DB->next_record()) {
    $Cache->delete_value("torrents_details_{$GroupID}");
    $Cache->delete_value("torrent_collages_{$GroupID}");
    $Cache->delete_value("torrent_collages_personal_{$GroupID}");
}
//Personal collages have CategoryID 0
if ($CategoryID == 0) {
    $DB->query("\n\t\tDELETE FROM collages\n\t\tWHERE ID = '{$CollageID}'");
    $DB->query("\n\t\tDELETE FROM collages_torrents\n\t\tWHERE CollageID = '{$CollageID}'");
    Comments::delete_page('collages', $CollageID);
} else {
    $DB->query("\n\t\tUPDATE collages\n\t\tSET Deleted = '1'\n\t\tWHERE ID = '{$CollageID}'");
    Subscriptions::flush_subscriptions('collages', $CollageID);
    Subscriptions::flush_quote_notifications('collages', $CollageID);
}
Misc::write_log("Collage {$CollageID} ({$Name}) was deleted by " . $LoggedUser['Username'] . ": {$Reason}");
$Cache->delete_value("collage_{$CollageID}");
header('Location: collages.php');