
<?php
/*
* (c) Rien van Hulten
* (w) rienvanhulten.nl
*/
function laatste_active_topics ($datum_formaat, $pad_naar_forum, $limit)
{
	include_once $pad_naar_forum . '/config.php';
	mysql_connect($dbhost, $dbuser, $dbpasswd) or die ("<p>Het verbinden met de database is mislukt. Onze excuses hiervoor. Neem indien nodig contact op via het contactformulier.</p>");  
	mysql_select_db ($dbname) or die ("<p>Het verbinden met de database is mislukt. Onze excuses hiervoor. Neem indien nodig contact op via het contactformulier.</p>");  
	
	$query = mysql_query("SELECT " . $table_prefix . "_topics.topic_id, " . $table_prefix . "_topics.topic_title, " . $table_prefix . "_topics.topic_poster, " . $table_prefix . "_topics.topic_replies, " . $table_prefix . "_users.username, " . $table_prefix . "_users.user_id, " . $table_prefix . "_posts.post_time, " . $table_prefix . "_topics.topic_last_post_id
	FROM " . $table_prefix . "_topics
	INNER JOIN " . $table_prefix . "_users ON ( " . $table_prefix . "_topics.topic_poster = " . $table_prefix . "_users.user_id )
	INNER JOIN " . $table_prefix . "_posts ON ( " . $table_prefix . "_topics.topic_last_post_id = " . $table_prefix . "_posts.post_id )
	ORDER BY " . $table_prefix . "_posts.post_time DESC
	LIMIT 0," . $limit);
	echo '<p>';
	while($array = mysql_fetch_array($query))  
	{
		$array['topic_replies'] = $array['topic_replies'] == 0 ? '<span style="color: orange">(' . $array['topic_replies'] . ')</span>' : '(' . $array['topic_replies'] . ')';
	?>
		[<?=date($datum_formaat, $array['post_time'])?>] <a href="<?=$pad_naar_forum?>/viewtopic.php?t=<?=$array['topic_id']?>#<?=$array['topic_last_post_id']?>"><?=$array['topic_title']?></a> <?=$array['topic_replies']?>, gestart door <a href="<?=$pad_naar_forum?>/profile.php?mode=viewprofile&u=<?=$array['user_id']?>"><?=$array['username']?></a>.<br />
	<?php
	}
	echo '</p>';
}
laatste_active_topics('d-m-Y H:i:s', 'phpbb', 10)
?>
