]>
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';
16 Session
::$sessionName = 'poche';
17 if ( !isset($_GET['login']) ) {
23 $notInstalledMessage = $poche -> getNotInstalledMessage();
25 # Parse GET & REFERER vars
26 $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
27 $view = Tools
::checkVar('view', 'home');
28 $action = Tools
::checkVar('action');
29 $id = Tools
::checkVar('id');
30 $_SESSION['sort'] = Tools
::checkVar('sort', 'id');
31 $url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
33 # vars to _always_ send to templates
35 'referer' => $referer,
37 'poche_url' => Tools
::getPocheUrl(),
38 'title' => _('wallabag, a read it later open source system'),
39 'token' => Session
::getToken(),
40 'theme' => $poche->getTheme()
43 if (! empty($notInstalledMessage)) {
44 if (! Poche
::$canRenderTemplates || ! Poche
::$configFileAvailable) {
45 # We cannot use Twig to display the error message
46 echo '<h1>Errors</h1><ol>';
47 foreach ($notInstalledMessage as $message) {
48 echo '<li>' . $message . '</li>';
53 # Twig is installed, put the error message in the template
54 $tpl_file = Tools
::getTplFile('error');
55 $tpl_vars = array_merge($tpl_vars, array('msg' => $poche->getNotInstalledMessage()));
56 echo $poche->tpl
->render($tpl_file, $tpl_vars);
62 if (isset($_GET['login'])) {
64 $poche->login($referer);
65 } elseif (isset($_GET['logout'])) {
68 } elseif (isset($_GET['config'])) {
70 $poche->updatePassword();
71 } elseif (isset($_GET['import'])) {
72 $import = $poche->import($_GET['from']);
73 } elseif (isset($_GET['download'])) {
75 } elseif (isset($_GET['empty-cache'])) {
77 } elseif (isset($_GET['export'])) {
79 } elseif (isset($_GET['updatetheme'])) {
80 $poche->updateTheme();
81 } elseif (isset($_GET['updatelanguage'])) {
82 $poche->updateLanguage();
83 } elseif (isset($_GET['uploadfile'])) {
85 } elseif (isset($_GET['feed'])) {
86 if (isset($_GET['action']) && $_GET['action'] == 'generate') {
87 $poche->generateToken();
90 $tag_id = (isset($_GET['tag_id']) ? intval($_GET['tag_id']) : 0);
91 $poche->generateFeeds($_GET['token'], $_GET['user_id'], $tag_id, $_GET['type']);
95 elseif (isset($_GET['plainurl']) && !empty($_GET['plainurl'])) {
96 $plain_url = new Url(base64_encode($_GET['plainurl']));
97 $poche->action('add', $plain_url);
100 if (Session
::isLogged()) {
101 $poche->action($action, $url, $id);
102 $tpl_file = Tools
::getTplFile($view);
103 $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id));
104 } elseif(isset($_SERVER['PHP_AUTH_USER'])) {
105 if($poche->store
->userExists($_SERVER['PHP_AUTH_USER'])) {
106 $poche->login($referer);
108 $poche->messages
->add('e', _('login failed: user doesn\'t exist'));
109 Tools
::logm('user doesn\'t exist');
110 $tpl_file = Tools
::getTplFile('login');
111 $tpl_vars['http_auth'] = 1;
113 } elseif(isset($_SERVER['REMOTE_USER'])) {
114 if($poche->store
->userExists($_SERVER['REMOTE_USER'])) {
115 $poche->login($referer);
117 $poche->messages
->add('e', _('login failed: user doesn\'t exist'));
118 Tools
::logm('user doesn\'t exist');
119 $tpl_file = Tools
::getTplFile('login');
120 $tpl_vars['http_auth'] = 1;
123 $tpl_file = Tools
::getTplFile('login');
124 $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);