Better example o index.php which uses cookies to store subscription datas
authorx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Sat, 10 Feb 2007 10:07:43 +0000 (10:07 +0000)
committerx2003bruneau <x2003bruneau@9869982d-c50d-0410-be91-f2a2ec7c7c7b>
Sat, 10 Feb 2007 10:07:43 +0000 (10:07 +0000)
git-svn-id: svn+ssh://murphy/home/svn/banana/trunk@199 9869982d-c50d-0410-be91-f2a2ec7c7c7b

banana/templates/banana-newmessage.inc.tpl
examples/index.php

index 853e785..e730c96 100644 (file)
@@ -10,7 +10,7 @@
         {if $values.fixed}
         {$values.fixed|htmlentities}
         {else}
-        <input type="text" name="{$header}" value="{$values.user|default:$smarty.request[$header]}" size="50" />
+        <input type="text" name="{$header}" value="{$values.user|default:$smarty.request.$header}" size="50" />
         {/if}
       </td>
     </tr>
index 5b19df9..9782014 100644 (file)
@@ -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();
+
 ?>
 <!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=UTF-8">
+    <meta http-equiv="Content-Type" content="text/html; 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">
@@ -27,7 +51,8 @@ if ($res != "") {
   </head>
   <body>
     <div class="bloc">
-<?php echo $res; ?>
+      <h1>Les Forums de Banana</h1>
+      <?php echo $res; ?>
       <div class="foot">
         <em>Banana</em>, a Web interface for a NNTP Server<br />
         Developed under GPL License for <a href="http://www.polytechnique.org">Polytechnique.org</a>
@@ -37,7 +62,6 @@ if ($res != "") {
   </body>
 </html>
 <?php
-}
 
 // vim:set et sw=4 sts=4 ts=4
 ?>