set_file('seite', PATH.'template.htm');
$tpl->set_block('seite', 'LOOP', 'LOOPSECTION');
$tpl->set_block('seite', 'COMMENTS', 'COMMENTSECTION');
$tpl->set_block('seite', 'COMMENTSHEADER', 'HEADER');
$tpl->set_block('seite', 'COMMENTFORM', 'FORM');
//$zeile = file($datafile);
$handle = @fopen($datafile, 'r');
if($handle){
while(!feof($handle)) {
$chunk = fgets($handle, 16384);
if(!empty($chunk))
$zeile[] = $chunk;
}
fclose($handle);
}
$zeilen = sizeof($zeile);
$seiten = ceil($zeilen / $newsperpage);
$zeile = array_reverse($zeile);
if(!isset($_GET['pn_go']))
$_GET['pn_go']='';
// ----- standard output of all news -------------------------------------------
if(!$_GET['pn_go'] OR $_GET['pn_go']=='')
{
// prepare the navigation links
if (!isset($_GET['page']))
$_GET['page'] = 1;
$newsUpperLimit = $_GET['page'] * $newsperpage;
$newsLowerLimit = $newsUpperLimit - $newsperpage;
if ($newsUpperLimit > $zeilen)
$newsUpperLimit = $zeilen;
// prepare all news
for ($i=$newsLowerLimit; $i<$newsUpperLimit; $i++)
{
$eintrag = explode('§',$zeile[$i]);
$datum = formatdate($eintrag[6], $dateformat);
$eintrag[1] = getname($eintrag[1], PATH.'inc/pn_userdata.php');
$eintrag[2] = formattext($eintrag[2], $smilies, $smiliespath, $texthtml);
$eintrag[3] = formattext($eintrag[3], $smilies, $smiliespath, $texthtml);
// category system
if($showcat=='yes')
$eintrag[5] = getcat($eintrag[5], PATH.'inc/pn_categories.dat','catpics', $catpics);
else
$eintrag[5] = '';
if($eintrag[4] != '')
$readmore = ''.$more.'';
else
$readmore = '';
$newsnr = $zeilen-$i.'.';
$commentscount = commentscount($eintrag[0]);
$comments = 'Comments ('.$commentscount.')';
$tpl->set_var(array(
'cat' => $eintrag[5],
'newsnr' => $newsnr,
'autor' => $eintrag[1],
'title' => $eintrag[2],
'news' => $eintrag[3],
'datum' => $datum,
'readmore' => $readmore,
'comments' => $comments));
$tpl->parse("LOOPSECTION", "LOOP", true);
}
}
// ----- a single detailed news ------------------------------------------------
if($_GET['pn_go'] == 'details')
{
for ($i=0; $i<$zeilen; $i++)
{
$eintrag = explode('§',$zeile[$i]);
if ($eintrag[0] == $_GET['id'])
{
$datum = formatdate($eintrag[6], $dateformat);
$eintrag[1] = getname($eintrag[1], PATH.'inc/pn_userdata.php');
$eintrag[2] = formattext($eintrag[2], $smilies, $smiliespath, $texthtml);
$eintrag[3] = formattext($eintrag[3], $smilies, $smiliespath, $texthtml);
if($eintrag[4] != '')
{
$eintrag[4] = formattext($eintrag[4], $smilies, $smiliespath, $texthtml);
$eintrag[3] = $eintrag[3].'
More:
'.$eintrag[4];
}
// category system
if($showcat=='yes') $eintrag[5] = getcat($eintrag[5], PATH.'inc/pn_categories.dat','catpics', $catpics);
else $eintrag[5] = '';
$commentscount = commentscount($eintrag[0]);
$comments = 'Comments ('.$commentscount.')';
if(!isset($newsnr))
$newsnr='';
$tpl->set_var(array(
'cat' => $eintrag[5],
'newsnr' => $newsnr,
'autor' => $eintrag[1],
'title' => $eintrag[2],
'news' => $eintrag[3],
'datum' => $datum,
'readmore' => '',
'comments' => $comments
));
$tpl->parse("LOOPSECTION", "LOOP", true);
break;
}
}
// show comments overview
$tpl->parse("HEADER", "COMMENTSHEADER", true);
$tpl->set_var(array("commentscount" => $commentscount));
// show comments
//$zeile = file($cf);
$zeile = array();
$handle = @fopen($cf, 'r');
if($handle){
while(!feof($handle)) {
$chunk = fgets($handle, 16384);
if(!empty($chunk))
$zeile[] = $chunk;
}
fclose($handle);
}
$zeilen = sizeof($zeile);
$commentnr=0;
for ($i=0; $i<$zeilen; $i++) {
$eintrag = explode("§",$zeile[$i]);
if ($eintrag[1] == $_GET['id']) {
$datum = formatdate($eintrag[5], $dateformat);
$eintrag[2] = formattext($eintrag[2], $smilies, $smiliespath, $commenthtml);
$author = ''.$eintrag[3].'';
$commentnr++;
$tpl->set_var(array(
"datum" => $datum,
"comment" => $eintrag[2],
"autor" => $author,
"commentnr" => '#'.$commentnr));
$tpl->parse("COMMENTSECTION", "COMMENTS", true);
}
}
// show comment form for a new entry
$saveurl = ROOT.$newsoutput.'?pn_go=savecomment'.$params;
empty($_GET['page']) ? $_GET['page']=1 : 0;
$backurl = ROOT.$newsoutput.'?pn_go=details&page='.$_GET['page'].'&id='.$_GET['id'];
$tpl->parse("FORM", "COMMENTFORM", true);
$tpl->set_var(array(
'saveurl' => $saveurl,
'commentid' => $_GET['id'],
'backurl' => $backurl));
}
// ----- save comment ----------------------------------------------------------
if ($_GET['pn_go'] == 'savecomment')
{
if (($_POST['name']=='') OR ($_POST['comment']==''))
{
echo '