whole bunch of changes :
[banana.git] / article.php
index 25ffb27..58d9a60 100644 (file)
@@ -7,86 +7,75 @@
 * Copyright: See COPYING files that comes with this distribution
 ********************************************************************************/
 
-require("include/session.inc.php");
-require("include/encoding.inc.php");
-require("include/wrapper.inc.php");
-require("include/format.inc.php");
-require("include/config.inc.php");
-require("include/NetNNTP.inc.php");
-require("include/spool.inc.php");
-require("include/post.inc.php");
-require("include/profile.inc.php");
-require("include/password.inc.php");
+require_once("include/session.inc.php");
+require_once("include/misc.inc.php");
+require_once("include/format.inc.php");
+require_once("include/config.inc.php");
+require_once("include/NetNNTP.inc.php");
+require_once("include/spool.inc.php");
+require_once("include/post.inc.php");
+require_once("include/profile.inc.php");
+require_once("include/password.inc.php");
+require_once("include/error.inc.php");
 
 $profile=getprofile();
-require($profile['locale']);
+require_once($profile['locale']);
 
-require("include/header.inc.php");
+require_once("include/header.inc.php");
 
-$group=strtolower(htmlentities($_REQUEST['group']));
-
-$mynntp = new nntp($news['server']);
-if (!$mynntp) {
-  echo "<p class=\"error\">\n\t".$locale['error']['connect']."\n</p>";
-  require("include/footer.inc.php");
-  exit;
+if (isset($_REQUEST['group'])) {
+  $group=htmlentities(strtolower($_REQUEST['group']));
+}
+if (isset($_REQUEST['id'])) {
+  $id=htmlentities(strtolower($_REQUEST['id']));
 }
 
+$nntp = new nntp($news['server']);
+if (!$nntp) error("nntpsock");
 if ($news['user']!="anonymous") {
-  $result = $mynntp->authinfo($news["user"],$news["pass"]);
-  if (!$result) {
-    echo "<p class=\"error\">\n\tYou have provided bad credentials to "
-    ."the server. Good bye !\n</p>";
-    require("include/footer.inc.php");
-    exit;
-  }
-}
-$spool = new spool($mynntp,$group,$profile['display'],$profile['lastnews']);
-if (!$spool) {
-  echo "<p class=\"error\">\n\tError while accessing group.\n</p>";
-  require("include/footer.inc.php");
-  exit;
+  $result = $nntp->authinfo($news["user"],$news["pass"]);
+  if (!$result) error("nntpauth");
 }
-$mynntp->group($group);
+$spool = new spool($nntp,$group,$profile['display'],$profile['lastnews']);
+if (!$spool) error("nntpspool");
+$nntp->group($group);
 
-$post = new post($mynntp,$_REQUEST['id']);
+$post = new NNTPPost($nntp,$id);
 if (!$post) {
-  if ($mynntp->lasterrorcode == "423") {
-    $spool->delid($_REQUEST['id']);
+  if ($nntp->lasterrorcode == "423") {
+    $spool->delid($id);
   }
-  echo "<p class=\"error\">\n\tError while reading message.\n</p>";
-  require("include/footer.inc.php");
-  exit;
+  error("nntpart");
 }
 
-$ndx = $spool->getndx($_REQUEST['id']);
+$ndx = $spool->getndx($id);
 
 ?>
-<div class="title">
+<h1>
   <?php echo $locale['article']['message'];?>
-</div>
+</h1>
 
 <?php
 if (isset($_GET['type']) && ($_GET['type']=='cancel') && (checkcancel($post->headers))) {
 ?>
-<p class="error">
+<p class="<?php echo $css['error']?>">
   <?php echo $locale['article']['cancel'];?>
-  <form action="thread.php" method="post">
-    <input type="hidden" name="group" value="<?php echo $group;?>" />
-    <input type="hidden" name="id" value="<?php 
-      echo $_REQUEST['id'];?>" />
-    <input type="hidden" name="type" value="cancel" />
-    <input type="submit" name="action" value="<?php echo 
-      $locale['article']['okbtn'];?>" />
-  </form>
 </p>
+<form action="thread.php" method="post">
+  <input type="hidden" name="group" value="<?php echo $group;?>" />
+  <input type="hidden" name="id" value="<?php 
+    echo $id;?>" />
+  <input type="hidden" name="type" value="cancel" />
+  <input type="submit" name="action" value="<?php echo 
+    $locale['article']['okbtn'];?>" />
+</form>
 <?
 }
 
 displayshortcuts();
 ?>
 
-<table class="bicol" cellpadding="0" cellspacing="0" 
+<table class="<?php echo $css['bicol']?>" cellpadding="0" cellspacing="0" 
 summary="<?php echo $locale['article']['summary'];?>">
   <tr>
     <th colspan="2">
@@ -94,9 +83,9 @@ summary="<?php echo $locale['article']['summary'];?>">
     </th>
   </tr>
 <?php
-foreach ($news['head'] as $real => $nick) {
+foreach ($news['headdisp'] as $nick) {
   if (isset($post->headers->$nick)) 
-    echo "<tr><td class=\"bicoltitre\">$real</td>"
+    echo "<tr><td class=\"{$css['bicoltitre']}\">{$locale['headers'][$nick]}</td>"
     ."<td>".formatdisplayheader($nick,$post->headers->$nick,$spool)
     ."</td></tr>\n";
 }
@@ -117,8 +106,9 @@ foreach ($news['head'] as $real => $nick) {
     </th>
   </tr> 
   <tr>
-    <td class="nopadd" colspan="2">
-      <table class="overview" cellpadding="0" cellspacing="0" summary="overview">
+    <td class="<?php echo $css['nopadd']?>" colspan="2">
+      <table class="<?php echo $css['overview']?>" cellpadding="0" 
+      cellspacing="0" summary="overview">
 <?php
 $spool->disp($ndx-$news['threadtop'],$ndx+$news['threadbottom'],$ndx);
 ?>
@@ -129,5 +119,5 @@ $spool->disp($ndx-$news['threadtop'],$ndx+$news['threadbottom'],$ndx);
 <?php
 displayshortcuts();
 
-require("include/footer.inc.php");
+require_once("include/footer.inc.php");
 ?>