]>
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 |
7f959169 NL |
14 | if (!empty($_POST)) { |
15 | if (!Session::isToken($_POST['token'])) { | |
16 | die(_('Wrong token')); | |
17 | } | |
18 | unset($_SESSION['tokens']); | |
19 | } | |
a1953dff | 20 | |
a4565e88 | 21 | $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; |
7f959169 | 22 | $view = Tools::checkVar('view', 'home'); |
63c35580 NL |
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'] : ''); | |
8c72b98d | 27 | |
a1953dff | 28 | if (isset($_GET['login'])) { |
4f5b44bd | 29 | # hello you |
c765c367 | 30 | $poche->login($referer); |
a1953dff | 31 | } |
32 | elseif (isset($_GET['logout'])) { | |
4f5b44bd | 33 | # see you soon ! |
c765c367 | 34 | $poche->logout(); |
a1953dff | 35 | } |
c765c367 | 36 | elseif (isset($_GET['config'])) { |
4f5b44bd | 37 | # Update password |
c765c367 NL |
38 | $poche->updatePassword(); |
39 | } | |
40 | elseif (isset($_GET['import'])) { | |
41 | $poche->import($_GET['from']); | |
da368cc8 | 42 | } |
63c35580 NL |
43 | elseif (isset($_GET['export'])) { |
44 | $poche->export(); | |
45 | } | |
a1953dff | 46 | |
a4565e88 | 47 | $tpl_vars = array( |
a4565e88 NL |
48 | 'referer' => $referer, |
49 | 'view' => $view, | |
eb1af592 | 50 | 'poche_url' => Tools::getPocheUrl(), |
a4565e88 | 51 | 'title' => _('poche, a read it later open source system'), |
8cbb2a88 | 52 | 'token' => Session::getToken(), |
a4565e88 | 53 | ); |
139769aa | 54 | |
e4d2565e | 55 | if (Session::isLogged()) { |
eb1af592 NL |
56 | $poche->action($action, $url, $id); |
57 | $tpl_file = Tools::getTplFile($view); | |
58 | $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id)); | |
e4d2565e | 59 | } |
60 | else { | |
8cbb2a88 | 61 | $tpl_file = 'login.twig'; |
8c72b98d | 62 | } |
a4565e88 | 63 | |
63c35580 | 64 | # Aaaaaaand action ! |
eb1af592 | 65 | echo $poche->tpl->render($tpl_file, $tpl_vars); |