]>
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 | |
a4565e88 | 13 | $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; |
7f959169 | 14 | $view = Tools::checkVar('view', 'home'); |
63c35580 NL |
15 | $action = Tools::checkVar('action'); |
16 | $id = Tools::checkVar('id'); | |
17 | $_SESSION['sort'] = Tools::checkVar('sort'); | |
18 | $url = new Url((isset ($_GET['url'])) ? $_GET['url'] : ''); | |
8c72b98d | 19 | |
a1953dff | 20 | if (isset($_GET['login'])) { |
4f5b44bd | 21 | # hello you |
c765c367 | 22 | $poche->login($referer); |
a1953dff | 23 | } |
24 | elseif (isset($_GET['logout'])) { | |
4f5b44bd | 25 | # see you soon ! |
c765c367 | 26 | $poche->logout(); |
a1953dff | 27 | } |
c765c367 | 28 | elseif (isset($_GET['config'])) { |
4f5b44bd | 29 | # Update password |
c765c367 NL |
30 | $poche->updatePassword(); |
31 | } | |
32 | elseif (isset($_GET['import'])) { | |
33 | $poche->import($_GET['from']); | |
da368cc8 | 34 | } |
63c35580 NL |
35 | elseif (isset($_GET['export'])) { |
36 | $poche->export(); | |
37 | } | |
a1953dff | 38 | |
a4565e88 | 39 | $tpl_vars = array( |
a4565e88 NL |
40 | 'referer' => $referer, |
41 | 'view' => $view, | |
eb1af592 | 42 | 'poche_url' => Tools::getPocheUrl(), |
a4565e88 | 43 | 'title' => _('poche, a read it later open source system'), |
8cbb2a88 | 44 | 'token' => Session::getToken(), |
a4565e88 | 45 | ); |
139769aa | 46 | |
e4d2565e | 47 | if (Session::isLogged()) { |
eb1af592 NL |
48 | $poche->action($action, $url, $id); |
49 | $tpl_file = Tools::getTplFile($view); | |
50 | $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id)); | |
e4d2565e | 51 | } |
52 | else { | |
8cbb2a88 | 53 | $tpl_file = 'login.twig'; |
8c72b98d | 54 | } |
a4565e88 | 55 | |
55821e04 | 56 | # because messages can be added in $poche->action(), we have to add this entry now (we can add it before) |
6a361945 NL |
57 | $messages = $poche->messages->display('all', FALSE); |
58 | $tpl_vars = array_merge($tpl_vars, array('messages' => $messages)); | |
55821e04 | 59 | |
63c35580 | 60 | # Aaaaaaand action ! |
eb1af592 | 61 | echo $poche->tpl->render($tpl_file, $tpl_vars); |