
<?php
defined ('main') or die ( 'no direct access' );
 
$query = "SELECT a.id, a.name, a.rep, a.erst as autor, b.id as fid, c.erst as last, c.id as pid, c.time , c.erstid as erstid, b.name AS fname
     FROM prefix_topics a
     LEFT JOIN prefix_forums b ON b.id = a.fid
     LEFT JOIN prefix_posts c ON c.id = a.last_post_id
     LEFT JOIN prefix_forumcats d ON d.id = b.cid AND b.id = a.fid
     LEFT JOIN prefix_groupusers vg ON vg.uid = ".$_SESSION['authid']." AND vg.gid = b.view
     LEFT JOIN prefix_groupusers rg ON rg.uid = ".$_SESSION['authid']." AND rg.gid = b.reply
     LEFT JOIN prefix_groupusers sg ON sg.uid = ".$_SESSION['authid']." AND sg.gid = b.start
     WHERE ((".$_SESSION['authright']." <= b.view AND b.view < 1)
     OR (".$_SESSION['authright']." <= b.reply AND b.reply < 1)
     OR (".$_SESSION['authright']." <= b.start AND b.start < 1)
     OR vg.fid IS NOT NULL
     OR rg.fid IS NOT NULL
     OR sg.fid IS NOT NULL
     OR -9 >= ".$_SESSION['authright'].")
    ORDER BY c.time DESC
    LIMIT 0,5";
    echo '';
    $resultID = db_query($query);
	
while ($row = db_fetch_assoc($resultID)) {
    $row['date'] = date('d.m.y - H:i',$row['time']);
    $row['page'] = ceil ( ($row['rep']+1)  / $allgAr['Fpanz'] );
	$row['fname'] = bbcode($row['fname']);
	
echo'<table width="100%" border="0" cellspacing="1" cellpadding="0"><tr><td colspan="2" align="left"><b><a class="forum_link" href="?forum-showposts-'.$row['id'].'-p'.$row['page'].'#'.$row['pid'].'" title="'.$row['name'].'">'.((strlen($row['name'])<50) ? $row['name'] : substr($row['name'],0,40).'...').'</a></b></td></tr><tr><td align="left"><table width="100%" border="0" cellspacing="0" cellpadding="0" ><tr><td align="left">Letzter:&nbsp;<a href="index.php?user-details-'.$row['erstid'].'">'.$row['last'].'</a></td><td align="right" style="padding-right:3px;">am:&nbsp;'.$row['date'].' Uhr</td></tr></table>
</td></tr><tr><td height="1" colspan="3" bgcolor="#CCCCCC"></td></tr></table>';	
    }
?>