X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=examples%2Findex.php;h=5ce833e9d4eedf81b84dafaaf169c40b76d2dbf9;hb=257640d8dbfbebbad42f6d6706a8ec27fa6db9ad;hp=5b19df956ee59b6631bab7814513f13808016af4;hpb=0e25d15dfb73aa6769f8b0d136974f36f1b3619f;p=banana.git diff --git a/examples/index.php b/examples/index.php index 5b19df9..5ce833e 100644 --- a/examples/index.php +++ b/examples/index.php @@ -1,6 +1,6 @@ run(); -if ($res != "") { +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 +Banana::$feed_updateOnDemand = true; // Update the feed cache when it is acceeded + +// 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']), time() + 25920000); + return true; + } +} + +// Minimalist login +if ((@$_GET['action'] == 'rss2') || + (!isset($_SESSION['banana_email']) || isset($_POST['change_login']) || isset($_POST['valid_change']))) { + if (isset($_COOKIE['banana_email']) && !isset($_POST['change_login']) && !isset($_POST['valid_change'])) { + $_SESSION['banana_email'] = $_COOKIE['banana_email']; + $_SESSION['banana_name'] = $_COOKIE['banana_name']; + } elseif (isset($_POST['valid_change'])) { + $_SESSION['banana_name'] = $_POST['name']; + $_SESSION['banana_email'] = $_POST['email']; + setcookie('banana_name', $_POST['name'], time() + 25920000); + setcookie('banana_email', $_POST['email'], time() + 25920000); + } else { +?> + + + + + + + Banana, a NNTP<->Web Gateway + + +
+

Les Forums de Banana

+ Merci d'entrer vos identifiants pour accéder à Banana : +
+
+ Nom :
+ Email : +
+ +
+
+
+
+ Banana, a Web interface for a NNTP Server
+ Developed under GPL License for Polytechnique.org
+ Use silk icons from www.famfamfam.com +
+
+ + +'; +Banana::$profile['lastnews'] = $_SESSION['banana_lastnews']; +setcookie('banana_lastnews', time(), time() + 25920000); + +// 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 ?> - - - - + + + + + + + + + + Banana, a NNTP<->Web Gateway
- +

Les Forums de Banana

+ +
+
+
+ Vous êtes :
+
+ +
+
Banana, a Web interface for a NNTP Server
- Developed under GPL License for Polytechnique.org + Developed under GPL License for Polytechnique.org
Use silk icons from www.famfamfam.com
+
+"; + foreach ($bt as &$entry) { + echo "
" . $entry['action'] . "
"; + echo "

" + . "Exécution en " . sprintf("%.3fs", $entry['time']) . "
" + . "Retour : " . $entry['code'] . "
" + . "Lignes : " . $entry['response'] . "

"; + } + echo "
"; + } +?>