diff options
author | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-04 20:58:31 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas.loeuillet@gmail.com> | 2013-08-04 20:58:31 +0200 |
commit | eb1af592194e225bf887e4893e697f0ab8dd9a26 (patch) | |
tree | 4ca66f2328ac5ab2abac1cfae98a0e1a7c4e5583 /index.php | |
parent | 3ba5f81b7bc99d7ff954aa5b76aca93c9e157e67 (diff) | |
download | wallabag-eb1af592194e225bf887e4893e697f0ab8dd9a26.tar.gz wallabag-eb1af592194e225bf887e4893e697f0ab8dd9a26.tar.zst wallabag-eb1af592194e225bf887e4893e697f0ab8dd9a26.zip |
refactoring
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 45 |
1 files changed, 23 insertions, 22 deletions
@@ -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 | ||
11 | include dirname(__FILE__).'/inc/config.php'; | 11 | include 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']; | |||
26 | if (isset($_GET['login'])) { | 26 | if (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 | } |
51 | elseif (isset($_GET['logout'])) { | 51 | elseif (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 | } |
57 | elseif (isset($_GET['config'])) { | 57 | elseif (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 | ||
92 | if (Session::isLogged()) { | 93 | if (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 | } |
97 | else { | 98 | else { |
98 | $tpl_file = 'login.twig'; | 99 | $tpl_file = 'login.twig'; |
99 | } | 100 | } |
100 | 101 | ||
101 | echo $twig->render($tpl_file, $tpl_vars); \ No newline at end of file | 102 | echo $poche->tpl->render($tpl_file, $tpl_vars); \ No newline at end of file |