]>
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 | ||
746f93c2 NL |
11 | if (file_exists(__DIR__ . '/inc/poche/myconfig.inc.php')) { |
12 | require_once __DIR__ . '/inc/poche/myconfig.inc.php'; | |
13 | } | |
bb5a7d9e NL |
14 | require_once './inc/poche/Tools.class.php'; |
15 | Tools::createMyConfig(); | |
16 | ||
eb1af592 | 17 | include dirname(__FILE__).'/inc/poche/config.inc.php'; |
1a268ba7 | 18 | |
ed06f040 | 19 | # Parse GET & REFERER vars |
a4565e88 | 20 | $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']; |
7f959169 | 21 | $view = Tools::checkVar('view', 'home'); |
63c35580 NL |
22 | $action = Tools::checkVar('action'); |
23 | $id = Tools::checkVar('id'); | |
f6df40db | 24 | $_SESSION['sort'] = Tools::checkVar('sort', 'id'); |
63c35580 | 25 | $url = new Url((isset ($_GET['url'])) ? $_GET['url'] : ''); |
8c72b98d | 26 | |
ed06f040 | 27 | # poche actions |
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'])) { | |
07ee09f4 | 41 | $import = $poche->import($_GET['from']); |
da368cc8 | 42 | } |
63c35580 NL |
43 | elseif (isset($_GET['export'])) { |
44 | $poche->export(); | |
45 | } | |
ce4a1dcc NL |
46 | elseif (isset($_GET['plainurl']) && !empty($_GET['plainurl'])) { |
47 | $plain_url = new Url(base64_encode($_GET['plainurl'])); | |
48 | $poche->action('add', $plain_url); | |
49 | } | |
693b3f86 | 50 | |
ed06f040 | 51 | # vars to send to templates |
a4565e88 | 52 | $tpl_vars = array( |
1b2abab6 | 53 | 'lang' => Tools::getDocLanguage($poche->user->getConfigValue('language')), |
a4565e88 NL |
54 | 'referer' => $referer, |
55 | 'view' => $view, | |
eb1af592 | 56 | 'poche_url' => Tools::getPocheUrl(), |
a4565e88 | 57 | 'title' => _('poche, a read it later open source system'), |
8cbb2a88 | 58 | 'token' => Session::getToken(), |
a4565e88 | 59 | ); |
139769aa | 60 | |
e4d2565e | 61 | if (Session::isLogged()) { |
eb1af592 NL |
62 | $poche->action($action, $url, $id); |
63 | $tpl_file = Tools::getTplFile($view); | |
64 | $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id)); | |
e4d2565e | 65 | } |
66 | else { | |
8cbb2a88 | 67 | $tpl_file = 'login.twig'; |
8c72b98d | 68 | } |
a4565e88 | 69 | |
55821e04 | 70 | # because messages can be added in $poche->action(), we have to add this entry now (we can add it before) |
6a361945 NL |
71 | $messages = $poche->messages->display('all', FALSE); |
72 | $tpl_vars = array_merge($tpl_vars, array('messages' => $messages)); | |
55821e04 | 73 | |
ed06f040 | 74 | # display poche |
eb1af592 | 75 | echo $poche->tpl->render($tpl_file, $tpl_vars); |