Exemplo n.º 1
0
 /**
  * Delete a torrent.
  *
  * @param int $ID The ID of the torrent to delete.
  * @param int $GroupID Set it if you have it handy, to save a query. Otherwise, it will be found.
  * @param string $OcelotReason The deletion reason for ocelot to report to users.
  */
 public static function delete_torrent($ID, $GroupID = 0, $OcelotReason = -1)
 {
     $QueryID = G::$DB->get_query_id();
     if (!$GroupID) {
         G::$DB->query("\n\t\t\t\tSELECT GroupID, UserID\n\t\t\t\tFROM torrents\n\t\t\t\tWHERE ID = '{$ID}'");
         list($GroupID, $UploaderID) = G::$DB->next_record();
     }
     if (empty($UserID)) {
         G::$DB->query("\n\t\t\t\tSELECT UserID\n\t\t\t\tFROM torrents\n\t\t\t\tWHERE ID = '{$ID}'");
         list($UserID) = G::$DB->next_record();
     }
     $RecentUploads = G::$Cache->get_value("recent_uploads_{$UserID}");
     if (is_array($RecentUploads)) {
         foreach ($RecentUploads as $Key => $Recent) {
             if ($Recent['ID'] == $GroupID) {
                 G::$Cache->delete_value("recent_uploads_{$UserID}");
             }
         }
     }
     G::$DB->query("\n\t\t\tSELECT info_hash\n\t\t\tFROM torrents\n\t\t\tWHERE ID = {$ID}");
     list($InfoHash) = G::$DB->next_record(MYSQLI_BOTH, false);
     G::$DB->query("\n\t\t\tDELETE FROM torrents\n\t\t\tWHERE ID = {$ID}");
     Tracker::update_tracker('delete_torrent', array('info_hash' => rawurlencode($InfoHash), 'id' => $ID, 'reason' => $OcelotReason));
     G::$Cache->decrement('stats_torrent_count');
     G::$DB->query("\n\t\t\tSELECT COUNT(ID)\n\t\t\tFROM torrents\n\t\t\tWHERE GroupID = '{$GroupID}'");
     list($Count) = G::$DB->next_record();
     if ($Count == 0) {
         Torrents::delete_group($GroupID);
     } else {
         Torrents::update_hash($GroupID);
     }
     // Torrent notifications
     G::$DB->query("\n\t\t\tSELECT UserID\n\t\t\tFROM users_notify_torrents\n\t\t\tWHERE TorrentID = '{$ID}'");
     while (list($UserID) = G::$DB->next_record()) {
         G::$Cache->delete_value("notifications_new_{$UserID}");
     }
     G::$DB->query("\n\t\t\tDELETE FROM users_notify_torrents\n\t\t\tWHERE TorrentID = '{$ID}'");
     G::$DB->query("\n\t\t\tUPDATE reportsv2\n\t\t\tSET\n\t\t\t\tStatus = 'Resolved',\n\t\t\t\tLastChangeTime = '" . sqltime() . "',\n\t\t\t\tModComment = 'Report already dealt with (torrent deleted)'\n\t\t\tWHERE TorrentID = {$ID}\n\t\t\t\tAND Status != 'Resolved'");
     $Reports = G::$DB->affected_rows();
     if ($Reports) {
         G::$Cache->decrement('num_torrent_reportsv2', $Reports);
     }
     G::$DB->query("\n\t\t\tDELETE FROM torrents_files\n\t\t\tWHERE TorrentID = '{$ID}'");
     G::$DB->query("\n\t\t\tDELETE FROM torrents_bad_tags\n\t\t\tWHERE TorrentID = {$ID}");
     G::$DB->query("\n\t\t\tDELETE FROM torrents_bad_folders\n\t\t\tWHERE TorrentID = {$ID}");
     G::$DB->query("\n\t\t\tDELETE FROM torrents_bad_files\n\t\t\tWHERE TorrentID = {$ID}");
     G::$DB->query("\n\t\t\tDELETE FROM torrents_cassette_approved\n\t\t\tWHERE TorrentID = {$ID}");
     G::$DB->query("\n\t\t\tDELETE FROM torrents_lossymaster_approved\n\t\t\tWHERE TorrentID = {$ID}");
     G::$DB->query("\n\t\t\tDELETE FROM torrents_lossyweb_approved\n\t\t\tWHERE TorrentID = {$ID}");
     // Tells Sphinx that the group is removed
     G::$DB->query("\n\t\t\tREPLACE INTO sphinx_delta (ID, Time)\n\t\t\tVALUES ({$ID}, UNIX_TIMESTAMP())");
     G::$Cache->delete_value("torrent_download_{$ID}");
     G::$Cache->delete_value("torrent_group_{$GroupID}");
     G::$Cache->delete_value("torrents_details_{$GroupID}");
     G::$DB->set_query_id($QueryID);
 }
