]> git.immae.eu Git - github/wallabag/wallabag.git/blob - index.php
Implemented Add Button
[github/wallabag/wallabag.git] / index.php
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 if (file_exists(__DIR__ . '/inc/poche/myconfig.inc.php')) {
12 require_once __DIR__ . '/inc/poche/myconfig.inc.php';
13 }
14 require_once './inc/poche/Tools.class.php';
15 Tools::createMyConfig();
16
17 include dirname(__FILE__).'/inc/poche/config.inc.php';
18
19 # Parse GET & REFERER vars
20 $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
21 $view = Tools::checkVar('view', 'home');
22 $action = Tools::checkVar('action');
23 $id = Tools::checkVar('id');
24 $_SESSION['sort'] = Tools::checkVar('sort', 'id');
25 $url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
26
27 # poche actions
28 if (isset($_GET['login'])) {
29 # hello you
30 $poche->login($referer);
31 }
32 elseif (isset($_GET['logout'])) {
33 # see you soon !
34 $poche->logout();
35 }
36 elseif (isset($_GET['config'])) {
37 # Update password
38 $poche->updatePassword();
39 }
40 elseif (isset($_GET['import'])) {
41 $import = $poche->import($_GET['from']);
42 }
43 elseif (isset($_GET['export'])) {
44 $poche->export();
45 }
46
47 if (isset($_GET['plainurl'])){
48 $poche->convertURLToBase64($_GET['plainurl']);}
49
50 # vars to send to templates
51 $tpl_vars = array(
52 'referer' => $referer,
53 'view' => $view,
54 'poche_url' => Tools::getPocheUrl(),
55 'title' => _('poche, a read it later open source system'),
56 'token' => Session::getToken(),
57 );
58
59 if (Session::isLogged()) {
60 $poche->action($action, $url, $id);
61 $tpl_file = Tools::getTplFile($view);
62 $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id));
63 }
64 else {
65 $tpl_file = 'login.twig';
66 }
67
68 # because messages can be added in $poche->action(), we have to add this entry now (we can add it before)
69 $messages = $poche->messages->display('all', FALSE);
70 $tpl_vars = array_merge($tpl_vars, array('messages' => $messages));
71
72 # display poche
73 echo $poche->tpl->render($tpl_file, $tpl_vars);