]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - index.php
a26c42e145f28f3f60bdae274569cc8efeb5df4b
3 * wallabag, self hostable application allowing you to not miss any content anymore
6 * @author Nicolas LÅ“uillet <nicolas@loeuillet.org>
8 * @license http://www.wtfpl.net/ see COPYING file
11 define ('POCHE', '1.5.2');
12 require 'check_setup.php';
13 require_once 'inc/poche/global.inc.php';
18 $notInstalledMessage = $poche -> getNotInstalledMessage();
20 # Parse GET & REFERER vars
21 $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
22 $view = Tools
::checkVar('view', 'home');
23 $action = Tools
::checkVar('action');
24 $id = Tools
::checkVar('id');
25 $_SESSION['sort'] = Tools
::checkVar('sort', 'id');
26 $url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
28 # vars to _always_ send to templates
30 'referer' => $referer,
32 'poche_url' => Tools
::getPocheUrl(),
33 'title' => _('poche, a read it later open source system'),
34 'token' => Session
::getToken(),
35 'theme' => $poche->getTheme()
38 if (! empty($notInstalledMessage)) {
39 if (! Poche
::$canRenderTemplates || ! Poche
::$configFileAvailable) {
40 # We cannot use Twig to display the error message
41 echo '<h1>Errors</h1><ol>';
42 foreach ($notInstalledMessage as $message) {
43 echo '<li>' . $message . '</li>';
48 # Twig is installed, put the error message in the template
49 $tpl_file = Tools
::getTplFile('error');
50 $tpl_vars = array_merge($tpl_vars, array('msg' => $poche->getNotInstalledMessage()));
51 echo $poche->tpl
->render($tpl_file, $tpl_vars);
57 if (isset($_GET['login'])) {
59 $poche->login($referer);
60 } elseif (isset($_GET['logout'])) {
63 } elseif (isset($_GET['config'])) {
65 $poche->updatePassword();
66 } elseif (isset($_GET['import'])) {
67 $import = $poche->import($_GET['from']);
68 } elseif (isset($_GET['download'])) {
70 } elseif (isset($_GET['empty-cache'])) {
72 } elseif (isset($_GET['export'])) {
74 } elseif (isset($_GET['updatetheme'])) {
75 $poche->updateTheme();
76 } elseif (isset($_GET['updatelanguage'])) {
77 $poche->updateLanguage();
78 } elseif (isset($_GET['feed'])) {
79 if (isset($_GET['action']) && $_GET['action'] == 'generate') {
80 $poche->generateToken();
83 $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0);
84 $poche->generateFeeds($_GET['token'], $_GET['user_id'], $tag_id, $_GET['type']);
88 elseif (isset($_GET['plainurl']) && !empty($_GET['plainurl'])) {
89 $plain_url = new Url(base64_encode($_GET['plainurl']));
90 $poche->action('add', $plain_url);
93 if (Session
::isLogged()) {
94 $poche->action($action, $url, $id);
95 $tpl_file = Tools
::getTplFile($view);
96 $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id));
97 } elseif(isset($_SERVER['PHP_AUTH_USER'])) {
98 if($poche->store
->userExists($_SERVER['PHP_AUTH_USER'])) {
99 $poche->login($referer);
101 $poche->messages
->add('e', _('login failed: user doesn\'t exist'));
102 Tools
::logm('user doesn\'t exist');
103 $tpl_file = Tools
::getTplFile('login');
104 $tpl_vars['http_auth'] = 1;
106 } elseif(isset($_SERVER['REMOTE_USER'])) {
107 if($poche->store
->userExists($_SERVER['REMOTE_USER'])) {
108 $poche->login($referer);
110 $poche->messages
->add('e', _('login failed: user doesn\'t exist'));
111 Tools
::logm('user doesn\'t exist');
112 $tpl_file = Tools
::getTplFile('login');
113 $tpl_vars['http_auth'] = 1;
116 $tpl_file = Tools
::getTplFile('login');
117 $tpl_vars['http_auth'] = 0;
120 # because messages can be added in $poche->action(), we have to add this entry now (we can add it before)
121 $messages = $poche->messages
->display('all', FALSE);
122 $tpl_vars = array_merge($tpl_vars, array('messages' => $messages));
125 echo $poche->tpl
->render($tpl_file, $tpl_vars);