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

global $lang , $get_user_class_color , $pic_base_url , $display_date_time;


	$content .="<table width='100%' border='0' cellspacing='0' cellpadding=5><tr>".
  "<td width='50%' align=left><b>Имя Темы</b></td>".
  "<td  align='center'><b>Сообщений</b></td>".
  "<td  align='center'><b>Просмотров</b></td>".
  "<td  align='center'><b>Автор</b></td>".
  "<td  align='center'><b>Посл. Сообщение</b></td>".
  "</tr>";

  $res = sql_query("SELECT posts.id AS pid, posts.topicid, posts.userid AS userpost , posts.added, topics.id AS tid, topics.userid AS usertopic, topics.subject, topics.forumid, topics.lastpost, topics.views, forums.name, users.username AS uname , users.class AS uclass, topicposter.username AS tusername , topicposter.class AS tclass
  , (SELECT COUNT(*) FROM posts WHERE topicid = tid) AS postscounts FROM posts, topics, forums, users, users AS topicposter
  WHERE posts.topicid = topics.id AND topics.forumid = forums.id AND posts.userid = users.id AND topics.userid = topicposter.id 
  ORDER  BY posts.added DESC 
  LIMIT 10") or sqlerr(__FILE__, __LINE__);

  while ($postsx = mysql_fetch_assoc($res))
  {
  
  $content .="<tr><td><a href=\"forum.php?action=viewtopic&topicid={$postsx["tid"]}\"><b>{$postsx["subject"]}</b></a><br /> в  <a href=\"forum.php?action=viewforum&forumid={$postsx["forumid"]}\">{$postsx["name"]}</a></td>".
  "<td align='center'>{$postsx["postscounts"]}</td>".
  "<td align='center'>{$postsx["views"]}</td>".
  "<td align='center'>&nbsp;<a href=userdetails.php?id={$postsx["usertopic"]}><b>".get_user_class_color($postsx['tclass'],$postsx["tusername"])."</b></a></td>".
  "<td align='left'>&nbsp;<a href=userdetails.php?id={$postsx["userpost"]}><b>".get_user_class_color($postsx['uclass'],$postsx["uname"])."</b></a>&nbsp;<a href=\"forum.php?action=viewtopic&topicid={$postsx["tid"]}&amp;page=p{$postsx["pid"]}#{$postsx["pid"]}\"><img src='$pic_base_url/latest.gif' border='0px' alt='Читать сообщение'></a><br />&nbsp;".$postsx["added"]."</td></tr>";
  
  }
$content .="</table>";
///////////////////////////////////////////////// END LAST X FORUM POSTS


?>