get_value("torrents_details_$GroupID"); } if ($RevisionID || !is_array($TorrentCache)) { // Fetch the group details $SQL = 'SELECT '; if (!$RevisionID) { $SQL .= ' g.WikiBody, g.WikiImage, '; } else { $SQL .= ' w.Body, w.Image, '; } $SQL .= " g.ID, g.Name, g.Year, g.RecordLabel, g.CatalogueNumber, g.ReleaseType, g.CategoryID, g.Time, g.VanityHouse, GROUP_CONCAT(DISTINCT tags.Name SEPARATOR '|'), GROUP_CONCAT(DISTINCT tags.ID SEPARATOR '|'), GROUP_CONCAT(tt.UserID SEPARATOR '|'), GROUP_CONCAT(tt.PositiveVotes SEPARATOR '|'), GROUP_CONCAT(tt.NegativeVotes SEPARATOR '|') FROM torrents_group AS g LEFT JOIN torrents_tags AS tt ON tt.GroupID = g.ID LEFT JOIN tags ON tags.ID = tt.TagID"; if ($RevisionID) { $SQL .= " LEFT JOIN wiki_torrents AS w ON w.PageID = '".db_string($GroupID)."' AND w.RevisionID = '".db_string($RevisionID)."' "; } $SQL .= " WHERE g.ID = '".db_string($GroupID)."' GROUP BY NULL"; $DB->query($SQL); $TorrentDetails = $DB->next_record(MYSQLI_ASSOC); // Fetch the individual torrents $DB->query(" SELECT 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) AS InfoHash, tbt.TorrentID AS BadTags, tbf.TorrentID AS BadFolders, tfi.TorrentID AS BadFiles, ca.TorrentID AS CassetteApproved, lma.TorrentID AS LossymasterApproved, lwa.TorrentID AS LossywebApproved, t.LastReseedRequest, tln.TorrentID AS LogInDB, t.ID AS HasFile FROM torrents AS t LEFT JOIN torrents_bad_tags AS tbt ON tbt.TorrentID = t.ID LEFT JOIN torrents_bad_folders AS tbf ON tbf.TorrentID = t.ID LEFT JOIN torrents_bad_files AS tfi ON tfi.TorrentID = t.ID LEFT JOIN torrents_cassette_approved AS ca ON ca.TorrentID = t.ID LEFT JOIN torrents_lossymaster_approved AS lma ON lma.TorrentID = t.ID LEFT JOIN torrents_lossyweb_approved AS lwa ON lwa.TorrentID = t.ID LEFT JOIN torrents_logs_new AS tln ON tln.TorrentID = t.ID WHERE t.GroupID = '".db_string($GroupID)."' GROUP BY t.ID ORDER BY t.Remastered ASC, (t.RemasterYear != 0) DESC, t.RemasterYear ASC, t.RemasterTitle ASC, t.RemasterRecordLabel ASC, t.RemasterCatalogueNumber ASC, t.Media ASC, t.Format, t.Encoding, t.ID"); $TorrentList = $DB->to_array('ID', MYSQLI_ASSOC); if (count($TorrentList) === 0 && $ApiCall == false) { header('Location: log.php?search='.(empty($_GET['torrentid']) ? "Group+$GroupID" : "Torrent+$_GET[torrentid]")); die(); } elseif (count($TorrentList) === 0 && $ApiCall == true) { return null; } if (in_array(0, $DB->collect('Seeders'))) { $CacheTime = 600; } else { $CacheTime = 3600; } // Store it all in cache if (!$RevisionID) { $Cache->cache_value("torrents_details_$GroupID", array($TorrentDetails, $TorrentList), $CacheTime); } } else { // If we're reading from cache $TorrentDetails = $TorrentCache[0]; $TorrentList = $TorrentCache[1]; } if ($PersonalProperties) { // Fetch all user specific torrent and group properties $TorrentDetails['Flags'] = array('IsSnatched' => false); foreach ($TorrentList as &$Torrent) { Torrents::torrent_properties($Torrent, $TorrentDetails['Flags']); } } if ($Return) { return array($TorrentDetails, $TorrentList); } } function get_torrent_info($TorrentID, $Return = true, $RevisionID = 0, $PersonalProperties = true, $ApiCall = false) { global $Cache, $DB; $GroupID = (int)torrentid_to_groupid($TorrentID); $GroupInfo = get_group_info($GroupID, $Return, $RevisionID, $PersonalProperties, $ApiCall); if ($GroupInfo) { foreach ($GroupInfo[1] as &$Torrent) { //Remove unneeded entries if ($Torrent['ID'] != $TorrentID) { unset($GroupInfo[1][$Torrent['ID']]); } if ($Return) { return $GroupInfo; } } } else { if ($Return) { return null; } } } //Check if a givin string can be validated as a torrenthash function is_valid_torrenthash($Str) { //6C19FF4C 6C1DD265 3B25832C 0F6228B2 52D743D5 $Str = str_replace(' ', '', $Str); if (preg_match('/^[0-9a-fA-F]{40}$/', $Str)) return $Str; return false; } //Functionality for the API to resolve input into other data. function torrenthash_to_torrentid($Str) { global $Cache, $DB; $DB->query(" SELECT ID FROM torrents WHERE HEX(info_hash) = '".db_string($Str)."'"); $TorrentID = (int)array_pop($DB->next_record(MYSQLI_ASSOC)); if ($TorrentID) { return $TorrentID; } return null; } function torrenthash_to_groupid($Str) { global $Cache, $DB; $DB->query(" SELECT GroupID FROM torrents WHERE HEX(info_hash) = '".db_string($Str)."'"); $GroupID = (int)array_pop($DB->next_record(MYSQLI_ASSOC)); if ($GroupID) { return $GroupID; } return null; } function torrentid_to_groupid($TorrentID) { global $Cache, $DB; $DB->query(" SELECT GroupID FROM torrents WHERE ID = '".db_string($TorrentID)."'"); $GroupID = (int)array_pop($DB->next_record(MYSQLI_ASSOC)); if ($GroupID) { return $GroupID; } return null; } //After adjusting / deleting logs, recalculate the score for the torrent. function set_torrent_logscore($TorrentID) { global $DB; $DB->query(" UPDATE torrents SET LogScore = ( SELECT FLOOR(AVG(Score)) FROM torrents_logs_new WHERE TorrentID = $TorrentID ) WHERE ID = $TorrentID"); } function get_group_requests($GroupID) { if (empty($GroupID) || !is_number($GroupID)) { return array(); } global $DB, $Cache; $Requests = $Cache->get_value("requests_group_$GroupID"); if ($Requests === false) { $DB->query(" SELECT ID FROM requests WHERE GroupID = $GroupID AND TimeFilled = '0000-00-00 00:00:00'"); $Requests = $DB->collect('ID'); $Cache->cache_value("requests_group_$GroupID", $Requests, 0); } return Requests::get_requests($Requests); } //Used by both sections/torrents/details.php and sections/reportsv2/report.php function build_torrents_table($Cache, $DB, $LoggedUser, $GroupID, $GroupName, $GroupCategoryID, $ReleaseType, $TorrentList, $Types, $Username, $ReportedTimes) { function filelist($Str) { return "\n" . Format::get_size($Str[1]) . "\n"; } $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 = ' "; foreach ($Reports as $Report) { if (check_perms('admin_reports')) { $ReporterID = $Report['ReporterID']; $Reporter = Users::user_info($ReporterID); $ReporterName = $Reporter['Username']; $ReportLinks = "$ReporterNamereported it"; } 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 .= " '; } $ReportInfo .= "\n\t\t
This torrent has '.$NumReports.' active '.($NumReports === 1 ? 'report' : 'reports').":
$ReportLinks ".time_diff($Report['ReportedTime'], 2, true, true).' for the reason "'.$ReportType['title'].'":
'.Text::full_format($Report['UserComment']).'
"; } $CanEdit = (check_perms('torrents_edit') || (($UserID == $LoggedUser['ID'] && !$LoggedUser['DisableWiki']) && !($Remastered && !$RemasterYear))); $RegenLink = check_perms('users_mod') ? ' Regenerate' : ''; $FileTable = ' '; 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", $Name, Format::get_size($FileSize)); } } else { $FileListSplit = explode("\n", $FileList); foreach ($FileListSplit as $File) { $FileInfo = Torrents::filelist_get_file($File); $FileTable .= sprintf("\n", $FileInfo['name'], Format::get_size($FileInfo['size'])); } } $FileTable .= '
File Names' . $RegenLink . '
' . ($FilePath ? "/$FilePath/" : '') . '
Size
%s%s
%s%s
'; $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++; ?> [ | FL | RP | ED | RM | PL ] »
Uploaded by = 1209600) { ?>
Last active:
Last active: = 345678 && time() - strtotime($LastReseedRequest) >= 864000) { ?>
Request re-seed
" . Text::full_format($Description) . ''; } ?>