Ejemplo n.º 1
0
function delete_torrent($ID, $GroupID=0) {
	global $DB, $Cache, $LoggedUser;
	if(!$GroupID) {
		$DB->query("SELECT GroupID, UserID FROM torrents WHERE ID='$ID'");
		list($GroupID, $UploaderID) = $DB->next_record();
	}
	if(empty($UserID)) {
		$DB->query("SELECT UserID FROM torrents WHERE ID='$ID'");
		list($UserID) = $DB->next_record();
	}

	$RecentUploads = $Cache->get_value('recent_uploads_'.$UserID);
	if(is_array($RecentUploads)) {
		foreach($RecentUploads as $Key => $Recent) {
			if($Recent['ID'] == $GroupID) {
				$Cache->delete_value('recent_uploads_'.$UserID);
			}
		}
	}
	
	
	
	$DB->query("UPDATE torrents SET flags=1 WHERE ID = '$ID'"); // Let xbtt delete the torrent
	$Cache->decrement('stats_torrent_count');

	$DB->query("SELECT COUNT(ID) FROM torrents WHERE GroupID='$GroupID' AND flags <> 1");
	list($Count) = $DB->next_record();

	if($Count == 0) {
		delete_group($GroupID);
	} else {
		update_hash($GroupID);
		//Artists
		$DB->query("SELECT ArtistID
				FROM torrents_artists 
				WHERE GroupID = ".$GroupID);
		$ArtistIDs = $DB->collect('ArtistID');
		foreach($ArtistIDs as $ArtistID) {
			$Cache->delete_value('artist_'.$ArtistID);
		}
	}

	// Torrent notifications
	$DB->query("SELECT UserID FROM users_notify_torrents WHERE TorrentID='$ID'");
	while(list($UserID) = $DB->next_record()) {
		$Cache->delete_value('notifications_new_'.$UserID);
	}
	$DB->query("DELETE FROM users_notify_torrents WHERE TorrentID='$ID'");
	
	$Cache->delete_value('torrent_download_'.$ID);
	$Cache->delete_value('torrent_group_'.$GroupID);
}
Ejemplo n.º 2
0
	$GroupID=$NewGroupID;
	
	//Collages
	$DB->query("SELECT CollageID FROM collages_torrents WHERE GroupID='$OldGroupID'"); //Select all collages that contain edited group
	while(list($CollageID) = $DB->next_record()) {
		$DB->query("UPDATE IGNORE collages_torrents SET GroupID='$NewGroupID' WHERE GroupID='$OldGroupID' AND CollageID='$CollageID'"); //Change collage groupid to new ID
		$DB->query("DELETE FROM collages_torrents WHERE GroupID='$OldGroupID' AND CollageID='$CollageID'");
		$Cache->delete_value('collage_'.$CollageID);
	}
	
	
	$DB->query("SELECT ID FROM torrents WHERE GroupID='$OldGroupID'");
	while(list($TorrentID) = $DB->next_record()) {
		$Cache->delete_value('torrent_download_'.$TorrentID);
	}
	$Cache->delete_value('torrents_details_'.$GroupID);
	
	$DB->query("SELECT DISTINCT ArtistID FROM torrents_artists WHERE GroupID IN ('$GroupID', '$OldGroupID')");
	while(list($ArtistID) = $DB->next_record()) {
		$Cache->delete_value('artist_'.$ArtistID); 
	}
	
	$Cache->delete_value('torrentcomments_count_'.$GroupID);
	$Cache->delete_value('torrentcomment_'.$GroupID.'_page_1');
	$Cache->delete_value('groups_artists_'.$GroupID);
	update_hash($GroupID);
	
	header('Location: torrents.php?id='.$GroupID);
}
?>
Ejemplo n.º 3
0
	if(!empty($TagName)) {
		// Check DB for tag matching name
		$DB->query("SELECT t.ID FROM tags AS t WHERE t.Name LIKE '".$TagName."'");
		list($TagID) = $DB->next_record();
	
		if(!$TagID) { // Tag doesn't exist yet - create tag
			$DB->query("INSERT INTO tags (Name, UserID) VALUES ('".$TagName."', ".$UserID.")");
			$TagID = $DB->inserted_id();
		} else {
			$DB->query("SELECT TagID FROM torrents_tags_votes WHERE GroupID='$GroupID' AND TagID='$TagID' AND UserID='$UserID'");
			if($DB->record_count()!=0) { // User has already voted on this tag, and is trying hax to make the rating go up
				header('Location: '.$_SERVER['HTTP_REFERER']);
				die();
			}
		}
	
		$DB->query("INSERT INTO torrents_tags 
			(TagID, GroupID, PositiveVotes, UserID) VALUES 
			('$TagID', '$GroupID', '3', '$UserID') 
			ON DUPLICATE KEY UPDATE PositiveVotes=PositiveVotes+2");
	
		$DB->query("INSERT INTO torrents_tags_votes (GroupID, TagID, UserID, Way) VALUES ('$GroupID', '$TagID', '$UserID', 'up')");
		
		
	}
}

update_hash($GroupID); // Delete torrent group cache
header('Location: '.$_SERVER['HTTP_REFERER']);
?>