]>
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
17 if (!Session
::isToken($_POST['token'])) {
18 #die(_('Wrong token'));
19 // TODO CORRIGER ICI !!!
21 unset($_SESSION['tokens']);
24 $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
26 if (isset($_GET['login'])) {
27 if (!empty($_POST['login']) && !empty($_POST['password'])) {
28 if (Session
::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], encode_string($_POST['password'] . $_POST['login']))) {
29 pocheTools
::logm('login successful');
30 $errors[]['value'] = _('login successful');
32 if (!empty($_POST['longlastingsession'])) {
33 $_SESSION['longlastingsession'] = 31536000;
34 $_SESSION['expires_on'] = time() +
$_SESSION['longlastingsession'];
35 session_set_cookie_params($_SESSION['longlastingsession']);
37 session_set_cookie_params(0); // when browser closes
39 session_regenerate_id(true);
40 pocheTools
::redirect($referer);
42 pocheTools
::logm('login failed');
43 $errors[]['value'] = _('Login failed !');
45 pocheTools
::logm('login failed');
48 elseif (isset($_GET['logout'])) {
49 pocheTools
::logm('logout');
51 pocheTools
::redirect();
53 elseif (isset($_GET['config'])) {
54 if (isset($_POST['password']) && isset($_POST['password_repeat'])) {
55 if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") {
56 pocheTools
::logm('password updated');
58 $store->updatePassword(encode_string($_POST['password'] . $_SESSION['login']));
59 #your password has been updated
62 #in demo mode, you can\'t update password
66 #your password can\'t be empty and you have to repeat it in the second field
70 # Traitement des paramètres et déclenchement des actions
71 $view = (isset ($_REQUEST['view'])) ? htmlentities($_REQUEST['view']) : 'home';
72 $full_head = (isset ($_REQUEST['full_head'])) ? htmlentities($_REQUEST['full_head']) : 'yes';
73 $action = (isset ($_REQUEST['action'])) ? htmlentities($_REQUEST['action']) : '';
74 $_SESSION['sort'] = (isset ($_REQUEST['sort'])) ? htmlentities($_REQUEST['sort']) : 'id';
75 $id = (isset ($_REQUEST['id'])) ? htmlspecialchars($_REQUEST['id']) : '';
76 $url = (isset ($_GET['url'])) ? $_GET['url'] : '';
79 'referer' => $referer,
81 'poche_url' => pocheTools
::getUrl(),
83 'title' => _('poche, a read it later open source system'),
84 'token' => Session
::getToken(),
88 if (Session
::isLogged()) {
89 action_to_do($action, $url, $id);
90 $tpl_file = get_tpl_file($view);
91 $tpl_vars = array_merge($tpl_vars, display_view($view, $id));
94 $tpl_file = 'login.twig';
97 echo $twig->render($tpl_file, $tpl_vars);