]> git.immae.eu Git - github/wallabag/wallabag.git/blame - index.php
Fix #149
[github/wallabag/wallabag.git] / index.php
CommitLineData
1a268ba7
NL
1<?php
2/**
3 * poche, a read it later open source system
4 *
5 * @category poche
421b65eb 6 * @author Nicolas Lœuillet <support@inthepoche.com>
1a268ba7
NL
7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file
9 */
10
bb5a7d9e
NL
11require_once './inc/poche/Tools.class.php';
12Tools::createMyConfig();
13
eb1af592 14include dirname(__FILE__).'/inc/poche/config.inc.php';
1a268ba7 15
ed06f040 16# Parse GET & REFERER vars
a4565e88 17$referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
7f959169 18$view = Tools::checkVar('view', 'home');
63c35580
NL
19$action = Tools::checkVar('action');
20$id = Tools::checkVar('id');
f6df40db 21$_SESSION['sort'] = Tools::checkVar('sort', 'id');
63c35580 22$url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
8c72b98d 23
ed06f040 24# poche actions
a1953dff 25if (isset($_GET['login'])) {
4f5b44bd 26 # hello you
c765c367 27 $poche->login($referer);
a1953dff 28}
29elseif (isset($_GET['logout'])) {
4f5b44bd 30 # see you soon !
c765c367 31 $poche->logout();
a1953dff 32}
c765c367 33elseif (isset($_GET['config'])) {
4f5b44bd 34 # Update password
c765c367
NL
35 $poche->updatePassword();
36}
37elseif (isset($_GET['import'])) {
07ee09f4 38 $import = $poche->import($_GET['from']);
da368cc8 39}
63c35580
NL
40elseif (isset($_GET['export'])) {
41 $poche->export();
42}
a1953dff 43
ed06f040 44# vars to send to templates
a4565e88 45$tpl_vars = array(
a4565e88
NL
46 'referer' => $referer,
47 'view' => $view,
eb1af592 48 'poche_url' => Tools::getPocheUrl(),
a4565e88 49 'title' => _('poche, a read it later open source system'),
8cbb2a88 50 'token' => Session::getToken(),
a4565e88 51);
139769aa 52
e4d2565e 53if (Session::isLogged()) {
eb1af592
NL
54 $poche->action($action, $url, $id);
55 $tpl_file = Tools::getTplFile($view);
56 $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id));
e4d2565e 57}
58else {
8cbb2a88 59 $tpl_file = 'login.twig';
8c72b98d 60}
a4565e88 61
55821e04 62# because messages can be added in $poche->action(), we have to add this entry now (we can add it before)
6a361945
NL
63$messages = $poche->messages->display('all', FALSE);
64$tpl_vars = array_merge($tpl_vars, array('messages' => $messages));
55821e04 65
ed06f040 66# display poche
eb1af592 67echo $poche->tpl->render($tpl_file, $tpl_vars);