]>
Commit | Line | Data |
---|---|---|
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 | // } | |
18 | // unset($_SESSION['tokens']); | |
19 | // } | |
20 | ||
21 | $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; | |
22 | $view = Tools::checkVar('view', 'home'); | |
23 | $action = Tools::checkVar('action'); | |
24 | $id = Tools::checkVar('id'); | |
25 | $_SESSION['sort'] = Tools::checkVar('sort'); | |
26 | $url = new Url((isset ($_GET['url'])) ? $_GET['url'] : ''); | |
27 | ||
28 | if (isset($_GET['login'])) { | |
29 | # hello you | |
30 | $poche->login($referer); | |
31 | } | |
32 | elseif (isset($_GET['logout'])) { | |
33 | # see you soon ! | |
34 | $poche->logout(); | |
35 | } | |
36 | elseif (isset($_GET['config'])) { | |
37 | # Update password | |
38 | $poche->updatePassword(); | |
39 | } | |
40 | elseif (isset($_GET['import'])) { | |
41 | $poche->import($_GET['from']); | |
42 | } | |
43 | elseif (isset($_GET['export'])) { | |
44 | $poche->export(); | |
45 | } | |
46 | ||
47 | $tpl_vars = array( | |
48 | 'referer' => $referer, | |
49 | 'view' => $view, | |
50 | 'poche_url' => Tools::getPocheUrl(), | |
51 | 'title' => _('poche, a read it later open source system'), | |
52 | 'token' => Session::getToken(), | |
53 | ); | |
54 | ||
55 | if (Session::isLogged()) { | |
56 | $poche->action($action, $url, $id); | |
57 | $tpl_file = Tools::getTplFile($view); | |
58 | $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id)); | |
59 | } | |
60 | else { | |
61 | $tpl_file = 'login.twig'; | |
62 | } | |
63 | ||
64 | # Aaaaaaand action ! | |
65 | echo $poche->tpl->render($tpl_file, $tpl_vars); |