From f9c536287738248a136b22f81c43d21eb95be47f Mon Sep 17 00:00:00 2001 From: x2003bruneau Date: Sat, 10 Feb 2007 10:07:43 +0000 Subject: [PATCH] Better example o index.php which uses cookies to store subscription datas git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@199 9869982d-c50d-0410-be91-f2a2ec7c7c7b --- banana/templates/banana-newmessage.inc.tpl | 2 +- examples/index.php | 36 +++++++++++++++++++++++++----- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/banana/templates/banana-newmessage.inc.tpl b/banana/templates/banana-newmessage.inc.tpl index 853e785..e730c96 100644 --- a/banana/templates/banana-newmessage.inc.tpl +++ b/banana/templates/banana-newmessage.inc.tpl @@ -10,7 +10,7 @@ {if $values.fixed} {$values.fixed|htmlentities} {else} - + {/if} diff --git a/examples/index.php b/examples/index.php index 5b19df9..9782014 100644 --- a/examples/index.php +++ b/examples/index.php @@ -8,16 +8,40 @@ ********************************************************************************/ require_once("banana/banana.inc.php"); -$banana = new Banana(); + +session_start(); + +class MyBanana extends Banana +{ + protected function action_saveSubs($groups) + { + parent::action_saveSubs($groups); + setcookie('banana_subs', serialize(Banana::$profile['subscribe'])); + return true; + } +} + +if (isset($_COOKIE['banana_subs'])) { + Banana::$profile['subscribe'] = unserialize($_COOKIE['banana_subs']); +} +if (!isset($_SESSION['banana_lastnews']) && isset($_COOKIE['banana_lastnews'])) { + $_SESSION['banana_lastnews'] = $_COOKIE['banana_lastnews']; +} +if (isset($_SESSION['banana_lastnews'])) { + Banana::$profile['lastnews'] = $_SESSION['banana_lastnews']; +} +setcookie('banana_lastnews', time()); + +$banana = new MyBanana(); $res = $banana->run(); -if ($res != "") { +session_write_close(); + ?> - + @@ -27,7 +51,8 @@ if ($res != "") {
- +

Les Forums de Banana

+
Banana, a Web interface for a NNTP Server
Developed under GPL License for Polytechnique.org @@ -37,7 +62,6 @@ if ($res != "") { -- 2.1.4