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

	global $prefix, $db, $user, $module_name, $admin, $anonpost, $admin_file, $pagenum, $adirectory, $version;
	$content = "";

// количество постов на странице
$postspg_in = file("config/config_forums.php");
eval ($postspg_in[4]);

	if ($version=="2.2 Lite") {
		$infoUser = "op=info&uname="; 
	} else {
		$infoUser = "op=userinfo&user_name=";
	}

		$i = 0;
	$result = $db->sql_query("SELECT a.name, a.totalshows, a.totalposts, a.id, a.cid, a.date, a.title, b.name FROM ".$prefix."_forums_topics AS a INNER JOIN ".$prefix."_forums_posts AS b ON (a.id = b.tid) AND (a.date = b.date) GROUP BY totalshows, totalposts, id, cid ORDER BY a.date DESC LIMIT 0, 7 ");
		/*то место где малясь подправил :)*/
		$content .=  "<table border=\"0\" cellpadding=\"3\" cellspacing=\"1\" width=\"100%\" class=\"bgcolor4\">
		<tr>
		    <th></th>
			<th>Тема</th>
			<th>Ответов</th>
			<th>Автор темы</th>
			<th>Просморов</th>
			<th>Последнее сообщение</th>
		</tr>";
		while (list($sender_name, $totalshow, $totalpost, $id, $c_cid, $last_date,  $com_text, $last_unme) = $db->sql_fetchrow($result)) {
		$c_cid = intval($c_cid);
		$lpost = $totalpost+1;

#		list ($last_date, $last_unme) = $db->sql_fetchrow( $db->sql_query("SELECT date, name FROM ".$prefix."_forums_posts   WHERE tid = '$id' ORDER BY date DESC ") );

		$num_pagelast = ceil ($lpost / $postspg);
		if ($num_pagelast > 1) {$num_pagelast = "&pagenum=$num_pagelast";} else {$num_pagelast = "";}
			$content .=  "
			<tr class=\"bgcolor1\">
				<td ><img src=\"images/blocks/Forums.gif\" border=\"0\" hspace=\"3\"></td>
				<td width=\"100%\" style=\"padding-right: 7px; padding-left: 7px;\" ><a href=\"index.php?name=Forums&op=showtopic&cat=$c_cid&id=$id\"><b>".bb_decode($com_text)."</b></a></td>
				<td align=\"center\">$totalpost</td>
				<td align=\"center\"><a href=\"index.php?name=Account&".$infoUser."$sender_name\" title=\""._PERSONALINFO."\" target=\"_blank\">$sender_name</a></td>
				<td align=\"center\">";
			$content .=  ($totalshow > 0 ? $totalshow : 0);
			$content .= "</td>"
				."<td align=\"center\"><a href=\"index.php?name=Forums&op=showtopic&cat=$c_cid".$num_pagelast."&id=$id#$lpost\">$last_date</a><br><a href=\"index.php?name=Account&".$infoUser."$last_unme\" title=\""._PERSONALINFO."\" target=\"_blank\">$last_unme</a></td>
			</tr>";

			if ($i < ($comnumcat-1)) $content .=  "<tr class=\"bgcolor3\"><td height=\"3px\" colspan=\"6\"></td></tr>";
			$a--;
			$i++;
		}
		$content .=  "</table>";

?>