*/
public function __construct()
{
- $url = parse_url(Banana::$host);
+ $url = parse_url(Banana::$nntp_host);
if ($url['scheme'] == 'nntps' || $url['scheme'] == 'snntp') {
$url['host'] = 'ssl://' . $url['host'];
}
/** Return a message
* @param id Id of the emssage (can be either an Message-id or a message index)
- * @param msg_headers Headers to process
- * @param is_msgid If is set, $id is en Message-Id
* @return A BananaMessage or null if the given id can't be retreived
*/
- public function getMessage($id, array $msg_headers = array(), $is_msgid = false)
+ public function &getMessage($id)
{
- if (!$is_msgid && Banana::$group != $this->ingroup) {
+ $message = null;
+ if (is_numeric($id) && Banana::$group != $this->ingroup) {
if (is_null(Banana::$spool)) {
$this->group(Banana::$group);
$this->ingroup = Banana::$group;
}
$data = $this->article($id);
if ($data !== false) {
- return new BananaMessage($data);
+ $message = new BananaMessage($data);
}
- return null;
+ return $message;
+ }
+
+ /** Return the sources of the message
+ */
+ public function getMessageSource($id)
+ {
+ if (is_numeric($id) && Banana::$group != $this->ingroup) {
+ if (is_null(Banana::$spool)) {
+ $this->group(Banana::$group);
+ $this->ingroup = Banana::$group;
+ } else {
+ $id = array_search($id, Banana::$spool->ids);
+ }
+ }
+ $data = $this->article($id);
+ if ($data !== false) {
+ return implode("\n", $data);
+ }
+ $data = null;
+ return $data;
}
/** Return the indexes of the messages presents in the Box
'Newsgroups' => Banana::$group,
'Subject' => 'cmsg ' . $message->getHeaderValue('message-id'),
'Control' => 'cancel ' . $message->getHeaderValue('message-id'));
- $headers = array_merge($headers, Banana::$custom_hdr);
+ $headers = array_merge($headers, Banana::$msgedit_headers);
$body = 'Message canceled with Banana';
$msg = BananaMessage::newMessage($headers, $body);
return $this->send($msg);
{
return 'NNTP';
}
-}
-/*
-require_once dirname(__FILE__) . '/spool.inc.php';
-$time = microtime(true);
-$nntp = new BananaNNTP('xorg.promo.x2002');
-if (!$nntp->isValid()) {
- echo "Beuh !\n";
- exit;
+ /** Return the filename for the spool
+ */
+ public function filename()
+ {
+ $url = parse_url(Banana::$nntp_host);
+ $file = '';
+ if (isset($url['host'])) {
+ $file .= $url['host'] . '_';
+ }
+ if (isset($url['port'])) {
+ $file .= $url['port'] . '_';
+ }
+ $file .= Banana::$group;
+ return $file;
+ }
}
-Banana::$protocole =& $nntp;
-Banana::$spool =& BananaSpool::getSpool('xorg.promo.x2002');
-$msg = $nntp->getMessage(3424);
-echo '<html><head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <link rel="stylesheet" type="text/css" href="css/banana.css"/>
-</head><body><table class="banana_msg"><tr><td>';
-//echo $msg->getFormattedBody('plain');
-echo $msg->getFormattedBody();
-echo '</td></tr></table></body></html>', "\n";
-$end = microtime(true);
-echo ($end - $time) . "s\n";
-*/
-
-// vim:set et sw=4 sts=4 ts=4:
+
+// vim:set et sw=4 sts=4 ts=4 enc=utf-8:
?>