post is now in the lib too. have to work on the actions now.
authorx2000habouzit <x2000habouzit>
Wed, 5 Jan 2005 08:19:16 +0000 (08:19 +0000)
committerx2000habouzit <x2000habouzit>
Wed, 5 Jan 2005 08:19:16 +0000 (08:19 +0000)
include/banana.inc.php.in
include/misc.inc.php
include/post.inc.php
post.php

index 413ddbe..3758c20 100644 (file)
@@ -30,7 +30,7 @@ class Banana
 
     var $host      = 'news://localhost:119/';
 
-    var $profile   = Array( 'name' => 'Anonymous <anonymouse@example.com', 'sig'  => '', 'org'  => '',
+    var $profile   = Array( 'name' => 'Anonymous <anonymouse@example.com>', 'sig'  => '', 'org'  => '',
             'customhdr' =>'', 'display' => 0, 'lastnews' => 0, 'locale'  => 'fr_FR', 'subscribe' => array());
     
     var $nntp;
@@ -121,6 +121,46 @@ class Banana
         return $res.$cuts;
     }
 
+    function action_newFup($group, $id = -1)
+    {
+        $subject = $body = '';
+        $target  = $group;
+        
+        if ($id > 0) {
+            $this->nntp->group($group);
+            $this->newPost($id);
+            if ($this->post) {
+                $subject = preg_replace("/^re\s*:\s*/i", 'Re: ', $this->post->headers['subject']);
+                $body    = $this->post->name." "._b_("a écrit")." :\n".wrap($this->post->body, "> ");
+                $target  = isset($this->post->headers['followup-to']) ? $this->post->headers['followup-to'] : $this->post->headers['newsgroups'];
+            }
+        }
+
+        $this->nntp->quit();
+
+        $cuts  = displayshortcuts();
+        $html  = '<h1>'._b_('Nouveau message').'</h1>'.$cuts;
+        $html .= '<form action="?" method="post">';
+        $html .= '<table class="bicol" cellpadding="0" cellspacing="0">';
+        $html .= '<tr><th colspan="2">'._b_('En-têtes').'</th></tr>';
+        $html .= '<tr><td>'._b_('Nom').'</td><td>'.htmlentities($this->profile['name']).'</td></tr>';
+        $html .= '<tr><td>'._b_('Sujet').'</td><td><input type="text" name="subject" value="'.htmlentities($subject).'" size="60" /></td></tr>';
+        $html .= '<tr><td>'._b_('Forums').'</td><td><input type="text" name="newsgroups" value="'.htmlentities($target).'" size="60" /></td></tr>';
+        $html .= '<tr><td>'._b_('Suivi à').'</td><td><input type="text" name="newsgroups" value="" size="60" /></td></tr>';
+        $html .= '<tr><td>'._b_('Organisation').'</td><td>'.$this->profile['org'].'</td></tr>';
+        $html .= '<tr><th colspan="2">'._b_('Corps').'</th></tr>';
+        $html .= '<tr><td colspan="2"><textarea name="body" cols="74" rows="16">'
+            .htmlentities($body).($this->profile['sig'] ? "\n\n-- \n".htmlentities($this->profile['sig']) : '').'</textarea></td></th>';
+        $html .= '<tr><td colspan="2"><input type="hidden" name="group" value="'.$group.'" />';
+        if ($id > 0) {
+            $html .= '<input type="hidden" name="id" value="'.$id.'" />';
+        }
+        $html .= '<input type="submit" /></td></tr>';
+        $html .= '</table></form>';
+
+        return $html.$cuts;
+    }
+
     /**************************************************************************/
     /*                                                                        */
     /**************************************************************************/
index a478bdb..1d85354 100644 (file)
@@ -120,7 +120,7 @@ function fancyDate($stamp) {
     } elseif ($today == 1 + $dday) {
         $format = _b_('hier')." %H:%M";
     } elseif ($today < 7 + $dday) {
-        $format = '%A %H:%M';
+        $format = '%a %H:%M';
     } else {
         $format = '%a %e %b';
     }
index b855a3b..b892b1e 100644 (file)
@@ -39,7 +39,7 @@ class BananaPost
             }
         }
 
-        if (preg_match('!charset=([^;]*);!', $this->headers['content-type'], $matches)) {
+        if (preg_match('!charset=([^;]*)\s*(;|$)!', $this->headers['content-type'], $matches)) {
             $this->body = iconv($matches[1], 'iso-8859-1', $this->body);
         }
     }
