<?php
	$db = PerfDb::init();
	$topic_r = $db->query("SELECT * FROM `forum_t` WHERE `time_last_post` > '". (time()-60*60*24) ."'")->rowCount();
	if($topic_r !=0) 
	{
		$topic_q = $db->query("SELECT * FROM `forum_t` WHERE `time_last_post` > '". (time()-60*60*24) ."' ORDER BY time_last_post DESC LIMIT 0, 6");
		while($topic = $topic_q->fetch()) 
		{
			echo '<div class="post">';
			if ($topic['closed'] == 1 && $topic['attach'] == 1) echo System::image('forum/pin-closed.png');
			else if ($topic['attach'] == 1) echo System::image('forum/pin.png');
			else if ($topic['closed'] == 1) echo System::image('forum/topic_closed.png');
			else echo System::image('forum/topic.png');	
			$topic_a = $db->query("SELECT * FROM `forum_pt` WHERE `topic_id` = '". $topic['id']."' ORDER BY time DESC LIMIT 1")->fetch();
			echo ' <a href="/forum/topic-'. $topic['id'] .'/">'. $topic['name'] .'</a>  ('. $db->query("SELECT id FROM `forum_pt` WHERE `topic_id` = '". $topic['id'] ."'")->rowCount().')<a href="/forum/topic-'. $topic['id'] .'?page=end">»</a> <br/> [<small class="gray">'. User::tnick($topic_a['user_id']).' / '. Filters::viewTime($topic_a['time']).'</small>]
			</div>';
		}
	}