Many fixes and optimisations:
authorx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Wed, 21 Feb 2007 17:34:53 +0000 (17:34 +0000)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Fri, 4 Jan 2008 23:35:28 +0000 (00:35 +0100)
-> update gettext translations and Makefile
-> mbox read uses a new helper written in C (need more tests)
-> CSS parser issues
-> encoding issues
...

git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@203 9869982d-c50d-0410-be91-f2a2ec7c7c7b

12 files changed:
Makefile
banana/banana.inc.php.in
banana/mbox.inc.php
banana/message.func.inc.php
banana/message.inc.php
banana/mimepart.inc.php
mbox-helper/Makefile [new file with mode: 0644]
mbox-helper/mbox-helper.c [new file with mode: 0644]
po/Makefile
po/banana.pot
po/en.po
po/fr.po

index 9ef09b0..ea0234a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -18,16 +18,17 @@ dist: clean pkg-dist
 clean:
        rm -rf locale banana/banana.inc.php
        make -C po clean
 clean:
        rm -rf locale banana/banana.inc.php
        make -C po clean
+       make -C mbox-helper clean
 
 %: %.in Makefile
        sed -e 's,@VERSION@,$(VERSION) The Bearded Release,g' $< > $@
 
 
 %: %.in Makefile
        sed -e 's,@VERSION@,$(VERSION) The Bearded Release,g' $< > $@
 
-
 # banana package targets
 
 pkg-build: banana/banana.inc.php
        make -C po
        make -C po clean
 # banana package targets
 
 pkg-build: banana/banana.inc.php
        make -C po
        make -C po clean
+       make -C mbox-helper
 
 pkg-dist: pkg-build
        rm -rf $(PKG_DIST) $(PKG_DIST).tar.gz
 
 pkg-dist: pkg-build
        rm -rf $(PKG_DIST) $(PKG_DIST).tar.gz
