/** * Will freeleech / neutral leech / normalise a set of torrents * * @param array $TorrentIDs An array of torrent IDs to iterate over * @param int $FreeNeutral 0 = normal, 1 = fl, 2 = nl * @param int $FreeLeechType 0 = Unknown, 1 = Staff picks, 2 = Perma-FL (Toolbox, etc.), 3 = Vanity House */ public static function freeleech_torrents($TorrentIDs, $FreeNeutral = 1, $FreeLeechType = 0) { if (!is_array($TorrentIDs)) { $TorrentIDs = array($TorrentIDs); } $QueryID = G::$DB->get_query_id(); G::$DB->query("\n\t\t\tUPDATE torrents\n\t\t\tSET FreeTorrent = '{$FreeNeutral}', FreeLeechType = '{$FreeLeechType}'\n\t\t\tWHERE ID IN (" . implode(', ', $TorrentIDs) . ')'); G::$DB->query(' SELECT ID, GroupID, info_hash FROM torrents WHERE ID IN (' . implode(', ', $TorrentIDs) . ') ORDER BY GroupID ASC'); $Torrents = G::$DB->to_array(false, MYSQLI_NUM, false); $GroupIDs = G::$DB->collect('GroupID'); G::$DB->set_query_id($QueryID); foreach ($Torrents as $Torrent) { list($TorrentID, $GroupID, $InfoHash) = $Torrent; Tracker::update_tracker('update_torrent', array('info_hash' => rawurlencode($InfoHash), 'freetorrent' => $FreeNeutral)); G::$Cache->delete_value("torrent_download_{$TorrentID}"); Misc::write_log(G::$LoggedUser['Username'] . " marked torrent {$TorrentID} freeleech type {$FreeLeechType}!"); Torrents::write_group_log($GroupID, $TorrentID, G::$LoggedUser['ID'], "marked as freeleech type {$FreeLeechType}!", 0); } foreach ($GroupIDs as $GroupID) { Torrents::update_hash($GroupID); } }
if (isset($_POST['undo'])) { $Cache->delete_value("deleted_tags_{$GroupID}" . '_' . $LoggedUser['ID']); } $Tags = explode(',', $_POST['tagname']); foreach ($Tags as $TagName) { $TagName = Misc::sanitize_tag($TagName); if (!empty($TagName)) { $TagName = Misc::get_alias_tag($TagName); // Check DB for tag matching name $DB->query("\n\t\t\tSELECT ID\n\t\t\tFROM tags\n\t\t\tWHERE Name LIKE '{$TagName}'"); list($TagID) = $DB->next_record(); if (!$TagID) { // Tag doesn't exist yet - create tag $DB->query("\n\t\t\t\tINSERT INTO tags (Name, UserID)\n\t\t\t\tVALUES ('{$TagName}', {$UserID})"); $TagID = $DB->inserted_id(); } else { $DB->query("\n\t\t\t\tSELECT TagID\n\t\t\t\tFROM torrents_tags_votes\n\t\t\t\tWHERE GroupID = '{$GroupID}'\n\t\t\t\t\tAND TagID = '{$TagID}'\n\t\t\t\t\tAND UserID = '{$UserID}'"); if ($DB->has_results()) { // 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("\n\t\t\tINSERT INTO torrents_tags\n\t\t\t\t(TagID, GroupID, PositiveVotes, UserID)\n\t\t\tVALUES\n\t\t\t\t('{$TagID}', '{$GroupID}', '3', '{$UserID}')\n\t\t\tON DUPLICATE KEY UPDATE\n\t\t\t\tPositiveVotes = PositiveVotes + 2"); $DB->query("\n\t\t\tINSERT INTO torrents_tags_votes\n\t\t\t\t(GroupID, TagID, UserID, Way)\n\t\t\tVALUES\n\t\t\t\t('{$GroupID}', '{$TagID}', '{$UserID}', 'up')"); $DB->query("\n\t\t\tINSERT INTO group_log\n\t\t\t\t(GroupID, UserID, Time, Info)\n\t\t\tVALUES\n\t\t\t\t('{$GroupID}', " . $LoggedUser['ID'] . ", '" . sqltime() . "', '" . db_string("Tag \"{$TagName}\" added to group") . "')"); } } Torrents::update_hash($GroupID); // Delete torrent group cache header('Location: ' . $_SERVER['HTTP_REFERER']);