X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=banana%2Fbanana.inc.php.in;h=1c42095824dc175d366e8a7bda0a172b7e9dfb2b;hb=8e519bd883bd22d554f4032a495816a29980f8d0;hp=0ca84e0d174324f5ed6cf539e18637910afb360d;hpb=fb6bea16dde5f04a8927411401eac9d47fb0c0a7;p=banana.git diff --git a/banana/banana.inc.php.in b/banana/banana.inc.php.in index 0ca84e0..1c42095 100644 --- a/banana/banana.inc.php.in +++ b/banana/banana.inc.php.in @@ -87,6 +87,9 @@ class Banana $this->_require('NetNNTP'); setlocale(LC_ALL, $this->profile['locale']); $this->nntp = new nntp($this->host); + if (!$this->nntp || !$this->nntp->valid) { + $this->nntp = null; + } } function run($class = 'Banana') @@ -202,7 +205,9 @@ class Banana function action_showThread($group, $first) { - $this->_newSpool($group, $this->profile['display'], $this->profile['lastnews']); + if (!$this->_newSpool($group, $this->profile['display'], $this->profile['lastnews'])) { + return '

'._b_('Impossible charger la liste des messages').'

'; + } if ($first > count($this->spool->overview)) { $first = count($this->spool->overview); @@ -222,9 +227,11 @@ class Banana function action_showArticle($group, $id, $part) { - $this->_newSpool($group, $this->profile['display'], $this->profile['lastnews']); - $this->_newPost($id); - if (!$this->post) { + if (!$this->_newSpool($group, $this->profile['display'], $this->profile['lastnews'])) { + return '

'._b_('Impossible charger la liste des messages').'

'; + } + + if (!$this->_newPost($id)) { if ($this->nntp->lasterrorcode == "423") { $this->spool->delid($id); } @@ -243,9 +250,11 @@ class Banana function action_getAttachment($group, $id, $pjid, $action) { - $this->_newSpool($group, $this->profile['display'], $this->profile['lastnews']); - $this->_newPost($id); - if (!$this->post) { + if (!$this->_newSpool($group, $this->profile['display'], $this->profile['lastnews'])) { + return '

'._b_('Impossible charger la liste des messages').'

'; + } + + if (!$this->_newPost($id)) { if ($this->nntp->lasterrorcode == "423") { $this->spool->delid($id); } @@ -263,8 +272,13 @@ class Banana function action_cancelArticle($group, $id) { - $this->_newSpool($group, $this->profile['display'], $this->profile['lastnews']); - $this->_newPost($id); + if (!$this->_newSpool($group, $this->profile['display'], $this->profile['lastnews'])) { + return '

'._b_('Impossible charger la liste des messages').'

'; + } + + if (!$this->_newPost($id)) { + return '

'._b_('Impossible de trouver le message à annuler').'

'; + } $mid = array_search($id, $this->spool->ids); if (!$this->post->checkcancel()) { @@ -280,7 +294,7 @@ class Banana if ($this->nntp->post($msg)) { $this->spool->delid($id); $this->nntp->quit(); - header("Location: ?group=$group&first=$id"); + redirect('group=' . $group . '&first=' . $id); } else { return '

'._b_('Impossible d\'annuler le message').'

'; } @@ -293,8 +307,7 @@ class Banana if ($id > 0) { $this->nntp->group($group); - $this->_newPost($id); - if ($this->post) { + if ($this->_newPost($id)) { $subject = preg_replace("/^re\s*:\s*/i", '', 'Re: '.$this->post->headers['subject']); $body = utf8_encode($this->post->name." "._b_("a écrit"))." :\n".wrap($this->post->get_body(), "> "); $target = isset($this->post->headers['followup-to']) ? $this->post->headers['followup-to'] : $this->post->headers['newsgroups']; @@ -326,7 +339,7 @@ class Banana $html .= ''; } $html .= ''; - $html .= ''; + $html .= ''; $html .= ''; return $html.$cuts; @@ -342,18 +355,32 @@ class Banana } } - $to = preg_replace('/\s*(,|;)\s*/', ',', $_POST['newsgroups']); - $this->_newSpool($group, $this->profile['display'], $this->profile['lastnews']); + $forums = preg_split('/\s*(,|;)\s*/', $_POST['newsgroups']); + $fup = $_POST['followup']; + if (sizeof($forums) > 1) { + if (empty($fup)) { + $fup = $forums[0]; + } + } + $to = implode(',', $forums); + + if (!$this->_newSpool($group, $this->profile['display'], $this->profile['lastnews'])) { + return '

'._b_('Impossible charger la liste des messages').'

'; + } + $body = preg_replace("/\n\.[ \t\r]*\n/m", "\n..\n", $_POST['body']); - $msg = 'From: '.$this->profile['name']."\n" + $msg = 'From: ' . $this->profile['name'] . "\n" . "Newsgroups: ". $to . "\n" - . "Subject: ".headerEncode($_POST['subject'], 128)."\n" + . "Subject: " . headerEncode($_POST['subject'], 128) . "\n" . (empty($this->profile['org']) ? '' : "Organization: {$this->profile['org']}\n") - . (empty($_POST['followup']) ? '' : 'Followup-To: '.$_POST['followup']."\n"); + . (empty($fup) ? '' : 'Followup-To: ' . $fup . "\n"); if ($artid != -1) { $this->_require('post'); $post = new BananaPost($artid); + if (!$post || !$post->valid) { + return '

'._b_('Impossible charger le message d\'origine').'

'; + } $refs = ( isset($post->headers['references']) ? $post->headers['references']." " : "" ); $msg .= "References: $refs{$post->headers['message-id']}\n"; } @@ -398,7 +425,7 @@ class Banana $msg .= $this->custom.$this->profile['customhdr']."\n".$body; if ($this->nntp->post($msg)) { - header("Location: ?group=$group".($artid==-1 ? '' : "&first=$artid")); + redirect('group=' . $group . ($artid == -1 ? '' : '&first=' . $artid)); } else { return "

"._b_('Impossible de poster le message')."

".$this->action_showThread($group, $artid); } @@ -412,13 +439,23 @@ class Banana $this->_require('spool'); if (!$this->spool || $this->spool->group != $group) { $this->spool = new BananaSpool($group, $disp, $since); + if (!$this->spool || !$this->spool->valid) { + $this->spool = null; + return false; + } } + return true; } function _newPost($id) { $this->_require('post'); $this->post = new BananaPost($id); + if (!$this->post || !$this->post->valid) { + $this->post = null; + return false; + } + return true; } function _newGroup()