]>
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'));
20 unset($_SESSION['tokens']);
23 $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
25 if (isset($_GET['login'])) {
26 if (!empty($_POST['login']) && !empty($_POST['password'])) {
27 if (Session
::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], encode_string($_POST['password'] . $_POST['login']))) {
28 pocheTools
::logm('login successful');
29 $errors[]['value'] = _('login successful');
31 if (!empty($_POST['longlastingsession'])) {
32 $_SESSION['longlastingsession'] = 31536000;
33 $_SESSION['expires_on'] = time() +
$_SESSION['longlastingsession'];
34 session_set_cookie_params($_SESSION['longlastingsession']);
36 session_set_cookie_params(0); // when browser closes
38 session_regenerate_id(true);
39 pocheTools
::redirect($referer);
41 pocheTools
::logm('login failed');
42 $errors[]['value'] = _('Login failed !');
44 pocheTools
::logm('login failed');
47 elseif (isset($_GET['logout'])) {
48 pocheTools
::logm('logout');
50 pocheTools
::redirect();
52 elseif (isset($_GET['config'])) {
53 if (isset($_POST['password']) && isset($_POST['password_repeat'])) {
54 if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") {
55 pocheTools
::logm('password updated');
57 $store->updatePassword(encode_string($_POST['password'] . $_SESSION['login']));
58 #your password has been updated
61 #in demo mode, you can\'t update password
65 #your password can\'t be empty and you have to repeat it in the second field
69 # Traitement des paramètres et déclenchement des actions
70 $view = (isset ($_REQUEST['view'])) ? htmlentities($_REQUEST['view']) : 'home';
71 $full_head = (isset ($_REQUEST['full_head'])) ? htmlentities($_REQUEST['full_head']) : 'yes';
72 $action = (isset ($_REQUEST['action'])) ? htmlentities($_REQUEST['action']) : '';
73 $_SESSION['sort'] = (isset ($_REQUEST['sort'])) ? htmlentities($_REQUEST['sort']) : 'id';
74 $id = (isset ($_REQUEST['id'])) ? htmlspecialchars($_REQUEST['id']) : '';
75 $url = (isset ($_GET['url'])) ? $_GET['url'] : '';
78 'referer' => $referer,
80 'poche_url' => pocheTools
::getUrl(),
82 'title' => _('poche, a read it later open source system'),
83 'token' => Session
::getToken(),
87 $tpl_file = 'home.twig';
89 if (Session
::isLogged()) {
90 action_to_do($action, $url, $id);
91 $tpl_vars = array_merge($tpl_vars, display_view($view, $id));
94 $tpl_file = 'login.twig';
97 echo $twig->render($tpl_file, $tpl_vars);