* $matches[2] = "http://www.polytechnique.org"
* $matches[3] = "]"
*/
- var $url_regexp = '(["\[])?((?:https?|ftp|news)://(?:&|,?[a-z@0-9.~%$£µ&i#\-+=_/\?])*)(["\]])?';
+ var $url_regexp = '(["\[])?((?:https?|ftp|news)://(?:&|,*[a-z@0-9.~%$£µ&i#\-+=_/\?])*)(["\]])?';
/** Boundary for multipart messages
}
if (!$banana->nntp) {
- return '<p class="error">'._b_('Impossible de contacter le serveur').'</p>';
+ $banana->state['page'] = 'error';
+ return makeTable('<p class="error">'._b_('Impossible de contacter le serveur').'</p>');
}
$group = empty($banana->get['group']) ? null : $banana->get['group'];
if (!is_null($group)
&& isset($banana->grp_pattern) && !preg_match('/' . $banana->grp_pattern . '/', $group)) {
- return '<p class="error">'
+ $banana->state['page'] = 'error';
+ return makeTable('<p class="error">'
. $group . _b_(' : ce newsgroup n\'existe pas ou vous n\'avez pas l\'autorisation d\'y accéder')
- . '</p>';
+ . '</p>');
}
$artid = empty($banana->get['artid']) ? null : strtolower($banana->get['artid']);
$partid = !isset($banana->get['part']) ? -1 : $banana->get['part'];
if (is_null($group)) {
if (isset($banana->get['subscribe'])) {
+ $banana->state['page'] = 'subscribe';
return makeTable($banana->action_listSubs());
} elseif (isset($_POST['validsubs'])) {
$banana->action_saveSubs();
}
+ $banana->state['page'] = 'forums';
return makeTable($banana->action_listGroups());
} elseif (is_null($artid)) {
if (isset($_POST['action']) && $_POST['action'] == 'new') {
return makeTable($banana->action_doFup($group, isset($_POST['artid']) ? intval($_POST['artid']) : -1));
} elseif ($action == 'new') {
+ $banana->state['page'] = 'action';
return makeTable($banana->action_newFup($group));
} else {
+ $banana->state['page'] = 'group';
return makeTable($banana->action_showThread($group, isset($banana->get['first']) ? intval($banana->get['first']) : 1));
}
}
if (!is_null($action)) {
+ $banana->state['page'] = 'action';
switch ($action) {
case 'cancel':
$res .= $banana->action_showArticle($group, $artid, $partid);
return makeTable($res . $att);
}
+ $banana->state['page'] = 'message';
return makeTable($banana->action_showArticle($group, $artid, $partid));
}
}
. "\n"
. "Message canceled with Banana";
if ($this->nntp->post($msg)) {
+ $ndx = $this->spool->getndx($artid) - 1;
+ if ($ndx > 50) {
+ $ndx = 0;
+ }
$this->spool->delid($id);
$this->nntp->quit();
redirectInBanana(Array('group' => $group,
- 'first' => $id));
+ 'first' => $ndx));
} else {
return '<p class="error">'._b_('Impossible d\'annuler le message').'</p>';
}
$subject = $body = '';
$target = $group;
- if ($id > 0) {
+ if (@$_POST['action'] == 'new') {
+ $subject = $_POST['subject'];
+ $body = $_POST['body'];
+ $target = $_POST['newsgroups'];
+ $followup = $_POST['followup'];
+ $this->state['page'] = 'action';
+ $this->state['group'] = $group;
+ $this->state['action'] = 'new';
+ if ($id != -1) {
+ $this->state['artid'] = $id;
+ }
+ } elseif ($id > 0) {
$this->nntp->group($group);
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'];
+ $subject = 'Re: ' . preg_replace("/^re\s*:\s*/i", '', $this->post->headers['subject']);
+ $body = to_entities(utf8_encode($this->post->name." "._b_("a écrit"))." :\n"
+ . wrap($this->post->get_body(), "> ")
+ . ($this->profile['sig'] ? "\n\n-- \n". $this->profile['sig'] : ''));
+ $target = isset($this->post->headers['followup-to']) ?
+ $this->post->headers['followup-to'] : $this->post->headers['newsgroups'];
+ $followup = null;
}
+ } else {
+ $targe = $group;
+ $subject = $followup = null;
+ $body = $this->profile['sig'] ? "\n\n-- \n". $this->profile['sig'] : '';
}
$this->nntp->quit();
$html = '<form enctype="multipart/form-data" action="'
. htmlentities(makeLink(Array('group' => $group)))
- .'" method="post" accept-charset="utf-8">';
- $html .= '<table class="bicol" cellpadding="0" cellspacing="0">';
- $html .= '<tr><th colspan="2">'._b_('En-têtes').'</th></tr>';
- $html .= '<tr><td>'._b_('Nom').'</td><td>'.htmlentities($this->profile['name']).'</td></tr>';
- $html .= '<tr><td>'._b_('Sujet').'</td><td><input type="text" name="subject" value="'.htmlentities($subject).'" size="60" /></td></tr>';
- $html .= '<tr><td>'._b_('Forums').'</td><td><input type="text" name="newsgroups" value="'.htmlentities($target).'" size="60" /></td></tr>';
- $html .= '<tr><td>'._b_('Suivi à').'</td><td><input type="text" name="followup" value="" size="60" /></td></tr>';
- $html .= '<tr><td>'._b_('Organisation').'</td><td>'.$this->profile['org'].'</td></tr>';
- $html .= '<tr><th colspan="2">'._b_('Corps').'</th></tr>';
- $html .= '<tr><td colspan="2"><textarea name="body" cols="74" rows="16">'
- . to_entities($body).($this->profile['sig'] ? "\n\n-- \n".htmlentities($this->profile['sig']) : '').'</textarea></td></tr>';
+ . '" method="post" accept-charset="utf-8">'
+ . '<table class="bicol" cellpadding="0" cellspacing="0">'
+ . '<tr><th colspan="2">' . _b_('En-têtes') . '</th></tr>'
+ . '<tr><td>' . _b_('Nom') . '</td>'
+ . '<td>' . htmlentities($this->profile['name']) . '</td></tr>'
+ . '<tr><td>' . _b_('Sujet') . '</td>'
+ . '<td><input type="text" name="subject" value="' . htmlentities($subject) . '" size="60" /></td></tr>'
+ . '<tr><td>' . _b_('Forums') . '</td>'
+ . '<td><input type="text" name="newsgroups" value="' . htmlentities($target) . '" size="60" /></td></tr>'
+ . '<tr><td>' . _b_('Suivi à') . '</td>'
+ . '<td><input type="text" name="followup" value="' . htmlentities($followup). '" size="60" /></td></tr>'
+ . '<tr><td>' . _b_('Organisation') . '</td>'
+ . '<td>' . $this->profile['org'] . '</td></tr>'
+ . '<tr><th colspan="2">' . _b_('Corps') . '</th></tr>'
+ . '<tr><td colspan="2"><textarea name="body" cols="74" rows="16">'
+ . $body . '</textarea></td></tr>';
if ($this->can_attach) {
- $html .= '<tr><th colspan="2">'._b_('Pièce jointe').'</th></tr>';
- $html .= '<tr><td colspan="2"><input type="hidden" name="MAX_FILE_SIZE" value="'.$this->maxfilesize.'" />';
- $html .= '<input type="file" name="newpj" size="40"/></td></tr>';
+ $html .= '<tr><th colspan="2">' . _b_('Pièce jointe') . '</th></tr>'
+ . '<tr><td colspan="2">'
+ . '<input type="hidden" name="MAX_FILE_SIZE" value="' . $this->maxfilesize . '" />'
+ . '<input type="file" name="newpj" size="40"/></td></tr>';
}
$html .= '<tr><th colspan="2">';
- if ($id > 0) {
- $html .= '<input type="hidden" name="artid" value="'.$id.'" />';
+ if ($id != -1) {
+ $html .= '<input type="hidden" name="artid" value="' . $id . '" />';
}
- $html .= '<input type="hidden" name="action" value="new" />';
- $html .= '<input type="submit" value="Envoyer le message" /></th></tr>';
- $html .= '</table></form>';
+ $html .= '<input type="hidden" name="action" value="new" />'
+ . '<input type="submit" value="' . _b_('Envoyer le message') . '" /></th></tr>'
+ . '</table></form>';
return $html;
}
function action_doFup($group, $artid = -1)
{
- if ( ! ( is_utf8($_POST['subject']) && is_utf8($_POST['name'])
- && is_utf8($_POST['org']) && is_utf8($_POST['body']) )
- ) {
- foreach(array('subject', 'name', 'org', 'body') as $key) {
+ if ( ! (is_utf8($_POST['subject']) && is_utf8($_POST['body']))) {
+ foreach(Array('subject', 'body') as $key) {
$_POST[$key] = utf8_encode($_POST[$key]);
}
}
if ($this->nntp->post($msg)) {
$dir = Array('group' => $group);
if ($artid != -1) {
- $dir['first'] = $artid;
+ $ndx = $this->spool->getndx($artid);
+ if ($ndx > 50) {
+ $dir['first'] = $ndx;
+ }
}
redirectInBanana($dir);
} else {
- return '<p class="error">' . _b_('Impossible de poster le message') . '</p>'
- . $this->action_showThread($group, $artid);
+ return '<p class="error">' . _b_('Impossible de poster le message. Le serveur a retourné l\'erreur :') . '</p>'
+ . '<pre class="error">' . utf8_encode($this->nntp->lasterrortext) .'</pre>'
+ . $this->action_newFup($group, $artid);
}
}