]>
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.6.1');
12 require 'check_setup.php';
13 require_once 'inc/poche/global.inc.php';
16 Session
::$sessionName = 'poche';
21 $notInstalledMessage = $poche -> getNotInstalledMessage();
23 # Parse GET & REFERER vars
24 $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
25 $view = Tools
::checkVar('view', 'home');
26 $action = Tools
::checkVar('action');
27 $id = Tools
::checkVar('id');
28 $_SESSION['sort'] = Tools
::checkVar('sort', 'id');
29 $url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
31 # vars to _always_ send to templates
33 'referer' => $referer,
35 'poche_url' => Tools
::getPocheUrl(),
36 'title' => _('wallabag, a read it later open source system'),
37 'token' => Session
::getToken(),
38 'theme' => $poche->getTheme()
41 if (! empty($notInstalledMessage)) {
42 if (! Poche
::$canRenderTemplates || ! Poche
::$configFileAvailable) {
43 # We cannot use Twig to display the error message
44 echo '<h1>Errors</h1><ol>';
45 foreach ($notInstalledMessage as $message) {
46 echo '<li>' . $message . '</li>';
51 # Twig is installed, put the error message in the template
52 $tpl_file = Tools
::getTplFile('error');
53 $tpl_vars = array_merge($tpl_vars, array('msg' => $poche->getNotInstalledMessage()));
54 echo $poche->tpl
->render($tpl_file, $tpl_vars);
60 if (isset($_GET['login'])) {
62 $poche->login($referer);
63 } elseif (isset($_GET['logout'])) {
66 } elseif (isset($_GET['config'])) {
68 $poche->updatePassword();
69 } elseif (isset($_GET['import'])) {
70 $import = $poche->import();
71 $tpl_vars = array_merge($tpl_vars, $import);
72 } elseif (isset($_GET['download'])) {
74 } elseif (isset($_GET['empty-cache'])) {
76 } elseif (isset($_GET['export'])) {
78 } elseif (isset($_GET['updatetheme'])) {
79 $poche->updateTheme();
80 } elseif (isset($_GET['updatelanguage'])) {
81 $poche->updateLanguage();
82 } elseif (isset($_GET['uploadfile'])) {
84 } elseif (isset($_GET['feed'])) {
85 if (isset($_GET['action']) && $_GET['action'] == 'generate') {
86 $poche->generateToken();
89 $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0);
90 $poche->generateFeeds($_GET['token'], $_GET['user_id'], $tag_id, $_GET['type']);
94 elseif (isset($_GET['plainurl']) && !empty($_GET['plainurl'])) {
95 $plain_url = new Url(base64_encode($_GET['plainurl']));
96 $poche->action('add', $plain_url);
99 if (Session
::isLogged()) {
100 $poche->action($action, $url, $id);
101 $tpl_file = Tools
::getTplFile($view);
102 $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id));
103 } elseif(isset($_SERVER['PHP_AUTH_USER'])) {
104 if($poche->store
->userExists($_SERVER['PHP_AUTH_USER'])) {
105 $poche->login($referer);
107 $poche->messages
->add('e', _('login failed: user doesn\'t exist'));
108 Tools
::logm('user doesn\'t exist');
109 $tpl_file = Tools
::getTplFile('login');
110 $tpl_vars['http_auth'] = 1;
112 } elseif(isset($_SERVER['REMOTE_USER'])) {
113 if($poche->store
->userExists($_SERVER['REMOTE_USER'])) {
114 $poche->login($referer);
116 $poche->messages
->add('e', _('login failed: user doesn\'t exist'));
117 Tools
::logm('user doesn\'t exist');
118 $tpl_file = Tools
::getTplFile('login');
119 $tpl_vars['http_auth'] = 1;
122 $tpl_file = Tools
::getTplFile('login');
123 $tpl_vars['http_auth'] = 0;
127 # because messages can be added in $poche->action(), we have to add this entry now (we can add it before)
128 $messages = $poche->messages
->display('all', FALSE);
129 $tpl_vars = array_merge($tpl_vars, array('messages' => $messages));
132 echo $poche->tpl
->render($tpl_file, $tpl_vars);