@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | { |
102 | 102 | $module->register(); |
103 | 103 | meta_refresh(3, $this->u_action); |
104 | - $message = $this->user->lang('TFA_KEY_ADDED') . '<br /><br />' . $this->user->lang('RETURN_UCP', '<a href="' . $this->u_action . '">', '</a>'); |
|
104 | + $message = $this->user->lang('TFA_KEY_ADDED').'<br /><br />'.$this->user->lang('RETURN_UCP', '<a href="'.$this->u_action.'">', '</a>'); |
|
105 | 105 | trigger_error($message); |
106 | 106 | } |
107 | 107 | 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 />' . $this->user->lang('RETURN_UCP', '<a href="' . $this->u_action . '">', '</a>'); |
|
230 | + $message = $this->user->lang('TFA_KEYS_DELETED').'<br /><br />'.$this->user->lang('RETURN_UCP', '<a href="'.$this->u_action.'">', '</a>'); |
|
231 | 231 | trigger_error($message); |
232 | 232 | } |
233 | 233 | } |
@@ -87,13 +87,13 @@ discard block |
||
87 | 87 | */ |
88 | 88 | public function __construct(driver_interface $db, config $config, user $user, service_collection $modules, template $template, helper $controller_helper, $registration_table, $user_table) |
89 | 89 | { |
90 | - $this->db = $db; |
|
91 | - $this->user = $user; |
|
92 | - $this->config = $config; |
|
93 | - $this->template = $template; |
|
90 | + $this->db = $db; |
|
91 | + $this->user = $user; |
|
92 | + $this->config = $config; |
|
93 | + $this->template = $template; |
|
94 | 94 | $this->controller_helper = $controller_helper; |
95 | 95 | $this->registration_table = $registration_table; |
96 | - $this->user_table = $user_table; |
|
96 | + $this->user_table = $user_table; |
|
97 | 97 | |
98 | 98 | $this->validateModules($modules); |
99 | 99 | |
@@ -257,9 +257,9 @@ discard block |
||
257 | 257 | 'tfa_random' => $random, |
258 | 258 | 'tfa_uid' => $user_id, |
259 | 259 | ); |
260 | - $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " |
|
260 | + $sql = 'UPDATE '.SESSIONS_TABLE.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary)." |
|
261 | 261 | WHERE |
262 | - session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "' AND |
|
262 | + session_id = '" . $this->db->sql_escape($this->user->data['session_id'])."' AND |
|
263 | 263 | session_user_id = " . (int) $this->user->data['user_id']; |
264 | 264 | $this->db->sql_query($sql); |
265 | 265 | |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | { |
288 | 288 | if (empty($userdata)) |
289 | 289 | { |
290 | - $sql = 'SELECT * FROM ' . $this->user_table . ' WHERE user_id = ' . (int) $user_id; |
|
290 | + $sql = 'SELECT * FROM '.$this->user_table.' WHERE user_id = '.(int) $user_id; |
|
291 | 291 | $result = $this->db->sql_query($sql); |
292 | 292 | $userdata = $this->db->sql_fetchrow($result); |
293 | 293 | $this->db->sql_freeresult($result); |
@@ -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); |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | */ |
86 | 86 | 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) |
87 | 87 | { |
88 | - $this->controller_helper = $controller_helper; |
|
89 | - $this->template = $template; |
|
90 | - $this->db = $db; |
|
91 | - $this->user = $user; |
|
92 | - $this->request = $request; |
|
93 | - $this->config = $config; |
|
94 | - $this->session_helper = $session_helper; |
|
95 | - $this->root_path = $root_path; |
|
96 | - $this->php_ext = $php_ext; |
|
88 | + $this->controller_helper = $controller_helper; |
|
89 | + $this->template = $template; |
|
90 | + $this->db = $db; |
|
91 | + $this->user = $user; |
|
92 | + $this->request = $request; |
|
93 | + $this->config = $config; |
|
94 | + $this->session_helper = $session_helper; |
|
95 | + $this->root_path = $root_path; |
|
96 | + $this->php_ext = $php_ext; |
|
97 | 97 | |
98 | 98 | } |
99 | 99 | |
@@ -129,9 +129,9 @@ 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 |
|
134 | + session_id = '" . $this->db->sql_escape($this->user->data['session_id'])."' AND |
|
135 | 135 | session_user_id = '" . (int) $this->user->data['user_id']; |
136 | 136 | $this->db->sql_query($sql); |
137 | 137 | |
@@ -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 (http_exception $ex) // @TODO: Replace exception with own exception |
|
158 | + } catch (http_exception $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); |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | protected function show_ucp_complete($table, $where = '') |
39 | 39 | { |
40 | 40 | $sql = 'SELECT * |
41 | - FROM ' . $this->db->sql_escape($table) . ' |
|
42 | - WHERE user_id = ' . (int) $this->user->data['user_id'] . ' ' . $where . ' |
|
41 | + FROM ' . $this->db->sql_escape($table).' |
|
42 | + WHERE user_id = ' . (int) $this->user->data['user_id'].' '.$where.' |
|
43 | 43 | ORDER BY registration_id ASC'; |
44 | 44 | |
45 | 45 | $result = $this->db->sql_query($sql); |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | protected function check_table_for_user($table, $user_id, $where = '') |
70 | 70 | { |
71 | 71 | $sql = 'SELECT COUNT(registration_id) as reg_id |
72 | - FROM ' . $this->db->sql_escape($table) . ' |
|
73 | - WHERE user_id = ' . (int) $user_id . ' ' . $where; |
|
72 | + FROM ' . $this->db->sql_escape($table).' |
|
73 | + WHERE user_id = ' . (int) $user_id.' '.$where; |
|
74 | 74 | $result = $this->db->sql_query($sql); |
75 | 75 | $row = $this->db->sql_fetchrow($result); |
76 | 76 | $this->db->sql_freeresult($result); |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | $sql_ary = array( |
178 | 178 | 'last_used' => time(), |
179 | 179 | ); |
180 | - $sql = 'UPDATE ' . $this->otp_registration_table . ' |
|
181 | - SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' |
|
180 | + $sql = 'UPDATE '.$this->otp_registration_table.' |
|
181 | + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary).' |
|
182 | 182 | WHERE |
183 | 183 | registration_id = ' . (int) $registration['registration_id']; |
184 | 184 | $this->db->sql_query($sql); |
@@ -208,9 +208,9 @@ discard block |
||
208 | 208 | public function register_start() |
209 | 209 | { |
210 | 210 | $secret = $this->otp->generateSecret(); |
211 | - $QR = $this->otp_helper->generateKeyURI('totp', $secret, generate_board_url(), '',0, 'sha1'); |
|
211 | + $QR = $this->otp_helper->generateKeyURI('totp', $secret, generate_board_url(), '', 0, 'sha1'); |
|
212 | 212 | $this->template->assign_vars(array( |
213 | - 'TFA_QR_CODE' => 'https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl=' . $QR, |
|
213 | + 'TFA_QR_CODE' => 'https://chart.googleapis.com/chart?chs=200x200&chld=M|0&cht=qr&chl='.$QR, |
|
214 | 214 | 'TFA_SECRET' => $secret, |
215 | 215 | 'L_TFA_ADD_OTP_KEY_EXPLAIN' => $this->user->lang('TFA_ADD_OTP_KEY_EXPLAIN', $secret), |
216 | 216 | 'S_HIDDEN_FIELDS_MODULE' => build_hidden_fields(array( |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | public function register() |
231 | 231 | { |
232 | 232 | $secret = $this->request->variable('secret', ''); |
233 | - $otp = $this->request->variable('register', ''); |
|
233 | + $otp = $this->request->variable('register', ''); |
|
234 | 234 | |
235 | 235 | if (!$this->otp->checkTOTP($secret, $otp, 'sha1')) |
236 | 236 | { |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | 'last_used' => time(), |
245 | 245 | ); |
246 | 246 | |
247 | - $sql = 'INSERT INTO ' . $this->otp_registration_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); |
|
247 | + $sql = 'INSERT INTO '.$this->otp_registration_table.' '.$this->db->sql_build_array('INSERT', $sql_ary); |
|
248 | 248 | $this->db->sql_query($sql); |
249 | 249 | } |
250 | 250 | |
@@ -267,8 +267,8 @@ discard block |
||
267 | 267 | */ |
268 | 268 | public function delete($key) |
269 | 269 | { |
270 | - $sql = 'DELETE FROM ' . $this->otp_registration_table . ' |
|
271 | - WHERE user_id = ' . (int) $this->user->data['user_id'] . ' |
|
270 | + $sql = 'DELETE FROM '.$this->otp_registration_table.' |
|
271 | + WHERE user_id = ' . (int) $this->user->data['user_id'].' |
|
272 | 272 | AND registration_id =' . (int) $key; |
273 | 273 | |
274 | 274 | $this->db->sql_query($sql); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | */ |
282 | 282 | private function getRegistrations($user_id) |
283 | 283 | { |
284 | - $sql = 'SELECT * FROM ' . $this->otp_registration_table . ' WHERE user_id = ' . (int) $user_id; |
|
284 | + $sql = 'SELECT * FROM '.$this->otp_registration_table.' WHERE user_id = '.(int) $user_id; |
|
285 | 285 | $result = $this->db->sql_query($sql); |
286 | 286 | $rows = $this->db->sql_fetchrowset($result); |
287 | 287 |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | $this->user = $user; |
61 | 61 | $this->request = $request; |
62 | 62 | $this->template = $template; |
63 | - $this->root_path= $root_path; |
|
63 | + $this->root_path = $root_path; |
|
64 | 64 | |
65 | - $this->registration_table = $registration_table; |
|
65 | + $this->registration_table = $registration_table; |
|
66 | 66 | |
67 | - $this->u2f = new \paul999\u2f\U2F('https://' . $this->request->server('HTTP_HOST')); |
|
67 | + $this->u2f = new \paul999\u2f\U2F('https://'.$this->request->server('HTTP_HOST')); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function is_potentially_usable($user_id = false) |
112 | 112 | { |
113 | - $browsercap = new Browscap($this->root_path . 'cache/'); |
|
113 | + $browsercap = new Browscap($this->root_path.'cache/'); |
|
114 | 114 | $info = $browsercap->getBrowser($this->request->server('HTTP_USER_AGENT')); |
115 | 115 | return strtolower($info->Browser) === 'chrome' && $this->is_ssl(); |
116 | 116 | } |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | try |
193 | 193 | { |
194 | 194 | $sql = 'SELECT u2f_request |
195 | - FROM ' . SESSIONS_TABLE . " |
|
195 | + FROM ' . SESSIONS_TABLE." |
|
196 | 196 | WHERE |
197 | - session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "' AND |
|
197 | + session_id = '" . $this->db->sql_escape($this->user->data['session_id'])."' AND |
|
198 | 198 | session_user_id = " . (int) $this->user->data['user_id']; |
199 | 199 | $result = $this->db->sql_query($sql); |
200 | 200 | $row = $this->db->sql_fetchrow($result); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | 'last_used' => time(), |
225 | 225 | ); |
226 | 226 | |
227 | - $sql = 'UPDATE ' . $this->registration_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE registration_id = ' . (int) $reg->getId(); |
|
227 | + $sql = 'UPDATE '.$this->registration_table.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary).' WHERE registration_id = '.(int) $reg->getId(); |
|
228 | 228 | $this->db->sql_query($sql); |
229 | 229 | |
230 | 230 | return true; |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | } |
236 | 236 | catch (\InvalidArgumentException $invalid) |
237 | 237 | { |
238 | - throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG' . '<br />' . $invalid->getMessage(), array(), $invalid); |
|
238 | + throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG'.'<br />'.$invalid->getMessage(), array(), $invalid); |
|
239 | 239 | } |
240 | 240 | return false; |
241 | 241 | } |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | 'last_used' => time(), |
321 | 321 | ); |
322 | 322 | |
323 | - $sql = 'INSERT INTO ' . $this->registration_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary); |
|
323 | + $sql = 'INSERT INTO '.$this->registration_table.' '.$this->db->sql_build_array('INSERT', $sql_ary); |
|
324 | 324 | $this->db->sql_query($sql); |
325 | 325 | |
326 | 326 | $sql_ary = array( |
@@ -352,8 +352,8 @@ discard block |
||
352 | 352 | */ |
353 | 353 | public function delete($key) |
354 | 354 | { |
355 | - $sql = 'DELETE FROM ' . $this->registration_table . ' |
|
356 | - WHERE user_id = ' . (int) $this->user->data['user_id'] . ' |
|
355 | + $sql = 'DELETE FROM '.$this->registration_table.' |
|
356 | + WHERE user_id = ' . (int) $this->user->data['user_id'].' |
|
357 | 357 | AND registration_id =' . (int) $key; |
358 | 358 | |
359 | 359 | $this->db->sql_query($sql); |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | */ |
396 | 396 | private function getRegistrations($user_id) |
397 | 397 | { |
398 | - $sql = 'SELECT * FROM ' . $this->registration_table . ' WHERE user_id = ' . (int) $user_id; |
|
398 | + $sql = 'SELECT * FROM '.$this->registration_table.' WHERE user_id = '.(int) $user_id; |
|
399 | 399 | $result = $this->db->sql_query($sql); |
400 | 400 | $rows = array(); |
401 | 401 | |
@@ -483,9 +483,9 @@ discard block |
||
483 | 483 | */ |
484 | 484 | private function update_session($sql_ary) |
485 | 485 | { |
486 | - $sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . " |
|
486 | + $sql = 'UPDATE '.SESSIONS_TABLE.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary)." |
|
487 | 487 | WHERE |
488 | - session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "' AND |
|
488 | + session_id = '" . $this->db->sql_escape($this->user->data['session_id'])."' AND |
|
489 | 489 | session_user_id = " . (int) $this->user->data['user_id']; |
490 | 490 | $this->db->sql_query($sql); |
491 | 491 |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | 'last_used' => time(), |
182 | 182 | 'valid' => false, |
183 | 183 | ); |
184 | - $sql = 'UPDATE ' . $this->backup_registration_table . ' |
|
185 | - SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' |
|
184 | + $sql = 'UPDATE '.$this->backup_registration_table.' |
|
185 | + SET ' . $this->db->sql_build_array('UPDATE', $sql_ary).' |
|
186 | 186 | WHERE |
187 | 187 | registration_id = ' . (int) $registration['registration_id']; |
188 | 188 | $this->db->sql_query($sql); |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | */ |
264 | 264 | public function delete($key) |
265 | 265 | { |
266 | - $sql = 'DELETE FROM ' . $this->backup_registration_table . ' |
|
267 | - WHERE user_id = ' . (int) $this->user->data['user_id'] . ' |
|
266 | + $sql = 'DELETE FROM '.$this->backup_registration_table.' |
|
267 | + WHERE user_id = ' . (int) $this->user->data['user_id'].' |
|
268 | 268 | AND registration_id =' . (int) $key; |
269 | 269 | |
270 | 270 | $this->db->sql_query($sql); |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | private function getRegistrations($user_id) |
279 | 279 | { |
280 | - $sql = 'SELECT * FROM ' . $this->backup_registration_table . ' WHERE user_id = ' . (int) $user_id; |
|
280 | + $sql = 'SELECT * FROM '.$this->backup_registration_table.' WHERE user_id = '.(int) $user_id; |
|
281 | 281 | $result = $this->db->sql_query($sql); |
282 | 282 | $rows = $this->db->sql_fetchrowset($result); |
283 | 283 |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function __construct(session_helper_interface $session_helper, user $user, request_interface $request, driver_interface $db, config $config, $php_ext, $root_path) |
75 | 75 | { |
76 | - $this->session_helper = $session_helper; |
|
77 | - $this->user = $user; |
|
76 | + $this->session_helper = $session_helper; |
|
77 | + $this->user = $user; |
|
78 | 78 | $this->request = $request; |
79 | - $this->config = $config; |
|
80 | - $this->db = $db; |
|
79 | + $this->config = $config; |
|
80 | + $this->db = $db; |
|
81 | 81 | $this->php_ext = $php_ext; |
82 | - $this->root_path = $root_path; |
|
82 | + $this->root_path = $root_path; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | } |
121 | 121 | 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'])) |
122 | 122 | { |
123 | - $sql = 'SELECT module_id FROM ' . MODULES_TABLE . " WHERE module_langname = 'UCP_TFA' OR module_langname = 'UCP_TFA_MANAGE'"; |
|
123 | + $sql = 'SELECT module_id FROM '.MODULES_TABLE." WHERE module_langname = 'UCP_TFA' OR module_langname = 'UCP_TFA_MANAGE'"; |
|
124 | 124 | $result = $this->db->sql_query($sql, 3600); |
125 | 125 | $allowed_i = array(); |
126 | 126 | |
@@ -132,13 +132,13 @@ discard block |
||
132 | 132 | $ucp_mode = '-paul999-tfa-ucp-tfa_module'; |
133 | 133 | $allowed_i[] = $ucp_mode; |
134 | 134 | |
135 | - if ($this->user->page['page_name'] === 'ucp.' . $this->php_ext && in_array($this->request->variable('i', ''), $allowed_i)) |
|
135 | + if ($this->user->page['page_name'] === 'ucp.'.$this->php_ext && in_array($this->request->variable('i', ''), $allowed_i)) |
|
136 | 136 | { |
137 | 137 | return; // We are at our UCP page, so skip any other checks. This page is always available |
138 | 138 | } |
139 | 139 | $this->user->add_lang_ext('paul999/tfa', 'common'); |
140 | 140 | $url = append_sid("{$this->root_path}ucp.{$this->php_ext}", "i={$ucp_mode}"); |
141 | - trigger_error($this->user->lang('TFA_REQUIRED_KEY_MISSING', '<a href="' . $url . '">', '</a>'), E_USER_WARNING); |
|
141 | + trigger_error($this->user->lang('TFA_REQUIRED_KEY_MISSING', '<a href="'.$url.'">', '</a>'), E_USER_WARNING); |
|
142 | 142 | |
143 | 143 | } |
144 | 144 | } |