rendered paste body<?
include(SERVER_ROOT.'/classes/class_text.php');
$Text=NEW TEXT;
include(SERVER_ROOT.'/classes/class_thread.php'); // Class that generates and stores threads and the quick reply box
$Thread = new THREAD;
$GroupID=ceil($_GET['id']);
if($_GET['revisionid'] && is_number($_GET['revisionid'])) {
$RevisionID = $_GET['revisionid'];
}
$TorrentCache=$Cache->get_value('detail_'.$GroupID.'_'.$RevisionID);
if(!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.CategoryID,
g.Time,
a.Name,
a.ID,
GROUP_CONCAT(DISTINCT tags.Name SEPARATOR '|'),
GROUP_CONCAT(DISTINCT tags.ID SEPARATOR '|'),
GROUP_CONCAT(tags.UserID 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
LEFT JOIN artists AS a ON a.ID=g.ArtistID ";
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->to_array();
// Fetch the individual torrents
$DB->query("
SELECT
t.ID,
t.Media,
t.Format,
t.Encoding,
t.Year,
t.RemasterTitle,
t.Scene,
t.HasLog,
t.HasCue,
t.FileCount,
t.Size,
t.Seeders,
t.Leechers,
t.Snatched,
t.FreeTorrent,
t.Time,
t.Description,
t.FileList,
t.UserID,
um.Username,
t.last_action
FROM torrents AS t
LEFT JOIN users_main AS um ON um.ID=t.UserID
WHERE t.GroupID='".db_string($GroupID)."'
ORDER BY t.Format DESC, t.Encoding, t.ID");
$TorrentList = $DB->to_array();
if(in_array(0, $DB->collect('Seeders'))) {
$Time = 600;
} else {
$Time = 3600;
}
// Store it all in cache
$Cache->cache_value('detail_'.$GroupID.'_'.$RevisionID,array($TorrentDetails,$TorrentList),$Time);
} else { // If we're reading from cache
$TorrentDetails=$TorrentCache[0];
$TorrentList=$TorrentCache[1];
}
// Group details
list($WikiBody,$WikiImage,$GroupID,$GroupName,$GroupYear,$GroupCategoryID,$GroupTime,$ArtistName,$ArtistID,$TorrentTags,$TorrentTagIDs,$TorrentTagUserIDs)=array_shift($TorrentDetails);
$DisplayType='Torrent';
$DisplayName=$GroupName;
$AltName=$GroupName; // Goes in the alt text of the image
$Title=$GroupName; // goes in <title>
$WikiBody = $Text->full_format($WikiBody);
if($ArtistID) {
$DisplayType="Album";
$DisplayName='<a href="artist.php?id='.$ArtistID.'">'.$ArtistName.'</a> - '.$DisplayName;
$AltName=$ArtistName." - ".$GroupName;
$Title=$ArtistName.' - '.$Title;
}
if($GroupYear>0) {
$DisplayName.=' ['.$GroupYear.']';
$AltName.=' ['.$GroupYear.']';
}
// Start output
show_header($Title,'browse,forums');
?>
<div class="thin">
<h2><?=$DisplayName?></h2>
<div class="linkbox">
<? if(check_perms('site_edit_wiki')) { ?>
<a href="torrents.php?action=editgroup&groupid=<?=$GroupID?>">[Edit description]</a>
<? } ?>
<a href="torrents.php?action=history&groupid=<?=$GroupID?>">[View history]</a>
<? if($RevisionID && check_perms('site_edit_wiki')) { ?>
<a href="/torrents.php?action=revert&groupid=<?=$GroupID ?>&revisionid=<?=$RevisionID ?>&auth=<?= $LoggedUser['AuthKey']?>">[Revert to this revision]</a>
<? } ?>
<a href="javascript:Bookmark();">[Bookmark]</a>
<a href="upload.php?groupid=<?=$GroupID?>">[Add format]</a>
</div>
<div class="sidebar">
<?
if ($WikiImage!="") {
?>
<div class="box">
<div class="head"><strong>Album Art</strong></div>
<p align="center"><a href="<?=$WikiImage?>" target="_blank"><img src="<?=$WikiImage?>" width="220" alt="<?=$AltName?>" title="<?= display_str($AltName); ?>" border="0" /></a></p>
</div>
<?
}
?>
<div class="box">
<div class="head"><strong>Tags</strong></div>
<?
if ($TorrentTags!="") {
?>
<ul class="stats nobullet">
<?
echo "<!-- $TorrentTagUserIDs -->";
$TorrentTags=explode('|',$TorrentTags);
$TorrentTagIDs=explode('|',$TorrentTagIDs);
$TorrentTagUserIDs=explode('|',$TorrentTagUserIDs);
while(list($TagKey,$TagName)=each($TorrentTags)) {
$TagID=$TorrentTagIDs[$TagKey];
$TagUserID=$TorrentTagUserIDs[$TagKey];
?>
<li>
<a href="torrents.php?searchtags=<?= $TagName; ?>"><?= display_str($TagName); ?></a>
<a href="torrents.php?action=vote_tag&way=up&groupid=<?= $GroupID?>&tagid=<?= $TagID?>&auth=<?= $LoggedUser['AuthKey']?>">[+]</a>
<a href="torrents.php?action=vote_tag&way=down&groupid=<?= $GroupID?>&tagid=<?= $TagID?>&auth=<?= $LoggedUser['AuthKey']?>">[-]</a>
<? if(check_perms('site_delete_tag')){ ?>
<a href="torrents.php?action=delete_tag&groupid=<?= $GroupID?>&tagid=<?= $TagID?>&auth=<?= $LoggedUser['AuthKey']?>">[X]</a>
<? }
if(check_perms('users_warn')){ ?>
<a href="user.php?id=<?= $TagUserID ?>">[U]</a>
<? } ?>
</li>
<?
}
?>
</ul>
<?
} else {
?>
There are no tags to display.
<?
}
?>
</div>
<div class="box">
<div class="head"><strong>Add tag</strong></div>
<div class="body">
<form action="torrents.php" method="post">
<input type="hidden" name="action" value="add_tag" />
<input type="hidden" name="groupid" value="<?= $GroupID ?>" />
<input type="text" name="tagname" size="20" />
<input type="submit" value="+" />
</form>
<br /><br />
<strong><a href="rules.php?p=tag">Tagging rules</a></strong>
</div>
</div>
</div>
<div class="main_column">
<table class="torrent_table">
<tr class="colhead_dark">
<td width="80%"><strong>Torrents</strong></td>
<td><strong>Size</strong></td>
<td class="sign"><img src="static/styles/<?= $LoggedUser['StyleName'] ?>/images/snatched.png" alt="Snatches" title="Snatches" /></td>
<td class="sign"><img src="static/styles/<?= $LoggedUser['StyleName'] ?>/images/seeders.png" alt="Seeders" title="Seeders" /></td>
<td class="sign"><img src="static/styles/<?= $LoggedUser['StyleName'] ?>/images/leechers.png" alt="Leechers" title="Leechers" /></td>
</tr>
<?
function filelist($Str) {
return "</td><td>".get_size($Str[1])."</td></tr>";
}
while(list($TorrentID, $Media, $Format, $Encoding, $Year, $RemasterTitle, $Scene, $HasLog, $HasCue, $FileCount, $Size, $Seeders, $Leechers, $Snatched, $FreeTorrent, $Time, $Description, $FileList, $UserID, $Username, $LastActive) = array_shift($TorrentList)) {
$temp_array = array('userid' => $UserID, 'username' => $Username, 'time' => $Time, 'torrentid' => $TorrentID);
$FileList=preg_replace("(_|-)", " ", $FileList);
$FileList=str_replace('|||','<tr><td>',display_str($FileList));
$FileList=preg_replace_callback('/\{\{\{([^\{]*)\}\}\}/i','filelist',$FileList);
$FileList='<table style="overflow-x:auto;"><tr class="colhead_dark"><td><strong>File Name</strong></td><td><strong>Size</strong></td></tr><tr><td>'.$FileList."</table>";
$ExtraInfo=''; // String that contains information on the torrent, eg. format and encoding
$AddExtra=''; // Separator between torrent properties
if ($Format) { $ExtraInfo.=display_str($Format); $AddExtra=' / '; }
if ($Encoding) { $ExtraInfo.=$AddExtra.display_str($Encoding); $AddExtra=' / '; }
if ($HasLog) { $ExtraInfo.=$AddExtra.'Log'; $AddExtra=' / '; }
if ($HasCue) { $ExtraInfo.=$AddExtra.'Cue'; $AddExtra=' / '; }
if ($Media) { $ExtraInfo.=$AddExtra.display_str($Media); $AddExtra=' / '; }
if ($Scene) { $ExtraInfo.=$AddExtra.'Scene'; $AddExtra=' / '; }
if ($RemasterTitle) { $ExtraInfo.=$AddExtra.display_str($RemasterTitle); $AddExtra=' - '; }
if ($Year) { $ExtraInfo.=$AddExtra.display_str($Year); $AddExtra=' / '; }
if ($FreeTorrent) { $ExtraInfo.=$AddExtra.'<strong>Freeleech!</strong>'; $AddExtra=' / '; }
if(!$ExtraInfo){
$ExtraInfo = $GroupName;
}
?>
<tr class="group_torrent" style="font-weight: normal;">
<td>
<span>[
<a href="torrents.php?action=download&id=<?= $TorrentID ?>&authkey=<?=$LoggedUser['AuthKey']?>&torrent_pass=<?=$LoggedUser['torrent_pass']?>" title="Download">DL</a>
| <a href="reports.php?action=report&id=<?= $TorrentID?>" title="Report">RP</a>
<? if(check_perms('torrents_edit') || $UserID == $LoggedUser['ID']) { ?>
| <a href="torrents.php?action=edit&id=<?= $TorrentID ?>" title="Edit">ED</a>
<? } ?>
<? if(check_perms('torrents_delete') || $UserID == $LoggedUser['ID']) { ?>
| <a href="torrents.php?action=delete&torrentid=<?= $TorrentID ?>" title="Remove">RM</a>
<? } ?>
]</span>
<a href="#" onclick="return swapDisplay('<?= $TorrentID; ?>','1');">» <?= $ExtraInfo; ?></a>
</td>
<td class="nobr"><?= get_size($Size); ?></td>
<td><?= number_format($Snatched); ?></td>
<td><?= number_format($Seeders); ?></td>
<td><?= number_format($Leechers); ?></td>
</tr>
<tr class="pad <? if($_GET['torrentid']!=$TorrentID) { ?>hide<? } ?>" id="torrent_<?= $TorrentID; ?>">
<td colspan="5">
<? } ?>
<blockquote>
Uploaded by <?= format_username($UserID, $Username)?> on <?= format_time($Time, true);?>
<? if($Seeders == 0){ ?>
<br />Last active: <?= format_time($LastActive, true);?>
<? }?>
</blockquote>
<? if($Description) {
echo '<blockquote>'.$Text->full_format($Description).'</blockquote>';}
?>
<?= $FileList; ?>
<? if($_GET['peers'] !=$TorrentID || !is_number($_GET['peers'])) {?>
<div class="linkbox"><a href="torrents.php?id=<?= $GroupID?>&torrentid=<?= $TorrentID?>&peers=<?= $TorrentID?>">[Show/hide peer list]</a></div>
<? } else { ?>
<div class="linkbox"><a href="javascript:swapPeerList(<?= $TorrentID?>)">[Show/hide peer list]</a></div>
<table id="peers_<?= $TorrentID; ?>">
<tr class="colhead_dark" style="font-weight: bold;">
<td>User</td>
<td>Active</td>
<td>Connectable</td>
<td>Up</td>
<td>%</td>
<td>Client</td>
</tr>
<?
$DB->query("SELECT
xu.uid,
um.Username,
xu.active,
xu.connectable,
xu.uploaded,
xu.remaining,
xu.useragent
FROM xbt_files_users AS xu
LEFT JOIN users_main AS um ON um.ID=xu.uid
WHERE xu.fid='$TorrentID'
ORDER BY xu.uploaded DESC");
while(list($PeerUserID, $Username, $Active, $Connectable, $Uploaded, $Remaining, $UserAgent) = $DB->next_record()) {
?>
<tr>
<td><?= format_username($PeerUserID, $Username)?></td>
<td><?= ($Active) ? '<span style="color:green">Yes</span>' : '<span style="color:red">No</span>' ?></td>
<td><?= ($Connectable) ? '<span style="color:green">Yes</span>' : '<span style="color:red">No</span> [<a href="user.php?action=connchecker" title="Connectivity Check">C</a>]' ?></td>
<td><?= get_size($Uploaded) ?></td>
<td><?= number_format(($Size-$Remaining)/$Size*100, 2)?></td>
<td><?= display_str($UserAgent)?></td>
</tr>
<?
}
?>
</table>
<? } ?>
<? if(($_GET['snatches'] !=$TorrentID || !is_number($_GET['snatches'])) && check_perms('site_view_torrent_snatchlist')) { ?>
<div class="linkbox"><a href="torrents.php?id=<?= $GroupID?>&torrentid=<?= $TorrentID?>&snatches=<?= $TorrentID?>">[Show/hide snatchlist]</a></div>
<? } elseif(check_perms('site_view_torrent_snatchlist')) { ?>
<div class="linkbox"><a href="javascript:swapSnatchList(<?= $TorrentID?>)">[Show/hide snatchlist]</a></div>
<table id="snatches_<?= $TorrentID; ?>">
<tr class="colhead_dark" style="font-weight: bold;">
<td>User</td>
<td>Time</td>
<td>User</td>
<td>Time</td>
</tr>
<tr>
<?
$DB->query("SELECT
xs.uid,
um.Username,
um.Enabled,
ui.Donor,
ui.Warned,
xs.tstamp
FROM xbt_snatched AS xs
LEFT JOIN users_main AS um ON um.ID=xs.uid
LEFT JOIN users_info AS ui ON ui.UserID=xs.uid
WHERE xs.fid='$TorrentID'
ORDER BY xs.tstamp DESC");
$i = 0;
while(list($SnatcherID, $Username, $Enabled, $Donor, $Warned, $Timestamp) = $DB->next_record()) {
if($i % 2 == 0 && $i>0){ ?>
</tr>
<tr>
<? } ?>
<td><?=format_username($SnatcherID, $Username, $Donor, $Warned, $Enabled)?></td>
<td><?=time_diff($Timestamp, '', 2, true)?></td>
<? $i++;
} ?>
</tr>
</table>
<? } ?>
</td>
</tr>
<?
?>
</table>
<div class="box">
<div class="head"><strong><?= $DisplayType; ?> info</strong></div>
<div class="body"><? if ($WikiBody!="") { echo $WikiBody; } else { echo "There is no information on this torrent."; } ?></div>
</div>
<tr class="pad <? if($_GET['torrentid']!=$TorrentID) { ?>hide<? } ?>" id="torrent_<?= $TorrentID; ?>">
<td colspan="5">
<? if($Seeders==0) { ?>
<div id="linkbox" style="text-align: center" >
<form method="post" action="">
<input type="hidden" id="action" name="action" value="reseed" />
<input type="hidden" id="gid" name="gid" value="<?= $GroupID?>" />
<input type="hidden" id="tid" name="tid" value="<?= $temp_array['torrentid']?>" />
<? if($ReseedTime<$WeekAgo) { ?>
<input type="submit" id="reseed" name="reseed" value="Request a reseed" />
<? } else { ?>
<input type="submit" id="reseed" name="reseed" value="Request a reseed" disabled />
<? } ?>
</form>
</div>
<? } ?>
<blockquote>
Uploaded by <?= format_username($temp_array['userid'], $temp_array['username'])?> on <?= format_time($temp_array['time'], true);?>
<?
if($_GET['page']){
$Page = $_GET['page'];
$Limit=TORRENT_COMMENTS_PER_PAGE*$_GET['page']-TORRENT_COMMENTS_PER_PAGE . ", " . TORRENT_COMMENTS_PER_PAGE;
}else {
$Page = 1;
$Limit=TORRENT_COMMENTS_PER_PAGE;
}
$CommentCount=$Cache->get_value('torrentcomments_count_'.$GroupID);
if (!$CommentCount) {
$DB->query("SELECT COUNT(ID) FROM torrents_comments WHERE GroupID='".$GroupID."'");
list($CommentCount)=$DB->next_record();
$Cache->cache_value('torrentcomments_count_'.$GroupID,$CommentCount,21600);
}
$Pages=get_pages('torrents.php',$_GET['page'],$CommentCount,TORRENT_COMMENTS_PER_PAGE,'id='.$GroupID,true, 15);
?>
<div class="linkbox"><?=$Pages?></div>
<?
$Cache->new_page('torrentcomment_'.$GroupID.'_page_'.$Page);
$SQL = "SELECT
tc.ID,
tc.AuthorID,
tc.AddedTime,
tc.Body,
tc.EditedUserID,
tc.EditedTime,
ed.Username,
um.Username,
um.PermissionID,
um.Title,
ui.Avatar,
ui.Donor,
ui.Warned,
um.Enabled
FROM torrents_comments as tc
LEFT JOIN users_main AS um ON um.ID = tc.AuthorID
LEFT JOIN users_info AS ui ON ui.UserID = tc.AuthorID
LEFT JOIN users_main AS ed ON ed.ID = tc.EditedUserID
WHERE tc.GroupID = '".$GroupID."'
LIMIT ".$Limit;
$Thread->set_query($SQL);
$Thread->set_page_type('torrent');
$Thread->set_thread_id($GroupID);
$Thread->set_page($Page);
$Thread->set_highlight_unread(true);
//$Thread->set_show_avatars(($LoggedUser['ViewAvatars'])? true : false);
$Thread->write();
$Thread->show_reply_box('Quick Reply');
// Update last read posts (torrents_last_read_topics table)
// This is only done if the user hasn't read the last post on the page
$Thread->update_last_read('torrents_last_read_topics');
?>
<div class="linkbox"><?=$Pages?></div>
</div>
</div>
<?
show_footer();
?>