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