]> git.immae.eu Git - github/wallabag/wallabag.git/blob - index.php
change doc url
[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 elseif (isset($_GET['plainurl']) && !empty($_GET['plainurl'])) {
47 $plain_url = new Url(base64_encode($_GET['plainurl']));
48 $poche->action('add', $plain_url);
49 }
50
51 # vars to send to templates
52 $tpl_vars = array(
53 'referer' => $referer,
54 'view' => $view,
55 'poche_url' => Tools::getPocheUrl(),
56 'title' => _('poche, a read it later open source system'),
57 'token' => Session::getToken(),
58 );
59
60 if (Session::isLogged()) {
61 $poche->action($action, $url, $id);
62 $tpl_file = Tools::getTplFile($view);
63 $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id));
64 }
65 else {
66 $tpl_file = 'login.twig';
67 }
68
69 # because messages can be added in $poche->action(), we have to add this entry now (we can add it before)
70 $messages = $poche->messages->display('all', FALSE);
71 $tpl_vars = array_merge($tpl_vars, array('messages' => $messages));
72
73 # display poche
74 echo $poche->tpl->render($tpl_file, $tpl_vars);