Better example o index.php which uses cookies to store subscription datas
[banana.git] / examples / index.php
CommitLineData
90962c86 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
4cc7f778 10require_once("banana/banana.inc.php");
fe44f824 11
12session_start();
13
14class 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
24if (isset($_COOKIE['banana_subs'])) {
25 Banana::$profile['subscribe'] = unserialize($_COOKIE['banana_subs']);
26}
27if (!isset($_SESSION['banana_lastnews']) && isset($_COOKIE['banana_lastnews'])) {
28 $_SESSION['banana_lastnews'] = $_COOKIE['banana_lastnews'];
29}
30if (isset($_SESSION['banana_lastnews'])) {
31 Banana::$profile['lastnews'] = $_SESSION['banana_lastnews'];
32}
33setcookie('banana_lastnews', time());
34
35$banana = new MyBanana();
0e25d15d 36$res = $banana->run();
90962c86 37
fe44f824 38session_write_close();
39
90962c86 40?>
0e25d15d 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">
8d99c683 43 <head>
fe44f824 44 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
8d99c683 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">
fe44f824 54 <h1>Les Forums de Banana</h1>
55 <?php echo $res; ?>
8d99c683 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>
35bf53d0 59 Use <em>silk</em> icons from <a href="http://www.famfamfam.com/lab/icons/silk/">www.famfamfam.com</a>
8d99c683 60 </div>
61 </div>
62 </body>
63</html>
608f5b71 64<?php
d5588318 65
66// vim:set et sw=4 sts=4 ts=4
608f5b71 67?>