index 8e9d3a7..e69de29 100644 (file)
@@ -1,583 +0,0 @@
-<?php
-/********************************************************************************
-* banana/banana.inc.php : banana main file
-* --------------------------
-*
-* This file is part of the banana distribution
-* Copyright: See COPYING files that comes with this distribution
-********************************************************************************/
-
-require_once dirname(__FILE__) . '/text.func.inc.php';
-
-class Banana
-{
-
-#######
-# Configuration variables
-#######
-
-### General ###
-    static public $profile = Array( 'signature'  => '',
-                                    'headers' => array('From' => 'Anonymous <anonymouse@example.com>'),
-                                    'display' => 0,
-                                    'lastnews' => 0,
-                                    'locale'  => 'fr_FR.UTF-8',
-                                    'subscribe' => array(),
-                                    'autoup' => 1);
-    static public $boxpattern;
-    static public $withtabs = true;
-    static public $mimeparts = array();
-
-### Spool ###
-    static public $spool_root    = '/var/spool/banana';
-    static public $spool_max     = 3000;
-    static public $spool_tbefore = 5;
-    static public $spool_tafter  = 5;
-    static public $spool_tmax    = 50;
-    static public $spool_boxlist = true;
-
-### Message processing ###
-    static public $msgparse_headers = array('content-disposition', 'content-transfer-encoding',
-                                       'content-type', 'content-id', 'date', 'followup-to',
-                                       'from', 'message-id', 'newsgroups', 'organization',
-                                       'references', 'subject', 'x-face', 'in-reply-to',
-                                       'to', 'cc', 'reply-to');
-
-### Message display ###
-    static public $msgshow_headers   = array('from', 'newsgroups', 'followup-to', 'to', 'cc', 'reply-to',
-                                       'organization', 'date', 'references', 'in-reply-to');
-    static public $msgshow_mimeparts = array('multipart/report', 'multipart/mixed', 
-                                             'text/html', 'text/plain', 'text/enriched', 'text', 'message');
-    static public $msgshow_xface     = true;
-    static public $msgshow_wrap      = 78;
-    static public $msgshow_externalimages = false;
-    static public $msgshow_hasextimages   = false;
-    static public $msgshow_withthread = true;
-
-    /** Match an url
-     * Should be included in a regexp delimited using /, !, , or @ (eg: "/$url_regexp/ui")
-     * If it matches, return 3 main parts :
-     *  \\1 and \\3 are delimiters
-     *  \\2 is the url
-     *
-     * eg : preg_match("!$url_regexp!i", "[http://www.polytechnique.org]", $matches);
-     *   $matches[1] = "["
-     *   $matches[2] = "http://www.polytechnique.org"
-     *   $matches[3] = "]"
-     */
-    static public $msgshow_url     = '(["\[])?((?:[a-z]+:\/\/|www\.)(?:[\.\,\;\!\:]*[a-z\@0-9~%$&i#\-+=_\/\?]+)+)(["\]])?';
-
-### Message edition ###
-    static public $msgedit_canattach  = true;
-    static public $msgedit_maxfilesize = 100000;
-    /** Global headers to use for messages
-     */
-    static public $msgedit_headers  = array('Mime-Version' => '1.0', 'User-Agent' => 'Banana @VERSION@');
-    /** Mime type order for quoting
-     */
-    static public $msgedit_mimeparts = array('multipart/report', 'multipart/mixed', 'text/plain', 'text/enriched', 'text/html', 'text', 'message');
-
-### Protocole ###
-    /** News serveur to use
-     */
-    static public $nntp_host   = 'news://localhost:119/';
-
-    static public $mbox_path   = '/var/mail';
-
-### Debug ###
-    static public $debug_nntp   = false;
-    static public $debug_smarty = false;
-
-
-#######
-# Constants
-#######    
-
-    // Actions
-    const ACTION_BOX_NEEDED = 1; // mask
-    const ACTION_BOX_LIST   = 2;
-    const ACTION_BOX_SUBS   = 4;
-    const ACTION_MSG_LIST   = 3;
-    const ACTION_MSG_READ   = 5;
-    const ACTION_MSG_NEW    = 9;
-    const ACTION_MSG_CANCEL = 17;
-    const ACTION_MSG_IMAGES = 33;
-
-    // Box list view
-    const BOXES_ALL = 0;
-    const BOXES_SUB = 1;
-    const BOXES_NEW = 2;
-
-    // Spool view mode
-    const SPOOL_ALL    = 0;
-    const SPOOL_UNREAD = 1;
-
-
-#######
-# Runtime variables
-#######
-
-    static public $protocole   = null;
-    static public $spool       = null;
-    static public $message     = null;
-    static public $page        = null;
-
-    static public $group       = null;
-    static public $artid       = null;
-    static public $action      = null;
-    static public $part        = null;
-    static public $first       = null;
-
-    /** Class parameters storage
-     */
-    public $params;
-
-
-#######
-# Banana Implementation
-#######
-
-    /** Build the instance of Banana
-     * This constructor only call \ref loadParams, connect to the server, and build the Smarty page
-     * @param protocole Protocole to use
-     */
-    public function __construct($params = null, $protocole = 'NNTP', $pageclass = 'BananaPage')
-    {
-        if (is_null($params)) {
-            $this->params = $_GET;
-        } else {
-            $this->params = $params;
-        }
-        $this->loadParams();
-
-        // connect to protocole handler
-        $classname = 'Banana' . $protocole;
-        if (!class_exists($classname)) {
-            Banana::load($protocole);
-        }    
-        Banana::$protocole = new $classname(Banana::$group);
-
-        // build the page
-        if ($pageclass == 'BananaPage') {
-            Banana::load('page');
-        }
-        Banana::$page = new $pageclass;
-        $types = array('multipart/report' => _b_('Rapport d\'erreur'),
-                       'multipart/mixed'  => _b_('Composition'),
-                       'text/html'        => _b_('Texte formaté'),
-                       'text/plain'       => _b_('Texte brut'),
-                       'text/enriched'    => _b_('Texte enrichi'),
-                       'text'             => _b_('Texte'),
-                       'message/rfc822'   => _b_('Mail'),
-                       'message'          => _b_('Message'),
-                       'source'           => _b_('Source'));
-        Banana::$mimeparts = array_merge($types, Banana::$mimeparts);
-    }
-
-    /** Fill state vars (Banana::$group, Banana::$artid, Banana::$action, Banana;:$part, Banana::$first)
-     */
-    protected function loadParams()
-    {
-        Banana::$group = isset($this->params['group']) ? $this->params['group'] : null;
-        Banana::$artid = isset($this->params['artid']) ? $this->params['artid'] : null;
-        Banana::$first = isset($this->params['first']) ? $this->params['first'] : null;
-        Banana::$part  = isset($this->params['part']) ? $this->params['part'] : 'text';
-
-        // Look for the action to execute
-        if (is_null(Banana::$group)) {
-            if (isset($this->params['action']) && $this->params['action'] == 'subscribe') {
-                Banana::$action = Banana::ACTION_BOX_SUBS;
-            } else {
-                Banana::$action = Banana::ACTION_BOX_LIST;
-            }
-            return;
-        }
-        $action = isset($this->params['action']) ? $this->params['action'] : null; 
-        if (is_null(Banana::$artid)) {
-            if ($action == 'new') {
-                Banana::$action = Banana::ACTION_MSG_NEW;
-            } else {
-                Banana::$action = Banana::ACTION_MSG_LIST;
-            }
-            return;
-        }
-        switch ($action) {
-          case 'new':
-            Banana::$action = Banana::ACTION_MSG_NEW;
-            return;
-          case 'cancel':
-            Banana::$action = Banana::ACTION_MSG_CANCEL;
-            return;
-          case 'showext':
-            Banana::$action = Banana::ACTION_MSG_IMAGES;
-            return;
-          default:
-            Banana::$action = Banana::ACTION_MSG_READ;
-        }
-    }
-
-    /** Run Banana
-     * This function need user profile to be initialised
-     */
-    public function run()
-    {
-        // Configure locales
-        setlocale(LC_ALL,  Banana::$profile['locale']);
-        
-        // Check if the state is valid
-        if (Banana::$protocole->lastErrNo()) {
-            return Banana::$page->kill(_b_('Une erreur a été rencontrée lors de la connexion au serveur') . '<br />'
-                                      . Banana::$protocole->lastError());
-        }
-        if (!Banana::$protocole->isValid()) {
-            return Banana::$page->kill(_b_('Connexion non-valide'));
-        }
-        if (Banana::$action & Banana::ACTION_BOX_NEEDED) {
-            if(Banana::$boxpattern && !preg_match('/' . Banana::$boxpattern . '/i', $group)) {
-                Banana::$page->setPage('group');        
-                return Banana::$page->kill(_b_("Ce newsgroup n'existe pas ou vous n'avez pas l'autorisation d'y accéder"));
-            }
-        }
-
-        // Dispatch to the action handlers
-        switch (Banana::$action) {
-          case Banana::ACTION_BOX_SUBS:
-            $error = $this->action_subscribe();
-            break;
-          case Banana::ACTION_BOX_LIST:
-            $error = $this->action_listBoxes();
-            break;
-          case Banana::ACTION_MSG_LIST:
-            $error = $this->action_showThread(Banana::$group, Banana::$first);
-            break;
-          case Banana::ACTION_MSG_IMAGES:
-            Banana::$msgshow_externalimages = true;
-          case Banana::ACTION_MSG_READ:
-            $error = $this->action_showMessage(Banana::$group, Banana::$artid, Banana::$part);
-            break;
-          case Banana::ACTION_MSG_NEW:
-            $error = $this->action_newMessage(Banana::$group, Banana::$artid);
-            break;
-          case Banana::ACTION_MSG_CANCEL:
-            $error = $this->action_cancelMessage(Banana::$group, Banana::$artid);
-            break;
-          default:
-            $error = _b_("L'action demandée n'est pas supportée par Banana");
-        }
-
-        // Generate the page
-        if (is_string($error)) {
-            return Banana::$page->kill($error);
-        }
-        return Banana::$page->run();
-    }
-
-    /** Return the CSS code to include in the headers
-     */
-    public function css()
-    {
-        return Banana::$page->css;
-    }
-
-    /**************************************************************************/
-    /* actions                                                                */
-    /**************************************************************************/
-    protected function action_saveSubs($groups)
-    {
-        Banana::$profile['subscribe'] = $groups;
-        return true;
-    }
-
-    protected function action_subscribe()
-    {
-        Banana::$page->setPage('subscribe');
-        if (isset($_POST['validsubs'])) {
-            $this->action_saveSubs(array_keys($_POST['subscribe']));
-            Banana::$page->redirect();
-        }
-        $groups = Banana::$protocole->getBoxList(Banana::BOXES_ALL);
-        Banana::$page->assign('groups', $groups);
-        return true;
-    }
-
-    protected function action_listBoxes()
-    {
-        Banana::$page->setPage('forums');
-        $groups    = Banana::$protocole->getBoxList(Banana::BOXES_SUB, Banana::$profile['lastnews'], true);
-        Banana::$page->assign('groups', $groups);
-        if (empty(Banana::$profile['subscribe']) || Banana::$profile['lastnews']) {
-            $newgroups = Banana::$protocole->getBoxList(Banana::BOXES_NEW, Banana::$profile['lastnews'], true);
-            Banana::$page->assign('newgroups', $newgroups);
-        }
-        return true;
-    }
-
-    protected function action_showThread($group, $first)
-    {
-        Banana::$page->setPage('thread');
-        if (!$this->loadSpool($group)) {
-            return _b_('Impossible charger la liste des messages de ') . $group;
-        }
-        if (Banana::$spool_boxlist) {
-            $groups = Banana::$protocole->getBoxList(Banana::BOXES_SUB, Banana::$profile['lastnews'], true);
-            Banana::$page->assign('groups', $groups);
-        }
-        Banana::$page->assign('msgbypage', Banana::$spool_tmax);
-        return true;
-    }
-
-    protected function action_showMessage($group, $artid, $partid = 'text')
-    {
-        Banana::$page->setPage('message');
-        $istext = $partid == 'text' || $partid == 'source'
-                || preg_match('!^[-a-z0-9_]+/[-a-z0-9_]+$!', $partid);
-        if ($istext) {
-            $this->loadSpool($group);
-        }
-        $msg =& $this->loadMessage($group, $artid);
-        if (is_null($msg)) {
-            $this->loadSpool($group);
-            $this->removeMessage($group, $artid);
-            return _b_('Le message demandé n\'existe pas. Il est possible qu\'il ait été annulé');
-        }
-        if ($partid == 'xface') {
-            $msg->getXFace();
-            exit;
-        } elseif (!$istext) {
-            $part = $msg->getPartById($partid);
-            if (!is_null($part)) {
-                $part->send(true);
-            }
-            $part = $msg->getFile($partid);
-            if (!is_null($part)) {
-                $part->send();
-            }
-            exit;
-        } elseif ($partid == 'text') {
-            $partid = null;
-            Banana::$page->assign('body', $msg->getFormattedBody($partid));
-        } elseif ($partid == 'source') {
-            $text = Banana::$protocole->getMessageSource($artid);
-            if (!is_utf8($text)) {
-                $text = utf8_encode($text);
-            }
-            Banana::$page->assign('body', '<pre>' . banana_htmlentities($text) . '</pre>');
-        } else {
-            Banana::$page->assign('body', $msg->getFormattedBody($partid));
-        }
-
-        if (Banana::$profile['autoup']) {
-            Banana::$spool->markAsRead($artid);
-        }
-        if (Banana::$spool_boxlist) {
-            $groups    = Banana::$protocole->getBoxList(Banana::BOXES_SUB, Banana::$profile['lastnews'], true);
-            Banana::$page->assign('groups', $groups);
-        }    
-        Banana::$page->assign_by_ref('message', $msg);
-        Banana::$page->assign('extimages', Banana::$msgshow_hasextimages);
-        Banana::$page->assign('headers', Banana::$msgshow_headers);
-        Banana::$page->assign('type', $partid);
-        return true;
-    }
-
-    protected function action_newMessage($group, $artid)
-    {
-        Banana::$page->setPage('new');
-        if (!Banana::$protocole->canSend()) {
-            return _b_('Vous n\'avez pas le droit de poster');
-        }
-        $hdrs    = Banana::$protocole->requestedHeaders();
-        $headers = array();
-        foreach ($hdrs as $header) {
-            $headers[$header] = array('name' => BananaMessage::translateHeaderName($header));
-            if (isset(Banana::$profile['headers'][$header])) {
-                $headers[$header]['fixed'] = Banana::$profile['headers'][$header];
-            }
-        }
-        if (isset($_POST['sendmessage'])) {
-            $hdr_values = array();
-            foreach ($hdrs as $header) {
-                $hdr_values[$header] = isset($headers[$header]['fixed']) ? $headers[$header]['fixed'] : @$_POST[$header];
-            }
-            if ($artid) {
-                $old =& $this->loadMessage($group, $artid);
-                $hdr_values['References'] = $old->getHeaderValue('references') . $old->getHeaderValue('message-id');
-            }
-            $msg = null;
-            if (empty($hdr_values['Subject'])) {
-                Banana::$page->trig(_b_('Le message doit avoir un sujet'));
-            } elseif (Banana::$msgedit_canattach && isset($_FILES['attachment'])) {
-                $uploaded = $_FILES['attachment'];
-                if (!is_uploaded_file($uploaded['tmp_name'])) {
-                    Banana::$page->trig(_b_('Une erreur est survenue lors du téléchargement du fichier'));
-                } else {
-                    $msg = BananaMessage::newMessage($hdr_values, $_POST['body'], $uploaded);
-                }
-            } else {
-                $msg = BananaMessage::newMessage($hdr_values, $_POST['body']);
-            }
-            if (!is_null($msg)) {
-                if (Banana::$protocole->send($msg)) {
-                    Banana::$page->redirect(array('group' => $group, 'artid' => $artid));
-                }
-                Banana::$page->trig(_b_('Une erreur est survenue lors de l\'envoi du message :') . '<br />'
-                                   . Banana::$protocole->lastError());
-            }
-        } else {
-            if (!is_null($artid)) {
-                $msg    =& $this->loadMessage($group, $artid);
-                $body    = $msg->getSender() . _b_(' a écrit :') . "\n" . $msg->quote();
-                $subject = $msg->getHeaderValue('subject');
-                $headers['Subject']['user'] = 'Re: ' . preg_replace("/^re\s*:\s*/i", '', $subject);
-                $target  = $msg->getHeaderValue($hdrs['reply']);
-                if (empty($target)) {
-                    $target = $group;
-                }
-                $headers[$hdrs['dest']]['user'] =& $target;
-            } else {
-                $body    = '';
-                $headers[$hdrs['dest']]['user'] = $group;
-            }
-            if (Banana::$profile['signature']) {
-                $body .=  "\n\n-- \n" . Banana::$profile['signature'];
-            }
-            Banana::$page->assign('body', $body);
-        }
-
-        Banana::$page->assign('maxfilesize', Banana::$msgedit_maxfilesize);
-        Banana::$page->assign('can_attach', Banana::$msgedit_canattach);
-        Banana::$page->assign('headers', $headers);
-        return true;
-    }
-
-    protected function action_cancelMessage($group, $artid)
-    {
-        Banana::$page->setPage('cancel');
-        $msg =& $this->loadMessage($group, $artid);
-        if (!$msg->canCancel()) {
-            return _b_('Vous n\'avez pas les droits suffisants pour supprimer ce message');
-        }
-        if (isset($_POST['cancel'])) {
-            $this->loadSpool($group);
-            $ndx = Banana::$spool->getNdX($id) - 1;
-            if (!Banana::$protocole->cancel($msg)) {
-                return _b_('Une erreur s\'est produite lors de l\'annulation du message :') . '<br />'
-                       . Banana::$protocole->lastError();
-            }
-            if ($ndx < 50) {
-                 $ndx = 0;
-            }
-            $this->removeMessage($group, $artid);
-            Banana::$page->redirect(Array('group' => $group, 'first' => $ndx));
-        }
-
-        Banana::$page->assign_by_ref('message', $msg);
-        Banana::$page->assign('body', $msg->getFormattedBody());
-        Banana::$page->assign('headers', Banana::$msgshow_headers);
-        return true;
-    }
-
-    /**************************************************************************/
-    /* Spoolgen functions                                                     */
-    /**************************************************************************/
-
-    private function checkErrors()
-    {
-        if (Banana::$protocole->lastErrno()) {
-            echo "\nL'erreur suivante s'est produite : "
-                . Banana::$protocole->lastErrno() . " "
-                . Banana::$protocole->lastError() . "\n";
-            return false;
-        }
-        return true;
-    } 
-
-    static public function createAllSpool(array $protos)
-    {
-        foreach ($protos as $proto) {
-            $banana = new Banana(array(), $proto);
-
-            if (!$banana->checkErrors()) {
-                continue;
-            }
-            $groups = Banana::$protocole->getBoxList();
-            if (!$banana->checkErrors()) {
-                continue;
-            }
-
-            print "** $proto **\n";
-            foreach (array_keys($groups) as $g) {
-                print "Generating spool for $g : ";
-                Banana::$group = $g;
-                $spool = $banana->loadSpool($g);
-                if (!$banana->checkErrors()) {
-                    break;
-                }
-                print "done.\n";
-                unset($spool);
-            }
-            print "\n";
-        }
-    }
-
-    /**************************************************************************/
-    /* Private functions                                                      */
-    /**************************************************************************/
-
-    protected function loadSpool($group)
-    {
-        Banana::load('spool');
-        if (!Banana::$spool || Banana::$spool->group != $group) {
-            $clean = false;
-            if ($group != @$_SESSION['banana_group']) {
-                unset($_SESSION['banana_message']);
-                unset($_SESSION['banana_artid']);
-                unset($_SESSION['banana_showhdr']);
-            }
-            BananaSpool::getSpool($group, Banana::$profile['lastnews'], Banana::$profile['autoup'] || $clean);
-            $_SESSION['banana_group'] = $group;
-            Banana::$spool->setMode(Banana::$profile['display'] ? Banana::SPOOL_UNREAD : Banana::SPOOL_ALL);
-        }
-        return true;
-    }
-
-    protected function &loadMessage($group, $artid)
-    {
-        Banana::load('message');
-        if ($group == @$_SESSION['banana_group'] && $artid == @$_SESSION['banana_artid']
-            && isset($_SESSION['banana_message'])) {
-            $message = unserialize($_SESSION['banana_message']);
-            Banana::$msgshow_headers = $_SESSION['banana_showhdr'];
-        }  else {
-            $message = Banana::$protocole->getMessage($artid);
-            $_SESSION['banana_group'] = $group;
-            $_SESSION['banana_artid'] = $artid;
-            $_SESSION['banana_message'] = serialize($message);
-            $_SESSION['banana_showhdr'] = Banana::$msgshow_headers;
-        }
-        Banana::$message =& $message;
-        return $message;
-    }
-
-    protected function removeMessage($group, $artid)
-    {
-        Banana::$spool->delId($artid);
-        if ($group == $_SESSION['banana_group'] && $artid == $_SESSION['banana_artid']) {
-            unset($_SESSION['banana_message']);
-            unset($_SESSION['banana_showhdr']);
-            unset($_SESSION['banana_artid']);
-        }
-        return true;
-    }
-
-    static private function load($file)
-    {
-        $file = strtolower($file) . '.inc.php';
-        if (!@include_once dirname(__FILE__) . "/$file") {
-            require_once $file;
-        }
-    }
-}
-
-// vim:set et sw=4 sts=4 ts=4 enc=utf-8:
-?>
index 68aac7c..52b9e7a 100644 (file)
@@ -13,36 +13,16 @@ require_once dirname(__FILE__) . '/message.inc.php';
 
 class BananaMBox implements BananaProtocoleInterface
 {
 
 class BananaMBox implements BananaProtocoleInterface
 {
-    private $inbox        = null;
-    private $file         = null;
-    private $filesize     = null;
-    private $current_id   = null;
-    private $at_beginning = false;
-    private $file_cache   = null;
-
+    private $debug      = false;
+    
     private $_lasterrno = 0;
     private $_lasterror = null;
     private $_lasterrno = 0;
     private $_lasterror = null;
-
-    private $count        = null;
-    private $new_messages = null;
-    private $messages     = null;
-
-    /** Build a protocole handler plugged on the given box
-     */
+    
     public function __construct()
     {
     public function __construct()
     {
-        $this->open();
+        $this->debug = Banana::$debug_mbox;
     }
     }
-
-    /** Close the file
-     */
-    public function __destruct()
-    {
-        $this->close();
-    }
-
-    /** Indicate if the Protocole handler has been succesfully built
-     */
+    
     public function isValid()
     {
         return true;
     public function isValid()
     {
         return true;
@@ -81,62 +61,67 @@ class BananaMBox implements BananaProtocoleInterface
         return array(Banana::$group => array('desc' => '', 'msgnum' => 0, 'unread' => 0));
     }
 
         return array(Banana::$group => array('desc' => '', 'msgnum' => 0, 'unread' => 0));
     }
 
-    /** Return a message
-     * @param id Id of the emssage (can be either an Message-id or a message index)
-     * @return A BananaMessage or null if the given id can't be retreived
-     */
-    public function &getMessage($id)
+    private function &getRawMessage($id)
     {
     {
-        $this->open();
         $message = null;
         $message = null;
-        if (is_null($this->file)) {
-            return $message;
-        }
         if (!is_numeric($id)) {
         if (!is_numeric($id)) {
-            if (!Banana::$spool) {
+            if (!Banana::$spool) { 
                 return $message;
             }
             $id = Banana::$spool->ids[$id];
         }
                 return $message;
             }
             $id = Banana::$spool->ids[$id];
         }
-        $messages = $this->readMessages(array($id));
-        if (!empty($messages)) {
-            $message = new BananaMessage($messages[$id]['message']);
+        $options = array ('-m ' . $id);
+        if (Banana::$spool->overview) {
+            if (Banana::$spool->overview[$id]) {
+               $options[] = '-p ' . $id . ':' . Banana::$spool->overview[$id]->storage['offset'];
+            } else {
+                $key       = max(array_keys(Banana::$spool->overview));
+                if ($key < $id) {
+                    $options[] = '-p ' . $key . ':' . Banana::$spool->overview[$key]->storage['offset'];
+                }
+            }
         }
         }
-        return $message;    
+        return $this->callHelper('-b', $options);
+    }
+
+    /** Return a message
+     * @param id Id of the emssage (can be either an Message-id or a message index)
+     * @return A BananaMessage or null if the given id can't be retreived
+     */
+    public function &getMessage($id)
+    {
+        $messages =& $this->getRawMessage($id);
+        if ($messages) {
+            $messages = new BananaMessage($messages);
+        }
+        return $messages;    
     }
 
     /** Return the sources of the given message
      */
     public function getMessageSource($id)
     }
 
     /** Return the sources of the given message
      */
     public function getMessageSource($id)
-    {
-        $this->open();
-        $message = null;
-        if (is_null($this->file)) {
-            return $message;
+    { 
+        $message =& $this->getRawMessage($id);
+        if ($message) {
+            $message = implode("\n", $message); 
         }
         }
-        if (!is_numeric($id)) {
-            if (!Banana::$spool) { 
-                return $message;
-            }   
-            $id = Banana::$spool->ids[$id];
-        } 
-        $message = $this->readMessages(array($id));
-        return implode("\n", $message[$id]['message']);
+        return $message;
     }   
 
     /** Compute the number of messages of the box
      */
     private function getCount()
     {
     }   
 
     /** Compute the number of messages of the box
      */
     private function getCount()
     {
-        $this->open();
-        $this->count = count(Banana::$spool->overview);
-        $max = @max(array_keys(Banana::$spool->overview));
-        if ($max && Banana::$spool->overview[$max]->storage['next'] == $this->filesize) {
-            $this->new_messages = 0;
-        } else {
-            $this->new_messages = $this->countMessages($this->count);
-            $this->count += $this->new_messages;
-        }    
+        $options = array();
+        if (Banana::$spool->overview) {
+            $key       = max(array_keys(Banana::$spool->overview));
+            $options[] = '-p ' . $key . ':' . Banana::$spool->overview[$key]->storage['offset'];
+        }
+        $val =& $this->callHelper('-c', $options);
+        if (!$val) {
+            return 0;
+        }
+        return intval(trim($val[0]));
     }
 
     /** Return the indexes of the messages presents in the Box
     }
 
     /** Return the indexes of the messages presents in the Box
@@ -144,14 +129,8 @@ class BananaMBox implements BananaProtocoleInterface
      */
     public function getIndexes()
     {
      */
     public function getIndexes()
     {
-        $this->open();
-        if (is_null($this->file)) {
-            return array(0, 0, 0);
-        }
-        if (is_null($this->count)) {
-            $this->getCount();
-        }
-        return array($this->count, 0, $this->count - 1);
+        $count = $this->getCount();
+        return array($count, 0, $count - 1);
     }
 
     /** Return the message headers (in BananaMessage) for messages from firstid to lastid
     }
 
     /** Return the message headers (in BananaMessage) for messages from firstid to lastid
@@ -159,28 +138,57 @@ class BananaMBox implements BananaProtocoleInterface
      */
     public function &getMessageHeaders($firstid, $lastid, array $msg_headers = array())
     {
      */
     public function &getMessageHeaders($firstid, $lastid, array $msg_headers = array())
     {
-        $this->open();
-        $msg_headers = array_map('strtolower', $msg_headers);
-        $messages =& $this->readMessages(range($firstid, $lastid), true);
-        $msg_headers = array_map('strtolower', $msg_headers);
-        $headers  = array();
-        if (is_null($this->file)) {
+        $headers = null;
+        $options = array();
+        $options[] = "-m $firstid:$lastid";
+        if (Banana::$spool->overview) {
+            if (isset(Banana::$spool->overview[$firstid])) {
+               $options[] = '-p ' . $firstid . ':' . Banana::$spool->overview[$firstid]->storage['offset'];
+            } else {
+                $key       = max(array_keys(Banana::$spool->overview));
+                if ($key < $firstid) {
+                    $options[] = '-p ' . $key . ':' . Banana::$spool->overview[$key]->storage['offset'];
+                }
+            }
+        }
+        $lines =& $this->callHelper('-d', $options, $msg_headers);
+        if (!$lines) {
             return $headers;
         }
             return $headers;
         }
-        foreach ($msg_headers as $header) {
-            foreach ($messages as $id=>&$message) {
-                if (!isset($headers[$id])) {
-                    $headers[$id] = array('beginning' => $message['beginning'], 'end' => $message['end']);
+        $headers = array();
+        while ($lines) {
+            $id = array_shift($lines);
+            if ($id === '') {
+                continue;
+            }
+            $offset = array_shift($lines);
+            if ($offset === '') {
+                continue;
+            }
+            $id     = intval($id);
+            $headers[$id] = array('beginning' => intval($offset));
+            while (true) {
+                $hname = array_shift($lines);
+                if ($hname === '') {
+                    break;
+                }
+                $hval  = array_shift($lines);
+                if ($hval === '') {
+                    break;
                 }
                 }
-                if ($header == 'date') {
-                    $headers[$id][$header] = @strtotime($message['message'][$header]);
+                if ($hname == 'date') {
+                    $headers[$id][$hname] = @strtotime($hval);
                 } else {
                 } else {
-                    $headers[$id][$header] = @$message['message'][$header];
+                    $headers[$id][$hname] = $hval;
                 }
             }
                 }
             }
+            if (!isset($headers[$id]['date'])) {
+                print_r($id);
+                print_r($offset);
+                print_r($headers[$id]);
+            }
         }
         }
-        unset($this->messages);
-        unset($messages);
+        array_walk_recursive($headers, array('BananaMimePart', 'decodeHeader'));
         return $headers;
     }
 
         return $headers;
     }
 
@@ -191,7 +199,6 @@ class BananaMBox implements BananaProtocoleInterface
         foreach ($messages as $id=>&$data) {
             if (isset(Banana::$spool->overview[$id])) {
                 Banana::$spool->overview[$id]->storage['offset'] = $data['beginning'];
         foreach ($messages as $id=>&$data) {
             if (isset(Banana::$spool->overview[$id])) {
                 Banana::$spool->overview[$id]->storage['offset'] = $data['beginning'];
-                Banana::$spool->overview[$id]->storage['next']   = $data['end'];
             }
         }
     }
             }
         }
     }
@@ -300,214 +307,26 @@ class BananaMBox implements BananaProtocoleInterface
 # MBox parser
 #######
 
 # MBox parser
 #######
 
-    private function open()
-    {
-        if ($this->inbox == Banana::$group) {
-            return;
-        }
-        $this->close();
-        $filename = $this->getFileName();
-        if (is_null($filename)) {
-            return;
-        }
-        $this->file = @fopen($filename, 'r');
-        if (!$this->file) {
-            $this->file = null;
-            $this->filesize = 0;
-        } else {
-            $this->filesize = filesize($filename);
-        }
-        $this->current_id   = 0;
-        $this->at_beginning = true;
-        $this->inbox        = Banana::$group;
-    }
-
-    private function close()
-    {
-        if (is_null($this->file)) {
-            return;
-        }
-        fclose($this->file);
-        $this->inbox        = null;
-        $this->file         = null;
-        $this->filesize     = null;
-        $this->current_id   = null;
-        $this->at_beginning = false;
-        $this->file_cache   = null;
-        $this->count        = null;
-        $this->new_messages = null;
-        $this->messages     = null;
-    }
-
-    /** Go to the given message
-     */
-    private function goTo($id)
-    {
-        if ($this->current_id == $id && $this->at_beginning) {
-            return true;
-        }
-        if ($id == 0) {
-            fseek($this->file, 0);
-            $this->current_id   = 0;
-            $this->at_beginning = true;
-            return true;
-        } elseif (isset(Banana::$spool->overview[$id]) || isset($this->messages[$id])) {
-            if (isset(Banana::$spool->overview[$id])) {
-                $pos = Banana::$spool->overview[$id]->storage['offset'];
-            } else {
-                $pos = $this->messages[$id]['beginning'];
-            }
-            if (fseek($this->file, $pos) == 0) {
-                $this->current_id   = $id;
-                $this->at_beginning = true;
-                return true;
-            } else {
-                $this->current_id = null;
-                $this->_lasterrno = 2;
-                $this->_lasterror = _b_('Can\'t find message ') . $id;
-                return false;
-            }
-        } else {
-            $max = @max(array_keys(Banana::$spool->overview));
-            if (is_null($max)) {
-                $max = 0;
-            }
-            if ($id <= $max && $max != 0) {
-                $this->current_id = null;
-                $this->_lasterrno = 3;
-                $this->_lasterror = _b_('Invalid message index ') . $id;
-                return false;
-            }
-            if (!$this->goTo($max)) {
-                return false;
-            }
-            if (feof($this->file)) {
-                $this->current_id = null;
-                $this->_lasterrno = 4;
-                $this->_lasterror = _b_('Requested index does not exists or file has been truncated');
-                return false;
-            }
-            while ($this->readCurrentMessage(true) && $this->current_id < $id);
-            if ($this->current_id == $id) {
-                return true;
-            }
-            $this->current_id = null;
-            $this->_lasterrno = 5;
-            $this->_lasterror = _b_('Requested index does not exists or file has been truncated');
-            return false;
-        }
-    }
-
-    private function countMessages($from = 0)
-    {
-        $this->messages =& $this->readMessages(array($from), true, true);
-        return count($this->messages);
-    }
-
-    /** Read the current message (identified by current_id)
-     * @param needFrom_ BOOLEAN is true if the first line *must* be a From_ line
-     * @param alignNext BOOLEAN is true if the buffer must be aligned at the beginning of the next From_ line
-     * @return message sources (without storage data)
-     */
-    private function &readCurrentMessage($stripBody = false, $needFrom_ = true, $alignNext = true)
+    private function &callHelper($action, array $options = array(), array $headers = array())
     {
     {
-        $file_cache =& $this->file_cache;
-        if ($file_cache && $file_cache != ftell($this->file)) {
-            $file_cache = null;
-        }
-        $msg        = array();
-        $canFrom_   = false;
-        $inBody     = false;
-        while(!feof($this->file)) {
-            // Process file cache
-            if ($file_cache) { // this is a From_ line
-                $needFrom_ = false;
-                $this->at_beginning = false;
-                $file_cache   = null;
-                continue;
-            }
-
-            // Read a line
-            $line    = rtrim(fgets($this->file), "\r\n");
-            
-            // Process From_ line
-            if ($needFrom_ || !$msg || $canFrom_) {
-                if (substr($line, 0, 5) == 'From ') { // this is a From_ line
-                    if ($needFrom_) {
-                        $needFrom = false;
-                    } elseif (!$msg) {
-                        continue;
-                    } else {
-                        $this->current_id++; // we are finally in the next message
-                        if ($alignNext) {  // align the file pointer at the beginning of the new message
-                            $this->at_beginning = true;
-                            $file_cache = ftell($this->file);
-                        }
-                        break;
-                    }
-                } elseif ($needFrom_) {
-                    return $msg;
-                }
-            }
-
-            // Process non-From_ lines
-            if (substr($line, 0, 6) == '>From ') { // remove inline From_ quotation
-                $line = substr($line, 1);
-            }
-            if (!$stripBody || !$inBody) {
-                $msg[] = $line; // add the line to the message source
-            }
-            $canFrom_ = empty($line); // check if next line can be a From_ line
-            if ($canFrom_ && !$inBody && $stripBody) {
-                $inBody = true;
-            }
-            $this->at_beginning = false;
+        $action .= ' -f ' . $this->getFileName();
+        $cmd = Banana::$mbox_helper . " $action " . implode(' ', $options) . ' ' . implode(' ', $headers);
+        if ($this->debug) {
+            echo $cmd . '<br />';
+            $start = microtime(true);
         }
         }
-        if (!feof($this->file) && !$canFrom_) {
-            $msg = array();
-        }
-        return $msg;
-    }
-
-    /** Read message with the given ids
-     * @param ids ARRAY of ids to look for
-     * @param strip BOOLEAN if true, only headers are retrieved
-     * @param from BOOLEAN if true, process all messages from max(ids) to the end of the mbox
-     * @return Array(Array('message' => message sources (or parsed message headers if $strip is true),
-     *                     'beginning' => offset of message beginning,
-     *                     'end' => offset of message end))
-     */
-    private function &readMessages(array $ids, $strip = false, $from = false)
-    {
-        if ($this->messages) {
-            return $this->messages;
+        exec($cmd, $out, $return);
+        if ($this->debug) {
+            echo '&nbsp;&nbsp;Execution : ' . (microtime(true) - $start) . 's<br />';
+            echo "&nbsp;&nbsp;Retour : $return<br />";
+            echo '&nbsp;&nbsp;Sortie : ' . count($out) . ' ligne(s)<br />';
         }
         }
-        sort($ids);
-        $messages = array();
-        while ((count($ids) || $from) && !feof($this->file)) {
-            if (count($ids)) {
-                $id = array_shift($ids);
-            } else {
-                $id++;
-            }
-            if ($id != $this->current_id || !$this->at_beginning) {
-                if (!$this->goTo($id)) {
-                    if (count($ids)) {
-                        continue;
-                    } else {
-                        break;
-                    }
-                }
-            }
-            $beginning = ftell($this->file);
-            $message   =& $this->readCurrentMessage($strip, false);
-            if ($strip) {
-                $message =& BananaMimePart::parseHeaders($message);
-            }
-            $end       = ftell($this->file);
-            $messages[$id] = array('message' => $message, 'beginning' => $beginning, 'end' => $end);
+        if ($return != 0) {
+            $this->_lasterrorno = 1;
+            $this->_lasterrorcode = "Helper failed";
+            $out = null;
         }
         }
-        return $messages;
+        return $out;
     }
 }
 
     }
 }
 