Exemplo n.º 2
0
    $DB->query("\n\t\tSELECT CollageID\n\t\tFROM collages_torrents\n\t\tWHERE GroupID = '{$OldGroupID}'");
    // Select all collages that contain edited group
    while (list($CollageID) = $DB->next_record()) {
        $DB->query("\n\t\t\tUPDATE IGNORE collages_torrents\n\t\t\tSET GroupID = '{$NewGroupID}'\n\t\t\tWHERE GroupID = '{$OldGroupID}'\n\t\t\t\tAND CollageID = '{$CollageID}'");
        // Change collage group ID to new ID
        $DB->query("\n\t\t\tDELETE FROM collages_torrents\n\t\t\tWHERE GroupID = '{$OldGroupID}'\n\t\t\t\tAND CollageID = '{$CollageID}'");
        $Cache->delete_value("collage_{$CollageID}");
    }
    $Cache->delete_value("torrent_collages_{$NewGroupID}");
    $Cache->delete_value("torrent_collages_personal_{$NewGroupID}");
    // Requests
    $DB->query("\n\t\tSELECT ID\n\t\tFROM requests\n\t\tWHERE GroupID = '{$OldGroupID}'");
    $Requests = $DB->collect('ID');
    $DB->query("\n\t\tUPDATE requests\n\t\tSET GroupID = '{$NewGroupID}'\n\t\tWHERE GroupID = '{$OldGroupID}'");
    foreach ($Requests as $RequestID) {
        $Cache->delete_value("request_{$RequestID}");
    }
    $Cache->delete_value('requests_group_' . $NewGroupID);
    Torrents::delete_group($GroupID);
    Torrents::write_group_log($NewGroupID, 0, $LoggedUser['ID'], "Merged Group {$GroupID} ({$Name}) to {$NewGroupID} ({$NewName})", 0);
    $DB->query("\n\t\tUPDATE group_log\n\t\tSET GroupID = {$NewGroupID}\n\t\tWHERE GroupID = {$GroupID}");
    $GroupID = $NewGroupID;
    $DB->query("\n\t\tSELECT ID\n\t\tFROM torrents\n\t\tWHERE GroupID = '{$OldGroupID}'");
    while (list($TorrentID) = $DB->next_record()) {
        $Cache->delete_value("torrent_download_{$TorrentID}");
    }
    $Cache->delete_value("torrents_details_{$GroupID}");
    $Cache->delete_value("groups_artists_{$GroupID}");
    Torrents::update_hash($GroupID);
    header("Location: torrents.php?id=" . $GroupID);
}
Exemplo n.º 3
0
				</ul>
				<input type="submit" value="Confirm" />
			</form>
		</div>
	</div>
<?php 
    View::show_footer();
} else {
    authorize();
    $DB->query("\n\t\tUPDATE torrents\n\t\tSET\tGroupID = '{$GroupID}'\n\t\tWHERE ID = {$TorrentID}");
    // Delete old torrent group if it's empty now
    $DB->query("\n\t\tSELECT COUNT(ID)\n\t\tFROM torrents\n\t\tWHERE GroupID = '{$OldGroupID}'");
    list($TorrentsInGroup) = $DB->next_record();
    if ($TorrentsInGroup == 0) {
        // TODO: votes etc!
        $DB->query("\n\t\t\tUPDATE comments\n\t\t\tSET PageID = '{$GroupID}'\n\t\t\tWHERE Page = 'torrents'\n\t\t\t\tAND PageID = '{$OldGroupID}'");
        $Cache->delete_value("torrent_comments_{$GroupID}_catalogue_0");
        $Cache->delete_value("torrent_comments_{$GroupID}");
        Torrents::delete_group($OldGroupID);
    } else {
        Torrents::update_hash($OldGroupID);
    }
    Torrents::update_hash($GroupID);
    Misc::write_log("Torrent {$TorrentID} was edited by " . $LoggedUser['Username']);
    // TODO: this is probably broken
    Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "merged group {$OldGroupID}", 0);
    $DB->query("\n\t\tUPDATE group_log\n\t\tSET GroupID = {$GroupID}\n\t\tWHERE GroupID = {$OldGroupID}");
    $Cache->delete_value("torrents_details_{$GroupID}");
    $Cache->delete_value("torrent_download_{$TorrentID}");
    header("Location: torrents.php?id={$GroupID}");
}
Exemplo n.º 4
0
                Torrents::regenerate_filelist($_GET['torrentid']);
                header('Location: torrents.php?torrentid=' . $_GET['torrentid']);
                die;
            } else {
                error(403);
            }
            break;
        case 'fix_group':
            if ((check_perms('users_mod') || check_perms('torrents_fix_ghosts')) && authorize() && !empty($_GET['groupid']) && is_number($_GET['groupid'])) {
                $DB->query('
					SELECT COUNT(ID)
					FROM torrents
					WHERE GroupID = ' . $_GET['groupid']);
                list($Count) = $DB->next_record();
                if ($Count == 0) {
                    Torrents::delete_group($_GET['groupid']);
                } else {
                }
                if (!empty($_GET['artistid']) && is_number($_GET['artistid'])) {
                    header('Location: artist.php?id=' . $_GET['artistid']);
                } else {
                    header('Location: torrents.php?id=' . $_GET['groupid']);
                }
            } else {
                error(403);
            }
            break;
        case 'add_cover_art':
            include SERVER_ROOT . '/sections/torrents/add_cover_art.php';
            break;
        case 'remove_cover_art':