Better example o index.php which uses cookies to store subscription datas
[banana.git] / examples / index.php
1 <?php
2 /********************************************************************************
3 * index.php : main page (newsgroups list)
4 * -----------
5 *
6 * This file is part of the banana distribution
7 * Copyright: See COPYING files that comes with this distribution
8 ********************************************************************************/
9
10 require_once("banana/banana.inc.php");
11
12 session_start();
13
14 class MyBanana extends Banana
15 {
16 protected function action_saveSubs($groups)
17 {
18 parent::action_saveSubs($groups);
19 setcookie('banana_subs', serialize(Banana::$profile['subscribe']));
20 return true;
21 }
22 }
23
24 if (isset($_COOKIE['banana_subs'])) {
25 Banana::$profile['subscribe'] = unserialize($_COOKIE['banana_subs']);
26 }
27 if (!isset($_SESSION['banana_lastnews']) && isset($_COOKIE['banana_lastnews'])) {
28 $_SESSION['banana_lastnews'] = $_COOKIE['banana_lastnews'];
29 }
30 if (isset($_SESSION['banana_lastnews'])) {
31 Banana::$profile['lastnews'] = $_SESSION['banana_lastnews'];
32 }
33 setcookie('banana_lastnews', time());
34
35 $banana = new MyBanana();
36 $res = $banana->run();
37
38 session_write_close();
39
40 ?>
41 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
42 <html xmlns="http://www.w3.org/1999/xhtml">
43 <head>
44 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
45 <meta name="description" content="WebForum2/Banana">
46 <link href="css/style.css" type="text/css" rel="stylesheet" media="screen">
47 <link href="css/banana.css" type="text/css" rel="stylesheet" media="screen">
48 <title>
49 Banana, a NNTP<->Web Gateway
50 </title>
51 </head>
52 <body>
53 <div class="bloc">
54 <h1>Les Forums de Banana</h1>
55 <?php echo $res; ?>
56 <div class="foot">
57 <em>Banana</em>, a Web interface for a NNTP Server<br />
58 Developed under GPL License for <a href="http://www.polytechnique.org">Polytechnique.org</a>
59 Use <em>silk</em> icons from <a href="http://www.famfamfam.com/lab/icons/silk/">www.famfamfam.com</a>
60 </div>
61 </div>
62 </body>
63 </html>
64 <?php
65
66 // vim:set et sw=4 sts=4 ts=4
67 ?>