aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php45
1 files changed, 23 insertions, 22 deletions
diff --git a/index.php b/index.php
index dc064428..40779698 100644
--- a/index.php
+++ b/index.php
@@ -8,7 +8,7 @@
8 * @license http://www.wtfpl.net/ see COPYING file 8 * @license http://www.wtfpl.net/ see COPYING file
9 */ 9 */
10 10
11include dirname(__FILE__).'/inc/config.php'; 11include dirname(__FILE__).'/inc/poche/config.inc.php';
12 12
13$notices = array(); 13$notices = array();
14 14
@@ -26,9 +26,9 @@ $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
26if (isset($_GET['login'])) { 26if (isset($_GET['login'])) {
27 # hello you 27 # hello you
28 if (!empty($_POST['login']) && !empty($_POST['password'])) { 28 if (!empty($_POST['login']) && !empty($_POST['password'])) {
29 if (Session::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], encode_string($_POST['password'] . $_POST['login']))) { 29 if (Session::login($_SESSION['login'], $_SESSION['pass'], $_POST['login'], Tools::encodeString($_POST['password'] . $_POST['login']))) {
30 pocheTools::logm('login successful'); 30 Tools::logm('login successful');
31 $pocheTools[]['value'] = _('login successful'); 31 $notices['value'] = _('login successful');
32 32
33 if (!empty($_POST['longlastingsession'])) { 33 if (!empty($_POST['longlastingsession'])) {
34 $_SESSION['longlastingsession'] = 31536000; 34 $_SESSION['longlastingsession'] = 31536000;
@@ -38,34 +38,34 @@ if (isset($_GET['login'])) {
38 session_set_cookie_params(0); 38 session_set_cookie_params(0);
39 } 39 }
40 session_regenerate_id(true); 40 session_regenerate_id(true);
41 pocheTools::redirect($referer); 41 Tools::redirect($referer);
42 } 42 }
43 pocheTools::logm('login failed'); 43 Tools::logm('login failed');
44 $notices[]['value'] = _('Login failed !'); 44 $notices['value'] = _('Login failed !');
45 pocheTools::redirect(); 45 Tools::redirect();
46 } else { 46 } else {
47 pocheTools::logm('login failed'); 47 Tools::logm('login failed');
48 pocheTools::redirect(); 48 Tools::redirect();
49 } 49 }
50} 50}
51elseif (isset($_GET['logout'])) { 51elseif (isset($_GET['logout'])) {
52 # see you soon ! 52 # see you soon !
53 pocheTools::logm('logout'); 53 Tools::logm('logout');
54 Session::logout(); 54 Session::logout();
55 pocheTools::redirect(); 55 Tools::redirect();
56} 56}
57elseif (isset($_GET['config'])) { 57elseif (isset($_GET['config'])) {
58 # Update password 58 # Update password
59 if (isset($_POST['password']) && isset($_POST['password_repeat'])) { 59 if (isset($_POST['password']) && isset($_POST['password_repeat'])) {
60 if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") { 60 if ($_POST['password'] == $_POST['password_repeat'] && $_POST['password'] != "") {
61 if (!MODE_DEMO) { 61 if (!MODE_DEMO) {
62 pocheTools::logm('password updated'); 62 Tools::logm('password updated');
63 $store->updatePassword(encode_string($_POST['password'] . $_SESSION['login'])); 63 $poche->store->updatePassword(Tools::encodeString($_POST['password'] . $_SESSION['login']));
64 Session::logout(); 64 Session::logout();
65 pocheTools::redirect(); 65 Tools::redirect();
66 } 66 }
67 else { 67 else {
68 pocheTools::logm('in demo mode, you can\'t do this'); 68 Tools::logm('in demo mode, you can\'t do this');
69 } 69 }
70 } 70 }
71 } 71 }
@@ -77,12 +77,13 @@ $full_head = (isset ($_REQUEST['full_head'])) ? htmlentities($_REQUEST['full_hea
77$action = (isset ($_REQUEST['action'])) ? htmlentities($_REQUEST['action']) : ''; 77$action = (isset ($_REQUEST['action'])) ? htmlentities($_REQUEST['action']) : '';
78$_SESSION['sort'] = (isset ($_REQUEST['sort'])) ? htmlentities($_REQUEST['sort']) : 'id'; 78$_SESSION['sort'] = (isset ($_REQUEST['sort'])) ? htmlentities($_REQUEST['sort']) : 'id';
79$id = (isset ($_REQUEST['id'])) ? htmlspecialchars($_REQUEST['id']) : ''; 79$id = (isset ($_REQUEST['id'])) ? htmlspecialchars($_REQUEST['id']) : '';
80$url = (isset ($_GET['url'])) ? $_GET['url'] : ''; 80
81$url = new Url((isset ($_GET['url'])) ? $_GET['url'] : '');
81 82
82$tpl_vars = array( 83$tpl_vars = array(
83 'referer' => $referer, 84 'referer' => $referer,
84 'view' => $view, 85 'view' => $view,
85 'poche_url' => pocheTools::getUrl(), 86 'poche_url' => Tools::getPocheUrl(),
86 'demo' => MODE_DEMO, 87 'demo' => MODE_DEMO,
87 'title' => _('poche, a read it later open source system'), 88 'title' => _('poche, a read it later open source system'),
88 'token' => Session::getToken(), 89 'token' => Session::getToken(),
@@ -90,12 +91,12 @@ $tpl_vars = array(
90); 91);
91 92
92if (Session::isLogged()) { 93if (Session::isLogged()) {
93 action_to_do($action, $url, $id); 94 $poche->action($action, $url, $id);
94 $tpl_file = get_tpl_file($view); 95 $tpl_file = Tools::getTplFile($view);
95 $tpl_vars = array_merge($tpl_vars, display_view($view, $id)); 96 $tpl_vars = array_merge($tpl_vars, $poche->displayView($view, $id));
96} 97}
97else { 98else {
98 $tpl_file = 'login.twig'; 99 $tpl_file = 'login.twig';
99} 100}
100 101
101echo $twig->render($tpl_file, $tpl_vars); \ No newline at end of file 102echo $poche->tpl->render($tpl_file, $tpl_vars); \ No newline at end of file