aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php24
1 files changed, 22 insertions, 2 deletions
diff --git a/index.php b/index.php
index 4aebfe10..66a2e816 100644
--- a/index.php
+++ b/index.php
@@ -8,7 +8,9 @@
8 * @license http://www.wtfpl.net/ see COPYING file 8 * @license http://www.wtfpl.net/ see COPYING file
9 */ 9 */
10 10
11define ('POCHE', '1.1.0');
11require_once 'inc/poche/global.inc.php'; 12require_once 'inc/poche/global.inc.php';
13session_start();
12 14
13# Start Poche 15# Start Poche
14$poche = new Poche(); 16$poche = new Poche();
@@ -35,7 +37,12 @@ $tpl_vars = array(
35if (! empty($notInstalledMessage)) { 37if (! empty($notInstalledMessage)) {
36 if (! Poche::$canRenderTemplates || ! Poche::$configFileAvailable) { 38 if (! Poche::$canRenderTemplates || ! Poche::$configFileAvailable) {
37 # We cannot use Twig to display the error message 39 # We cannot use Twig to display the error message
38 die($notInstalledMessage); 40 echo '<h1>Errors</h1><ol>';
41 foreach ($notInstalledMessage as $message) {
42 echo '<li>' . $message . '</li>';
43 }
44 echo '</ol>';
45 die();
39 } else { 46 } else {
40 # Twig is installed, put the error message in the template 47 # Twig is installed, put the error message in the template
41 $tpl_file = Tools::getTplFile('error'); 48 $tpl_file = Tools::getTplFile('error');
@@ -61,7 +68,10 @@ if (isset($_GET['login'])) {
61 $poche->export(); 68 $poche->export();
62} elseif (isset($_GET['updatetheme'])) { 69} elseif (isset($_GET['updatetheme'])) {
63 $poche->updateTheme(); 70 $poche->updateTheme();
71} elseif (isset($_GET['updatelanguage'])) {
72 $poche->updateLanguage();
64} 73}
74
65elseif (isset($_GET['plainurl']) && !empty($_GET['plainurl'])) { 75elseif (isset($_GET['plainurl']) && !empty($_GET['plainurl'])) {
66 $plain_url = new Url(base64_encode($_GET['plainurl'])); 76 $plain_url = new Url(base64_encode($_GET['plainurl']));
67 $poche->action('add', $plain_url); 77 $poche->action('add', $plain_url);
@@ -71,8 +81,18 @@ if (Session::isLogged()) {
71 $poche->action($action, $url, $id); 81 $poche->action($action, $url, $id);
72 $tpl_file = Tools::getTplFile($view); 82 $tpl_file = Tools::getTplFile($view);
73 $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id)); 83 $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id));
84} elseif(isset($_SERVER['PHP_AUTH_USER'])) {
85 if($poche->store->userExists($_SERVER['PHP_AUTH_USER'])) {
86 $poche->login($referer);
87 } else {
88 $poche->messages->add('e', _('login failed: user doesn\'t exist'));
89 Tools::logm('user doesn\'t exist');
90 $tpl_file = Tools::getTplFile('login');
91 $tpl_vars['http_auth'] = 1;
92 }
74} else { 93} else {
75 $tpl_file = Tools::getTplFile('login'); 94 $tpl_file = Tools::getTplFile('login');
95 $tpl_vars['http_auth'] = 0;
76} 96}
77 97
78# because messages can be added in $poche->action(), we have to add this entry now (we can add it before) 98# because messages can be added in $poche->action(), we have to add this entry now (we can add it before)
@@ -80,4 +100,4 @@ $messages = $poche->messages->display('all', FALSE);
80$tpl_vars = array_merge($tpl_vars, array('messages' => $messages)); 100$tpl_vars = array_merge($tpl_vars, array('messages' => $messages));
81 101
82# display poche 102# display poche
83echo $poche->tpl->render($tpl_file, $tpl_vars); \ No newline at end of file 103echo $poche->tpl->render($tpl_file, $tpl_vars);