<?php
If (!defined("INBCWE")) {
    die("Dieses Script kann nicht ausserhalb des Frameworks laufen!");
} 
// Anzahl der Themen
$limit = "5";
// Überlange Themen kürzen (0 = Nein, x = Anzahl der auszugebenden Zeichen)
$length = "0";

//Nicht sichtbare Foren ausschließen
$unviewable = get_unviewable_forums();
if($unviewable)
{
$unviewwhere = "AND fid NOT IN ('2',".$unviewable.")";
}else{
$unviewwhere = "AND fid<>2";
}

// Themen aus Datenbank holen
$query = $db->query ("SELECT subject,username,pid,uid,tid,fid,dateline FROM ".TABLE_PREFIX."posts WHERE visible='1' $unviewwhere ORDER BY dateline DESC LIMIT 0,".$limit."");

while($threads = $db->fetch_array($query))
{
// Forum ermitteln
$query2 = $db->query ("SELECT name FROM ".TABLE_PREFIX."forums WHERE fid = '".$threads['fid']."'");
$forums = $db->fetch_array($query2);
$threads['name']=$forums['name'];
$threads['date']=date("d.m.y H:i",$threads["dateline"]);
$threads['urlusername']=urlencode($threads['username']);
// Betreff kürzen?
if ($length != 0)
{
    if (strlen($threads['subject']) > $length) 
    {
    $threads['subject'] = substr($threads['subject'],0,$length) . "...";
    }
}
$forum[]=$threads;
}
$tpl->assign("forum",$forum);
    $navrow .= $tpl->fetch('nav_lastpost.tpl');
?>
