]> git.immae.eu Git - github/wallabag/wallabag.git/blob - index.php
Merge pull request #140 from inthepoche/master
[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 require_once './inc/poche/Tools.class.php';
12 Tools::createMyConfig();
13
14 include 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
25 if (isset($_GET['login'])) {
26 # hello you
27 $poche->login($referer);
28 }
29 elseif (isset($_GET['logout'])) {
30 # see you soon !
31 $poche->logout();
32 }
33 elseif (isset($_GET['config'])) {
34 # Update password
35 $poche->updatePassword();
36 }
37 elseif (isset($_GET['import'])) {
38 $import = $poche->import($_GET['from']);
39 }
40 elseif (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
53 if (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 }
58 else {
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
67 echo $poche->tpl->render($tpl_file, $tpl_vars);