]> git.immae.eu Git - github/wallabag/wallabag.git/blob - index.php
d0dd4ab5070da8150299509dedbe949423602965
[github/wallabag/wallabag.git] / index.php
1 <?php
2 /**
3 * poche, a read it later open source system
4 *
5 * @category poche
6 * @author Nicolas LÅ“uillet <support@inthepoche.com>
7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file
9 */
10
11 include dirname(__FILE__).'/inc/poche/config.inc.php';
12
13 $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
14 $view = Tools::checkVar('view', 'home');
15 $action = Tools::checkVar('action');
16 $id = Tools::checkVar('id');
17 $_SESSION['sort'] = Tools::checkVar('sort');
18 $url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
19
20 if (isset($_GET['login'])) {
21 # hello you
22 $poche->login($referer);
23 }
24 elseif (isset($_GET['logout'])) {
25 # see you soon !
26 $poche->logout();
27 }
28 elseif (isset($_GET['config'])) {
29 # Update password
30 $poche->updatePassword();
31 }
32 elseif (isset($_GET['import'])) {
33 $poche->import($_GET['from']);
34 }
35 elseif (isset($_GET['export'])) {
36 $poche->export();
37 }
38
39 $tpl_vars = array(
40 'referer' => $referer,
41 'view' => $view,
42 'poche_url' => Tools::getPocheUrl(),
43 'title' => _('poche, a read it later open source system'),
44 'token' => Session::getToken(),
45 );
46
47 if (Session::isLogged()) {
48 $poche->action($action, $url, $id);
49 $tpl_file = Tools::getTplFile($view);
50 $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id));
51 }
52 else {
53 $tpl_file = 'login.twig';
54 }
55
56 # because messages can be added in $poche->action(), we have to add this entry now (we can add it before)
57 $messages = $poche->messages->display('all', FALSE);
58 $tpl_vars = array_merge($tpl_vars, array('messages' => $messages));
59
60 # Aaaaaaand action !
61 echo $poche->tpl->render($tpl_file, $tpl_vars);