@@ -42,8 +42,8 @@ |
||
42 | 42 | protected function role_exists($role) |
43 | 43 | { |
44 | 44 | $sql = 'SELECT role_id |
45 | - FROM ' . ACL_ROLES_TABLE . " |
|
46 | - WHERE role_name = '" . $this->db->sql_escape($role) . "'"; |
|
45 | + FROM ' . ACL_ROLES_TABLE." |
|
46 | + WHERE role_name = '" . $this->db->sql_escape($role)."'"; |
|
47 | 47 | $result = $this->db->sql_query_limit($sql, 1); |
48 | 48 | $role_id = $this->db->sql_fetchfield('role_id'); |
49 | 49 | $this->db->sql_freeresult($result); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | return array( |
18 | 18 | 'add_tables' => array( |
19 | - $this->table_prefix . 'tfa_registration' => array( |
|
19 | + $this->table_prefix.'tfa_registration' => array( |
|
20 | 20 | 'COLUMNS' => array( |
21 | 21 | 'registration_id' => array('UINT', null, 'auto_increment'), |
22 | 22 | 'user_id' => array('UINT', 0), |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | { |
41 | 41 | return array( |
42 | 42 | 'drop_tables' => array( |
43 | - $this->table_prefix . 'tfa_registration', |
|
43 | + $this->table_prefix.'tfa_registration', |
|
44 | 44 | ), |
45 | 45 | ); |
46 | 46 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | { |
25 | 25 | return array( |
26 | 26 | 'add_columns' => array( |
27 | - $this->table_prefix . 'sessions' => array( |
|
27 | + $this->table_prefix.'sessions' => array( |
|
28 | 28 | 'u2f_request' => array('TEXT', null), |
29 | 29 | ), |
30 | 30 | ), |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | { |
36 | 36 | return array( |
37 | 37 | 'drop_columns' => array( |
38 | - $this->table_prefix . 'sessions' => array( |
|
38 | + $this->table_prefix.'sessions' => array( |
|
39 | 39 | 'u2f_request', |
40 | 40 | ), |
41 | 41 | ), |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | { |
103 | 103 | $module->register(); |
104 | 104 | meta_refresh(3, $this->u_action); |
105 | - $message = $this->user->lang['TFA_KEY_ADDED'] . '<br /><br />' . sprintf($this->user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); |
|
105 | + $message = $this->user->lang['TFA_KEY_ADDED'].'<br /><br />'.sprintf($this->user->lang['RETURN_UCP'], '<a href="'.$this->u_action.'">', '</a>'); |
|
106 | 106 | trigger_error($message); |
107 | 107 | } |
108 | 108 | if ($module->can_register()) |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | } |
228 | 228 | } |
229 | 229 | meta_refresh(3, $this->u_action); |
230 | - $message = $this->user->lang['TFA_KEYS_DELETED'] . '<br /><br />' . sprintf($this->user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); |
|
230 | + $message = $this->user->lang['TFA_KEYS_DELETED'].'<br /><br />'.sprintf($this->user->lang['RETURN_UCP'], '<a href="'.$this->u_action.'">', '</a>'); |
|
231 | 231 | trigger_error($message); |
232 | 232 | } |
233 | 233 | } |
@@ -108,18 +108,15 @@ discard block |
||
108 | 108 | if ($module->can_register()) |
109 | 109 | { |
110 | 110 | $this->tpl_name = $module->register_start(); |
111 | - } |
|
112 | - else |
|
111 | + } else |
|
113 | 112 | { |
114 | 113 | $error[] = 'TFA_MODULE_NO_REGISTER'; |
115 | 114 | } |
116 | - } |
|
117 | - else |
|
115 | + } else |
|
118 | 116 | { |
119 | 117 | $error[] = $this->user->lang('TFA_MODULE_NOT_FOUND', $class); |
120 | 118 | } |
121 | - } |
|
122 | - catch (\Exception $e) |
|
119 | + } catch (\Exception $e) |
|
123 | 120 | { |
124 | 121 | $error[] = $e->getMessage(); |
125 | 122 | } |
@@ -151,8 +148,7 @@ discard block |
||
151 | 148 | if (!check_form_key('ucp_tfa_keys')) |
152 | 149 | { |
153 | 150 | $error[] = 'FORM_INVALID'; |
154 | - } |
|
155 | - else |
|
151 | + } else |
|
156 | 152 | { |
157 | 153 | if ($this->request->variable('md', false, false, \phpbb\request\request_interface::POST)) |
158 | 154 | { |
@@ -152,8 +152,7 @@ discard block |
||
152 | 152 | if (!empty($secure)) |
153 | 153 | { |
154 | 154 | return 'on' == strtolower($secure) || '1' == $secure; |
155 | - } |
|
156 | - else if ('443' == $this->request->server('SERVER_PORT')) |
|
155 | + } else if ('443' == $this->request->server('SERVER_PORT')) |
|
157 | 156 | { |
158 | 157 | return true; |
159 | 158 | } |
@@ -234,10 +233,12 @@ discard block |
||
234 | 233 | |
235 | 234 | if (property_exists($response, 'errorCode')) |
236 | 235 | { |
237 | - if ($response->errorCode == 4) // errorCode 4 means that this device wasn't registered |
|
236 | + if ($response->errorCode == 4) { |
|
237 | + // errorCode 4 means that this device wasn't registered |
|
238 | 238 | { |
239 | 239 | throw new AccessDeniedHttpException($this->user->lang('TFA_NOT_REGISTERED')); |
240 | 240 | } |
241 | + } |
|
241 | 242 | throw new BadRequestHttpException($this->user->lang('TFA_SOMETHING_WENT_WRONG')); |
242 | 243 | } |
243 | 244 | $result = new AuthenticationResponse($response->signatureData, $response->clientData, $response->keyHandle); // Do not need to include errorCode, as we already handled it. |
@@ -251,12 +252,10 @@ discard block |
||
251 | 252 | |
252 | 253 | $sql = 'UPDATE ' . $this->registration_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE registration_id = ' . (int) $reg->getId(); |
253 | 254 | $this->db->sql_query($sql); |
254 | - } |
|
255 | - catch (U2fError $error) |
|
255 | + } catch (U2fError $error) |
|
256 | 256 | { |
257 | 257 | $this->createError($error); |
258 | - } |
|
259 | - catch (\InvalidArgumentException $invalid) |
|
258 | + } catch (\InvalidArgumentException $invalid) |
|
260 | 259 | { |
261 | 260 | throw new BadRequestHttpException($this->user->lang('TFA_SOMETHING_WENT_WRONG') . '<br />' . $invalid->getMessage(), $invalid); |
262 | 261 | } |
@@ -351,8 +350,7 @@ discard block |
||
351 | 350 | ); |
352 | 351 | |
353 | 352 | $this->update_session($sql_ary); |
354 | - } |
|
355 | - catch (U2fError $err) |
|
353 | + } catch (U2fError $err) |
|
356 | 354 | { |
357 | 355 | $this->createError($err); |
358 | 356 | } |
@@ -61,11 +61,11 @@ discard block |
||
61 | 61 | $this->user = $user; |
62 | 62 | $this->request = $request; |
63 | 63 | $this->template = $template; |
64 | - $this->root_path= $root_path; |
|
64 | + $this->root_path = $root_path; |
|
65 | 65 | |
66 | - $this->registration_table = $registration_table; |
|
66 | + $this->registration_table = $registration_table; |
|
67 | 67 | |
68 | - $this->u2f = new \paul999\u2f\U2F('https://' . $this->request->server('HTTP_HOST')); |
|
68 | + $this->u2f = new \paul999\u2f\U2F('https://'.$this->request->server('HTTP_HOST')); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | return false; |
99 | 99 | } |
100 | 100 | $sql = 'SELECT COUNT(registration_id) as reg_id |
101 | - FROM ' . $this->registration_table . ' |
|
101 | + FROM ' . $this->registration_table.' |
|
102 | 102 | WHERE |
103 | 103 | user_id = ' . (int) $user_id; |
104 | 104 | $result = $this->db->sql_query($sql); |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function is_potentially_usable($user_id = false) |
121 | 121 | { |
122 | - $browsercap = new Browscap($this->root_path . 'cache/'); |
|
122 | + $browsercap = new Browscap($this->root_path.'cache/'); |
|
123 | 123 | $info = $browsercap->getBrowser($this->request->server('HTTP_USER_AGENT')); |
124 | 124 | return strtolower($info->Browser) === 'chrome' && $this->is_ssl(); |
125 | 125 | } |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | try |
201 | 201 | { |
202 | 202 | $sql = 'SELECT u2f_request |
203 | - FROM ' . SESSIONS_TABLE . ' |
|
203 | + FROM ' . SESSIONS_TABLE.' |
|
204 | 204 | WHERE |
205 | - session_id = \'' . $this->db->sql_escape($this->user->data['session_id']) . '\' AND |
|
205 | + session_id = \'' . $this->db->sql_escape($this->user->data['session_id']).'\' AND |
|
206 | 206 | session_user_id = ' . (int) $this->user->data['user_id']; |
207 | 207 | $result = $this->db->sql_query($sql); |
208 | 208 | $row = $this->db->sql_fetchrow($result); |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | 'last_used' => time(), |
233 | 233 | ); |
234 | 234 | |
235 | - $sql = 'UPDATE ' . $this->registration_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE registration_id = ' . (int) $reg->getId(); |
|
235 | + $sql = 'UPDATE '.$this->registration_table.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary).' WHERE registration_id = '.(int) $reg->getId(); |
|
236 | 236 | $this->db->sql_query($sql); |
237 | 237 | } |
238 | 238 | catch (U2fError $error) |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | } |
242 | 242 | catch (\InvalidArgumentException $invalid) |
243 | 243 | { |
244 | - throw new BadRequestHttpException($this->user->lang('TFA_SOMETHING_WENT_WRONG') . '<br />' . $invalid->getMessage(), $invalid); |
|
244 | + throw new BadRequestHttpException($this->user->lang('TFA_SOMETHING_WENT_WRONG').'<br />'.$invalid->getMessage(), $invalid); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | 'last_used' => time(), |
327 | 327 | ); |
328 | 328 | |
329 | - $sql = 'INSERT INTO ' . $this->registration_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); |
|
329 | + $sql = 'INSERT INTO '.$this->registration_table.' '.$this->db->sql_build_array('INSERT', $sql_ary); |
|
330 | 330 | $this->db->sql_query($sql); |
331 | 331 | |
332 | 332 | $sql_ary = array( |
@@ -358,8 +358,8 @@ discard block |
||
358 | 358 | */ |
359 | 359 | public function delete($key) |
360 | 360 | { |
361 | - $sql = 'DELETE FROM ' . $this->registration_table . ' |
|
362 | - WHERE user_id = ' . (int) $this->user->data['user_id'] . ' |
|
361 | + $sql = 'DELETE FROM '.$this->registration_table.' |
|
362 | + WHERE user_id = ' . (int) $this->user->data['user_id'].' |
|
363 | 363 | AND registration_id =' . (int) $key; |
364 | 364 | |
365 | 365 | $this->db->sql_query($sql); |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | */ |
402 | 402 | private function getRegistrations($user_id) |
403 | 403 | { |
404 | - $sql = 'SELECT * FROM ' . $this->registration_table . ' WHERE user_id = ' . (int) $user_id; |
|
404 | + $sql = 'SELECT * FROM '.$this->registration_table.' WHERE user_id = '.(int) $user_id; |
|
405 | 405 | $result = $this->db->sql_query($sql); |
406 | 406 | $rows = array(); |
407 | 407 | |
@@ -489,9 +489,9 @@ discard block |
||
489 | 489 | */ |
490 | 490 | private function update_session($sql_ary) |
491 | 491 | { |
492 | - $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' |
|
492 | + $sql = 'UPDATE '.SESSIONS_TABLE.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary).' |
|
493 | 493 | WHERE |
494 | - session_id = \'' . $this->db->sql_escape($this->user->data['session_id']) . '\' AND |
|
494 | + session_id = \'' . $this->db->sql_escape($this->user->data['session_id']).'\' AND |
|
495 | 495 | session_user_id = ' . (int) $this->user->data['user_id']; |
496 | 496 | $this->db->sql_query($sql); |
497 | 497 |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | 'title' => 'ACP_TFA_SETTINGS', |
44 | 44 | 'vars' => array( |
45 | 45 | 'legend1' => 'ACP_TFA_SETTINGS', |
46 | - 'tfa_mode' => array('lang' => 'TFA_MODE', 'validate' => 'int', 'type' => 'select', 'method' => 'select_tfa_method', 'explain' => true), |
|
46 | + 'tfa_mode' => array('lang' => 'TFA_MODE', 'validate' => 'int', 'type' => 'select', 'method' => 'select_tfa_method', 'explain' => true), |
|
47 | 47 | |
48 | 48 | 'legend4' => 'ACP_SUBMIT_CHANGES', |
49 | 49 | ) |
@@ -97,12 +97,12 @@ discard block |
||
97 | 97 | |
98 | 98 | if ($submit) |
99 | 99 | { |
100 | - $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_TFA_CONFIG_' . strtoupper($mode)); |
|
100 | + $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_TFA_CONFIG_'.strtoupper($mode)); |
|
101 | 101 | |
102 | 102 | $message = $user->lang('CONFIG_UPDATED'); |
103 | 103 | $message_type = E_USER_NOTICE; |
104 | 104 | |
105 | - trigger_error($message . adm_back_link($this->u_action), $message_type); |
|
105 | + trigger_error($message.adm_back_link($this->u_action), $message_type); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | if (!$request->is_secure()) |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | $template->assign_vars(array( |
117 | 117 | 'L_TITLE' => $user->lang[$display_vars['title']], |
118 | - 'L_TITLE_EXPLAIN' => $user->lang[$display_vars['title'] . '_EXPLAIN'], |
|
118 | + 'L_TITLE_EXPLAIN' => $user->lang[$display_vars['title'].'_EXPLAIN'], |
|
119 | 119 | |
120 | 120 | 'S_ERROR' => (sizeof($error)) ? true : false, |
121 | 121 | 'ERROR_MSG' => implode('<br />', $error), |
@@ -144,9 +144,9 @@ discard block |
||
144 | 144 | $type = explode(':', $vars['type']); |
145 | 145 | |
146 | 146 | $l_explain = ''; |
147 | - if ($vars['explain'] && isset($user->lang[$vars['lang'] . '_EXPLAIN'])) |
|
147 | + if ($vars['explain'] && isset($user->lang[$vars['lang'].'_EXPLAIN'])) |
|
148 | 148 | { |
149 | - $l_explain = $user->lang[$vars['lang'] . '_EXPLAIN']; |
|
149 | + $l_explain = $user->lang[$vars['lang'].'_EXPLAIN']; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | $content = build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | foreach ($act_ary as $key => $data) |
188 | 188 | { |
189 | 189 | $selected = ($data == $selected_value) ? ' selected="selected"' : ''; |
190 | - $act_options .= '<option value="' . $data . '"' . $selected . '>' . $user->lang($key) . '</option>'; |
|
190 | + $act_options .= '<option value="'.$data.'"'.$selected.'>'.$user->lang($key).'</option>'; |
|
191 | 191 | } |
192 | 192 | return $act_options; |
193 | 193 | } |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | */ |
73 | 73 | public function __construct(driver_interface $db, config $config, user $user, service_collection $modules, $registration_table, $user_table) |
74 | 74 | { |
75 | - $this->db = $db; |
|
76 | - $this->user = $user; |
|
77 | - $this->config = $config; |
|
78 | - $this->registration_table = $registration_table; |
|
79 | - $this->user_table = $user_table; |
|
75 | + $this->db = $db; |
|
76 | + $this->user = $user; |
|
77 | + $this->config = $config; |
|
78 | + $this->registration_table = $registration_table; |
|
79 | + $this->user_table = $user_table; |
|
80 | 80 | |
81 | 81 | $this->validateModules($modules); |
82 | 82 | } |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | { |
205 | 205 | if (empty($userdata)) |
206 | 206 | { |
207 | - $sql = 'SELECT * FROM ' . $this->user_table . ' WHERE user_id = ' . (int) $user_id; |
|
207 | + $sql = 'SELECT * FROM '.$this->user_table.' WHERE user_id = '.(int) $user_id; |
|
208 | 208 | $result = $this->db->sql_query($sql); |
209 | 209 | $userdata = $this->db->sql_fetchrow($result); |
210 | 210 | $this->db->sql_freeresult($result); |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | protected function show_ucp_complete($table) |
38 | 38 | { |
39 | 39 | $sql = 'SELECT * |
40 | - FROM ' . $table . ' |
|
41 | - WHERE user_id = ' . (int) $this->user->data['user_id'] . ' |
|
40 | + FROM ' . $table.' |
|
41 | + WHERE user_id = ' . (int) $this->user->data['user_id'].' |
|
42 | 42 | ORDER BY registration_id ASC'; |
43 | 43 | |
44 | 44 | $result = $this->db->sql_query($sql); |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | protected function check_table_for_user($table, $user_id) |
68 | 68 | { |
69 | 69 | $sql = 'SELECT COUNT(registration_id) as reg_id |
70 | - FROM ' . $table . ' |
|
70 | + FROM ' . $table.' |
|
71 | 71 | WHERE |
72 | 72 | user_id = ' . (int) $user_id; |
73 | 73 | $result = $this->db->sql_query($sql); |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | return array( |
18 | 18 | 'add_tables' => array( |
19 | - $this->table_prefix . 'tfa_otp_reg' => array( |
|
19 | + $this->table_prefix.'tfa_otp_reg' => array( |
|
20 | 20 | 'COLUMNS' => array( |
21 | 21 | 'registration_id' => array('UINT', null, 'auto_increment'), |
22 | 22 | 'user_id' => array('UINT', 0), |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | { |
38 | 38 | return array( |
39 | 39 | 'drop_tables' => array( |
40 | - $this->table_prefix . 'tfa_otp_registration', |
|
40 | + $this->table_prefix.'tfa_otp_registration', |
|
41 | 41 | ), |
42 | 42 | ); |
43 | 43 | } |