<?php
if(!defined('DATALIFEENGINE'))
{
  die("Hacking attempt!");
}

	while ($row = $db->get_row($result_topics))
	{
		if ($forum_config['topic_abc'])
		{
			if (strlen($row['title']) > $forum_config['topic_abc'])
			{
				$row['title'] = substr ($row['title'], 0, $forum_config['topic_abc']).'...';
			}
			
			if (strlen($row['topic_descr']) > $forum_config['topic_abc'])
			{
				$row['topic_descr'] = substr ($row['topic_descr'], 0, $forum_config['topic_abc']).'...';
			}
		}
		
		$topic_link = link_topic($row['tid'], $row['title']);
		
		if ($row['hidden']){$topic_link = $forum_config['forum_pr_modr'].' '.$topic_link;}
		if (!$row['fixed']){$topic_link = $forum_config['forum_pr_imp'].' '.$topic_link;}
		if ($row['frage']){$topic_link = $forum_config['forum_pr_vote'].' '.$topic_link;}

		$tpl->load_template($tpl_dir.'topics.tpl');

        $tpl->set('{status}', topic_status($row['tid'], $row['last_date'], $row['post'], $row['topic_status'], $row['frage']));
		$tpl->set('{title}', stripslashes($topic_link));
		$tpl->set('{description}', stripslashes($row['topic_descr']));
		$tpl->set('{show}', $row['views']);
		$tpl->set('{post}', $row['post']);

        $str='';
        $nom='';
        $str=ceil($row['post']/$forum_config['post_inpage']);
        if ($str>1) {
            if ($str<=5) {
                for ($i = 1; $i <= $str; $i++) {
                $topic_linker="/forum/topic_".$row['tid']."/".$i."/";
                $nom.="<a id=\"pagen\" href='$topic_linker'>$i</a>&nbsp;";}
                $tpl->set('{str}', $nom);
            }
            if ($str>5){
                for ($i = 1; $i <= 5; $i++) {
                $topic_linker="/forum/topic_".$row['tid']."/".$i."/";
                $nom.="<a id=\"pagen\" href='$topic_linker'>$i</a>&nbsp;";
                }
                $nom.="...";
                $topic_linker="/forum/topic_".$row['tid']."/".$str."/";
                $nom.="<a id=\"pagen\" href='$topic_linker'>$str</a>";
                $tpl->set('{str}', $nom);
            }
        } else $tpl->set('{str}', '');
		
		$tpl->set('{author}', link_user($row['author_topic']));
		
		$tpl->set('{last}', topic_last ($row['tid'], $row['last_poster_name'], $row['last_date'], $row['post'], $row['last_post_id']));
		
		if ($mass_prune)
		{
			$tpl->set('[selected]',"");
			
			$tpl->set('{selected}', "<input OnClick=\"select_id('{$row['tid']}');\" type='checkbox' name=\"sid[{$row['tid']}]\" value=\"{$row['tid']}\">");
			
			$tpl->set('[/selected]',"");
		}
		
		else
		{
			$tpl->set_block("'\\[selected\\](.*?)\\[/selected\\]'si","");
		}
		
		$tpl->compile('topics');
		
		$tpl->clear();
		
		$is_topics = 1;
	}
?>