]> git.immae.eu Git - github/wallabag/wallabag.git/blob - index.php
#100: welcome to you, instapaper users
[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 #XSRF protection with token
14 // if (!empty($_POST)) {
15 // if (!Session::isToken($_POST['token'])) {
16 // die(_('Wrong token'));
17 // // TODO remettre le test
18 // }
19 // unset($_SESSION['tokens']);
20 // }
21
22 $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
23 $view = Tools::checkVar('view');
24 $action = Tools::checkVar('action');
25 $id = Tools::checkVar('id');
26 $_SESSION['sort'] = Tools::checkVar('sort');
27 $url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
28
29 if (isset($_GET['login'])) {
30 # hello you
31 $poche->login($referer);
32 }
33 elseif (isset($_GET['logout'])) {
34 # see you soon !
35 $poche->logout();
36 }
37 elseif (isset($_GET['config'])) {
38 # Update password
39 $poche->updatePassword();
40 }
41 elseif (isset($_GET['import'])) {
42 $poche->import($_GET['from']);
43 }
44 elseif (isset($_GET['export'])) {
45 $poche->export();
46 }
47
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
56 if (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 }
61 else {
62 $tpl_file = 'login.twig';
63 }
64
65 # Aaaaaaand action !
66 echo $poche->tpl->render($tpl_file, $tpl_vars);