index e8aeef8..1628f37 100644 (file)
@@ -311,13 +311,20 @@ function banana_cleanStyles($tag, $attributes)
     return ' ' . $style . trim($attributes);
 }
 
     return ' ' . $style . trim($attributes);
 }
 
+function banana__filterCss($text)
+{
+    $text = preg_replace("/(,[\s\n\r]*)/s", '\1 .banana .message .body .html ', $text);
+    return '.banana .message .body .html ' . $text;
+}
+
 function banana_filterCss($css)
 {
 function banana_filterCss($css)
 {
-    $css = preg_replace("/(^|\n|,)\s*(\w+[^\{\}\<]+\{)/s", '\1.banana .message .body .html \2', $css);
+    preg_match_all("/(^|\n|,\s*)\s*([\#\.@\w][^;\{\}\<]*?[\{])/s", $css, $matches);
+    $css = preg_replace("/(^|\n)\s*([\#\.@\w][^;\{\}\<]*?)([\{])/se", '"\1" . banana__filterCss("\2") . "\3"', $css);
     $css = preg_replace('/ body\b/i', '', $css);
     if (!Banana::$msgshow_externalimages) {
     $css = preg_replace('/ body\b/i', '', $css);
     if (!Banana::$msgshow_externalimages) {
-        if (preg_match("/url\(((ht|f)tps?:.*?)\)/i", $css)) {
-            $css = preg_replace("/url\(((ht|f)tps?:.*?)\)/i", 'url(invalid-image.png)', $css);
+        if (preg_match('!url\([^:\)]+:(//|\\\).*?\)!i', $css)) {
+            $css = preg_replace('!url\([^:\)]+:(//|\\\).*?\)!i', 'url(invalid-image.png)', $css);
             Banana::$msgshow_hasextimages = true;
         }
     }
             Banana::$msgshow_hasextimages = true;
         }
     }
@@ -360,7 +367,7 @@ function banana_cleanHtml($source, $to_xhtml = false)
         $css = null;
         if (preg_match('/<head.*?>(.*?)<\/head>/is', $source, $matches)) {
             $source = preg_replace('/<head.*?>.*?<\/head>/is', '', $source);
         $css = null;
         if (preg_match('/<head.*?>(.*?)<\/head>/is', $source, $matches)) {
             $source = preg_replace('/<head.*?>.*?<\/head>/is', '', $source);
-            preg_match_all('/<style.*?type="text\/css".*?>(.*?)<\/style>/is', $matches[1], $matches);
+            preg_match_all('/<style(?:.*?type="text\/css".*?)?>(.*?)<\/style>/is', $matches[1], $matches);
             foreach ($matches[1] as &$match) {
                 $css .= $match;
             }
             foreach ($matches[1] as &$match) {
                 $css .= $match;
             }
index 935e8c3..66786da 100644 (file)
@@ -206,7 +206,7 @@ final class BananaMessage extends BananaMimePart
         if (isset($refs['references'])) {
             $text = str_replace('><', '> <', $refs['references']);
             return preg_split('/\s/', strtr($text, Banana::$spool->ids));
         if (isset($refs['references'])) {
             $text = str_replace('><', '> <', $refs['references']);
             return preg_split('/\s/', strtr($text, Banana::$spool->ids));
-        } elseif (isset($refs['in-reply-to'])) {
+        } elseif (isset($refs['in-reply-to']) && isset(Banana::$spool->ids[$refs['in-reply-to']])) {
             return array(Banana::$spool->ids[$refs['in-reply-to']]);
         } else {
             return array();
             return array(Banana::$spool->ids[$refs['in-reply-to']]);
         } else {
             return array();
index cf1e94a..1ca1ec8 100644 (file)
@@ -160,14 +160,14 @@ class BananaMimePart
             $encoding     = '8bit';
             $charset      = 'CP1252';
             $content_type = 'text/plain';
             $encoding     = '8bit';
             $charset      = 'CP1252';
             $content_type = 'text/plain';
-            $format       = strtolower($this->getHeader('x-rfc2646', '/format="?([^"]+?)"?\s*(;|$)/i'));
+            $format       = strtolower($this->getHeader('x-rfc2646', '/format="?([^ w@"]+?)"?\s*(;|$)/i'));
         } else {
             $encoding     = strtolower($this->getHeader('content-transfer-encoding'));
             $disposition  = $this->getHeader('content-disposition', '/(inline|attachment)/i');
         } else {
             $encoding     = strtolower($this->getHeader('content-transfer-encoding'));
             $disposition  = $this->getHeader('content-disposition', '/(inline|attachment)/i');
-            $boundary     = $this->getHeader('content-type', '/boundary="?([^"]+?)"?\s*(;|$)/i');
-            $charset      = strtolower($this->getHeader('content-type', '/charset="?([^"]+?)"?\s*(;|$)/i'));
-            $filename     = $this->getHeader('content-disposition', '/filename="?([^"]+?)"?\s*(;|$)/i');
-            $format       = strtolower($this->getHeader('content-type', '/format="?([^"]+?)"?\s*(;|$)/i'));
+            $boundary     = $this->getHeader('content-type', '/boundary="?([^ "]+?)"?\s*(;|$)/i');
+            $charset      = strtolower($this->getHeader('content-type', '/charset="?([^ "]+?)"?\s*(;|$)/i'));
+            $filename     = $this->getHeader('content-disposition', '/filename="?([^ "]+?)"?\s*(;|$)/i');
+            $format       = strtolower($this->getHeader('content-type', '/format="?([^ "]+?)"?\s*(;|$)/i'));
             $id           = $this->getHeader('content-id', '/<(.*?)>/');
             if (empty($filename)) {
                 $filename = $this->getHeader('content-type', '/name="?([^"]+)"?/');
             $id           = $this->getHeader('content-id', '/<(.*?)>/');
             if (empty($filename)) {
                 $filename = $this->getHeader('content-type', '/name="?([^"]+)"?/');
@@ -269,16 +269,16 @@ class BananaMimePart
     static public function &parseHeaders(array &$lines)
     {
         $headers = array();
     static public function &parseHeaders(array &$lines)
     {
         $headers = array();
-        while (count($lines)) {
+        while ($lines) {
             $line = array_shift($lines);
             $line = array_shift($lines);
-            if (preg_match('/^[\t\r ]+/', $line) && isset($hdr)) {
+            if (isset($hdr) && $line && ctype_space($line{0})) {
                 $headers[$hdr] .= ' ' . trim($line);
             } elseif (!empty($line)) {
                 $headers[$hdr] .= ' ' . trim($line);
             } elseif (!empty($line)) {
-                if (preg_match("/:[ \t\r]*/", $line)) {
-                    list($hdr, $val) = split(":[ \t\r]*", $line, 2);
+                if (strpos($line, ':') !== false) {
+                    list($hdr, $val) = explode(":", $line, 2);
                     $hdr = strtolower($hdr);
                     if (in_array($hdr, Banana::$msgparse_headers)) {  
                     $hdr = strtolower($hdr);
                     if (in_array($hdr, Banana::$msgparse_headers)) {  
-                        $headers[$hdr] = $val;
+                        $headers[$hdr] = ltrim($val);
                     } else {
                         unset($hdr);
                     }
                     } else {
                         unset($hdr);
                     }
@@ -448,8 +448,8 @@ class BananaMimePart
               case 'html': return banana_formatHtml($this);
               case 'enriched': case 'richtext': return banana_formatRichText($this);
               default:
               case 'html': return banana_formatHtml($this);
               case 'enriched': case 'richtext': return banana_formatRichText($this);
               default:
-                if ($type == 'message') {
-                    return '<hr />' . banana_formatPlainText($this);
+                if ($type == 'message') { // we have a raw source of data (no specific pre-formatting)
+                    return '<hr />' . utf8_encode(banana_formatPlainText($this));
                 }
                 return banana_formatPlainText($this);
             }
                 }
                 return banana_formatPlainText($this);
             }
diff --git a/mbox-helper/Makefile b/mbox-helper/Makefile
new file mode 100644 (file)
index 0000000..c3806bb
--- /dev/null
@@ -0,0 +1,11 @@
+CFLAGS=-O2
+
+all: mbox-helper Makefile
+
+mbox-helper: mbox-helper.o
+
+mbox-helper.o: mbox-helper.c
+
+clean:
+       -rm *.o
+       -rm mbox-helper
diff --git a/mbox-helper/mbox-helper.c b/mbox-helper/mbox-helper.c
new file mode 100644 (file)
index 0000000..56c0e35
--- /dev/null
@@ -0,0 +1,425 @@
+/** Read an mbox
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <locale.h>
+
+/** Macros
+ */
+#define LTRIM(pos)              while (isspace(*pos)) { pos++; }
+#define STRTOLOWER(str, ptr)    for (ptr = str ; *ptr ; ptr++) { *ptr = tolower(*ptr); }
+
+/** Boolean
+ */
+typedef char bool;
+#define TRUE ((bool)(-1))
+#define FALSE ((bool)(0))
+
+/** MBox pointer
+ */
+typedef struct
+{
+    FILE *fp; // File pointer
+    long int lastLine;          // Offset of the precedent line (-1 if invalid)
+    long int currentLine;       // Offset of the current line
+    long int messageId;         // Current message Id
+    long int messageBeginning;  // Offset of the beginning of the message (FROM_ line)
+
+    char *line;                 // Line buffer
+    bool isFrom_;               // Is the current line a From_ line ?
+}
+MBox;
+
+/** Open a mbox
+ */
+MBox *openMBox(char *filename)
+{
+    FILE *fp;
+    MBox *mbox;
+
+    fp = fopen(filename, "r"); 
+    if (!fp) {
+        return NULL;
+    }
+
+    mbox = (MBox*)malloc(sizeof(MBox));
+    mbox->fp               = fp;
+    mbox->lastLine         = -1;
+    mbox->currentLine      = 0;
+    mbox->messageId        = 0;
+    mbox->messageBeginning = 0;
+    mbox->line             = NULL;
+    mbox->isFrom_          = FALSE;
+    return mbox;
+}
+
+/** Close a mbox
+ */
+void closeMBox(MBox *mbox)
+{
+    if (!mbox) {
+        return;
+    }
+    fclose(mbox->fp);
+    if (mbox->line) {
+        free(mbox->line);
+    }
+    free(mbox);
+}
+
+/** Read a line in a file
+ */
+char *readLine(MBox *mbox)
+{
+    int length;
+    mbox->lastLine    = mbox->currentLine;
+    mbox->currentLine = ftell(mbox->fp);
+    mbox->isFrom_ = FALSE;
+    
+    if (!mbox->line) {
+        mbox->line = (char*)malloc(1001);
+    }
+    if (!fgets(mbox->line, 1000, mbox->fp)) {
+        mbox->currentLine = -1;
+        return NULL;
+    }
+    length = ftell(mbox->fp) - mbox->currentLine;
+    if (length > 1000) {
+        length = 1000;
+    }
+    if (length) {
+        while (length >= 0 && (isspace(mbox->line[length]) || mbox->line[length] == '\0')) {
+            length--;
+        }
+        mbox->line[length + 1] = '\0';
+    }
+    mbox->isFrom_     = (strstr(mbox->line, "From ") == mbox->line);
+    if (mbox->isFrom_ && mbox->messageBeginning != mbox->currentLine) {
+        mbox->messageBeginning = mbox->currentLine;
+        mbox->messageId++;
+    }
+    return mbox->line;
+}
+
+/** Return to the last line
+ */
+bool lastLine(MBox *mbox)
+{
+    if (mbox->lastLine != -1) {
+        fseek(mbox->fp, mbox->lastLine, SEEK_SET);
+        mbox->lastLine = -1;
+        readLine(mbox);
+        return TRUE;
+    }
+    return FALSE;
+}
+
+bool readFrom_(MBox *mbox)
+{
+    if (!mbox->isFrom_) {
+        readLine(mbox);
+    }
+    if (!mbox->isFrom_) {
+        return FALSE;
+    }
+    return TRUE; 
+}
+
+/** Read a message
+ */
+void readMessage(MBox *mbox, bool display)
+{
+    if (!readFrom_(mbox)) {
+        return;
+    }
+    while (readLine(mbox)) {
+        if (mbox->isFrom_) {
+            return;
+        }
+        if (display) {
+            if (strstr(mbox->line, ">From ") == mbox->line) {
+                puts(mbox->line + 1);
+            } else {
+                puts(mbox->line);
+            }
+        }
+    }
+}
+
+/** Read the headers of a message
+ */
+void readHeaders(MBox *mbox, char **headers, int hdrsize)
+{
+    char *current = NULL;
+    char *pos, *ptr;
+    int size, i;
+    
+    if (!readFrom_(mbox)) {
+        return;
+    }
+    printf("%d\n%d\n", mbox->messageId, mbox->messageBeginning);
+    while (readLine(mbox)) {
+        if (mbox->isFrom_ || !strlen(mbox->line)) {
+            break;
+        }
+        if (current && strlen(mbox->line) && isspace(*(mbox->line))) {
+            pos = mbox->line;
+            LTRIM(pos);
+            printf(" %s", pos);
+        } else {
+            if (current) {
+                printf("\n");
+                free(current);
+                current = NULL;
+            }
+            pos = strchr(mbox->line, ':');
+            if (!pos || pos == mbox->line) {
+                continue;
+            }
+            size = pos - mbox->line;
+            for (i = 0 ; i < hdrsize ; i++) {
+                if (strlen(headers[i]) == size && strcasestr(mbox->line, headers[i]) == mbox->line) {
+                    current = (char*)malloc(size + 1);
+                    strcpy(current, headers[i]);
+                    current[size] = '\0'; 
+                }
+            }
+            if (!current && !hdrsize) {
+                current = (char*)malloc(size + 1);
+                strncpy(current, mbox->line, size);
+                current[size] = '\0';
+                STRTOLOWER(current, ptr);
+            }
+            if (current) {
+                puts(current);
+                pos++;
+                LTRIM(pos);
+                printf("%s", pos);
+            }
+        }
+    }
+    if (current) {
+        printf("\n");
+        free(current);
+        current = NULL;
+    }
+    printf("\n");
+}
+
+/** Go back to the beginning of the file
+ */
+void rewindMBox(MBox *mbox)
+{
+    fseek(mbox->fp, 0, SEEK_SET);
+    mbox->messageId = 0;
+    mbox->messageBeginning = 0;
+    readLine(mbox);
+}
+
+/** Go back to the beginning of the message
+ */
+bool rewindMessage(MBox *mbox)
+{
+    if (mbox->isFrom_) {
+        return TRUE;
+    }
+    fseek(mbox->fp, mbox->messageBeginning, SEEK_SET);
+    mbox->currentLine = -1;
+    mbox->lastLine = -1;
+    readLine(mbox);
+    return mbox->isFrom_;
+}
+
+/** Move to the given offset
+ */
+bool goToOffset(MBox *mbox, int offset, int index)
+{
+    fseek(mbox->fp, offset, SEEK_SET);
+    mbox->currentLine = -1;
+    mbox->lastLine    = -1;
+    mbox->messageBeginning = offset;
+    mbox->messageId   = index;
+    readLine(mbox);
+    if (!mbox->isFrom_) {
+        return FALSE;
+    }
+    return TRUE;
+}
+
+/** Move to the given message number
+ */
+bool goToMessage(MBox *mbox, int index)
+{
+    if (mbox->messageId > index) {
+        rewindMBox(mbox); 
+    } else if(mbox->messageId == index) {
+        rewindMessage(mbox);
+        return TRUE;
+    } else if (!mbox->isFrom_) {
+        while (!feof(mbox->fp) && !mbox->isFrom_) {
+            readLine(mbox);
+        }
+        if (feof(mbox->fp)) {
+            return FALSE;
+        }
+    }
+    while (mbox->messageId < index && !feof(mbox->fp)) {
+        readMessage(mbox, FALSE);
+    }
+    if (mbox->messageId == index) {
+        return TRUE;
+    }
+    return FALSE;
+}
+
+
+/** Display the program help
+ */
+void help(void)
+{
+    printf("Usage: mbox-helper [action] [options] -f filename [header1 [header2 ...]]\n"
+           "Actions: only the last action given is applied\n"
+           "    -c               compute the number of messages. If -p is given, process the file starting à the given offset\n"
+           "    -d               return the headers of the messages given with the -m option. If no header is given in the\n"
+           "                     command line options, all the headers are returned. The headers are return with the format:\n"
+           "                        MSG1_ID\\n\n"
+           "                        MSG1_OFFSET\\n\n"
+           "                        MSG1_HEADER1_NAME\\n\n"
+           "                        MSG1_HEADER1_VALUE\\n\n"
+           "                        MSG1_HEADER2_NAME\\n\n"
+           "                        MSG2_HEADER2_VALUE\\n\n"
+           "                        ...\n"
+           "                     Messages are separated by a blank line\n"
+           "    -b               return the body of the message given by -m (only 1 message is returned)\n"
+           "Options:\n"
+           "    -m begin[:end]   id or range of messages to process\n"
+           "    -p id:pos        indicate that message `id` begins at offset `pos`\n"
+           "    -h               print this help\n");
+}
+
+/** Display an error message
+ * This function display the giver error, then show the program help and exit the program
+ */
+void error(char *message)
+{
+    fprintf(stderr, "Invalid parameters: %s\n", message);
+    help();
+    exit(1);
+}
+
+/** Main function
+ */
+int main(int argc, char *argv[])
+{
+    int c, i = 0;
+    int fmid = -1, lmid = -1;
+    int pmid = 0, pos = 0;
+    char *filename = NULL;
+    char **headers = NULL;
+    char action;
+    int headerNb   = 0;
+    char *endptr;
+    MBox *mbox;
+    
+    /* getopt variables */
+    extern char *optarg;
+    extern int optind, optopt;
+
+    while ((c = getopt(argc, argv, ":bcdp:hm:f:")) != -1) {
+        switch (c) {
+          case 'f':
+            filename = optarg;
+            break;
+          case 'm':
+            fmid = strtol(optarg, &endptr, 10);
+            if (endptr == optarg) {
+                error("invalid message id");
+            }
+            if (*endptr != ':') {
+                lmid = fmid;
+            } else {
+                lmid = atoi(endptr + 1);
+            }
+            break;
+          case 'p':
+            if ((endptr = strchr(optarg, ':')) != NULL) {
+                pmid = strtol(optarg, &endptr, 10);
+                if (*endptr != ':') {
+                   error("invalid position couple given");
+                }
+                pos = atoi(endptr + 1);
+            } else {
+                error("invalid position given");
+            }
+            break;
+          case 'c': case 'd': case 'b':
+            action = c;
+            break;
+          case 'h':
+            help();
+            return 0;
+          case ':':
+            fprintf(stderr, "Missing argument to -%c\n", optopt);
+            break;
+          case '?':
+            fprintf(stderr, "Unrecognized option: -%c\n", optopt);
+            break;
+        }
+    }
+    
+    if (!filename) {
+        error("no file defined");
+    }
+
+    setlocale(LC_ALL, "C");
+  
+    headerNb = argc - optind;
+    headers  = (argv + optind);
+    for (i = 0 ; i < headerNb ; i++) {
+        STRTOLOWER(headers[i], endptr);
+    }
+
+    mbox = openMBox(filename);
+    if (!mbox) {
+        fprintf(stderr, "can't open file '%s'", filename);
+    }
+    if ((fmid >= pmid || fmid == -1) && pos) {
+        if (!goToOffset(mbox, pos, pmid)) {
+            fprintf(stderr, "Offset %d do not match with a message beginning\n", pos);
+            rewindMBox(mbox);
+        }   
+    }
+    switch (action) {
+      case 'b':
+        if (fmid == -1) {
+            fprintf(stderr, "you have to define a message number");
+            break;
+        }
+        goToMessage(mbox, fmid);
+        readMessage(mbox, TRUE);
+        break;
+      case 'c':
+        while (!feof(mbox->fp)) {
+            readLine(mbox);
+        }
+        printf("%d\n", mbox->messageId + 1);
+        break;
+      case 'd':
+        if (fmid == -1) {
+             fprintf(stderr, "you have to define a message number");
+             break;
+        }
+        for (i = fmid ; i <= lmid ; i++) {
+            goToMessage(mbox, i);
+            readHeaders(mbox, headers, headerNb);
+        }
+        break;
+    }
+    closeMBox(mbox);
+
+    return 0;
+}
index 92f5b61..0f1f716 100644 (file)
@@ -10,10 +10,14 @@ all: banana.pot ${LANGS:=.lang}
 clean:
        rm -f *.po~ *.lang
 
 clean:
        rm -f *.po~ *.lang
 
-banana.pot: ../banana/*.php
+banana.pot:
        @echo Parsing Tree for new messages
        @echo
        @echo Parsing Tree for new messages
        @echo
-       @xgettext --from-code=iso-8859-15 -j -k_b_ -o banana.pot $<
+       @echo "<?php " > template.php
+       @grep "|b" ../banana/templates/*.tpl | sed 's/\(.*\)\("[^"]*"\)|b\(.*\)/$var = _b_(\2);/g' >> template.php
+       @echo "?>" >> template.php
+       @xgettext --from-code=UTF-8 -j -k_b_ -o banana.pot ../banana/*.php ./template.php
+       @rm template.php
 
 %.lang: banana.pot ../banana/*.php %.po
        @echo Generating $(@:.lang=.po)
 
 %.lang: banana.pot ../banana/*.php %.po
        @echo Generating $(@:.lang=.po)
index 6ce6bb1..975f016 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2006-09-18 21:50+0200\n"
+"POT-Creation-Date: 2007-02-21 17:48+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -16,203 +16,187 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: ../banana/banana.inc.php:54 ../banana/banana.inc.php:119
-msgid "Impossible de contacter le serveur"
-msgstr ""
-
-#: ../banana/banana.inc.php:93 ../banana/banana.inc.php:169
-msgid "Voulez-vous vraiment annuler ce message ?"
-msgstr ""
-
-#: ../banana/banana.inc.php:124
-msgid "Les forums de Banana"
+#: ../banana/message.inc.php:49
+msgid "De"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:126 ../banana/banana.inc.php:215
-msgid "Les forums suivants ont été créés depuis ton dernier passage :"
+#: ../banana/message.inc.php:50 template.php:27
+msgid "Sujet"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:140 ../banana/misc.inc.php:150
-msgid "Abonnements"
+#: ../banana/message.inc.php:51
+msgid "Forums"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:175 ../banana/banana.inc.php:265
-#: ../banana/banana.inc.php:286
-msgid "Impossible d'accéder au message.   Le message a peut-être été annulé"
+#: ../banana/message.inc.php:52
+msgid "Suivi à"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:179
-msgid "Message"
+#: ../banana/message.inc.php:53
+msgid "À"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:194 ../banana/banana.inc.php:309
-msgid "Vous n'avez pas les permissions pour annuler ce message"
+#: ../banana/message.inc.php:54
+msgid "Copie à"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:208 ../banana/banana.inc.php:328
-msgid "Impossible d'annuler le message"
+#: ../banana/message.inc.php:55
+msgid "Copie cachée à"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:222 ../banana/banana.inc.php:352
-msgid "a écrit"
+#: ../banana/message.inc.php:56
+msgid "Répondre à"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:230 ../banana/misc.inc.php:156
-msgid "Nouveau message"
+#: ../banana/message.inc.php:57 template.php:26
+msgid "Date"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:233 ../banana/post.inc.php:100
-#: ../banana/banana.inc.php:371
-msgid "En-têtes"
+#: ../banana/message.inc.php:58
+msgid "Organisation"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:234 ../banana/groups.inc.php:93
-#: ../banana/banana.inc.php:372
-msgid "Nom"
+#: ../banana/message.inc.php:60
+msgid "Références"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:235 ../banana/misc.inc.php:34
-#: ../banana/spool.inc.php:360 ../banana/banana.inc.php:374
-msgid "Sujet"
+#: ../banana/message.inc.php:61
+msgid "Image"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:236 ../banana/misc.inc.php:35
-#: ../banana/banana.inc.php:376
-msgid "Forums"
+#: ../banana/page.inc.php:106
+msgid "Abonnements"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:237 ../banana/banana.inc.php:378
-msgid "Suivi à"
+#: ../banana/page.inc.php:107
+msgid "Les forums"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:238 ../banana/misc.inc.php:38
-#: ../banana/banana.inc.php:380
-msgid "Organisation"
+#: ../banana/page.inc.php:111
+msgid "Message"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:239 ../banana/post.inc.php:111
-#: ../banana/banana.inc.php:382
-msgid "Corps"
+#: ../banana/page.inc.php:113
+msgid "Annulation"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:275 ../banana/banana.inc.php:283
-msgid "Impossible de poster le message"
+#: ../banana/page.inc.php:115 template.php:17
+msgid "Répondre"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/groups.inc.php:87
-msgid "Total"
+#: ../banana/page.inc.php:118
+msgid "Nouveau"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/groups.inc.php:89
-msgid "Abo."
+#: ../banana/page.inc.php:139
+msgid "La page demandée n'existe pas"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/groups.inc.php:91
-msgid "Nouveaux"
+#: ../banana/page.inc.php:311
+msgid "alt"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/groups.inc.php:93
-msgid "Description"
+#: ../banana/spool.inc.php:389
+msgid "hier"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/misc.inc.php:33
-msgid "De"
+#: ../banana/spool.inc.php:448
+msgid "(pas de sujet)"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/misc.inc.php:36
-msgid "Suivi-à"
+#: template.php:2
+msgid ""
+"Les nouveaux groupes suivants ont été créés depuis votre dernière visite"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/misc.inc.php:37 ../banana/spool.inc.php:359
-msgid "Date"
+#: template.php:3
+msgid "Voulez-vous vraiment annuler ce message ?"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/misc.inc.php:39
-msgid "Références"
+#: template.php:4
+msgid "Annuler !"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/misc.inc.php:40
-msgid "Image"
+#: template.php:5 template.php:10
+msgid "Valider"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/misc.inc.php:115
-msgid "hier"
+#: template.php:6
+msgid "Total"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/misc.inc.php:148
-msgid "Liste des forums"
+#: template.php:7
+msgid "Nouveaux"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/misc.inc.php:171
-msgid "Répondre"
+#: template.php:8
+msgid "Nom"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/misc.inc.php:174
-msgid "Annuler ce message"
+#: template.php:9
+msgid "Description"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/post.inc.php:114
-msgid "apercu"
+#: template.php:11 template.php:25
+msgid "Message non-lu suivant"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/spool.inc.php:361
-msgid "Auteur"
+#: template.php:12
+msgid "Message précédent"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/spool.inc.php:372
-msgid "Aucun message dans ce forum"
+#: template.php:13
+msgid "Message suivant"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:127
-msgid ""
-" : ce newsgroup n'existe pas ou vous n'avez pas l'autorisation d'y accéder"
+#: template.php:14
+msgid "Discussion précédente"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:237 ../banana/banana.inc.php:257
-msgid "Impossible charger la liste des messages de "
+#: template.php:15
+msgid "Discussion suivante"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:278 ../banana/banana.inc.php:300
-#: ../banana/banana.inc.php:420
-msgid "Impossible charger la liste des messages"
+#: template.php:16 template.php:28
+msgid "Nouveau message"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:293
-msgid "Impossible d'accéder à la pièce jointe."
+#: template.php:18
+msgid "Annuler"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:304
-msgid "Impossible de trouver le message à annuler"
+#: template.php:19
+msgid "Enregistrer"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:386
-msgid "Pièce jointe"
+#: template.php:20
+msgid "Versions"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:396
-msgid "Envoyer le message"
+#: template.php:21
+msgid "Afficher les images externes"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:434
-msgid "Impossible charger le message d'origine"
+#: template.php:22
+msgid "Composer un nouveau message"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:457
-msgid "Fichier trop gros pour être envoyé : "
+#: template.php:23
+msgid "Fichier joint"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:461
-msgid "Erreur lors de l'upload de "
+#: template.php:24
+msgid "Envoyer le message"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:465
-msgid "Le fichier spécifié n'existe pas : "
+#: template.php:29
+msgid "Auteur"
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:469
-msgid "Une erreur est survenue sur le serveur lors de l'upload de "
+#: template.php:30
+msgid "Aperçu de "
 msgstr ""
 
 msgstr ""
 
-#: ../banana/banana.inc.php:486
-msgid "Impossible de poster le message. Le serveur a retourné l'erreur :"
+#: template.php:31
+msgid "Aucun message dans ce forum"
 msgstr ""
 msgstr ""
index 0a555e9..db1229c 100644 (file)
--- a/po/en.po
+++ b/po/en.po
@@ -7,218 +7,194 @@ msgid ""
 msgstr ""
 "Project-Id-Version: en\n"
 "Report-Msgid-Bugs-To: \n"
 msgstr ""
 "Project-Id-Version: en\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2006-09-18 21:50+0200\n"
+"POT-Creation-Date: 2007-02-21 17:48+0100\n"
 "PO-Revision-Date: 2005-01-02 17:13+0100\n"
 "PO-Revision-Date: 2005-01-02 17:13+0100\n"
-"Last-Translator: Pierre Habouzit <pierre.habouzit@m4x.org>\n"
+"Last-Translator: Florent Bruneau <florent.bruneau@m4x.org>\n"
 "Language-Team:  <en@li.org>\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Language-Team:  <en@li.org>\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
-"X-Generator: KBabel 1.9.1\n"
 
 
-#: ../banana/banana.inc.php:54 ../banana/banana.inc.php:119
-msgid "Impossible de contacter le serveur"
-msgstr "Server unreachable"
-
-#: ../banana/banana.inc.php:93 ../banana/banana.inc.php:169
-msgid "Voulez-vous vraiment annuler ce message ?"
-msgstr "Do you really want to cancel that post ?"
+#: ../banana/message.inc.php:49
+msgid "De"
+msgstr "From"
 
 
-#: ../banana/banana.inc.php:124
-msgid "Les forums de Banana"
-msgstr "Banana's Bewsgroups"
+#: ../banana/message.inc.php:50 template.php:27
+msgid "Sujet"
+msgstr "Subject"
 
 
-#: ../banana/banana.inc.php:126 ../banana/banana.inc.php:215
-msgid "Les forums suivants ont été créés depuis ton dernier passage :"
-msgstr "This newsgroups are recent :"
+#: ../banana/message.inc.php:51
+msgid "Forums"
+msgstr "Newsgroups"
 
 
-#: ../banana/banana.inc.php:140 ../banana/misc.inc.php:150
-msgid "Abonnements"
-msgstr "Subscription list"
+#: ../banana/message.inc.php:52
+msgid "Suivi à"
+msgstr "Followup-to"
 
 
-#: ../banana/banana.inc.php:175 ../banana/banana.inc.php:265
-#: ../banana/banana.inc.php:286
-msgid "Impossible d'accéder au message.   Le message a peut-être été annulé"
-msgstr "The post is not reachable.  It may have been canceled"
+#: ../banana/message.inc.php:53
+msgid "À"
+msgstr "To"
 
 
-#: ../banana/banana.inc.php:179
-msgid "Message"
-msgstr "Post"
+#: ../banana/message.inc.php:54
+msgid "Copie à"
+msgstr "Copy to"
 
 
-#: ../banana/banana.inc.php:194 ../banana/banana.inc.php:309
-msgid "Vous n'avez pas les permissions pour annuler ce message"
-msgstr "You are not allowed to cancel that post"
+#: ../banana/message.inc.php:55
+msgid "Copie cachée à"
+msgstr "Hidden copy to"
 
 
-#: ../banana/banana.inc.php:208 ../banana/banana.inc.php:328
-msgid "Impossible d'annuler le message"
-msgstr "Impossible to cancel that post"
+#: ../banana/message.inc.php:56
+msgid "Répondre à"
+msgstr "Reply to"
 
 
-#: ../banana/banana.inc.php:222 ../banana/banana.inc.php:352
-msgid "a écrit"
-msgstr "wrote"
-
-#: ../banana/banana.inc.php:230 ../banana/misc.inc.php:156
-msgid "Nouveau message"
-msgstr "New post"
+#: ../banana/message.inc.php:57 template.php:26
+msgid "Date"
+msgstr "Date"
 
 
-#: ../banana/banana.inc.php:233 ../banana/post.inc.php:100
-#: ../banana/banana.inc.php:371
-msgid "En-têtes"
-msgstr "Headers"
+#: ../banana/message.inc.php:58
+msgid "Organisation"
+msgstr "Organization"
 
 
-#: ../banana/banana.inc.php:234 ../banana/groups.inc.php:93
-#: ../banana/banana.inc.php:372
-msgid "Nom"
-msgstr "From"
+#: ../banana/message.inc.php:60
+msgid "Références"
+msgstr "References"
 
 
-#: ../banana/banana.inc.php:235 ../banana/misc.inc.php:34
-#: ../banana/spool.inc.php:360 ../banana/banana.inc.php:374
-msgid "Sujet"
-msgstr "Subject"
+#: ../banana/message.inc.php:61
+msgid "Image"
+msgstr "Image"
 
 
-#: ../banana/banana.inc.php:236 ../banana/misc.inc.php:35
-#: ../banana/banana.inc.php:376
-msgid "Forums"
-msgstr "NewsGroups"
+#: ../banana/page.inc.php:106
+msgid "Abonnements"
+msgstr "Subscriptions"
 
 
-#: ../banana/banana.inc.php:237 ../banana/banana.inc.php:378
-msgid "Suivi à"
-msgstr "Followup To"
+#: ../banana/page.inc.php:107
+msgid "Les forums"
+msgstr "The forums"
 
 
-#: ../banana/banana.inc.php:238 ../banana/misc.inc.php:38
-#: ../banana/banana.inc.php:380
-msgid "Organisation"
-msgstr "Organization"
+#: ../banana/page.inc.php:111
+msgid "Message"
+msgstr "Message"
 
 
-#: ../banana/banana.inc.php:239 ../banana/post.inc.php:111
-#: ../banana/banana.inc.php:382
-msgid "Corps"
-msgstr "Body"
+#: ../banana/page.inc.php:113
+msgid "Annulation"
+msgstr "Cancel"
 
 
-#: ../banana/banana.inc.php:275 ../banana/banana.inc.php:283
-msgid "Impossible de poster le message"
-msgstr "Impossible to post that message"
+#: ../banana/page.inc.php:115 template.php:17
+msgid "Répondre"
+msgstr "Reply"
 
 
-#: ../banana/groups.inc.php:87
-msgid "Total"
-msgstr "Total"
+#: ../banana/page.inc.php:118
+msgid "Nouveau"
+msgstr "New"
 
 
-#: ../banana/groups.inc.php:89
-msgid "Abo."
-msgstr "Sub."
+#: ../banana/page.inc.php:139
+msgid "La page demandée n'existe pas"
+msgstr "The requested page does not exist"
 
 
-#: ../banana/groups.inc.php:91
-msgid "Nouveaux"
-msgstr "New"
+#: ../banana/page.inc.php:311
+msgid "alt"
+msgstr "alt"
 
 
-#: ../banana/groups.inc.php:93
-msgid "Description"
-msgstr "Description"
+#: ../banana/spool.inc.php:389
+msgid "hier"
+msgstr "yesterday"
 
 
-#: ../banana/misc.inc.php:33
-msgid "De"
-msgstr "From"
+#: ../banana/spool.inc.php:448
+msgid "(pas de sujet)"
+msgstr "(no subject)"
 
 
-#: ../banana/misc.inc.php:36
-msgid "Suivi-à"
-msgstr "Followup To"
+#: template.php:2
+msgid "Les nouveaux groupes suivants ont été créés depuis votre dernière visite"
+msgstr "The following groups have been created since your last visit"
 
 
-#: ../banana/misc.inc.php:37 ../banana/spool.inc.php:359
-msgid "Date"
-msgstr "Date"
+#: template.php:3
+msgid "Voulez-vous vraiment annuler ce message ?"
+msgstr "Are you sure you want to cancel this message?"
 
 
-#: ../banana/misc.inc.php:39
-msgid "Références"
-msgstr "References"
+#: template.php:4
+msgid "Annuler !"
+msgstr "Cancel!"
 
 
-#: ../banana/misc.inc.php:40
-msgid "Image"
-msgstr "Image"
+#: template.php:5 template.php:10
+msgid "Valider"
+msgstr "Valid"
 
 
-#: ../banana/misc.inc.php:115
-msgid "hier"
-msgstr "yesterday"
+#: template.php:6
+msgid "Total"
+msgstr "Total"
 
 
-#: ../banana/misc.inc.php:148
-msgid "Liste des forums"
-msgstr "Newsgroups list"
+#: template.php:7
+msgid "Nouveaux"
+msgstr "News"
 
 
-#: ../banana/misc.inc.php:171
-msgid "Répondre"
-msgstr "Answer"
+#: template.php:8
+msgid "Nom"
+msgstr "Name"
 
 
-#: ../banana/misc.inc.php:174
-msgid "Annuler ce message"
-msgstr "Cancel post"
+#: template.php:9
+msgid "Description"
+msgstr "Description"
 
 
-#: ../banana/post.inc.php:114
-msgid "apercu"
-msgstr "preview"
+#: template.php:11 template.php:25
+msgid "Message non-lu suivant"
+msgstr "Next unread message"
 
 
-#: ../banana/spool.inc.php:361
-msgid "Auteur"
-msgstr "Author"
+#: template.php:12
+msgid "Message précédent"
+msgstr "Previous message"
 
 
-#: ../banana/spool.inc.php:372
-msgid "Aucun message dans ce forum"
-msgstr "No post in this newsgroup"
+#: template.php:13
+msgid "Message suivant"
+msgstr "Next message"
 
 
-#: ../banana/banana.inc.php:127
-msgid ""
-" : ce newsgroup n'existe pas ou vous n'avez pas l'autorisation d'y accéder"
-msgstr ""
+#: template.php:14
+msgid "Discussion précédente"
+msgstr "Previous thread"
 
 
-#: ../banana/banana.inc.php:237 ../banana/banana.inc.php:257
-#, fuzzy
-msgid "Impossible charger la liste des messages de "
-msgstr "Impossible to post that message"
+#: template.php:15
+msgid "Discussion suivante"
+msgstr "Next thread"
 
 
-#: ../banana/banana.inc.php:278 ../banana/banana.inc.php:300
-#: ../banana/banana.inc.php:420
-#, fuzzy
-msgid "Impossible charger la liste des messages"
-msgstr "Impossible to post that message"
+#: template.php:16 template.php:28
+msgid "Nouveau message"
+msgstr "New message"
 
 
-#: ../banana/banana.inc.php:293
-msgid "Impossible d'accéder à la pièce jointe."
-msgstr ""
+#: template.php:18
+msgid "Annuler"
+msgstr "Cancel"
 
 
-#: ../banana/banana.inc.php:304
-#, fuzzy
-msgid "Impossible de trouver le message à annuler"
-msgstr "Impossible to post that message"
+#: template.php:19
+msgid "Enregistrer"
+msgstr "Save"
 
 
-#: ../banana/banana.inc.php:386
-msgid "Pièce jointe"
-msgstr ""
+#: template.php:20
+msgid "Versions"
+msgstr "Versions"
 
 
-#: ../banana/banana.inc.php:396
-#, fuzzy
-msgid "Envoyer le message"
-msgstr "Cancel post"
+#: template.php:21
+msgid "Afficher les images externes"
+msgstr "Show external images"
 
 
-#: ../banana/banana.inc.php:434
-#, fuzzy
-msgid "Impossible charger le message d'origine"
-msgstr "Impossible to cancel that post"
+#: template.php:22
+msgid "Composer un nouveau message"
+msgstr "Write a new message"
 
 
-#: ../banana/banana.inc.php:457
-msgid "Fichier trop gros pour être envoyé : "
-msgstr ""
+#: template.php:23
+msgid "Fichier joint"
+msgstr "Attachment"
 
 
-#: ../banana/banana.inc.php:461
-msgid "Erreur lors de l'upload de "
-msgstr ""
+#: template.php:24
+msgid "Envoyer le message"
+msgstr "Send the message"
 
 
-#: ../banana/banana.inc.php:465
-msgid "Le fichier spécifié n'existe pas : "
-msgstr ""
+#: template.php:29
+msgid "Auteur"
+msgstr "Author"
 
 
-#: ../banana/banana.inc.php:469
-msgid "Une erreur est survenue sur le serveur lors de l'upload de "
-msgstr ""
+#: template.php:30
+msgid "Aperçu de "
+msgstr "Preview of "
 
 
-#: ../banana/banana.inc.php:486
-#, fuzzy
-msgid "Impossible de poster le message. Le serveur a retourné l'erreur :"
-msgstr "Impossible to post that message"
+#: template.php:31
+msgid "Aucun message dans ce forum"
+msgstr "No message on this forum"
index 09c0b96..d357e7e 100644 (file)
--- a/po/fr.po
+++ b/po/fr.po
@@ -7,218 +7,194 @@ msgid ""
 msgstr ""
 "Project-Id-Version: fr\n"
 "Report-Msgid-Bugs-To: \n"
 msgstr ""
 "Project-Id-Version: fr\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2006-09-18 21:50+0200\n"
+"POT-Creation-Date: 2007-02-21 17:48+0100\n"
 "PO-Revision-Date: 2005-01-02 17:13+0100\n"
 "PO-Revision-Date: 2005-01-02 17:13+0100\n"
-"Last-Translator: Pierre Habouzit <pierre.habouzit@m4x.org>\n"
+"Last-Translator: Florent Bruneau <florent.bruneau@m4x.org>\n"
 "Language-Team:  <fr@li.org>\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Language-Team:  <fr@li.org>\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
-"X-Generator: KBabel 1.9.1\n"
 
 
-#: ../banana/banana.inc.php:54 ../banana/banana.inc.php:119
-msgid "Impossible de contacter le serveur"
-msgstr "Impossible de contacter le serveur"
+#: ../banana/message.inc.php:49
+msgid "De"
+msgstr "De"
 
 
-#: ../banana/banana.inc.php:93 ../banana/banana.inc.php:169
-msgid "Voulez-vous vraiment annuler ce message ?"
-msgstr "Voulez-vous vraiment annuler ce message ?"
+#: ../banana/message.inc.php:50 template.php:27
+msgid "Sujet"
+msgstr "Sujet"
+
+#: ../banana/message.inc.php:51
+msgid "Forums"
+msgstr "Forums"
+
+#: ../banana/message.inc.php:52
+msgid "Suivi à"
+msgstr "Suivi à"
+
+#: ../banana/message.inc.php:53
+msgid "À"
+msgstr "À"
+
+#: ../banana/message.inc.php:54
+msgid "Copie à"
+msgstr "Copie à"
+
+#: ../banana/message.inc.php:55
+msgid "Copie cachée à"
+msgstr "Copie cachée à"
+
+#: ../banana/message.inc.php:56
+msgid "Répondre à"
+msgstr "Répondre à"
+
+#: ../banana/message.inc.php:57 template.php:26
+msgid "Date"
+msgstr "Date"
+
+#: ../banana/message.inc.php:58
+msgid "Organisation"
+msgstr "Organisation"
 
 
-#: ../banana/banana.inc.php:124
-msgid "Les forums de Banana"
-msgstr "Les forums de Banana"
+#: ../banana/message.inc.php:60
+msgid "Références"
+msgstr "Références"
 
 
-#: ../banana/banana.inc.php:126 ../banana/banana.inc.php:215
-msgid "Les forums suivants ont été créés depuis ton dernier passage :"
-msgstr "Les forums suivants ont été créés depuis ton dernier passage :"
+#: ../banana/message.inc.php:61
+msgid "Image"
+msgstr "Image"
 
 
-#: ../banana/banana.inc.php:140 ../banana/misc.inc.php:150
+#: ../banana/page.inc.php:106
 msgid "Abonnements"
 msgstr "Abonnements"
 
 msgid "Abonnements"
 msgstr "Abonnements"
 
-#: ../banana/banana.inc.php:175 ../banana/banana.inc.php:265
-#: ../banana/banana.inc.php:286
-msgid "Impossible d'accéder au message.   Le message a peut-être été annulé"
-msgstr "Impossible d'accéder au message.   Le message a peut-être été annulé"
+#: ../banana/page.inc.php:107
+msgid "Les forums"
+msgstr "Les forums"
 
 
-#: ../banana/banana.inc.php:179
+#: ../banana/page.inc.php:111
 msgid "Message"
 msgstr "Message"
 
 msgid "Message"
 msgstr "Message"
 
-#: ../banana/banana.inc.php:194 ../banana/banana.inc.php:309
-msgid "Vous n'avez pas les permissions pour annuler ce message"
-msgstr "Vous n'avez pas les permissions pour annuler ce message"
-
-#: ../banana/banana.inc.php:208 ../banana/banana.inc.php:328
-msgid "Impossible d'annuler le message"
-msgstr "Impossible d'annuler le message"
+#: ../banana/page.inc.php:113
+msgid "Annulation"
+msgstr "Annulation"
 
 
-#: ../banana/banana.inc.php:222 ../banana/banana.inc.php:352
-msgid "a écrit"
-msgstr "a écrit"
+#: ../banana/page.inc.php:115 template.php:17
+msgid "Répondre"
+msgstr "Répondre"
 
 
-#: ../banana/banana.inc.php:230 ../banana/misc.inc.php:156
-msgid "Nouveau message"
-msgstr "Nouveau message"
+#: ../banana/page.inc.php:118
+msgid "Nouveau"
+msgstr "Nouveau"
 
 
-#: ../banana/banana.inc.php:233 ../banana/post.inc.php:100
-#: ../banana/banana.inc.php:371
-msgid "En-têtes"
-msgstr "En-têtes"
+#: ../banana/page.inc.php:139
+msgid "La page demandée n'existe pas"
+msgstr "La page demandée n'existe pas"
 
 
-#: ../banana/banana.inc.php:234 ../banana/groups.inc.php:93
-#: ../banana/banana.inc.php:372
-msgid "Nom"
-msgstr "Nom"
+#: ../banana/page.inc.php:311
+msgid "alt"
+msgstr "alt"
 
 
-#: ../banana/banana.inc.php:235 ../banana/misc.inc.php:34
-#: ../banana/spool.inc.php:360 ../banana/banana.inc.php:374
-msgid "Sujet"
-msgstr "Sujet"
+#: ../banana/spool.inc.php:389
+msgid "hier"
+msgstr "hier"
 
 
-#: ../banana/banana.inc.php:236 ../banana/misc.inc.php:35
-#: ../banana/banana.inc.php:376
-msgid "Forums"
-msgstr "Forums"
+#: ../banana/spool.inc.php:448
+msgid "(pas de sujet)"
+msgstr "(pas de sujet)"
 
 
-#: ../banana/banana.inc.php:237 ../banana/banana.inc.php:378
-msgid "Suivi à"
-msgstr "Suivi à"
+#: template.php:2
+msgid "Les nouveaux groupes suivants ont été créés depuis votre dernière visite"
+msgstr "Les nouveaux groupes suivants ont été créés depuis votre dernière visite"
 
 
-#: ../banana/banana.inc.php:238 ../banana/misc.inc.php:38
-#: ../banana/banana.inc.php:380
-msgid "Organisation"
-msgstr "Organisation"
+#: template.php:3
+msgid "Voulez-vous vraiment annuler ce message ?"
+msgstr "Voulez-vous vraiment annuler ce message ?"
 
 
-#: ../banana/banana.inc.php:239 ../banana/post.inc.php:111
-#: ../banana/banana.inc.php:382
-msgid "Corps"
-msgstr "Corps"
+#: template.php:4
+msgid "Annuler !"
+msgstr "Annuler !"
 
 
-#: ../banana/banana.inc.php:275 ../banana/banana.inc.php:283
-msgid "Impossible de poster le message"
-msgstr "Impossible de poster le message"
+#: template.php:5 template.php:10
+msgid "Valider"
+msgstr "Valider"
 
 
-#: ../banana/groups.inc.php:87
+#: template.php:6
 msgid "Total"
 msgstr "Total"
 
 msgid "Total"
 msgstr "Total"
 
-#: ../banana/groups.inc.php:89
-msgid "Abo."
-msgstr "Abo."
-
-#: ../banana/groups.inc.php:91
+#: template.php:7
 msgid "Nouveaux"
 msgstr "Nouveaux"
 
 msgid "Nouveaux"
 msgstr "Nouveaux"
 
-#: ../banana/groups.inc.php:93
+#: template.php:8
+msgid "Nom"
+msgstr "Nom"
+
+#: template.php:9
 msgid "Description"
 msgstr "Description"
 
 msgid "Description"
 msgstr "Description"
 
-#: ../banana/misc.inc.php:33
-msgid "De"
-msgstr "De"
-
-#: ../banana/misc.inc.php:36
-msgid "Suivi-à"
-msgstr "Suivi-à"
-
-#: ../banana/misc.inc.php:37 ../banana/spool.inc.php:359
-msgid "Date"
-msgstr "Date"
-
-#: ../banana/misc.inc.php:39
-msgid "Références"
-msgstr "Références"
-
-#: ../banana/misc.inc.php:40
-msgid "Image"
-msgstr "Image"
+#: template.php:11 template.php:25
+msgid "Message non-lu suivant"
+msgstr "Message non-lu suivant"
 
 
-#: ../banana/misc.inc.php:115
-msgid "hier"
-msgstr "hier"
-
-#: ../banana/misc.inc.php:148
-msgid "Liste des forums"
-msgstr "Liste des forums"
-
-#: ../banana/misc.inc.php:171
-msgid "Répondre"
-msgstr "Répondre"
+#: template.php:12
+msgid "Message précédent"
+msgstr "Message précédent"
 
 
-#: ../banana/misc.inc.php:174
-msgid "Annuler ce message"
-msgstr "Annuler ce message"
+#: template.php:13
+msgid "Message suivant"
+msgstr "Message suivant"
 
 
-#: ../banana/post.inc.php:114
-msgid "apercu"
-msgstr "apercu"
+#: template.php:14
+msgid "Discussion précédente"
+msgstr "Discussion précédente"
 
 
-#: ../banana/spool.inc.php:361
-msgid "Auteur"
-msgstr "Auteur"
+#: template.php:15
+msgid "Discussion suivante"
+msgstr "Discussion suivante"
 
 
-#: ../banana/spool.inc.php:372
-msgid "Aucun message dans ce forum"
-msgstr "Aucun message dans ce forum"
+#: template.php:16 template.php:28
+msgid "Nouveau message"
+msgstr "Nouveau message"
 
 
-#: ../banana/banana.inc.php:127
-msgid ""
-" : ce newsgroup n'existe pas ou vous n'avez pas l'autorisation d'y accéder"
-msgstr ""
+#: template.php:18
+msgid "Annuler"
+msgstr "Annuler"
 
 
-#: ../banana/banana.inc.php:237 ../banana/banana.inc.php:257
-#, fuzzy
-msgid "Impossible charger la liste des messages de "
-msgstr "Impossible de poster le message"
+#: template.php:19
+msgid "Enregistrer"
+msgstr "Enregistrer"
 
 
-#: ../banana/banana.inc.php:278 ../banana/banana.inc.php:300
-#: ../banana/banana.inc.php:420
-#, fuzzy
-msgid "Impossible charger la liste des messages"
-msgstr "Impossible de poster le message"
+#: template.php:20
+msgid "Versions"
+msgstr "Versions"
 
 
-#: ../banana/banana.inc.php:293
-msgid "Impossible d'accéder à la pièce jointe."
-msgstr ""
+#: template.php:21
+msgid "Afficher les images externes"
+msgstr "Afficher les images externes"
 
 
-#: ../banana/banana.inc.php:304
-#, fuzzy
-msgid "Impossible de trouver le message à annuler"
-msgstr "Impossible de poster le message"
+#: template.php:22
+msgid "Composer un nouveau message"
+msgstr "Composer un nouveau message"
 
 
-#: ../banana/banana.inc.php:386
-msgid "Pièce jointe"
-msgstr ""
+#: template.php:23
+msgid "Fichier joint"
+msgstr "Fichier joint"
 
 
-#: ../banana/banana.inc.php:396
-#, fuzzy
+#: template.php:24
 msgid "Envoyer le message"
 msgid "Envoyer le message"
-msgstr "Annuler ce message"
+msgstr "Envoyer le message"
 
 
-#: ../banana/banana.inc.php:434
-#, fuzzy
-msgid "Impossible charger le message d'origine"
-msgstr "Impossible d'annuler le message"
-
-#: ../banana/banana.inc.php:457
-msgid "Fichier trop gros pour être envoyé : "
-msgstr ""
-
-#: ../banana/banana.inc.php:461
-msgid "Erreur lors de l'upload de "
-msgstr ""
-
-#: ../banana/banana.inc.php:465
-msgid "Le fichier spécifié n'existe pas : "
-msgstr ""
+#: template.php:29
+msgid "Auteur"
+msgstr "Auteur"
 
 
-#: ../banana/banana.inc.php:469
-msgid "Une erreur est survenue sur le serveur lors de l'upload de "
-msgstr ""
+#: template.php:30
+msgid "Aperçu de "
+msgstr "Aperçu de "
 
 
-#: ../banana/banana.inc.php:486
-#, fuzzy
-msgid "Impossible de poster le message. Le serveur a retourné l'erreur :"
-msgstr "Impossible de poster le message"
+#: template.php:31
+msgid "Aucun message dans ce forum"
+msgstr "Aucun message dans ce forum"