<?php
if (!defined('BLOCK_FILE')) {
 Header("Location: ../index.php");
 exit;
}

global $rootpath;

$count = get_row_count('indexreleases');
$blocktitle = "Релизы".(get_user_class() >= UC_MODERATOR ? "<font class=\"small\"> - [<a class=\"altlink\" href=\"indexadd.php\"><b>Новый</b></a>]</font>" : "");

if (!$count) {
	$content .= "Нет релизов на трекере...";
} else {
	$perpage = 5;
	list($pagertop, $pagerbottom, $limit) = pager($perpage, $count, $_SERVER["PHP_SELF"] . "?" );
	$res = sql_query("SELECT i.*, c.id AS catid, c.name AS catname, c.image AS catimage FROM indexreleases AS i LEFT JOIN categories AS c ON i.cat = c.id ORDER BY id DESC $limit") or sqlerr(__FILE__, __LINE__);
	while ($release = mysql_fetch_array($res)) {
		$catid = $release["catid"];
		$catname = $release["catname"];
		$catimage = $release["catimage"];
	
		$content .= "<div class=\"glavnaya-title\"><a href=\"details.php?id=$release[torrentid]\" alt=\"$release[name]\"><b>".htmlspecialchars($release["name"])."</b>".(get_user_class() >= UC_MODERATOR ? "<font class=\"small\"> [<a href=\"indexedit.php?action=edit&id=$release[id]&returnto=" . urlencode($_SERVER['PHP_SELF']) . "\"><b>Редактировать</b></a>][<a href=\"indexdelete.php?action=delete&id=$release[id]&returnto=" . urlencode($_SERVER['PHP_SELF']) . "\"><b>Удалить</b></a>]</font>" : "")."</a></div>";
		$content .= "<div class=\"glavnaya\">";
		$content .= "
		<div class=\"glavnaya-descr black\"><a href=\"details.php?id=$release[torrentid]\" alt=\"$release[name]\"><img alt=\"$release[name]\" src=\"$release[poster]\" width=\"175\" class=\"poster-img style-img\"></a>
		".(!empty($catname) ? "<a href=\"browse.php?cat=$catid\"><img src=\"pic/cats/$catimage\" alt=\"$catname\" title=\"$catname\" align=\"right\" border=\"0\" /></a>" : "").format_comment($release["top"])."<br />".format_comment($release["center"])."<br />".format_comment($release["bottom"])."
		</div>		
		";
		$content .= "<div class=\"clear\"></div><div class=\"glavnaya-go\" align=\"right\"><a href=\"details.php?id=$release[torrentid]\"><b>[подробнее]</b></a></div></div>";
	}
	
	$content .= $pagerbottom;
}

?>