]>
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 | // // 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 | 'demo' => MODE_DEMO, | |
53 | 'title' => _('poche, a read it later open source system'), | |
54 | 'token' => Session::getToken(), | |
55 | ); | |
56 | ||
57 | if (Session::isLogged()) { | |
58 | $poche->action($action, $url, $id); | |
59 | $tpl_file = Tools::getTplFile($view); | |
60 | $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id)); | |
61 | } | |
62 | else { | |
63 | $tpl_file = 'login.twig'; | |
64 | } | |
65 | ||
66 | # Aaaaaaand action ! | |
67 | echo $poche->tpl->render($tpl_file, $tpl_vars); |