]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - index.php
3 * poche, a read it later open source system
6 * @author Nicolas LÅ“uillet <support@inthepoche.com>
8 * @license http://www.wtfpl.net/ see COPYING file
11 include dirname(__FILE__
).'/inc/config.php';
15 # XSRF protection with token
16 // if (!empty($_POST)) {
17 // if (!Session::isToken($_POST['token'])) {
18 // die(_('Wrong token'));
19 // // TODO remettre le test
21 // unset($_SESSION['tokens']);
24 $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
26 if (isset($_GET['login'])) {
28 if (!empty($_POST['login']) && !empty($_POST['password'])) {
29 if (Session
::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], encode_string($_POST['password'] . $_POST['login']))) {
30 pocheTools
::logm('login successful');
31 $pocheTools[]['value'] = _('login successful');
33 if (!empty($_POST['longlastingsession'])) {
34 $_SESSION['longlastingsession'] = 31536000;
35 $_SESSION['expires_on'] = time() +
$_SESSION['longlastingsession'];
36 session_set_cookie_params($_SESSION['longlastingsession']);
38 session_set_cookie_params(0);
40 session_regenerate_id(true);
41 pocheTools
::redirect($referer);
43 pocheTools
::logm('login failed');
44 $notices[]['value'] = _('Login failed !');
45 pocheTools
::redirect();
47 pocheTools
::logm('login failed');
48 pocheTools
::redirect();
51 elseif (isset($_GET['logout'])) {
53 pocheTools
::logm('logout');
55 pocheTools
::redirect();
57 elseif (isset($_GET['config'])) {
59 if (isset($_POST['password']) && isset($_POST['password_repeat'])) {
60 if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") {
62 pocheTools
::logm('password updated');
63 $store->updatePassword(encode_string($_POST['password'] . $_SESSION['login']));
65 pocheTools
::redirect();
68 pocheTools
::logm('in demo mode, you can\'t do this');
75 $view = (isset ($_REQUEST['view'])) ? htmlentities($_REQUEST['view']) : 'home';
76 $full_head = (isset ($_REQUEST['full_head'])) ? htmlentities($_REQUEST['full_head']) : 'yes';
77 $action = (isset ($_REQUEST['action'])) ? htmlentities($_REQUEST['action']) : '';
78 $_SESSION['sort'] = (isset ($_REQUEST['sort'])) ? htmlentities($_REQUEST['sort']) : 'id';
79 $id = (isset ($_REQUEST['id'])) ? htmlspecialchars($_REQUEST['id']) : '';
80 $url = (isset ($_GET['url'])) ? $_GET['url'] : '';
83 'referer' => $referer,
85 'poche_url' => pocheTools
::getUrl(),
87 'title' => _('poche, a read it later open source system'),
88 'token' => Session
::getToken(),
89 'notices' => $notices,
92 if (Session
::isLogged()) {
93 action_to_do($action, $url, $id);
94 $tpl_file = get_tpl_file($view);
95 $tpl_vars = array_merge($tpl_vars, display_view($view, $id));
98 $tpl_file = 'login.twig';
101 echo $twig->render($tpl_file, $tpl_vars);