]> git.immae.eu Git - github/wallabag/wallabag.git/blame_incremental - index.php
fix bug #112 link to shaarli
[github/wallabag/wallabag.git] / index.php
... / ...
CommitLineData
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
11require_once './inc/poche/Tools.class.php';
12Tools::createMyConfig();
13
14include dirname(__FILE__).'/inc/poche/config.inc.php';
15
16# Parse GET & REFERER vars
17$referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
18$view = Tools::checkVar('view', 'home');
19$action = Tools::checkVar('action');
20$id = Tools::checkVar('id');
21$_SESSION['sort'] = Tools::checkVar('sort', 'id');
22$url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
23
24# poche actions
25if (isset($_GET['login'])) {
26 # hello you
27 $poche->login($referer);
28}
29elseif (isset($_GET['logout'])) {
30 # see you soon !
31 $poche->logout();
32}
33elseif (isset($_GET['config'])) {
34 # Update password
35 $poche->updatePassword();
36}
37elseif (isset($_GET['import'])) {
38 $import = $poche->import($_GET['from']);
39}
40elseif (isset($_GET['export'])) {
41 $poche->export();
42}
43
44# vars to send to templates
45$tpl_vars = array(
46 'referer' => $referer,
47 'view' => $view,
48 'poche_url' => Tools::getPocheUrl(),
49 'title' => _('poche, a read it later open source system'),
50 'token' => Session::getToken(),
51);
52
53if (Session::isLogged()) {
54 $poche->action($action, $url, $id);
55 $tpl_file = Tools::getTplFile($view);
56 $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id));
57}
58else {
59 $tpl_file = 'login.twig';
60}
61
62# because messages can be added in $poche->action(), we have to add this entry now (we can add it before)
63$messages = $poche->messages->display('all', FALSE);
64$tpl_vars = array_merge($tpl_vars, array('messages' => $messages));
65
66# display poche
67echo $poche->tpl->render($tpl_file, $tpl_vars);