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 { +?> + +
+ + + + +" . $entry['action'] . ""; + echo "
"
+ . "Exécution en " . sprintf("%.3fs", $entry['time']) . "
"
+ . "Retour : " . $entry['code'] . "
"
+ . "Lignes : " . $entry['response'] . "