]>
Commit | Line | Data |
---|---|---|
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 | ||
eb1af592 | 11 | include dirname(__FILE__).'/inc/poche/config.inc.php'; |
1a268ba7 | 12 | |
63c35580 | 13 | #XSRF protection with token |
2a1791a4 NL |
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 | // } | |
a1953dff | 21 | |
a4565e88 | 22 | $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; |
63c35580 NL |
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'] : ''); | |
8c72b98d | 28 | |
a1953dff | 29 | if (isset($_GET['login'])) { |
4f5b44bd | 30 | # hello you |
c765c367 | 31 | $poche->login($referer); |
a1953dff | 32 | } |
33 | elseif (isset($_GET['logout'])) { | |
4f5b44bd | 34 | # see you soon ! |
c765c367 | 35 | $poche->logout(); |
a1953dff | 36 | } |
c765c367 | 37 | elseif (isset($_GET['config'])) { |
4f5b44bd | 38 | # Update password |
c765c367 NL |
39 | $poche->updatePassword(); |
40 | } | |
41 | elseif (isset($_GET['import'])) { | |
42 | $poche->import($_GET['from']); | |
da368cc8 | 43 | } |
63c35580 NL |
44 | elseif (isset($_GET['export'])) { |
45 | $poche->export(); | |
46 | } | |
a1953dff | 47 | |
a4565e88 | 48 | $tpl_vars = array( |
a4565e88 NL |
49 | 'referer' => $referer, |
50 | 'view' => $view, | |
eb1af592 | 51 | 'poche_url' => Tools::getPocheUrl(), |
a4565e88 | 52 | 'title' => _('poche, a read it later open source system'), |
8cbb2a88 | 53 | 'token' => Session::getToken(), |
a4565e88 | 54 | ); |
139769aa | 55 | |
e4d2565e | 56 | if (Session::isLogged()) { |
eb1af592 NL |
57 | $poche->action($action, $url, $id); |
58 | $tpl_file = Tools::getTplFile($view); | |
59 | $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id)); | |
e4d2565e | 60 | } |
61 | else { | |
8cbb2a88 | 62 | $tpl_file = 'login.twig'; |
8c72b98d | 63 | } |
a4565e88 | 64 | |
63c35580 | 65 | # Aaaaaaand action ! |
eb1af592 | 66 | echo $poche->tpl->render($tpl_file, $tpl_vars); |