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