unset($ExtendedArtists[2]); unset($ExtendedArtists[3]); $DisplayName = Artists::display_artists($ExtendedArtists); } elseif (!empty($Artists)) { $DisplayName = Artists::display_artists(array(1 => $Artists)); } else { $DisplayName = ''; } $DisplayName .= '<a href="torrents.php?id=' . $GroupID . '&torrentid=' . $TorrentID . '" class="tooltip" title="View torrent" dir="ltr">' . $GroupName . '</a>'; if ($GroupYear > 0) { $DisplayName .= " [{$GroupYear}]"; } if ($GroupVanityHouse) { $DisplayName .= ' [<abbr class="tooltip" title="This is a Vanity House release">VH</abbr>]'; } $ExtraInfo = Torrents::torrent_info($Torrent); if ($ExtraInfo) { $DisplayName .= " - {$ExtraInfo}"; } ?> <tr class="torrent torrent_row<?php echo ($Torrent['IsSnatched'] ? ' snatched_torrent' : '') . ($GroupFlags['IsSnatched'] ? ' snatched_group' : ''); ?> "> <td class="center cats_col"> <div title="<?php echo $TorrentTags->title(); ?> " class="tooltip <?php echo Format::css_category($GroupCategoryID); ?>
?> _box .images').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets"><?php echo $FirstCol ? 'Hide' : 'Show'; ?> </a> </span> </td> </tr> <tr class="images<?php echo $FirstCol ? '' : ' hidden'; ?> "> <?php foreach ($Collage as $C) { $Group = Torrents::get_groups(array($C['GroupID']), true, true, false); extract(Torrents::array_group($Group[$C['GroupID']])); $Name = ''; $Name .= Artists::display_artists(array('1' => $Artists), false, true); $Name .= $GroupName; ?> <td> <a href="torrents.php?id=<?php echo $GroupID; ?> "> <img class="tooltip" title="<?php echo $Name; ?> " src="<?php echo ImageTools::process($C['WikiImage'], true); ?>
function build_torrents_table($Cache, $DB, $LoggedUser, $GroupID, $GroupName, $GroupCategoryID, $ReleaseType, $TorrentList, $Types, $Username, $ReportedTimes) { function filelist($Str) { return "</td>\n<td>" . Format::get_size($Str[1]) . "</td>\n</tr>"; } $LastRemasterYear = '-'; $LastRemasterTitle = ''; $LastRemasterRecordLabel = ''; $LastRemasterCatalogueNumber = ''; $EditionID = 0; foreach ($TorrentList as $Torrent) { //t.ID, t.Media, t.Format, t.Encoding, t.Remastered, t.RemasterYear, //t.RemasterTitle, t.RemasterRecordLabel, t.RemasterCatalogueNumber, t.Scene, //t.HasLog, t.HasCue, t.LogScore, t.FileCount, t.Size, t.Seeders, t.Leechers, //t.Snatched, t.FreeTorrent, t.Time, t.Description, t.FileList, //t.FilePath, t.UserID, t.last_action, HEX(t.info_hash), (bad tags), (bad folders), (bad filenames), //(cassette approved), (lossy master approved), (lossy web approved), t.LastReseedRequest, //LogInDB, (has file), Torrents::torrent_properties() list($TorrentID, $Media, $Format, $Encoding, $Remastered, $RemasterYear, $RemasterTitle, $RemasterRecordLabel, $RemasterCatalogueNumber, $Scene, $HasLog, $HasCue, $LogScore, $FileCount, $Size, $Seeders, $Leechers, $Snatched, $FreeTorrent, $TorrentTime, $Description, $FileList, $FilePath, $UserID, $LastActive, $InfoHash, $BadTags, $BadFolders, $BadFiles, $CassetteApproved, $LossymasterApproved, $LossywebApproved, $LastReseedRequest, $LogInDB, $HasFile, $PersonalFL, $IsSnatched) = array_values($Torrent); if ($Remastered && !$RemasterYear) { $FirstUnknown = !isset($FirstUnknown); } $Reported = false; unset($ReportedTimes); $Reports = Torrents::get_reports($TorrentID); $NumReports = count($Reports); if ($NumReports > 0) { $Reported = true; include SERVER_ROOT . '/sections/reportsv2/array.php'; $ReportInfo = ' <table class="reportinfo_table"> <tr class="colhead_dark" style="font-weight: bold;"> <td>This torrent has ' . $NumReports . ' active ' . ($NumReports === 1 ? 'report' : 'reports') . ":</td>\n\t\t\t</tr>"; foreach ($Reports as $Report) { if (check_perms('admin_reports')) { $ReporterID = $Report['ReporterID']; $Reporter = Users::user_info($ReporterID); $ReporterName = $Reporter['Username']; $ReportLinks = "<a href=\"user.php?id={$ReporterID}\">{$ReporterName}</a> <a href=\"reportsv2.php?view=report&id={$Report['ID']}\">reported it</a>"; } else { $ReportLinks = 'Someone reported it'; } if (isset($Types[$GroupCategoryID][$Report['Type']])) { $ReportType = $Types[$GroupCategoryID][$Report['Type']]; } elseif (isset($Types['master'][$Report['Type']])) { $ReportType = $Types['master'][$Report['Type']]; } else { //There was a type but it wasn't an option! $ReportType = $Types['master']['other']; } $ReportInfo .= "\n\t\t\t<tr>\n\t\t\t\t<td>{$ReportLinks} " . time_diff($Report['ReportedTime'], 2, true, true) . ' for the reason "' . $ReportType['title'] . '": <blockquote>' . Text::full_format($Report['UserComment']) . '</blockquote> </td> </tr>'; } $ReportInfo .= "\n\t\t</table>"; } $CanEdit = check_perms('torrents_edit') || $UserID == $LoggedUser['ID'] && !$LoggedUser['DisableWiki'] && !($Remastered && !$RemasterYear); $RegenLink = check_perms('users_mod') ? ' <a href="torrents.php?action=regen_filelist&torrentid=' . $TorrentID . '" class="brackets">Regenerate</a>' : ''; $FileTable = ' <table class="filelist_table"> <tr class="colhead_dark"> <td> <div class="filelist_title" style="float: left;">File Names' . $RegenLink . '</div> <div class="filelist_path" style="float: right;">' . ($FilePath ? "/{$FilePath}/" : '') . '</div> </td> <td> <strong>Size</strong> </td> </tr>'; if (substr($FileList, -3) == '}}}') { // Old style $FileListSplit = explode('|||', $FileList); foreach ($FileListSplit as $File) { $NameEnd = strrpos($File, '{{{'); $Name = substr($File, 0, $NameEnd); if ($Spaces = strspn($Name, ' ')) { $Name = str_replace(' ', ' ', substr($Name, 0, $Spaces)) . substr($Name, $Spaces); } $FileSize = substr($File, $NameEnd + 3, -3); $FileTable .= sprintf("\n<tr><td>%s</td><td class=\"number_column\">%s</td></tr>", $Name, Format::get_size($FileSize)); } } else { $FileListSplit = explode("\n", $FileList); foreach ($FileListSplit as $File) { $FileInfo = Torrents::filelist_get_file($File); $FileTable .= sprintf("\n<tr><td>%s</td><td class=\"number_column\">%s</td></tr>", $FileInfo['name'], Format::get_size($FileInfo['size'])); } } $FileTable .= ' </table>'; $ExtraInfo = ''; // String that contains information on the torrent (e.g. format and encoding) $AddExtra = ''; // Separator between torrent properties $TorrentUploader = $Username; // Save this for "Uploaded by:" below // similar to Torrents::torrent_info() if ($Format) { $ExtraInfo .= display_str($Format); $AddExtra = ' / '; } if ($Encoding) { $ExtraInfo .= $AddExtra . display_str($Encoding); $AddExtra = ' / '; } if ($HasLog) { $ExtraInfo .= "{$AddExtra}Log"; $AddExtra = ' / '; } if ($HasLog && $LogInDB) { $ExtraInfo .= ' (' . (int) $LogScore . '%)'; } if ($HasCue) { $ExtraInfo .= "{$AddExtra}Cue"; $AddExtra = ' / '; } if ($Scene) { $ExtraInfo .= "{$AddExtra}Scene"; $AddExtra = ' / '; } if (!$ExtraInfo) { $ExtraInfo = $GroupName; $AddExtra = ' / '; } if ($IsSnatched) { $ExtraInfo .= $AddExtra . Format::torrent_label('Snatched!'); $AddExtra = ' / '; } if ($FreeTorrent == '1') { $ExtraInfo .= $AddExtra . Format::torrent_label('Freeleech!'); $AddExtra = ' / '; } if ($FreeTorrent == '2') { $ExtraInfo .= $AddExtra . Format::torrent_label('Neutral Leech!'); $AddExtra = ' / '; } if ($PersonalFL) { $ExtraInfo .= $AddExtra . Format::torrent_label('Personal Freeleech!'); $AddExtra = ' / '; } if ($Reported) { $ExtraInfo .= $AddExtra . Format::torrent_label('Reported'); $AddExtra = ' / '; } if (!empty($BadTags)) { $ExtraInfo .= $AddExtra . Format::torrent_label('Bad Tags'); $AddExtra = ' / '; } if (!empty($BadFolders)) { $ExtraInfo .= $AddExtra . Format::torrent_label('Bad Folders'); $AddExtra = ' / '; } if (!empty($CassetteApproved)) { $ExtraInfo .= $AddExtra . Format::torrent_label('Cassette Approved'); $AddExtra = ' / '; } if (!empty($LossymasterApproved)) { $ExtraInfo .= $AddExtra . Format::torrent_label('Lossy Master Approved'); $AddExtra = ' / '; } if (!empty($LossywebApproved)) { $ExtraInfo .= $AddExtra . Format::torrent_label('Lossy WEB Approved'); $AddExtra = ' / '; } if (!empty($BadFiles)) { $ExtraInfo .= $AddExtra . Format::torrent_label('Bad File Names'); $AddExtra = ' / '; } if ($GroupCategoryID == 1 && ($RemasterTitle != $LastRemasterTitle || $RemasterYear != $LastRemasterYear || $RemasterRecordLabel != $LastRemasterRecordLabel || $RemasterCatalogueNumber != $LastRemasterCatalogueNumber || $FirstUnknown || $Media != $LastMedia)) { $EditionID++; ?> <tr class="releases_<?php echo $ReleaseType; ?> groupid_<?php echo $GroupID; ?> edition group_torrent"> <td colspan="5" class="edition_info"><strong><a href="#" onclick="toggle_edition(<?php echo $GroupID; ?> , <?php echo $EditionID; ?> , this, event);" class="tooltip" title="Collapse this edition. Hold "Ctrl" while clicking to collapse all editions in this torrent group.">−</a> <?php echo Torrents::edition_string($Torrent, $TorrentDetails); ?> </strong></td> </tr> <?php } $LastRemasterTitle = $RemasterTitle; $LastRemasterYear = $RemasterYear; $LastRemasterRecordLabel = $RemasterRecordLabel; $LastRemasterCatalogueNumber = $RemasterCatalogueNumber; $LastMedia = $Media; ?> <tr class="torrent_row releases_<?php echo $ReleaseType; ?> groupid_<?php echo $GroupID; ?> edition_<?php echo $EditionID; ?> group_torrent<?php echo $IsSnatched ? ' snatched_torrent' : ''; ?> " style="font-weight: normal;" id="torrent<?php echo $TorrentID; ?> "> <td> <span>[ <a href="torrents.php?action=download&id=<?php echo $TorrentID; ?> &authkey=<?php echo $LoggedUser['AuthKey']; ?> &torrent_pass=<?php echo $LoggedUser['torrent_pass']; ?> " class="tooltip" title="Download"><?php echo $HasFile ? 'DL' : 'Missing'; ?> </a> <?php if (Torrents::can_use_token($Torrent)) { ?> | <a href="torrents.php?action=download&id=<?php echo $TorrentID; ?> &authkey=<?php echo $LoggedUser['AuthKey']; ?> &torrent_pass=<?php echo $LoggedUser['torrent_pass']; ?> &usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a> <?php } ?> | <a href="reportsv2.php?action=report&id=<?php echo $TorrentID; ?> " class="tooltip" title="Report">RP</a> <?php if ($CanEdit) { ?> | <a href="torrents.php?action=edit&id=<?php echo $TorrentID; ?> " class="tooltip" title="Edit">ED</a> <?php } if (check_perms('torrents_delete') || $UserID == $LoggedUser['ID']) { ?> | <a href="torrents.php?action=delete&torrentid=<?php echo $TorrentID; ?> " class="tooltip" title="Remove">RM</a> <?php } ?> | <a href="torrents.php?torrentid=<?php echo $TorrentID; ?> " class="tooltip" title="Permalink">PL</a> ]</span> » <a href="#" onclick="$('#torrent_<?php echo $TorrentID; ?> ').gtoggle(); return false;"><?php echo $ExtraInfo; ?> </a> </td> <td class="number_column nobr"><?php echo Format::get_size($Size); ?> </td> <td class="number_column"><?php echo number_format($Snatched); ?> </td> <td class="number_column"><?php echo number_format($Seeders); ?> </td> <td class="number_column"><?php echo number_format($Leechers); ?> </td> </tr> <tr class="releases_<?php echo $ReleaseType; ?> groupid_<?php echo $GroupID; ?> edition_<?php echo $EditionID; ?> torrentdetails pad<?php if (!isset($_GET['torrentid']) || $_GET['torrentid'] != $TorrentID) { ?> hidden<?php } ?> " id="torrent_<?php echo $TorrentID; ?> "> <td colspan="5"> <blockquote> Uploaded by <?php echo Users::format_username($UserID, false, false, false); ?> <?php echo time_diff($TorrentTime); if ($Seeders == 0) { if ($LastActive != '0000-00-00 00:00:00' && time() - strtotime($LastActive) >= 1209600) { ?> <br /><strong>Last active: <?php echo time_diff($LastActive); ?> </strong> <?php } else { ?> <br />Last active: <?php echo time_diff($LastActive); } if ($LastActive != '0000-00-00 00:00:00' && time() - strtotime($LastActive) >= 345678 && time() - strtotime($LastReseedRequest) >= 864000) { ?> <br /><a href="torrents.php?action=reseed&torrentid=<?php echo $TorrentID; ?> &groupid=<?php echo $GroupID; ?> " class="brackets">Request re-seed</a> <?php } } ?> </blockquote> <?php if (check_perms('site_moderate_requests')) { ?> <div class="linkbox"> <a href="torrents.php?action=masspm&id=<?php echo $GroupID; ?> &torrentid=<?php echo $TorrentID; ?> " class="brackets">Mass PM snatchers</a> </div> <?php } ?> <div class="linkbox"> <a href="#" class="brackets" onclick="show_peers('<?php echo $TorrentID; ?> ', 0); return false;">View peer list</a> <?php if (check_perms('site_view_torrent_snatchlist')) { ?> <a href="#" class="brackets tooltip" onclick="show_downloads('<?php echo $TorrentID; ?> ', 0); return false;" title="View the list of users that have clicked the "DL" button.">View download list</a> <a href="#" class="brackets tooltip" onclick="show_snatches('<?php echo $TorrentID; ?> ', 0); return false;" title="View the list of users that have reported a snatch to the tracker.">View snatch list</a> <?php } ?> <a href="#" class="brackets" onclick="show_files('<?php echo $TorrentID; ?> '); return false;">View file list</a> <?php if ($Reported) { ?> <a href="#" class="brackets" onclick="show_reported('<?php echo $TorrentID; ?> '); return false;">View report information</a> <?php } ?> </div> <div id="peers_<?php echo $TorrentID; ?> " class="hidden"></div> <div id="downloads_<?php echo $TorrentID; ?> " class="hidden"></div> <div id="snatches_<?php echo $TorrentID; ?> " class="hidden"></div> <div id="files_<?php echo $TorrentID; ?> " class="hidden"><?php echo $FileTable; ?> </div> <?php if ($Reported) { ?> <div id="reported_<?php echo $TorrentID; ?> " class="hidden"><?php echo $ReportInfo; ?> </div> <?php } if (!empty($Description)) { echo "\n\t\t\t\t\t\t<blockquote>" . Text::full_format($Description) . '</blockquote>'; } ?> </td> </tr> <?php } }
$DB->set_query_id($Results); $JsonNotifications = array(); $NumNew = 0; $FilterGroups = array(); while ($Result = $DB->next_record(MYSQLI_ASSOC)) { if (!$Result['FilterID']) { $Result['FilterID'] = 0; } if (!isset($FilterGroups[$Result['FilterID']])) { $FilterGroups[$Result['FilterID']] = array(); $FilterGroups[$Result['FilterID']]['FilterLabel'] = $Result['Label'] ? $Result['Label'] : false; } array_push($FilterGroups[$Result['FilterID']], $Result); } unset($Result); foreach ($FilterGroups as $FilterID => $FilterResults) { unset($FilterResults['FilterLabel']); foreach ($FilterResults as $Result) { $TorrentID = $Result['TorrentID']; // $GroupID = $Result['GroupID']; $GroupInfo = $TorrentGroups[$Result['GroupID']]; extract(Torrents::array_group($GroupInfo)); // all group data $TorrentInfo = $GroupInfo['Torrents'][$TorrentID]; if ($Result['UnRead'] == 1) { $NumNew++; } $JsonNotifications[] = array('torrentId' => (int) $TorrentID, 'groupId' => (int) $GroupID, 'groupName' => $GroupName, 'groupCategoryId' => (int) $GroupCategoryID, 'wikiImage' => $WikiImage, 'torrentTags' => $TagList, 'size' => (double) $TorrentInfo['Size'], 'fileCount' => (int) $TorrentInfo['FileCount'], 'format' => $TorrentInfo['Format'], 'encoding' => $TorrentInfo['Encoding'], 'media' => $TorrentInfo['Media'], 'scene' => $TorrentInfo['Scene'] == 1, 'groupYear' => (int) $GroupYear, 'remasterYear' => (int) $TorrentInfo['RemasterYear'], 'remasterTitle' => $TorrentInfo['RemasterTitle'], 'snatched' => (int) $TorrentInfo['Snatched'], 'seeders' => (int) $TorrentInfo['Seeders'], 'leechers' => (int) $TorrentInfo['Leechers'], 'notificationTime' => $TorrentInfo['Time'], 'hasLog' => $TorrentInfo['HasLog'] == 1, 'hasCue' => $TorrentInfo['HasCue'] == 1, 'logScore' => (double) $TorrentInfo['LogScore'], 'freeTorrent' => $TorrentInfo['FreeTorrent'] == 1, 'logInDb' => $TorrentInfo['HasLog'] == 1, 'unread' => $Result['UnRead'] == 1); } } json_print("success", array('currentPages' => intval($Page), 'pages' => ceil($TorrentCount / NOTIFICATIONS_PER_PAGE), 'numNew' => $NumNew, 'results' => $JsonNotifications));
<?php authorize(); $GroupID = $_POST['groupid']; $OldGroupID = $GroupID; $NewName = $_POST['name']; if (!$GroupID || !is_number($GroupID)) { error(404); } if (empty($NewName)) { error('Torrent groups must have a name'); } if (!check_perms('torrents_edit')) { error(403); } $DB->query("\n\tSELECT Name\n\tFROM torrents_group\n\tWHERE ID = {$GroupID}"); list($OldName) = $DB->next_record(MYSQLI_NUM, false); $DB->query("\n\tUPDATE torrents_group\n\tSET Name = '" . db_string($NewName) . "'\n\tWHERE ID = '{$GroupID}'"); $Cache->delete_value("torrents_details_{$GroupID}"); Torrents::update_hash($GroupID); Misc::write_log("Torrent Group {$GroupID} ({$OldName}) was renamed to \"{$NewName}\" from \"{$OldName}\" by " . $LoggedUser['Username']); Torrents::write_group_log($GroupID, 0, $LoggedUser['ID'], "renamed to \"{$NewName}\" from \"{$OldName}\"", 0); header("Location: torrents.php?id={$GroupID}");
} } //Stupid Recent Snatches On User Page if ($CategoryID == '1' && $Image != '') { $RecentSnatches = $Cache->get_value("recent_snatches_{$UserID}"); if (!empty($RecentSnatches)) { $Snatch = array('ID' => $GroupID, 'Name' => $Name, 'Artist' => $Artists, 'WikiImage' => $Image); if (!in_array($Snatch, $RecentSnatches)) { if (count($RecentSnatches) === 5) { array_pop($RecentSnatches); } array_unshift($RecentSnatches, $Snatch); } elseif (!is_array($RecentSnatches)) { $RecentSnatches = array($Snatch); } $Cache->cache_value("recent_snatches_{$UserID}", $RecentSnatches, 0); } } $DB->query("\n\tINSERT IGNORE INTO users_downloads (UserID, TorrentID, Time)\n\tVALUES ('{$UserID}', '{$TorrentID}', '" . sqltime() . "')"); $DB->query("\n\tSELECT File\n\tFROM torrents_files\n\tWHERE TorrentID = '{$TorrentID}'"); Torrents::set_snatch_update_time($UserID, Torrents::SNATCHED_UPDATE_AFTERDL); list($Contents) = $DB->next_record(MYSQLI_NUM, false); $FileName = TorrentsDL::construct_file_name($Info['PlainArtists'], $Name, $Year, $Media, $Format, $Encoding, false, $DownloadAlt); if ($DownloadAlt) { header('Content-Type: text/plain; charset=utf-8'); } elseif (!$DownloadAlt || $Failed) { header('Content-Type: application/x-bittorrent; charset=utf-8'); } header('Content-disposition: attachment; filename="' . $FileName . '"'); echo TorrentsDL::get_file($Contents, ANNOUNCE_URL . "/{$TorrentPass}/announce"); define('SKIP_NO_CACHE_HEADERS', 1);
<?php //******************************************************************************// //--------------- Restore all VH-recommended torrents to NL --------------------// //---- For use after resetting the FL/NL database (after sitewide freeleech) ---// authorize(); if (!check_perms('site_manage_recommendations')) { error(403); } $DB->query(' SELECT GroupID FROM torrents_recommended'); $ToNL = $DB->next_record(); Torrents::freeleech_groups($ToNL, 2, 3); ?> Done
$TorrentTags = new Tags($TagList); if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5]) || !empty($ExtendedArtists[6])) { unset($ExtendedArtists[2]); unset($ExtendedArtists[3]); $DisplayName = Artists::display_artists($ExtendedArtists); } else { $DisplayName = ''; } $DisplayName .= "<a href=\"torrents.php?id={$GroupID}&torrentid={$FlacID}\" class=\"tooltip\" title=\"View torrent\" dir=\"ltr\">{$GroupName}</a>"; if ($GroupYear > 0) { $DisplayName .= " [{$GroupYear}]"; } if ($ReleaseType > 0) { $DisplayName .= " [" . $ReleaseTypes[$ReleaseType] . "]"; } $ExtraInfo = Torrents::torrent_info($Torrents[$FlacID]); if ($ExtraInfo) { $DisplayName .= ' - ' . $ExtraInfo; } ?> <tr class="torrent torrent_row<?php echo $Torrents[$FlacID]['IsSnatched'] ? ' snatched_torrent' : ''; ?> "> <td> <span class="torrent_links_block"> <a href="torrents.php?action=download&id=<?php echo $FlacID; ?> &authkey=<?php echo $LoggedUser['AuthKey'];
<?php //******************************************************************************// //--------------- Add a recommendation -----------------------------------------// authorize(); if (!check_perms('site_recommend_own') && !check_perms('site_manage_recommendations')) { error(403); } $URL = trim($_POST['url']); // Make sure the URL they entered is on our site, and is a link to a torrent $URLRegex = '/^https?:\\/\\/(www\\.|ssl\\.)?' . NONSSL_SITE_URL . '\\/torrents\\.php\\?id=([0-9]+)$/i'; $Val->SetFields('url', '1', 'regex', 'The URL must be a link to a torrent on the site.', array('regex' => '/^' . TORRENT_GROUP_REGEX . '/i')); $Err = $Val->ValidateForm($_POST); // Validate the form if ($Err) { // if something didn't validate error($Err); header('Location: ' . $_SERVER['HTTP_REFERER']); exit; } // Get torrent ID preg_match('/^' . TORRENT_GROUP_REGEX . '/i', $URL, $Matches); $GroupID = $Matches[4]; if (empty($GroupID) || !is_number($GroupID)) { error(404); } $DB->query("INSERT INTO torrents_recommended (GroupID, UserID, Time) VALUES ('" . db_string($GroupID) . "', {$LoggedUser['ID']}, '" . sqltime() . "')"); Torrents::freeleech_groups($GroupID, 2, 3); $Cache->delete_value('recommend'); header('Location: ' . $_SERVER['HTTP_REFERER']);
?> </div> <? } ?> <div class="group_info clear"> <span> [ <a href="torrents.php?action=download&id=<?php echo $TorrentID; ?> &authkey=<?php echo $LoggedUser['AuthKey']; ?> &torrent_pass=<?php echo $LoggedUser['torrent_pass']; ?> " class="tooltip" title="Download">DL</a> <? if (Torrents::can_use_token($Data)) { ?> | <a href="torrents.php?action=download&id=<?php echo $TorrentID; ?> &authkey=<?php echo $LoggedUser['AuthKey']; ?> &torrent_pass=<?php echo $LoggedUser['torrent_pass']; ?> &usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a> <? } ?> | <a href="reportsv2.php?action=report&id=<?php echo $TorrentID; ?> " class="tooltip" title="Report">RP</a> ]
} if ($Cache->get_value("torrent_{$TorrentID}_lock")) { error('Torrent cannot be deleted because the upload process is not completed yet. Please try again later.'); } $DB->query("\n\tSELECT\n\t\tt.UserID,\n\t\tt.GroupID,\n\t\tt.Size,\n\t\tt.info_hash,\n\t\ttg.Name,\n\t\tag.Name,\n\t\tt.Time,\n\t\tCOUNT(x.uid)\n\tFROM torrents AS t\n\t\tLEFT JOIN torrents_group AS tg ON tg.ID = t.GroupID\n\t\tLEFT JOIN artists_group AS ag ON ag.ArtistID = tg.ArtistID\n\t\tLEFT JOIN xbt_snatched AS x ON x.fid = t.ID\n\tWHERE t.ID = '{$TorrentID}'"); list($UserID, $GroupID, $Size, $InfoHash, $Name, $ArtistName, $Time, $Snatches) = $DB->next_record(MYSQLI_NUM, false); if (($LoggedUser['ID'] != $UserID || time_ago($Time) > 3600 * 24 * 7 || $Snatches > 4) && !check_perms('torrents_delete')) { error(403); } if ($ArtistName) { $Name = "{$ArtistName} - {$Name}"; } if (isset($_SESSION['logged_user']['multi_delete'])) { if ($_SESSION['logged_user']['multi_delete'] >= 3 && !check_perms('torrents_delete_fast')) { error('You have recently deleted 3 torrents. Please contact a staff member if you need to delete more.'); } $_SESSION['logged_user']['multi_delete']++; } else { $_SESSION['logged_user']['multi_delete'] = 1; } $InfoHash = unpack('H*', $InfoHash); Torrents::delete_torrent($TorrentID, $GroupID); Misc::write_log("Torrent {$TorrentID} ({$Name}) (" . number_format($Size / (1024 * 1024), 2) . ' MB) (' . strtoupper($InfoHash[1]) . ') was deleted by ' . $LoggedUser['Username'] . ': ' . $_POST['reason'] . ' ' . $_POST['extra']); Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], 'deleted torrent (' . number_format($Size / (1024 * 1024), 2) . ' MB, ' . strtoupper($InfoHash[1]) . ') for reason: ' . $_POST['reason'] . ' ' . $_POST['extra'], 0); View::show_header('Torrent deleted'); ?> <div class="thin"> <h3>Torrent was successfully deleted.</h3> </div> <?php View::show_footer();
/** * Returns an array with User Bookmark data: group IDs, collage data, torrent data * @param string|int $UserID * @return array Group IDs, Bookmark Data, Torrent List */ public static function get_bookmarks($UserID) { $UserID = (int) $UserID; if ($Data = G::$Cache->get_value("bookmarks_group_ids_{$UserID}")) { list($GroupIDs, $BookmarkData) = $Data; } else { $QueryID = G::$DB->get_query_id(); G::$DB->query("\n\t\t\t\tSELECT GroupID, Sort, `Time`\n\t\t\t\tFROM bookmarks_torrents\n\t\t\t\tWHERE UserID = {$UserID}\n\t\t\t\tORDER BY Sort, `Time` ASC"); $GroupIDs = G::$DB->collect('GroupID'); $BookmarkData = G::$DB->to_array('GroupID', MYSQLI_ASSOC); G::$DB->set_query_id($QueryID); G::$Cache->cache_value("bookmarks_group_ids_{$UserID}", array($GroupIDs, $BookmarkData), 3600); } $TorrentList = Torrents::get_groups($GroupIDs); return array($GroupIDs, $BookmarkData, $TorrentList); }
$TorrentTags = new Tags($TagList); if (!empty($ExtendedArtists[1]) || !empty($ExtendedArtists[4]) || !empty($ExtendedArtists[5]) || !empty($ExtendedArtists[6])) { unset($ExtendedArtists[2]); unset($ExtendedArtists[3]); $DisplayName = Artists::display_artists($ExtendedArtists); } else { $DisplayName = ''; } $DisplayName .= "<a href=\"torrents.php?id={$GroupID}&torrentid={$TorrentID}#torrent{$TorrentID}\" class=\"tooltip\" title=\"View torrent\" dir=\"ltr\">{$GroupName}</a>"; if ($GroupYear > 0) { $DisplayName .= " [{$GroupYear}]"; } if ($ReleaseType > 0) { $DisplayName .= ' [' . $ReleaseTypes[$ReleaseType] . ']'; } $ExtraInfo = Torrents::torrent_info($Torrents[$TorrentID]); if ($ExtraInfo) { $DisplayName .= ' - ' . $ExtraInfo; } ?> <tr class="torrent torrent_row<?php echo $Torrents[$TorrentID]['IsSnatched'] ? ' snatched_torrent' : ''; ?> "> <td> <span class="torrent_links_block"> <a href="torrents.php?action=download&id=<?php echo $TorrentID; ?> &authkey=<?php echo $LoggedUser['AuthKey'];
$Debug->set_flag('SELECTed ' . $_GET['filter'] . ' torrents'); $Snatched = $DB->to_array(); $Debug->set_flag('Received data from DB'); shuffle($Snatched); // randomize results while ($ResultCount < TORRENTS_PER_PAGE && count($Snatched) > 0) { // we throw TORRENTS_PER_PAGE results into Sphinx until we have at least TORRENTS_PER_PAGE results (or no snatches left) $SnatchedTmp = array_slice($Snatched, 0, TORRENTS_PER_PAGE); $Snatched = array_slice($Snatched, TORRENTS_PER_PAGE); $SphQL = transcode_init_sphql(); $SphQL->where('groupid', array_map(function ($row) { return $row['GroupID']; }, $SnatchedTmp)); $SphQLResult = $SphQL->query(); $ResultsTmp = $SphQLResult->collect('groupid'); $GroupsTmp = Torrents::get_groups(array_values($ResultsTmp)); $GroupsTmp = transcode_parse_groups($GroupsTmp); // Since we're asking Sphinxql about groups and remidents, the result can/will contain different editions that are transcodable but weren't snatched, so let's filter them out foreach ($GroupsTmp as $GroupID => $Group) { foreach ($Group['Editions'] as $RemIdent => $Edition) { $EditionSnatched = false; foreach ($SnatchedTmp as $SnatchedTmpE) { if (isset($Edition['FlacIDs'][$SnatchedTmpE['fid']])) { $EditionSnatched = true; break; } } if (!$EditionSnatched || count($Edition['MP3s']) === 3) { unset($GroupsTmp[$GroupID]['Editions'][$RemIdent]); } }
if (!$Data['Remastered']) { $MasterName = 'Original Release'; if ($GroupRecordLabel) { $MasterName .= $AddExtra . $GroupRecordLabel; $AddExtra = ' / '; } if ($GroupCatalogueNumber) { $MasterName .= $AddExtra . $GroupCatalogueNumber; $AddExtra = ' / '; } } else { $MasterName = 'Unknown Release(s)'; } $MasterName .= $AddExtra . display_str($Data['Media']); } } $LastRemasterTitle = $Data['RemasterTitle']; $LastRemasterYear = $Data['RemasterYear']; $LastRemasterRecordLabel = $Data['RemasterRecordLabel']; $LastRemasterCatalogueNumber = $Data['RemasterCatalogueNumber']; $LastMedia = $Data['Media']; $JsonTorrents[] = array('torrentId' => (int) $TorrentID, 'editionId' => (int) $EditionID, 'artists' => $JsonArtists, 'remastered' => $Data['Remastered'] == '1', 'remasterYear' => (int) $Data['RemasterYear'], 'remasterCatalogueNumber' => $Data['RemasterCatalogueNumber'], 'remasterTitle' => $Data['RemasterTitle'], 'media' => $Data['Media'], 'encoding' => $Data['Encoding'], 'format' => $Data['Format'], 'hasLog' => $Data['HasLog'] == '1', 'logScore' => (int) $Data['LogScore'], 'hasCue' => $Data['HasCue'] == '1', 'scene' => $Data['Scene'] == '1', 'vanityHouse' => $GroupInfo['VanityHouse'] == '1', 'fileCount' => (int) $Data['FileCount'], 'time' => $Data['Time'], 'size' => (int) $Data['Size'], 'snatches' => (int) $Data['Snatched'], 'seeders' => (int) $Data['Seeders'], 'leechers' => (int) $Data['Leechers'], 'isFreeleech' => $Data['FreeTorrent'] == '1', 'isNeutralLeech' => $Data['FreeTorrent'] == '2', 'isPersonalFreeleech' => $Data['PersonalFL'], 'canUseToken' => Torrents::can_use_token($Data), 'hasSnatched' => $Data['IsSnatched']); } $JsonGroups[] = array('groupId' => (int) $GroupID, 'groupName' => $GroupName, 'artist' => $DisplayName, 'cover' => $GroupInfo['WikiImage'], 'tags' => $TagList, 'bookmarked' => in_array($GroupID, $Bookmarks), 'vanityHouse' => $GroupInfo['VanityHouse'] == '1', 'groupYear' => (int) $GroupYear, 'releaseType' => $ReleaseTypes[$ReleaseType], 'groupTime' => (string) $GroupTime, 'maxSize' => (int) $MaxSize, 'totalSnatched' => (int) $TotalSnatched, 'totalSeeders' => (int) $TotalSeeders, 'totalLeechers' => (int) $TotalLeechers, 'torrents' => $JsonTorrents); } else { // Viewing a type that does not require grouping list($TorrentID, $Data) = each($Torrents); $JsonGroups[] = array('groupId' => (int) $GroupID, 'groupName' => $GroupName, 'torrentId' => (int) $TorrentID, 'tags' => $TagList, 'category' => $Categories[$CategoryID - 1], 'fileCount' => (int) $Data['FileCount'], 'groupTime' => (string) strtotime($Data['Time']), 'size' => (int) $Data['Size'], 'snatches' => (int) $Data['Snatched'], 'seeders' => (int) $Data['Seeders'], 'leechers' => (int) $Data['Leechers'], 'isFreeleech' => $Data['FreeTorrent'] == '1', 'isNeutralLeech' => $Data['FreeTorrent'] == '2', 'isPersonalFreeleech' => $Data['PersonalFL'], 'canUseToken' => Torrents::can_use_token($Data), 'hasSnatched' => $Data['IsSnatched']); } } echo json_encode(array('status' => 'success', 'response' => array('currentPage' => intval($Page), 'pages' => ceil($NumResults / TORRENTS_PER_PAGE), 'results' => $JsonGroups)));
$ArtistForm = Artists::get_artist($GroupID); if ($TorrentDetails['CategoryID'] == 0) { $CategoryName = "Unknown"; } else { $CategoryName = $Categories[$TorrentDetails['CategoryID'] - 1]; } $JsonMusicInfo = array(); if ($CategoryName == "Music") { $JsonMusicInfo = array('composers' => $ArtistForm[4] == null ? array() : pullmediainfo($ArtistForm[4]), 'dj' => $ArtistForm[6] == null ? array() : pullmediainfo($ArtistForm[6]), 'artists' => $ArtistForm[1] == null ? array() : pullmediainfo($ArtistForm[1]), 'with' => $ArtistForm[2] == null ? array() : pullmediainfo($ArtistForm[2]), 'conductor' => $ArtistForm[5] == null ? array() : pullmediainfo($ArtistForm[5]), 'remixedBy' => $ArtistForm[3] == null ? array() : pullmediainfo($ArtistForm[3]), 'producer' => $ArtistForm[7] == null ? array() : pullmediainfo($ArtistForm[7])); } else { $JsonMusicInfo = null; } $TagList = explode('|', $TorrentDetails['GROUP_CONCAT(DISTINCT tags.Name SEPARATOR \'|\')']); $JsonTorrentDetails = array('wikiBody' => Text::full_format($TorrentDetails['WikiBody']), 'wikiImage' => $TorrentDetails['WikiImage'], 'id' => (int) $TorrentDetails['ID'], 'name' => $TorrentDetails['Name'], 'year' => (int) $TorrentDetails['Year'], 'recordLabel' => $TorrentDetails['RecordLabel'], 'catalogueNumber' => $TorrentDetails['CatalogueNumber'], 'releaseType' => (int) $TorrentDetails['ReleaseType'], 'categoryId' => (int) $TorrentDetails['CategoryID'], 'categoryName' => $CategoryName, 'time' => $TorrentDetails['Time'], 'vanityHouse' => $TorrentDetails['VanityHouse'] == 1, 'isBookmarked' => Bookmarks::has_bookmarked('torrent', $GroupID), 'musicInfo' => $JsonMusicInfo, 'tags' => $TagList); $Torrent = $TorrentList[$TorrentID]; $Reports = Torrents::get_reports($TorrentID); if (count($Reports) > 0) { $Torrent['Reported'] = true; } else { $Torrent['Reported'] = false; } // Convert file list back to the old format $FileList = explode("\n", $Torrent['FileList']); foreach ($FileList as &$File) { $File = Torrents::filelist_old_format($File); } unset($File); $FileList = implode('|||', $FileList); $Userinfo = Users::user_info($Torrent['UserID']); $JsonTorrentList[] = array('id' => (int) $Torrent['ID'], 'infoHash' => $Torrent['InfoHash'], 'media' => $Torrent['Media'], 'format' => $Torrent['Format'], 'encoding' => $Torrent['Encoding'], 'remastered' => $Torrent['Remastered'] == 1, 'remasterYear' => (int) $Torrent['RemasterYear'], 'remasterTitle' => $Torrent['RemasterTitle'], 'remasterRecordLabel' => $Torrent['RemasterRecordLabel'], 'remasterCatalogueNumber' => $Torrent['RemasterCatalogueNumber'], 'scene' => $Torrent['Scene'] == 1, 'hasLog' => $Torrent['HasLog'] == 1, 'hasCue' => $Torrent['HasCue'] == 1, 'logScore' => (int) $Torrent['LogScore'], 'fileCount' => (int) $Torrent['FileCount'], 'size' => (int) $Torrent['Size'], 'seeders' => (int) $Torrent['Seeders'], 'leechers' => (int) $Torrent['Leechers'], 'snatched' => (int) $Torrent['Snatched'], 'freeTorrent' => $Torrent['FreeTorrent'] == 1, 'reported' => $Torrent['Reported'], 'time' => $Torrent['Time'], 'description' => $Torrent['Description'], 'fileList' => $FileList, 'filePath' => $Torrent['FilePath'], 'userId' => (int) $Torrent['UserID'], 'username' => $Userinfo['Username']); json_print("success", array('group' => $JsonTorrentDetails, 'torrent' => array_pop($JsonTorrentList)));
$PublicTorrent = true; } // File list and size list($ExtraTotalSize, $ExtraFileList) = $ExtraTor->file_list(); $ExtraDirName = isset($ExtraTor->Dec['info']['files']) ? Format::make_utf8($ExtraTor->get_name()) : ''; $ExtraTmpFileList = array(); foreach ($ExtraFileList as $ExtraFile) { list($ExtraSize, $ExtraName) = $ExtraFile; check_file($Type, $ExtraName); // Make sure the file name is not too long if (mb_strlen($ExtraName, 'UTF-8') + mb_strlen($ExtraDirName, 'UTF-8') + 1 > MAX_FILENAME_LENGTH) { $Err = "The torrent contained one or more files with too long of a name: <br />{$ExtraDirName}/{$ExtraName}"; break; } // Add file and size to array $ExtraTmpFileList[] = Torrents::filelist_format_file($ExtraFile); } // To be stored in the database $ThisInsert['FilePath'] = db_string($ExtraDirName); $ThisInsert['FileString'] = db_string(implode("\n", $ExtraTmpFileList)); $ThisInsert['InfoHash'] = pack('H*', $ExtraTor->info_hash()); $ThisInsert['NumFiles'] = count($ExtraFileList); $ThisInsert['TorEnc'] = db_string($ExtraTor->encode()); $ThisInsert['TotalSize'] = $ExtraTotalSize; $Debug->set_flag('upload: torrent decoded'); $DB->query("\n\t\tSELECT ID\n\t\tFROM torrents\n\t\tWHERE info_hash = '" . db_string($ThisInsert['InfoHash']) . "'"); if ($DB->has_results()) { list($ExtraID) = $DB->next_record(); $DB->query("\n\t\t\tSELECT TorrentID\n\t\t\tFROM torrents_files\n\t\t\tWHERE TorrentID = {$ExtraID}"); if ($DB->has_results()) { $Err = "<a href=\"torrents.php?torrentid={$ExtraID}\">The exact same torrent file already exists on the site!</a>";
<?php $GroupID = $_GET['groupid']; if (!is_number($GroupID)) { error(404); } View::show_header("History for Group {$GroupID}"); $Groups = Torrents::get_groups(array($GroupID), true, true, false); if (!empty($Groups[$GroupID])) { $Group = $Groups[$GroupID]; $Title = Artists::display_artists($Group['ExtendedArtists']) . '<a href="torrents.php?id=' . $GroupID . '">' . $Group['Name'] . '</a>'; } else { $Title = "Group {$GroupID}"; } ?> <div class="thin"> <div class="header"> <h2>History for <?php echo $Title; ?> </h2> </div> <table> <tr class="colhead"> <td>Date</td> <td>Torrent</td> <td>User</td> <td>Info</td> </tr> <?php
// Get $Limit last quote notifications // We deal with the information about torrents and requests later on... $sql = "\n\tSELECT\n\t\tSQL_CALC_FOUND_ROWS\n\t\tq.Page,\n\t\tq.PageID,\n\t\tq.PostID,\n\t\tq.QuoterID,\n\t\tq.Date,\n\t\tq.UnRead,\n\t\tf.ID as ForumID,\n\t\tf.Name as ForumName,\n\t\tt.Title as ForumTitle,\n\t\ta.Name as ArtistName,\n\t\tc.Name as CollageName\n\tFROM users_notify_quoted AS q\n\t\tLEFT JOIN forums_topics AS t ON t.ID = q.PageID\n\t\tLEFT JOIN forums AS f ON f.ID = t.ForumID\n\t\tLEFT JOIN artists_group AS a ON a.ArtistID = q.PageID\n\t\tLEFT JOIN collages AS c ON c.ID = q.PageID\n\tWHERE q.UserID = {$LoggedUser['ID']}\n\t\tAND (q.Page != 'forums' OR " . Forums::user_forums_sql() . ")\n\t\tAND (q.Page != 'collages' OR c.Deleted = '0')\n\t\t{$UnreadSQL}\n\tORDER BY q.Date DESC\n\tLIMIT {$Limit}"; $DB->query($sql); $Results = $DB->to_array(false, MYSQLI_ASSOC, false); $DB->query('SELECT FOUND_ROWS()'); list($NumResults) = $DB->next_record(); $TorrentGroups = $Requests = array(); foreach ($Results as $Result) { if ($Result['Page'] == 'torrents') { $TorrentGroups[] = $Result['PageID']; } elseif ($Result['Page'] == 'requests') { $Requests[] = $Result['PageID']; } } $TorrentGroups = Torrents::get_groups($TorrentGroups, true, true, false); $Requests = Requests::get_requests($Requests); //Start printing page View::show_header('Quote Notifications'); ?> <div class="thin"> <div class="header"> <h2> Quote notifications <?php echo $NumResults && !empty($UnreadSQL) ? " ({$NumResults} new)" : ''; ?> </h2> <div class="linkbox pager"> <br /> <?php
if (isset($Escaped['delete']) && check_perms('users_mod')) { $DB->query("\n\t\t\tSELECT Username\n\t\t\tFROM users_main\n\t\t\tWHERE ID = {$UploaderID}"); list($UpUsername) = $DB->next_record(); $Log = "Torrent {$TorrentID} ({$RawName}) uploaded by {$UpUsername} was deleted by " . $LoggedUser['Username']; $Log .= $Escaped['resolve_type'] == 'custom' ? '' : ' for the reason: ' . $ResolveType['title'] . "."; if (isset($Escaped['log_message']) && $Escaped['log_message'] != '') { $Log .= ' ( ' . $Escaped['log_message'] . ' )'; } $DB->query("\n\t\t\tSELECT GroupID, hex(info_hash)\n\t\t\tFROM torrents\n\t\t\tWHERE ID = {$TorrentID}"); list($GroupID, $InfoHash) = $DB->next_record(); Torrents::delete_torrent($TorrentID, 0, $ResolveType['reason']); //$InfoHash = unpack("H*", $InfoHash); $Log .= ' (' . strtoupper($InfoHash) . ')'; Misc::write_log($Log); $Log = 'deleted torrent for the reason: ' . $ResolveType['title'] . '. ( ' . $Escaped['log_message'] . ' )'; Torrents::write_group_log($GroupID, $TorrentID, $LoggedUser['ID'], $Log, 0); } else { $Log = "No log message (torrent wasn't deleted)."; } //Warnings / remove upload if ($Upload) { $Cache->begin_transaction("user_info_heavy_{$UploaderID}"); $Cache->update_row(false, array('DisableUpload' => '1')); $Cache->commit_transaction(0); $DB->query("\n\t\t\tUPDATE users_info\n\t\t\tSET DisableUpload = '1'\n\t\t\tWHERE UserID = {$UploaderID}"); } if ($Warning > 0) { $WarnLength = $Warning * (7 * 24 * 60 * 60); $Reason = "Uploader of torrent ({$TorrentID}) {$RawName} which was resolved with the preset: " . $ResolveType['title'] . '.'; if ($Escaped['admin_message']) { $Reason .= ' (' . $Escaped['admin_message'] . ').';
</div> </td> <td> <span class="brackets"> <a href="torrents.php?action=download&id=<?php echo $TorrentID; ?> &authkey=<?php echo $LoggedUser['AuthKey']; ?> &torrent_pass=<?php echo $LoggedUser['torrent_pass']; ?> " class="tooltip" title="Download">DL</a> <?php if (Torrents::can_use_token($Torrent)) { ?> | <a href="torrents.php?action=download&id=<?php echo $TorrentID; ?> &authkey=<?php echo $LoggedUser['AuthKey']; ?> &torrent_pass=<?php echo $LoggedUser['torrent_pass']; ?> &usetoken=1" class="tooltip" title="Use a FL Token" onclick="return confirm('Are you sure you want to use a freeleech token here?');">FL</a> <?php } ?> | <a href="reportsv2.php?action=report&id=<?php
if ($_GET['type'] !== '0') { $_GET['type'] = display_str($_GET['type']); } } $SphQL = new SphinxqlQuery(); $SphQL->select('id, groupid')->from('better_transcode')->where('logscore', 100)->where_match('FLAC', 'format')->where_match($List, 'encoding', false)->order_by('RAND()')->limit(0, TORRENTS_PER_PAGE, TORRENTS_PER_PAGE); if (!empty($_GET['search'])) { $SphQL->where_match($_GET['search'], '(groupname,artistname,year,taglist)'); } $SphQLResult = $SphQL->query(); $TorrentCount = $SphQLResult->get_meta('total'); if ($TorrentCount == 0) { error('No results found!'); } $Results = $SphQLResult->to_array('groupid'); $Groups = Torrents::get_groups(array_keys($Results)); $TorrentGroups = array(); foreach ($Groups as $GroupID => $Group) { if (empty($Group['Torrents'])) { unset($Groups[$GroupID]); continue; } foreach ($Group['Torrents'] as $Torrent) { $TorRemIdent = "{$Torrent['Media']} {$Torrent['RemasterYear']} {$Torrent['RemasterTitle']} {$Torrent['RemasterRecordLabel']} {$Torrent['RemasterCatalogueNumber']}"; if (!isset($TorrentGroups[$Group['ID']])) { $TorrentGroups[$Group['ID']] = array($TorRemIdent => array('FlacID' => 0, 'Formats' => array(), 'RemasterTitle' => $Torrent['RemasterTitle'], 'RemasterYear' => $Torrent['RemasterYear'], 'RemasterRecordLabel' => $Torrent['RemasterRecordLabel'], 'RemasterCatalogueNumber' => $Torrent['RemasterCatalogueNumber'], 'IsSnatched' => false)); } elseif (!isset($TorrentGroups[$Group['ID']][$TorRemIdent])) { $TorrentGroups[$Group['ID']][$TorRemIdent] = array('FlacID' => 0, 'Formats' => array(), 'RemasterTitle' => $Torrent['RemasterTitle'], 'RemasterYear' => $Torrent['RemasterYear'], 'RemasterRecordLabel' => $Torrent['RemasterRecordLabel'], 'RemasterCatalogueNumber' => $Torrent['RemasterCatalogueNumber'], 'IsSnatched' => false); } if (isset($EncodingKeys[$Torrent['Encoding']])) { $TorrentGroups[$Group['ID']][$TorRemIdent]['Formats'][$Torrent['Encoding']] = true;
</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}"); }
<?php $TorrentID = (int) $_GET['torrentid']; $DB->query("\n\tSELECT last_action, LastReseedRequest, UserID, Time, GroupID\n\tFROM torrents\n\tWHERE ID = '{$TorrentID}'"); list($LastActive, $LastReseedRequest, $UploaderID, $UploadedTime, $GroupID) = $DB->next_record(); if (!check_perms('users_mod')) { if (time() - strtotime($LastReseedRequest) < 864000) { error('There was already a re-seed request for this torrent within the past 10 days.'); } if ($LastActive == '0000-00-00 00:00:00' || time() - strtotime($LastActive) < 345678) { error(403); } } $DB->query("\n\tUPDATE torrents\n\tSET LastReseedRequest = NOW()\n\tWHERE ID = '{$TorrentID}'"); $Group = Torrents::get_groups(array($GroupID)); extract(Torrents::array_group($Group[$GroupID])); $Name = Artists::display_artists(array('1' => $Artists), false, true); $Name .= $GroupName; $usersToNotify = array(); $DB->query("\n\tSELECT s.uid AS id, MAX(s.tstamp) AS tstamp\n\tFROM xbt_snatched as s\n\tINNER JOIN users_main as u\n\tON s.uid = u.ID\n\tWHERE s.fid = '{$TorrentID}'\n\tAND u.Enabled = '1'\n\tGROUP BY s.uid\n ORDER BY tstamp DESC\n\tLIMIT 100"); if ($DB->has_results()) { $Users = $DB->to_array(); foreach ($Users as $User) { $UserID = $User['id']; $TimeStamp = $User['tstamp']; $usersToNotify[$UserID] = array("snatched", $TimeStamp); } } $usersToNotify[$UploaderID] = array("uploaded", strtotime($UploadedTime)); foreach ($usersToNotify as $UserID => $info) { $Username = Users::user_info($UserID)['Username'];
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']);
&authkey=<?php echo $LoggedUser['AuthKey']; ?> &torrent_pass=<?php echo $LoggedUser['torrent_pass']; ?> " title="Download" class="brackets tooltip">DL</a> </span> » <a href="torrents.php?id=<?php echo $GroupID; ?> &torrentid=<?php echo $TorrentID; ?> "><?php echo Torrents::torrent_info($Torrent); ?> </a> </td> <td class="number_column nobr"><?php echo Format::get_size($Torrent['Size']); ?> </td> <td class="number_column"><?php echo number_format($Torrent['Snatched']); ?> </td> <td class="number_column<?php echo $Torrent['Seeders'] == 0 ? ' r00' : ''; ?> "><?php
$InactivityExceptionsMade = array(); $i = 0; foreach ($Torrents as $Torrent) { list($ID, $GroupID, $Name, $Format, $Encoding, $UserID, $Media, $InfoHash) = $Torrent; if (array_key_exists($UserID, $InactivityExceptionsMade) && time() < $InactivityExceptionsMade[$UserID]) { // don't delete the torrent! continue; } $ArtistName = Artists::display_artists(Artists::get_artist($GroupID), false, false, false); if ($ArtistName) { $Name = "{$ArtistName} - {$Name}"; } if ($Format && $Encoding) { $Name .= ' [' . (empty($Media) ? '' : "{$Media} / ") . "{$Format} / {$Encoding}]"; } Torrents::delete_torrent($ID, $GroupID); $LogEntries[] = db_string("Torrent {$ID} ({$Name}) (" . strtoupper($InfoHash) . ") was deleted for inactivity (unseeded)"); if (!array_key_exists($UserID, $DeleteNotes)) { $DeleteNotes[$UserID] = array('Count' => 0, 'Msg' => ''); } $DeleteNotes[$UserID]['Msg'] .= "\n{$Name}"; $DeleteNotes[$UserID]['Count']++; ++$i; if ($i % 500 == 0) { echo "{$i} inactive torrents removed.\n"; } } echo "{$i} torrents deleted for inactivity.\n"; foreach ($DeleteNotes as $UserID => $MessageInfo) { $Singular = $MessageInfo['Count'] == 1 ? true : false; Misc::send_pm($UserID, 0, $MessageInfo['Count'] . ' of your torrents ' . ($Singular ? 'has' : 'have') . ' been deleted for inactivity', ($Singular ? 'One' : 'Some') . ' of your uploads ' . ($Singular ? 'has' : 'have') . ' been deleted for being unseeded. Since ' . ($Singular ? 'it' : 'they') . ' didn\'t break any rules (we hope), please feel free to re-upload ' . ($Singular ? 'it' : 'them') . ".\n\nThe following torrent" . ($Singular ? ' was' : 's were') . ' deleted:' . $MessageInfo['Msg']);
$Size = (int) $_POST['size']; $Units = db_string($_POST['scale']); if (empty($Size) || !in_array($Units, array('k', 'm', 'g'))) { $Err = 'Invalid size or units'; } else { $Bytes = Format::get_bytes($Size . $Units); $DB->query("\n SELECT ID\n FROM torrents\n WHERE ID IN (" . implode(', ', $TorrentIDs) . ")\n AND Size > '{$Bytes}'"); $LargeTorrents = $DB->collect('ID'); $TorrentIDs = array_diff($TorrentIDs, $LargeTorrents); } } if (sizeof($TorrentIDs) > 0) { Torrents::freeleech_torrents($TorrentIDs, $FreeLeechType, $FreeLeechReason); } if (isset($LargeTorrents) && sizeof($LargeTorrents) > 0) { Torrents::freeleech_torrents($LargeTorrents, 2, $FreeLeechReason); } $Err = 'Done!'; } } } } ?> <div class="thin"> <div class="box pad box2"> <?php if (isset($Err)) { ?> <strong class="important_text"><?php echo $Err; ?>
/** * Convenience function to allow for passing groups to Torrents::freeleech_torrents() * * @param array $GroupIDs the groups in question * @param int $FreeNeutral see Torrents::freeleech_torrents() * @param int $FreeLeechType see Torrents::freeleech_torrents() */ public static function freeleech_groups($GroupIDs, $FreeNeutral = 1, $FreeLeechType = 0) { $QueryID = G::$DB->get_query_id(); if (!is_array($GroupIDs)) { $GroupIDs = array($GroupIDs); } G::$DB->query(' SELECT ID FROM torrents WHERE GroupID IN (' . implode(', ', $GroupIDs) . ')'); if (G::$DB->has_results()) { $TorrentIDs = G::$DB->collect('ID'); Torrents::freeleech_torrents($TorrentIDs, $FreeNeutral, $FreeLeechType); } G::$DB->set_query_id($QueryID); }
private static function to_html($Array) { global $SSL; self::$Levels++; /* * Hax prevention * That's the original comment on this. * Most likely this was implemented to avoid anyone nesting enough * elements to reach PHP's memory limit as nested elements are * solved recursively. * Original value of 10, it is now replaced in favor of * $MaximumNests. * If this line is ever executed then something is, infact * being haxed as the if before the block type switch for different * tags should always be limiting ahead of this line. * (Larger than vs. smaller than.) */ if (self::$Levels > self::$MaximumNests) { return $Block['Val']; // Hax prevention, breaks upon exceeding nests. } $Str = ''; foreach ($Array as $Block) { if (is_string($Block)) { $Str .= self::smileys($Block); continue; } if (self::$Levels < self::$MaximumNests) { switch ($Block['Type']) { case 'b': $Str .= '<strong>' . self::to_html($Block['Val']) . '</strong>'; break; case 'u': $Str .= '<span style="text-decoration: underline;">' . self::to_html($Block['Val']) . '</span>'; break; case 'i': $Str .= '<span style="font-style: italic;">' . self::to_html($Block['Val']) . "</span>"; break; case 's': $Str .= '<span style="text-decoration: line-through;">' . self::to_html($Block['Val']) . '</span>'; break; case 'important': $Str .= '<strong class="important_text">' . self::to_html($Block['Val']) . '</strong>'; break; case 'user': $Str .= '<a href="user.php?action=search&search=' . urlencode($Block['Val']) . '">' . $Block['Val'] . '</a>'; break; case 'artist': $Str .= '<a href="artist.php?artistname=' . urlencode(Format::undisplay_str($Block['Val'])) . '">' . $Block['Val'] . '</a>'; break; case 'rule': $Rule = trim(strtolower($Block['Val'])); if ($Rule[0] != 'r' && $Rule[0] != 'h') { $Rule = 'r' . $Rule; } $Str .= '<a href="rules.php?p=upload#' . urlencode(Format::undisplay_str($Rule)) . '">' . preg_replace('/[aA-zZ]/', '', $Block['Val']) . '</a>'; break; case 'torrent': $Pattern = '/(' . NONSSL_SITE_URL . '\\/torrents\\.php.*[\\?&]id=)?(\\d+)($|&|\\#).*/i'; $Matches = array(); if (preg_match($Pattern, $Block['Val'], $Matches)) { if (isset($Matches[2])) { $GroupID = $Matches[2]; $Groups = Torrents::get_groups(array($GroupID), true, true, false); if ($Groups[$GroupID]) { $Group = $Groups[$GroupID]; $Str .= Artists::display_artists($Group['ExtendedArtists']) . '<a href="torrents.php?id=' . $GroupID . '">' . $Group['Name'] . '</a>'; } else { $Str .= '[torrent]' . str_replace('[inlineurl]', '', $Block['Val']) . '[/torrent]'; } } } else { $Str .= '[torrent]' . str_replace('[inlineurl]', '', $Block['Val']) . '[/torrent]'; } break; case 'wiki': $Str .= '<a href="wiki.php?action=article&name=' . urlencode($Block['Val']) . '">' . $Block['Val'] . '</a>'; break; case 'tex': $Str .= '<img style="vertical-align: middle;" src="' . STATIC_SERVER . 'blank.gif" onload="if (this.src.substr(this.src.length - 9, this.src.length) == \'blank.gif\') { this.src = \'https://chart.googleapis.com/chart?cht=tx&chf=bg,s,FFFFFF00&chl=' . urlencode(mb_convert_encoding($Block['Val'], 'UTF-8', 'HTML-ENTITIES')) . '&chco=\' + hexify(getComputedStyle(this.parentNode, null).color); }" alt="' . $Block['Val'] . '" />'; break; case 'plain': $Str .= $Block['Val']; break; case 'pre': $Str .= '<pre>' . $Block['Val'] . '</pre>'; break; case 'code': $Str .= '<code>' . $Block['Val'] . '</code>'; break; case 'list': $Str .= "<{$Block['ListType']} class=\"postlist\">"; foreach ($Block['Val'] as $Line) { $Str .= '<li>' . self::to_html($Line) . '</li>'; } $Str .= '</' . $Block['ListType'] . '>'; break; case 'align': $ValidAttribs = array('left', 'center', 'right'); if (!in_array($Block['Attr'], $ValidAttribs)) { $Str .= '[align=' . $Block['Attr'] . ']' . self::to_html($Block['Val']) . '[/align]'; } else { $Str .= '<div style="text-align: ' . $Block['Attr'] . ';">' . self::to_html($Block['Val']) . '</div>'; } break; case 'color': case 'colour': $ValidAttribs = array('aqua', 'black', 'blue', 'fuchsia', 'green', 'grey', 'lime', 'maroon', 'navy', 'olive', 'purple', 'red', 'silver', 'teal', 'white', 'yellow'); if (!in_array($Block['Attr'], $ValidAttribs) && !preg_match('/^#[0-9a-f]{6}$/', $Block['Attr'])) { $Str .= '[color=' . $Block['Attr'] . ']' . self::to_html($Block['Val']) . '[/color]'; } else { $Str .= '<span style="color: ' . $Block['Attr'] . ';">' . self::to_html($Block['Val']) . '</span>'; } break; case 'headline': $text = self::to_html($Block['Val']); $raw = self::raw_text($Block['Val']); if (!in_array($Block['Attr'], self::$HeadlineLevels)) { $Str .= sprintf('%1$s%2$s%1$s', str_repeat('=', $Block['Attr'] + 1), $text); } else { $id = '_' . crc32($raw . self::$HeadlineID); if (self::$InQuotes === 0) { self::$Headlines[] = array($Block['Attr'], $raw, $id); } $Str .= sprintf('<h%1$d id="%3$s">%2$s</h%1$d>', $Block['Attr'] + 2, $text, $id); self::$HeadlineID++; } break; case 'inlinesize': case 'size': $ValidAttribs = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10'); if (!in_array($Block['Attr'], $ValidAttribs)) { $Str .= '[size=' . $Block['Attr'] . ']' . self::to_html($Block['Val']) . '[/size]'; } else { $Str .= '<span class="size' . $Block['Attr'] . '">' . self::to_html($Block['Val']) . '</span>'; } break; case 'quote': self::$NoImg++; // No images inside quote tags self::$InQuotes++; if (self::$InQuotes == self::$NestsBeforeHide) { //Put quotes that are nested beyond the specified limit in [hide] tags. $Str .= '<strong>Older quotes</strong>: <a href="javascript:void(0);" onclick="BBCode.spoiler(this);">Show</a>'; $Str .= '<blockquote class="hidden spoiler">'; } if (!empty($Block['Attr'])) { $Exploded = explode('|', self::to_html($Block['Attr'])); if (isset($Exploded[1]) && (is_numeric($Exploded[1]) || in_array($Exploded[1][0], array('a', 't', 'c', 'r')) && is_numeric(substr($Exploded[1], 1)))) { // the part after | is either a number or starts with a, t, c or r, followed by a number (forum post, artist comment, torrent comment, collage comment or request comment, respectively) $PostID = trim($Exploded[1]); $Str .= '<a href="#" onclick="QuoteJump(event, \'' . $PostID . '\'); return false;"><strong class="quoteheader">' . $Exploded[0] . '</strong> wrote: </a>'; } else { $Str .= '<strong class="quoteheader">' . $Exploded[0] . '</strong> wrote: '; } } $Str .= '<blockquote>' . self::to_html($Block['Val']) . '</blockquote>'; if (self::$InQuotes == self::$NestsBeforeHide) { //Close quote the deeply nested quote [hide]. $Str .= '</blockquote><br />'; // Ensure new line after quote train hiding } self::$NoImg--; self::$InQuotes--; break; case 'hide': $Str .= '<strong>' . ($Block['Attr'] ? $Block['Attr'] : 'Hidden text') . '</strong>: <a href="javascript:void(0);" onclick="BBCode.spoiler(this);">Show</a>'; $Str .= '<blockquote class="hidden spoiler">' . self::to_html($Block['Val']) . '</blockquote>'; break; case 'mature': if (G::$LoggedUser['EnableMatureContent']) { if (!empty($Block['Attr'])) { $Str .= '<strong class="mature" style="font-size: 1.2em;">Mature content:</strong><strong> ' . $Block['Attr'] . '</strong><br /> <a href="javascript:void(0);" onclick="BBCode.spoiler(this);">Show</a>'; $Str .= '<blockquote class="hidden spoiler">' . self::to_html($Block['Val']) . '</blockquote>'; } else { $Str .= '<strong>Use of the [mature] tag requires a description.</strong> The correct format is as follows: <strong>[mature=description] ...content... [/mature]</strong>, where "description" is a mandatory description of the post. Misleading descriptions will be penalized. For further information on our mature content policies, please refer to this <a href="wiki.php?action=article&id=1063">wiki</a>.'; } } else { $Str .= '<span class="mature_blocked" style="font-style: italic;"><a href="wiki.php?action=article&id=1063">Mature content</a> has been blocked. You can choose to view mature content by editing your <a href="user.php?action=edit&userid=' . G::$LoggedUser['ID'] . '">settings</a>.</span>'; } break; case 'img': if (self::$NoImg > 0 && self::valid_url($Block['Val'])) { $Str .= '<a rel="noreferrer" target="_blank" href="' . $Block['Val'] . '">' . $Block['Val'] . '</a> (image)'; break; } if (!self::valid_url($Block['Val'], '\\.(jpe?g|gif|png|bmp|tiff)')) { $Str .= '[img]' . $Block['Val'] . '[/img]'; } else { $LocalURL = self::local_url($Block['Val']); if ($LocalURL) { $Str .= '<img class="scale_image" onclick="lightbox.init(this, $(this).width());" alt="' . $Block['Val'] . '" src="' . $LocalURL . '" />'; } else { $Str .= '<img class="scale_image" onclick="lightbox.init(this, $(this).width());" alt="' . $Block['Val'] . '" src="' . ImageTools::process($Block['Val']) . '" />'; } } break; case 'aud': if (self::$NoImg > 0 && self::valid_url($Block['Val'])) { $Str .= '<a rel="noreferrer" target="_blank" href="' . $Block['Val'] . '">' . $Block['Val'] . '</a> (audio)'; break; } if (!self::valid_url($Block['Val'], '\\.(mp3|ogg|wav)')) { $Str .= '[aud]' . $Block['Val'] . '[/aud]'; } else { //TODO: Proxy this for staff? $Str .= '<audio controls="controls" src="' . $Block['Val'] . '"><a rel="noreferrer" target="_blank" href="' . $Block['Val'] . '">' . $Block['Val'] . '</a></audio>'; } break; case 'url': // Make sure the URL has a label if (empty($Block['Val'])) { $Block['Val'] = $Block['Attr']; $NoName = true; // If there isn't a Val for this } else { $Block['Val'] = self::to_html($Block['Val']); $NoName = false; } if (!self::valid_url($Block['Attr'])) { $Str .= '[url=' . $Block['Attr'] . ']' . $Block['Val'] . '[/url]'; } else { $LocalURL = self::local_url($Block['Attr']); if ($LocalURL) { if ($NoName) { $Block['Val'] = substr($LocalURL, 1); } $Str .= '<a href="' . $LocalURL . '">' . $Block['Val'] . '</a>'; } else { $Str .= '<a rel="noreferrer" target="_blank" href="' . $Block['Attr'] . '">' . $Block['Val'] . '</a>'; } } break; case 'inlineurl': if (!self::valid_url($Block['Attr'], '', true)) { $Array = self::parse($Block['Attr']); $Block['Attr'] = $Array; $Str .= self::to_html($Block['Attr']); } else { $LocalURL = self::local_url($Block['Attr']); if ($LocalURL) { $Str .= '<a href="' . $LocalURL . '">' . substr($LocalURL, 1) . '</a>'; } else { $Str .= '<a rel="noreferrer" target="_blank" href="' . $Block['Attr'] . '">' . $Block['Attr'] . '</a>'; } } break; } } } self::$Levels--; return $Str; }