@@ -11,12 +11,9 @@ |
||
| 11 | 11 | namespace paul999\tfa\event; |
| 12 | 12 | |
| 13 | 13 | use paul999\tfa\helper\session_helper_interface; |
| 14 | -use paul999\tfa\modules\module_interface; |
|
| 15 | 14 | use phpbb\config\config; |
| 16 | -use phpbb\controller\helper; |
|
| 17 | 15 | use phpbb\db\driver\driver_interface; |
| 18 | 16 | use phpbb\request\request_interface; |
| 19 | -use phpbb\template\template; |
|
| 20 | 17 | use phpbb\user; |
| 21 | 18 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
| 22 | 19 | use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; |
@@ -77,13 +77,13 @@ discard block |
||
| 77 | 77 | */ |
| 78 | 78 | public function __construct(session_helper_interface $session_helper, user $user, request_interface $request, driver_interface $db, config $config, $php_ext, $root_path) |
| 79 | 79 | { |
| 80 | - $this->session_helper = $session_helper; |
|
| 81 | - $this->user = $user; |
|
| 80 | + $this->session_helper = $session_helper; |
|
| 81 | + $this->user = $user; |
|
| 82 | 82 | $this->request = $request; |
| 83 | - $this->config = $config; |
|
| 84 | - $this->db = $db; |
|
| 83 | + $this->config = $config; |
|
| 84 | + $this->db = $db; |
|
| 85 | 85 | $this->php_ext = $php_ext; |
| 86 | - $this->root_path = $root_path; |
|
| 86 | + $this->root_path = $root_path; |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | if ($this->user->data['is_bot'] == false && $this->user->data['user_id'] != ANONYMOUS && $this->session_helper->isTfaRequired($this->user->data['user_id'], false, $this->user->data) && !$this->session_helper->isTfaRegistered($this->user->data['user_id'])) |
| 124 | 124 | { |
| 125 | - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . ' WHERE module_langname = \'UCP_TFA\' OR module_langname = \'UCP_TFA_MANAGE\''; |
|
| 125 | + $sql = 'SELECT module_id FROM '.MODULES_TABLE.' WHERE module_langname = \'UCP_TFA\' OR module_langname = \'UCP_TFA_MANAGE\''; |
|
| 126 | 126 | $result = $this->db->sql_query($sql, 3600); |
| 127 | 127 | $allowed_i = array(); |
| 128 | 128 | |
@@ -134,13 +134,13 @@ discard block |
||
| 134 | 134 | $ucp_mode = "-paul999-tfa-ucp-tfa_module"; |
| 135 | 135 | $allowed_i[] = $ucp_mode; |
| 136 | 136 | |
| 137 | - if ($this->user->page['page_name'] == 'ucp.' . $this->php_ext && in_array($this->request->variable('i', ''), $allowed_i)) |
|
| 137 | + if ($this->user->page['page_name'] == 'ucp.'.$this->php_ext && in_array($this->request->variable('i', ''), $allowed_i)) |
|
| 138 | 138 | { |
| 139 | 139 | return; // We are at our UCP page, so skip any other checks. This page is always available |
| 140 | 140 | } |
| 141 | 141 | $this->user->add_lang_ext('paul999/tfa', 'common'); |
| 142 | 142 | $url = append_sid("{$this->root_path}ucp.{$this->php_ext}", "i={$ucp_mode}"); |
| 143 | - trigger_error($this->user->lang('TFA_REQUIRED_KEY_MISSING', '<a href="' . $url . '">', '</a>'), E_USER_WARNING); |
|
| 143 | + trigger_error($this->user->lang('TFA_REQUIRED_KEY_MISSING', '<a href="'.$url.'">', '</a>'), E_USER_WARNING); |
|
| 144 | 144 | |
| 145 | 145 | } |
| 146 | 146 | } |
@@ -182,8 +182,8 @@ discard block |
||
| 182 | 182 | 'last_used' => time(), |
| 183 | 183 | 'valid' => false, |
| 184 | 184 | ); |
| 185 | - $sql = 'UPDATE ' . $this->backup_registration_table . ' |
|
| 186 | - SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' |
|
| 185 | + $sql = 'UPDATE '.$this->backup_registration_table.' |
|
| 186 | + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary).' |
|
| 187 | 187 | WHERE |
| 188 | 188 | registration_id = ' . (int) $registration['registration_id']; |
| 189 | 189 | $this->db->sql_query($sql); |
@@ -265,8 +265,8 @@ discard block |
||
| 265 | 265 | */ |
| 266 | 266 | public function delete($key) |
| 267 | 267 | { |
| 268 | - $sql = 'DELETE FROM ' . $this->backup_registration_table . ' |
|
| 269 | - WHERE user_id = ' . (int) $this->user->data['user_id'] . ' |
|
| 268 | + $sql = 'DELETE FROM '.$this->backup_registration_table.' |
|
| 269 | + WHERE user_id = ' . (int) $this->user->data['user_id'].' |
|
| 270 | 270 | AND registration_id =' . (int) $key; |
| 271 | 271 | |
| 272 | 272 | $this->db->sql_query($sql); |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | */ |
| 280 | 280 | private function getRegistrations($user_id) |
| 281 | 281 | { |
| 282 | - $sql = 'SELECT * FROM ' . $this->backup_registration_table . ' WHERE user_id = ' . (int) $user_id; |
|
| 282 | + $sql = 'SELECT * FROM '.$this->backup_registration_table.' WHERE user_id = '.(int) $user_id; |
|
| 283 | 283 | $result = $this->db->sql_query($sql); |
| 284 | 284 | $rows = $this->db->sql_fetchrowset($result); |
| 285 | 285 | |
@@ -88,13 +88,13 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function __construct(driver_interface $db, config $config, user $user, service_collection $modules, template $template, helper $controller_helper, $registration_table, $user_table) |
| 90 | 90 | { |
| 91 | - $this->db = $db; |
|
| 92 | - $this->user = $user; |
|
| 93 | - $this->config = $config; |
|
| 94 | - $this->template = $template; |
|
| 91 | + $this->db = $db; |
|
| 92 | + $this->user = $user; |
|
| 93 | + $this->config = $config; |
|
| 94 | + $this->template = $template; |
|
| 95 | 95 | $this->controller_helper = $controller_helper; |
| 96 | 96 | $this->registration_table = $registration_table; |
| 97 | - $this->user_table = $user_table; |
|
| 97 | + $this->user_table = $user_table; |
|
| 98 | 98 | |
| 99 | 99 | $this->validateModules($modules); |
| 100 | 100 | |
@@ -258,9 +258,9 @@ discard block |
||
| 258 | 258 | 'tfa_random' => $random, |
| 259 | 259 | 'tfa_uid' => $user_id, |
| 260 | 260 | ); |
| 261 | - $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' |
|
| 261 | + $sql = 'UPDATE '.SESSIONS_TABLE.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary).' |
|
| 262 | 262 | WHERE |
| 263 | - session_id = \'' . $this->db->sql_escape($this->user->data['session_id']) . '\' AND |
|
| 263 | + session_id = \'' . $this->db->sql_escape($this->user->data['session_id']).'\' AND |
|
| 264 | 264 | session_user_id = ' . (int) $this->user->data['user_id']; |
| 265 | 265 | $this->db->sql_query($sql); |
| 266 | 266 | |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | { |
| 289 | 289 | if (empty($userdata)) |
| 290 | 290 | { |
| 291 | - $sql = 'SELECT * FROM ' . $this->user_table . ' WHERE user_id = ' . (int) $user_id; |
|
| 291 | + $sql = 'SELECT * FROM '.$this->user_table.' WHERE user_id = '.(int) $user_id; |
|
| 292 | 292 | $result = $this->db->sql_query($sql); |
| 293 | 293 | $userdata = $this->db->sql_fetchrow($result); |
| 294 | 294 | $this->db->sql_freeresult($result); |
@@ -86,15 +86,15 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public function __construct(helper $controller_helper, driver_interface $db, template $template, user $user, request_interface $request, config $config, session_helper_interface $session_helper, $root_path, $php_ext) |
| 88 | 88 | { |
| 89 | - $this->controller_helper = $controller_helper; |
|
| 90 | - $this->template = $template; |
|
| 91 | - $this->db = $db; |
|
| 92 | - $this->user = $user; |
|
| 93 | - $this->request = $request; |
|
| 94 | - $this->config = $config; |
|
| 95 | - $this->session_helper = $session_helper; |
|
| 96 | - $this->root_path = $root_path; |
|
| 97 | - $this->php_ext = $php_ext; |
|
| 89 | + $this->controller_helper = $controller_helper; |
|
| 90 | + $this->template = $template; |
|
| 91 | + $this->db = $db; |
|
| 92 | + $this->user = $user; |
|
| 93 | + $this->request = $request; |
|
| 94 | + $this->config = $config; |
|
| 95 | + $this->session_helper = $session_helper; |
|
| 96 | + $this->root_path = $root_path; |
|
| 97 | + $this->php_ext = $php_ext; |
|
| 98 | 98 | |
| 99 | 99 | } |
| 100 | 100 | |
@@ -129,10 +129,10 @@ discard block |
||
| 129 | 129 | 'tfa_random' => '', |
| 130 | 130 | 'tfa_uid' => 0, |
| 131 | 131 | ); |
| 132 | - $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' |
|
| 132 | + $sql = 'UPDATE '.SESSIONS_TABLE.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary).' |
|
| 133 | 133 | WHERE |
| 134 | - session_id = \'' . $this->db->sql_escape($this->user->data['session_id']) . '\' AND |
|
| 135 | - session_user_id = ' . (int)$this->user->data['user_id']; |
|
| 134 | + session_id = \'' . $this->db->sql_escape($this->user->data['session_id']).'\' AND |
|
| 135 | + session_user_id = ' . (int) $this->user->data['user_id']; |
|
| 136 | 136 | $this->db->sql_query($sql); |
| 137 | 137 | |
| 138 | 138 | if (empty($class)) |
@@ -180,8 +180,8 @@ discard block |
||
| 180 | 180 | if ($admin) |
| 181 | 181 | { |
| 182 | 182 | // the login array is used because the user ids do not differ for re-authentication |
| 183 | - $sql = 'DELETE FROM ' . SESSIONS_TABLE . " |
|
| 184 | - WHERE session_id = '" . $this->db->sql_escape($old_session_id) . "' |
|
| 183 | + $sql = 'DELETE FROM '.SESSIONS_TABLE." |
|
| 184 | + WHERE session_id = '" . $this->db->sql_escape($old_session_id)."' |
|
| 185 | 185 | AND session_user_id = " . (int) $user_id; |
| 186 | 186 | $this->db->sql_query($sql); |
| 187 | 187 | |
@@ -155,8 +155,7 @@ |
||
| 155 | 155 | $this->template->assign_var('S_ERROR', $this->user->lang('TFA_INCORRECT_KEY')); |
| 156 | 156 | $this->session_helper->generate_page($user_id, $admin, $auto_login, $viewonline, $redirect); |
| 157 | 157 | } |
| 158 | - } |
|
| 159 | - catch (BadRequestHttpException $ex) // @TODO: Replace exception with own exception |
|
| 158 | + } catch (BadRequestHttpException $ex) // @TODO: Replace exception with own exception |
|
| 160 | 159 | { |
| 161 | 160 | $this->template->assign_var('S_ERROR', $ex->getMessage()); |
| 162 | 161 | $this->session_helper->generate_page($user_id, $admin, $auto_login, $viewonline, $redirect); |