예제 #1
0
파일: delete.php 프로젝트: Kufirc/Gazelle
        $UpdateArrayForums = array('NumPosts' => '-1', 'LastPostID' => $LastTopicPostID, 'LastPostAuthorID' => $LastTopicAuthorID, 'LastPostTime' => $LastTopicPostTime, 'LastPostTopicID' => $LastTopicID, 'Title' => $LastTopicTitle);
    } else {
        // Topic is still the most recent in its forum
        $DB->query("\n\t\t\tUPDATE forums\n\t\t\tSET\n\t\t\t\tLastPostID = '{$LastID}',\n\t\t\t\tLastPostAuthorID = '{$LastAuthorID}',\n\t\t\t\tLastPostTime = '{$LastTime}'\n\t\t\tWHERE ID = '{$ForumID}'\n\t\t\t\tAND LastPostTopicID = '{$TopicID}'");
        $UpdateArrayForums = array('NumPosts' => '-1', 'LastPostID' => $LastID, 'LastPostAuthorID' => $LastAuthorID, 'LastPostTime' => $LastTime);
    }
    $UpdateArrayThread = array('Posts' => '-1', 'LastPostAuthorID' => $LastAuthorID);
} else {
    $UpdateArrayForums = array('NumPosts' => '-1');
    $UpdateArrayThread = array('Posts' => '-1');
}
if ($StickyPostID == $PostID) {
    $DB->query("\n\t\tUPDATE forums_topics\n\t\tSET StickyPostID = 0\n\t\tWHERE ID = {$TopicID}");
}
//We need to clear all subsequential catalogues as they've all been bumped with the absence of this post
$ThisCatalogue = floor((POSTS_PER_PAGE * $Page - POSTS_PER_PAGE) / THREAD_CATALOGUE);
$LastCatalogue = floor((POSTS_PER_PAGE * $Pages - POSTS_PER_PAGE) / THREAD_CATALOGUE);
for ($i = $ThisCatalogue; $i <= $LastCatalogue; $i++) {
    $Cache->delete_value("thread_{$TopicID}" . "_catalogue_{$i}");
}
$Cache->begin_transaction("thread_{$TopicID}" . '_info');
$Cache->update_row(false, $UpdateArrayThread);
$Cache->commit_transaction();
$Cache->begin_transaction('forums_list');
$Cache->update_row($ForumID, $UpdateArrayForums);
$Cache->commit_transaction();
$Cache->delete_value("forums_{$ForumID}");
Subscriptions::flush_subscriptions('forums', $TopicID);
// quote notifications
Subscriptions::flush_quote_notifications('forums', $TopicID);
$DB->query("\n\tDELETE FROM users_notify_quoted\n\tWHERE Page = 'forums'\n\t\tAND PostID = '{$PostID}'");
예제 #2
0
 /**
  * Delete all comments on $Page/$PageID (deals with quote notifications and subscriptions as well)
  * @param string $Page
  * @param int $PageID
  * @return boolean
  */
 public static function delete_page($Page, $PageID)
 {
     $QueryID = G::$DB->get_query_id();
     // 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\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()) {
         return false;
     }
     list($CommPages) = G::$DB->next_record();
     // Delete comments
     G::$DB->query("\n\t\t\tDELETE FROM comments\n\t\t\tWHERE Page = '{$Page}'\n\t\t\t\tAND PageID = {$PageID}");
     // Delete quote notifications
     Subscriptions::flush_quote_notifications($Page, $PageID);
     G::$DB->query("\n\t\t\tDELETE FROM users_notify_quoted\n\t\t\tWHERE Page = '{$Page}'\n\t\t\t\tAND PageID = {$PageID}");
     // Deal with subscriptions
     Subscriptions::move_subscriptions($Page, $PageID, null);
     // Clear cache
     $LastCatalogue = floor((TORRENT_COMMENTS_PER_PAGE * $CommPages - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
     for ($i = 0; $i <= $LastCatalogue; ++$i) {
         G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $i);
     }
     G::$Cache->delete_value($Page . '_comments_' . $PageID);
     G::$DB->set_query_id($QueryID);
     return true;
 }
예제 #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');