/* Private functions */
/**************************************************************************/
- private function loadSpool($group)
+ protected function loadSpool($group)
{
Banana::load('spool');
if (!Banana::$spool || Banana::$spool->group != $group) {
return true;
}
- private function &loadMessage($group, $artid)
+ protected function &loadMessage($group, $artid)
{
Banana::load('message');
if ($group == @$_SESSION['banana_group'] && $artid == @$_SESSION['banana_artid']
return $message;
}
- private function removeMessage($group, $artid)
+ protected function removeMessage($group, $artid)
{
Banana::$spool->delId($artid);
if ($group == $_SESSION['banana_group']) {
class BananaMBox implements BananaProtocoleInterface
{
- private $boxname;
-
private $file = null;
private $filesize = null;
private $current_id = null;
/** Build a protocole handler plugged on the given box
*/
- public function __construct($box = null)
+ public function __construct()
{
- $this->boxname = $box;
- $filename = $this->getFileName($box);
+ $filename = $this->getFileName(Banana::$group);
if (is_null($filename)) {
return;
}
*/
public function isValid()
{
- return is_null($this->boxname) || !is_null($this->file);
+ return !Banana::$group || $this->file;
}
/** Indicate last error n°
*/
public function getBoxList($mode = Banana::BOXES_ALL, $since = 0, $withstats = false)
{
- return array($this->boxname => array('desc' => '', 'msgnum' => 0, 'unread' => 0));
+ return array(Banana::$group => array('desc' => '', 'msgnum' => 0, 'unread' => 0));
}
/** Return a message
class BananaNNTP extends BananaNNTPCore implements BananaProtocoleInterface
{
- private $groupname = null;
private $description = null;
private $ingroup = null;
/** Build a protocole handler plugged on the given box
*/
- public function __construct($box = null)
+ public function __construct()
{
$url = parse_url(Banana::$host);
if ($url['scheme'] == 'nntps' || $url['scheme'] == 'snntp') {
parent::__construct($url['host'], $url['port'], 120, false);
$this->authinfo($url['user'], $url['pass']);
}
- $this->groupname = $box;
}
/** Return the descript;ion of the current box
if ($this->description) {
return $this->description;
}
- $descs = $this->xgtitle($this->groupname);
- if (isset($descs[$this->groupname])) {
- $this->description = $descs[$this->groupname];
+ $descs = $this->xgtitle(Banana::$group);
+ if (isset($descs[Banana::$group])) {
+ $this->description = $descs[Banana::$group];
}
return $this->description;
}
*/
public function getMessage($id, array $msg_headers = array(), $is_msgid = false)
{
- if (!$is_msgid && $this->groupname != $this->ingroup) {
+ if (!$is_msgid && Banana::$group != $this->ingroup) {
if (is_null(Banana::$spool)) {
- $this->group($this->groupname);
- $this->ingroup = $this->groupname;
+ $this->group(Banana::$group);
+ $this->ingroup = Banana::$group;
} else {
$id = array_search($id, Banana::$spool->ids);
}
*/
public function getIndexes()
{
- list($msgnum, $first, $last, $groupname) = $this->group($this->groupname);
- $this->ingroup = $this->groupname;
+ list($msgnum, $first, $last, $groupname) = $this->group(Banana::$group);
+ $this->ingroup = Banana::$group;
return array($msgnum, $first, $last);
}
*/
public function getNewIndexes($since)
{
- return $this->newnews($this->groupname, $since);
+ return $this->newnews(Banana::$group, $since);
}
/** Return true if can post
public function cancel(BananaMessage &$message)
{
$headers = Array('From' => Banana::$profile['From'],
- 'Newsgroups' => $this->groupname,
+ 'Newsgroups' => Banana::$group,
'Subject' => 'cmsg ' . $message->getHeaderValue('message-id'),
'Control' => 'cancel ' . $message->getHeaderValue('message-id'));
$headers = array_merge($headers, Banana::$custom_hdr);
{
/** Build a protocole handler plugged on the given box
*/
- public function __construct($box = null);
+ public function __construct();
/** Indicate if the Protocole handler has been succesfully built
*/
********************************************************************************/
require_once("banana/banana.inc.php");
-$res = Banana::run();
+$banana = new Banana();
+$res = $banana->run();
if ($res != "") {
?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
- charset=iso-8859-1">
+ charset=UTF-8">
<meta name="description" content="WebForum2/Banana">
<link href="css/style.css" type="text/css" rel="stylesheet" media="screen">
<link href="css/banana.css" type="text/css" rel="stylesheet" media="screen">
-#! /usr/bin/php4
+#!/usr/bin/php5
<?php
/********************************************************************************
* spoolgen.php : spool generation
class MyBanana extends Banana
{
- function MyBanana()
+ public function __construct()
{
global $opt;
- $this->host = "http://{$opt['u']}:{$opt['p']}@localhost:119/";
- echo $this->host;
- parent::Banana();
+ Banana::$host = "news://{$opt['u']}:{$opt['p']}@localhost:119/\n";
+ echo Banana::$host;
+ parent::__construct();
}
- function createAllSpool()
+ private function checkErrors()
{
- $this->_require('groups');
- $this->_require('spool');
- $this->_require('misc');
+ if (Banana::$protocole->lastErrno()) {
+ echo "\nL'erreur suivante s'est produite : "
+ . Banana::$protocole->lastErrno() . " "
+ . Banana::$protocole->lastError() . "\n";
+ exit;
+ }
+ }
- $groups = new BananaGroups(BANANA_GROUP_ALL);
+ public function createAllSpool()
+ {
+ $this->checkErrors();
+ $groups = Banana::$protocole->getBoxList();
+ $this->checkErrors();
- foreach (array_keys($groups->overview) as $g) {
+ foreach (array_keys($groups) as $g) {
print "Generating spool for $g : ";
- $spool = new BananaSpool($g);
+ Banana::$group = $g;
+ $spool = $this->loadSpool($g);
+ $this->checkErrors();
print "done.\n";
unset($spool);
}
- $this->nntp->quit();
}
}