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 '


Bitte fülle alle Felder aus! Du wirst in 3 Sekunden weitergeleitet.
Wenn Du nicht länger warten willst, klicke hier.
'; echo ''; } else { $cf = PATH.'inc/pn_comments.dat'; //$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); // add leading 0´s if ($zeilen) { $eintrag = explode("§",$zeile[$zeilen-1]); $id = sprintf("%15d", ++$eintrag[0]); } else $id='0000001'; $_POST['name'] = cleantext($_POST['name'], 1); $_POST['email'] = cleantext($_POST['email'], 1); $_POST['comment'] = cleantext($_POST['comment']); $datum = time(); $nl = chr(13).chr(10); $fp = fopen($cf,"a"); flock($fp,2); fwrite($fp, my_nl2br(implode(array ($id, $_POST['commentid'], $_POST['comment'], $_POST['name'], $_POST['email'], $datum) ,"§")) . $nl); flock($fp,3); fclose($fp); echo '


Dein Kommentar wurde erfolgreich eingetragen. Du wirst in 3 Sekunden weitergeleitet.
Wenn Du nicht länger warten willst, klicke hier.
'; echo ''; } } // ----- navigation links ------------------------------------------------------ if(!$_GET['pn_go'] OR $_GET['pn_go']=='') { $nxt = '
'.a(); $last=''; $top=''; $backlink = ''; if ($zeilen > $newsperpage) { $nextid = $_GET['page'] - 1; $lastid = $_GET['page'] + 1; if ($nextid != 0) $last = ''.$lasttext.''; else $last = $lasttext; $top = 'nach oben'; if ($lastid <= $seiten) $next = ''.$nexttext.''; else $next = $nexttext; $next = $next.$nxt; } else $next = $nxt; $tpl->set_var(array('last' => $last, 'top' => $top, 'backlink'=> $backlink, 'next' => $next)); } else { $next = a(); $last=''; $top=''; if(isset($_GET['page'])) $_GET['page']==''; if($_GET['pn_go'] != 'savecomment') $backlink = '
Zurück
'; $tpl->set_var(array('last' => $last, 'top' => $top, 'backlink'=> $backlink, 'next' => $next)); } // ----- the rest -------------------------------------------------------------- $tpl->set_var(array('admin' => PATH.'admin/')); // parse and output site $tpl->parse("out", "seite"); $tpl->p("out"); ?>