]> git.immae.eu Git - github/wallabag/wallabag.git/blame - index.php
bug fix #266: make installation steps easier
[github/wallabag/wallabag.git] / index.php
CommitLineData
1a268ba7
NL
1<?php
2/**
3 * poche, a read it later open source system
4 *
5 * @category poche
421b65eb 6 * @author Nicolas Lœuillet <support@inthepoche.com>
1a268ba7
NL
7 * @copyright 2013
8 * @license http://www.wtfpl.net/ see COPYING file
9 */
10
00dbaf90 11require_once 'inc/poche/global.inc.php';
bb5a7d9e 12
00dbaf90
NL
13# Start Poche
14$poche = new Poche();
15$notInstalledMessage = $poche -> getNotInstalledMessage();
1a268ba7 16
ed06f040 17# Parse GET & REFERER vars
a4565e88 18$referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
7f959169 19$view = Tools::checkVar('view', 'home');
63c35580
NL
20$action = Tools::checkVar('action');
21$id = Tools::checkVar('id');
f6df40db 22$_SESSION['sort'] = Tools::checkVar('sort', 'id');
63c35580 23$url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
8c72b98d 24
00dbaf90
NL
25# vars to _always_ send to templates
26$tpl_vars = array(
27 'referer' => $referer,
28 'view' => $view,
29 'poche_url' => Tools::getPocheUrl(),
30 'title' => _('poche, a read it later open source system'),
31 'token' => Session::getToken(),
32 'theme' => $poche->getTheme()
33);
34
35if (! empty($notInstalledMessage)) {
36 if (! Poche::$canRenderTemplates || ! Poche::$configFileAvailable) {
37 # We cannot use Twig to display the error message
9d3b88b3
NL
38 echo '<h1>Errors</h1><ol>';
39 foreach ($notInstalledMessage as $message) {
40 echo '<li>' . $message . '</li>';
41 }
42 echo '</ol>';
43 die();
00dbaf90
NL
44 } else {
45 # Twig is installed, put the error message in the template
46 $tpl_file = Tools::getTplFile('error');
47 $tpl_vars = array_merge($tpl_vars, array('msg' => $poche->getNotInstalledMessage()));
48 echo $poche->tpl->render($tpl_file, $tpl_vars);
49 exit;
50 }
51}
52
ed06f040 53# poche actions
a1953dff 54if (isset($_GET['login'])) {
4f5b44bd 55 # hello you
c765c367 56 $poche->login($referer);
00dbaf90 57} elseif (isset($_GET['logout'])) {
4f5b44bd 58 # see you soon !
c765c367 59 $poche->logout();
00dbaf90 60} elseif (isset($_GET['config'])) {
4f5b44bd 61 # Update password
c765c367 62 $poche->updatePassword();
00dbaf90 63} elseif (isset($_GET['import'])) {
07ee09f4 64 $import = $poche->import($_GET['from']);
00dbaf90 65} elseif (isset($_GET['export'])) {
63c35580 66 $poche->export();
00dbaf90
NL
67} elseif (isset($_GET['updatetheme'])) {
68 $poche->updateTheme();
63c35580 69}
ce4a1dcc
NL
70elseif (isset($_GET['plainurl']) && !empty($_GET['plainurl'])) {
71 $plain_url = new Url(base64_encode($_GET['plainurl']));
72 $poche->action('add', $plain_url);
73}
693b3f86 74
e4d2565e 75if (Session::isLogged()) {
eb1af592
NL
76 $poche->action($action, $url, $id);
77 $tpl_file = Tools::getTplFile($view);
78 $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id));
00dbaf90
NL
79} else {
80 $tpl_file = Tools::getTplFile('login');
8c72b98d 81}
a4565e88 82
55821e04 83# because messages can be added in $poche->action(), we have to add this entry now (we can add it before)
6a361945
NL
84$messages = $poche->messages->display('all', FALSE);
85$tpl_vars = array_merge($tpl_vars, array('messages' => $messages));
55821e04 86
ed06f040 87# display poche
eb1af592 88echo $poche->tpl->render($tpl_file, $tpl_vars);