config.inc.php is now a REAL file of the package
[banana.git] / post.php
index 1ef262b..b15ab66 100644 (file)
--- a/post.php
+++ b/post.php
@@ -7,84 +7,82 @@
 * Copyright: See COPYING files that comes with this distribution
 ********************************************************************************/
 
-require("include/session.inc.php");
-require("include/encoding.inc.php");
-require("include/format.inc.php");
-require("include/config.inc.php");
-require("include/NetNNTP.inc.php");
-require("include/post.inc.php");
-require("include/spool.inc.php");
-require("include/password.inc.php");
-require("include/profile.inc.php");
-require("include/wrapper.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/post.inc.php");
+require_once("include/spool.inc.php");
+require_once("include/password.inc.php");
+require_once("include/profile.inc.php");
+require_once("include/error.inc.php");
 
 $profile = getprofile();
-require($profile['locale']);
-
-require("include/header.inc.php");
+require_once("include/header.inc.php");
 if (isset($_REQUEST['group'])) {
-  $group=htmlentities(strtolower($_REQUEST['group']));
+    $group=htmlentities(strtolower($_REQUEST['group']));
 }
 if (isset($_REQUEST['id'])) {
-  $id=htmlentities(strtolower($_REQUEST['id']));
+    $id=htmlentities(strtolower($_REQUEST['id']));
 }
 
 if (isset($group)) {
-  $target = $group;
+    $target = $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;
-}
+$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\t".$locale['error']['credentials']
-      ."\n</p>";
-    require("include/footer.inc.php");
-    exit;
-  }
+    $result = $nntp->authinfo($news["user"],$news["pass"]);
+    if (!$result) error("nntpauth");
 }
 
 if (isset($group) && isset($id) && isset($_REQUEST['type']) && 
-  ($_REQUEST['type']=='followup')) {
-  $rq=$mynntp->group($group);
-  $post = new post($mynntp,$id);
-  if ($post) {
-    $subject = (preg_match("/^re:/i",$post->headers->subject)?"":"Re: ")
-      .$post->headers->subject;
-    $body = $post->headers->name." wrote :\n".wrap($post->body, ">");
-    if (isset($post->headers->followup))
-      $target=$post->headers->followup;
-    else
-      $target=$post->headers->newsgroups;
-  }
+        ($_REQUEST['type']=='followup')) {
+    $rq=$nntp->group($group);
+    $post = new BananaPost($nntp,$id);
+    if ($post) {
+        $subject = (preg_match("/^re:/i",$post->headers['subject'])?"":"Re: ").$post->headers['subject'];
+        if ($profile['dropsig']) {
+            $cutoff=strpos($post->body,"\n-- \n");
+            if ($cutoff) {
+                $quotetext = substr($post->body,0,strpos($post->body,"\n-- \n"));
+            } else {
+                $quotetext = $post->body;
+            }
+        } else {
+            $quotetext = $post->body;
+        }
+        $body = $post->name." wrote :\n".wrap($quotetext, "> ");
+        if (isset($post->headers['followup-to']))
+            $target = $post->headers['followup-to'];
+        else
+            $target = $post->headers['newsgroups'];
+    }
 }
 
-$mynntp->quit();
+$nntp->quit();
 ?>
-<div class="<?php echo $css['title']?>">
-  <?php echo $locale['post']['title'];?>
-</div>
+<h1>
+  <?php echo _b_('Nouveau message'); ?>
+</h1>
 <?php
 
 displayshortcuts();
 
 ?>
 
-<form action="thread.php" method="POST">
+<form action="thread.php" method="post">
 <table class="<?php echo $css['bicol']?>" cellpadding="0" cellspacing="0" border="0">
   <tr>
     <th colspan="2">
-      <?php echo $locale['post']['headers'];?>
+      <?php echo _b_('En-têtes'); ?>
     </th>
   </tr>
   <tr>
     <td class="<?php echo $css['bicoltitre'];?>">
-      <?php echo $locale['post']['name'];?>
+      <?php echo _b_('Nom'); ?>
     </td>
     <td>
       <?php echo htmlentities($profile['name']); ?>
@@ -92,7 +90,7 @@ displayshortcuts();
   </tr>
   <tr>
     <td class="<?php echo $css['bicoltitre'];?>">
-      <?php echo $locale['post']['subject'];?>
+      <?php echo _b_('Sujet'); ?>
     </td>
     <td>
       <input type="text" name="subject" value="<?php echo 
@@ -101,7 +99,7 @@ displayshortcuts();
   </tr>
   <tr>
     <td class="<?php echo $css['bicoltitre'];?>">
-      <?php echo $locale['post']['newsgroups'];?>
+      <?php echo _b_('Forums'); ?>
     </td>
     <td>
       <input type="text" name="newsgroups" value="<?php echo
@@ -110,7 +108,7 @@ displayshortcuts();
   </tr>
   <tr>
     <td class="<?php echo $css['bicoltitre'];?>">
-      <?php echo $locale['post']['fu2'];?>
+      <?php echo _b_('Suivi-à'); ?>
     </td>
     <td>
       <input type="text" name="followup" value="" />
@@ -118,7 +116,7 @@ displayshortcuts();
   </tr>
   <tr>
     <td class="<?php echo $css['bicoltitre'];?>">
-      <?php echo $locale['post']['organization'];?>
+      <?php echo _b_('Organisation'); ?>
     </td>
     <td>
       <?php echo $profile['org']; ?>
@@ -126,14 +124,14 @@ displayshortcuts();
   </tr>
   <tr>
     <th colspan="2">
-      <?php echo $locale['post']['body'];?>
+      <?php echo _b_('Corps'); ?>
     </th>
   </tr>
   <tr>
     <td class="<?php echo $css['bicolvpadd'];?>" colspan="2">
-      <textarea name="body" cols="90" rows="10"><?php echo 
-      (isset($body)?$body:"").($profile['sig']!=''?"\n\n-- \n"
-      .$profile['sig']:"");?></textarea>
+      <textarea name="body" cols="90" rows="16"><?php echo 
+      (isset($body)?htmlentities($body):"").
+      ($profile['sig']!=''?"\n\n-- \n".htmlentities($profile['sig']):"");?></textarea>
     </td>
   </tr>
   <tr>
@@ -154,9 +152,10 @@ if (isset($group) && isset($id) && isset($_REQUEST['type'])
 ?>
       <input type="submit" name="action" value="OK" />
     </td>
+  </tr>
 </table>
 </form>
 <?php
 displayshortcuts();
-require("include/footer.inc.php");
+require_once("include/footer.inc.php");
 ?>