$error = $this->action_listBoxes();
break;
case Banana::ACTION_BOX_FEED:
- return $this->action_feed(); // generate its own xml
+ $this->action_feed(); // generate its own xml
+ break;
case Banana::ACTION_MSG_LIST:
$error = $this->action_showThread(Banana::$group, Banana::$first);
break;
Banana::load('feed');
if (Banana::$group) {
$feed =& BananaFeed::getFeed();
- return $feed->toXML();
+ $feed->toXML();
}
if (Banana::$profile['subscribe']) {
$subfeed = null;
$feed =& BananaFeed::getFeed();
$subfeed =& BananaFeed::merge($subfeed, $feed, _b_('Abonnements'), _b_('Mes abonnements Banana'));
}
- return $subfeed->toXML();
+ $subfeed->toXML();
}
- return Banana::$page->feed();
+ Banana::$page->feed();
}
protected function action_showThread($group, $first)
<?php
/********************************************************************************
-* index.php : main page (newsgroups list)
+* index.php : Banana NNTP client example
* -----------
*
* This file is part of the banana distribution
session_start();
+// Some configuration
+Banana::$nntp_host = 'news://user:password@host:119/'; // where is the news server
+Banana::$spool_root = dirname(__FILE__) . '/spool'; // where to store cache files
+Banana::$debug_nntp = false; // if true, show the NNTP backtrace
+Banana::$debug_smarty = false; // if true, shos php-error in page generation
+Banana::$feed_active = true; // Activate RSS feed
+
+// Implement a Banana which stores subscription list in a cookie
class MyBanana extends Banana
{
protected function action_saveSubs($groups)
{
parent::action_saveSubs($groups);
- setcookie('banana_subs', serialize(Banana::$profile['subscribe']));
+ setcookie('banana_subs', serialize(Banana::$profile['subscribe']), time() + 25920000);
return true;
}
}
+// Restore subscription list
if (isset($_COOKIE['banana_subs'])) {
Banana::$profile['subscribe'] = unserialize($_COOKIE['banana_subs']);
}
+
+// Compute and set last visit time
if (!isset($_SESSION['banana_lastnews']) && isset($_COOKIE['banana_lastnews'])) {
$_SESSION['banana_lastnews'] = $_COOKIE['banana_lastnews'];
+} else if (!isset($_SESSION['banana_lastnews'])) {
+ $_SESSION['banana_lastnews'] = 0;
}
-if (isset($_SESSION['banana_lastnews'])) {
- Banana::$profile['lastnews'] = $_SESSION['banana_lastnews'];
-}
-setcookie('banana_lastnews', time());
+Banana::$profile['lastnews'] = $_SESSION['banana_lastnews'];
+setcookie('banana_lastnews', time(), time() + 25920000);
-$banana = new MyBanana();
-$res = $banana->run();
-$css = $banana->css();
-$bt = $banana->backtrace();
+// Run Bananan
+$banana = new MyBanana(); // Create the instance of Banana
+$res = $banana->run(); // Run banana, and generate the XHTML output
+$css = $banana->css(); // Get the CSS code to add in my page headers
+$feed = $banana->feed(); // Get a link to banana's feed. You need to use Banana::refreshAllFeeds in a cron or enable Banana::$feed_updateOnDemand in order to keep up-to-date feeds
+$bt = $banana->backtrace(); // Get protocole execution backtrace
session_write_close();
+// Genererate the page
?>
<!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">
<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">
+<?php if ($feed) { ?>
+ <link rel="alternate" type="application/rss+xml" title="Banana :: Abonnements" href="<?php echo htmlentities($feed); ?>" />
+<?php } ?>
<?php if ($css) { ?>
<style type="text/css">
<?php echo $css; ?>
Use <em>silk</em> icons from <a href="http://www.famfamfam.com/lab/icons/silk/">www.famfamfam.com</a>
</div>
<?php
+ // Generate the protocole Backtrace at the bottom of the page
if ($bt) {
echo "<div class=\"backtrace\">";
foreach ($bt as &$entry) {
require_once("banana/banana.inc.php");
-$opt = getopt('u:p:h');
+$opt = getopt('u:P:p:hfr:');
if(isset($opt['h'])) {
echo <<<EOF
-usage: spoolgen.php [ -u user ] [ -p pass ]
+usage: spoolgen.php [-h] [-f] [ -u user ] [ -p pass ] [ -P port ] [ -r spool_root ]
create all spools, using user user and pass pass
+ if -f is set, also refresh the RSS feed
EOF;
exit;
}
-Banana::$nntp_host = "news://{$opt['u']}:{$opt['p']}@localhost:119/\n";
-Banana::createAllSpool(array('NNTP'));
+if (!isset($opt['P'])) {
+ $opt['P'] = '119';
+}
+Banana::$nntp_host = "news://{$opt['u']}:{$opt['p']}@localhost:{$opt['P']}/\n";
+if (isset($opt['r'])) {
+ Banana::$spool_root = $opt['r'];
+}
+if (isset($opt['f'])) {
+ Banana::createAllSpool(array('NNTP'));
+} else {
+ Banana::refreshAllFeeds(array('NNTP'));
+}
// vim:set et sw=4 sts=4 ts=4
?>