index d76909b..ab792cb 100644 (file)
--- a/post.php
+++ b/post.php
@@ -13,118 +13,10 @@ require_once("include/header.inc.php");
 if (isset($_REQUEST['group'])) {
     $group = htmlentities(strtolower($_REQUEST['group']));
 }
-if (isset($_REQUEST['id'])) {
-    $id = htmlentities(strtolower($_REQUEST['id']));
-}
-
-if (isset($group)) {
-    $target = $group;
-}
-
-if (isset($group) && isset($id) && isset($_REQUEST['type']) && ($_REQUEST['type']=='followup')) {
-    $banana->nntp->group($group);
-    $banana->newPost($id);
-    $body = '';
-    if ($banana->post) {
-        $subject = (preg_match("/^re\s*:\s*/i", $banana->post->headers['subject']) ? '' : 'Re: ').$banana->post->headers['subject'];
-        $body    = $banana->post->name." wrote :\n".wrap($banana->post->body, "> ");
-        $target  = isset($banana->post->headers['followup-to']) ? $banana->post->headers['followup-to'] : $banana->post->headers['newsgroups'];
-    }
-}
 
-$banana->nntp->quit();
-?>
-<h1>
-  <?php echo _b_('Nouveau message'); ?>
-</h1>
-<?php
+$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : -1;
 
-echo displayshortcuts();
+echo $banana->action_newFup($group, $id);
 
-?>
-
-<form action="thread.php" method="post">
-  <table class="bicol" cellpadding="0" cellspacing="0" border="0">
-    <tr>
-      <th colspan="2">
-        <?php echo _b_('En-têtes'); ?>
-      </th>
-    </tr>
-    <tr>
-      <td class="<?php echo $css['bicoltitre'];?>">
-        <?php echo _b_('Nom'); ?>
-      </td>
-      <td>
-        <?php echo htmlentities($banana->profile['name']); ?>
-      </td>
-    </tr>
-    <tr>
-      <td class="<?php echo $css['bicoltitre'];?>">
-        <?php echo _b_('Sujet'); ?>
-      </td>
-      <td>
-        <input type="text" name="subject" value="<?php if (isset($subject)) echo $subject; ?>" />
-      </td>
-    </tr>
-    <tr>
-      <td class="<?php echo $css['bicoltitre'];?>">
-        <?php echo _b_('Forums'); ?>
-      </td>
-      <td>
-        <input type="text" name="newsgroups" value="<?php if (isset($target)) echo $target; ?>" />
-      </td>
-    </tr>
-    <tr>
-      <td class="<?php echo $css['bicoltitre'];?>">
-        <?php echo _b_('Suivi-à'); ?>
-      </td>
-      <td>
-        <input type="text" name="followup" value="" />
-      </td>
-    </tr>
-    <tr>
-      <td class="<?php echo $css['bicoltitre'];?>">
-        <?php echo _b_('Organisation'); ?>
-      </td>
-      <td>
-        <?php echo $banana->profile['org']; ?>
-      </td>
-    </tr>
-    <tr>
-      <th colspan="2">
-        <?php echo _b_('Corps'); ?>
-      </th>
-    </tr>
-    <tr>
-      <td class="<?php echo $css['bicolvpadd'];?>" colspan="2">
-        <textarea name="body" cols="90" rows="16"><?php
-        echo htmlentities($body);
-        if ($banana->profile['sig']) echo "\n\n-- \n".htmlentities($banana->profile['sig']);
-        ?></textarea>
-      </td>
-    </tr>
-    <tr>
-      <td class="<?php echo $css['bouton']?>" colspan="2">
-  <?php
-  if (isset($group) && isset($id) && isset($_REQUEST['type']) 
-    && ($_REQUEST['type']=='followup')) {
-  ?>
-        <input type="hidden" name="type" value="followupok" />
-        <input type="hidden" name="group" value="<?php echo $group;?>" />
-        <input type="hidden" name="id" value="<?php echo $id;?>" />
-  <?php
-  } else {
-  ?>
-        <input type="hidden" name="type" value="new" />
-  <?php
-  }
-  ?>
-        <input type="submit" name="action" value="OK" />
-      </td>
-    </tr>
-  </table>
-</form>
-<?php
-echo displayshortcuts();
 require_once("include/footer.inc.php");
 ?>