]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - index.php
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.3');
12 require 'check_setup.php';
13 require_once 'inc/poche/global.inc.php';
17 $notInstalledMessage = $poche -> getNotInstalledMessage();
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'] : '');
27 # vars to _always_ send to templates
29 'referer' => $referer,
31 'poche_url' => Tools
::getPocheUrl(),
32 'title' => _('wallabag, a read it later open source system'),
33 'token' => Session
::getToken(),
34 'theme' => $poche->getTheme()
37 if (! empty($notInstalledMessage)) {
38 if (! Poche
::$canRenderTemplates || ! Poche
::$configFileAvailable) {
39 # We cannot use Twig to display the error message
40 echo '<h1>Errors</h1><ol>';
41 foreach ($notInstalledMessage as $message) {
42 echo '<li>' . $message . '</li>';
47 # Twig is installed, put the error message in the template
48 $tpl_file = Tools
::getTplFile('error');
49 $tpl_vars = array_merge($tpl_vars, array('msg' => $poche->getNotInstalledMessage()));
50 echo $poche->tpl
->render($tpl_file, $tpl_vars);
56 if (isset($_GET['login'])) {
58 $poche->login($referer);
59 } elseif (isset($_GET['logout'])) {
62 } elseif (isset($_GET['config'])) {
64 $poche->updatePassword();
65 } elseif (isset($_GET['import'])) {
66 $import = $poche->import($_GET['from']);
67 } elseif (isset($_GET['download'])) {
69 } elseif (isset($_GET['empty-cache'])) {
71 } elseif (isset($_GET['export'])) {
73 } elseif (isset($_GET['updatetheme'])) {
74 $poche->updateTheme();
75 } elseif (isset($_GET['updatelanguage'])) {
76 $poche->updateLanguage();
77 } elseif (isset($_GET['uploadfile'])) {
79 } elseif (isset($_GET['feed'])) {
80 if (isset($_GET['action']) && $_GET['action'] == 'generate') {
81 $poche->generateToken();
84 $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0);
85 $poche->generateFeeds($_GET['token'], $_GET['user_id'], $tag_id, $_GET['type']);
89 elseif (isset($_GET['plainurl']) && !empty($_GET['plainurl'])) {
90 $plain_url = new Url(base64_encode($_GET['plainurl']));
91 $poche->action('add', $plain_url);
94 if (Session
::isLogged()) {
95 $poche->action($action, $url, $id);
96 $tpl_file = Tools
::getTplFile($view);
97 $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id));
98 } elseif(isset($_SERVER['PHP_AUTH_USER'])) {
99 if($poche->store
->userExists($_SERVER['PHP_AUTH_USER'])) {
100 $poche->login($referer);
102 $poche->messages
->add('e', _('login failed: user doesn\'t exist'));
103 Tools
::logm('user doesn\'t exist');
104 $tpl_file = Tools
::getTplFile('login');
105 $tpl_vars['http_auth'] = 1;
107 } elseif(isset($_SERVER['REMOTE_USER'])) {
108 if($poche->store
->userExists($_SERVER['REMOTE_USER'])) {
109 $poche->login($referer);
111 $poche->messages
->add('e', _('login failed: user doesn\'t exist'));
112 Tools
::logm('user doesn\'t exist');
113 $tpl_file = Tools
::getTplFile('login');
114 $tpl_vars['http_auth'] = 1;
117 $tpl_file = Tools
::getTplFile('login');
118 $tpl_vars['http_auth'] = 0;
121 # because messages can be added in $poche->action(), we have to add this entry now (we can add it before)
122 $messages = $poche->messages
->display('all', FALSE);
123 $tpl_vars = array_merge($tpl_vars, array('messages' => $messages));
126 echo $poche->tpl
->render($tpl_file, $tpl_vars);