Completed
Pull Request — master (#9)
by
unknown
04:37 queued 03:00
created
acp/tfa_module.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
144 144
 			$type = explode(':', $vars['type']);
145 145
 
146 146
 			$l_explain = '';
147
-			if ($vars['explain'] && array_key_exists($vars['lang'] . '_EXPLAIN', $user->lang))
147
+			if ($vars['explain'] && array_key_exists($vars['lang'].'_EXPLAIN', $user->lang))
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);
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 		foreach ($act_ary as $key => $data)
187 187
 		{
188 188
 			$selected = ($data == $selected_value) ? ' selected="selected"' : '';
189
-			$act_options .= '<option value="' . $data . '"' . $selected . '>' . $user->lang($key) . '</option>';
189
+			$act_options .= '<option value="'.$data.'"'.$selected.'>'.$user->lang($key).'</option>';
190 190
 		}
191 191
 		return $act_options;
192 192
 	}
Please login to merge, or discard this patch.
migrations/update_sessions2.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
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
 					'tfa_random'    => array('TEXT', null),
29 29
 					'tfa_uid'		=> array('UINT', 0),
30 30
 				),
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	{
37 37
 		return array(
38 38
 			'drop_columns'        => array(
39
-				$this->table_prefix . 'sessions'        => array(
39
+				$this->table_prefix.'sessions'        => array(
40 40
 					'tfa_random',
41 41
 				),
42 42
 			),
Please login to merge, or discard this patch.
modules/u2f.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
 		$this->user     = $user;
60 60
 		$this->request  = $request;
61 61
 		$this->template = $template;
62
-		$this->root_path= $root_path;
62
+		$this->root_path = $root_path;
63 63
 
64
-		$this->registration_table	= $registration_table;
64
+		$this->registration_table = $registration_table;
65 65
 
66
-		$this->u2f = new \paul999\u2f\U2F('https://' . $this->request->server('HTTP_HOST'));
66
+		$this->u2f = new \paul999\u2f\U2F('https://'.$this->request->server('HTTP_HOST'));
67 67
 	}
68 68
 
69 69
 	/**
@@ -190,9 +190,9 @@  discard block
 block discarded – undo
190 190
 		try
191 191
 		{
192 192
 			$sql = 'SELECT u2f_request 
193
-				FROM ' . SESSIONS_TABLE . " 
193
+				FROM ' . SESSIONS_TABLE." 
194 194
 				WHERE
195
-					session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "' AND
195
+					session_id = '" . $this->db->sql_escape($this->user->data['session_id'])."' AND
196 196
 					session_user_id = " . (int) $this->user->data['user_id'];
197 197
 			$result = $this->db->sql_query($sql);
198 198
 			$row = $this->db->sql_fetchrow($result);
@@ -222,7 +222,7 @@  discard block
 block discarded – undo
222 222
 				'last_used' => time(),
223 223
 			);
224 224
 
225
-			$sql = 'UPDATE ' . $this->registration_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE registration_id = ' . (int) $reg->getId();
225
+			$sql = 'UPDATE '.$this->registration_table.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary).' WHERE registration_id = '.(int) $reg->getId();
226 226
 			$this->db->sql_query($sql);
227 227
 
228 228
 			return true;
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 				'last_used' => time(),
319 319
 			);
320 320
 
321
-			$sql = 'INSERT INTO ' . $this->registration_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
321
+			$sql = 'INSERT INTO '.$this->registration_table.' '.$this->db->sql_build_array('INSERT', $sql_ary);
322 322
 			$this->db->sql_query($sql);
323 323
 
324 324
 			$sql_ary = array(
@@ -350,8 +350,8 @@  discard block
 block discarded – undo
350 350
 	 */
351 351
 	public function delete($key)
352 352
 	{
353
-		$sql = 'DELETE FROM ' . $this->registration_table . '
354
-			WHERE user_id = ' . (int) $this->user->data['user_id'] . '
353
+		$sql = 'DELETE FROM '.$this->registration_table.'
354
+			WHERE user_id = ' . (int) $this->user->data['user_id'].'
355 355
 			AND registration_id =' . (int) $key;
356 356
 
357 357
 		$this->db->sql_query($sql);
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 	 */
394 394
 	private function getRegistrations($user_id)
395 395
 	{
396
-		$sql = 'SELECT * FROM ' . $this->registration_table . ' WHERE user_id = ' . (int) $user_id;
396
+		$sql = 'SELECT * FROM '.$this->registration_table.' WHERE user_id = '.(int) $user_id;
397 397
 		$result = $this->db->sql_query($sql);
398 398
 		$rows = array();
399 399
 
@@ -481,9 +481,9 @@  discard block
 block discarded – undo
481 481
 	 */
482 482
 	private function update_session($sql_ary)
483 483
 	{
484
-		$sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . "
484
+		$sql = 'UPDATE '.SESSIONS_TABLE.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary)."
485 485
 			WHERE
486
-				session_id = '" . $this->db->sql_escape($this->user->data['session_id']) . "' AND
486
+				session_id = '" . $this->db->sql_escape($this->user->data['session_id'])."' AND
487 487
 				session_user_id = " . (int) $this->user->data['user_id'];
488 488
 		$this->db->sql_query($sql);
489 489
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -9 removed lines patch added patch discarded remove patch
@@ -123,8 +123,7 @@  discard block
 block discarded – undo
123 123
 		if (!empty($secure))
124 124
 		{
125 125
 			return 'on' === strtolower($secure) || '1' == $secure;
126
-		}
127
-		else if ('443' == $this->request->server('SERVER_PORT'))
126
+		} else if ('443' == $this->request->server('SERVER_PORT'))
128 127
 		{
129 128
 			return true;
130 129
 		}
@@ -207,10 +206,12 @@  discard block
 block discarded – undo
207 206
 
208 207
 			if (property_exists($response, 'errorCode'))
209 208
 			{
210
-				if ($response->errorCode == 4) // errorCode 4 means that this device wasn't registered
209
+				if ($response->errorCode == 4) {
210
+					// errorCode 4 means that this device wasn't registered
211 211
 				{
212 212
 					throw new http_exception(403, 'TFA_NOT_REGISTERED');
213 213
 				}
214
+				}
214 215
 				throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG');
215 216
 			}
216 217
 			$result = new AuthenticationResponse($response->signatureData, $response->clientData, $response->keyHandle); // Do not need to include errorCode, as we already handled it.
@@ -226,12 +227,10 @@  discard block
 block discarded – undo
226 227
 			$this->db->sql_query($sql);
227 228
 
228 229
 			return true;
229
-		}
230
-		catch (U2fError $error)
230
+		} catch (U2fError $error)
231 231
 		{
232 232
 			$this->createError($error);
233
-		}
234
-		catch (\InvalidArgumentException $invalid)
233
+		} catch (\InvalidArgumentException $invalid)
235 234
 		{
236 235
 			throw new http_exception(400, 'TFA_SOMETHING_WENT_WRONG');
237 236
 		}
@@ -326,8 +325,7 @@  discard block
 block discarded – undo
326 325
 			);
327 326
 
328 327
 			$this->update_session($sql_ary);
329
-		}
330
-		catch (U2fError $err)
328
+		} catch (U2fError $err)
331 329
 		{
332 330
 			$this->createError($err);
333 331
 		}
Please login to merge, or discard this patch.
event/listener.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function __construct(session_helper_interface $session_helper, user $user, request_interface $request, driver_interface $db, template $template, config $config, $php_ext, $root_path)
81 81
 	{
82
-		$this->session_helper		= $session_helper;
83
-		$this->user					= $user;
84
-		$this->request				= $request;
85
-		$this->config				= $config;
86
-		$this->db					= $db;
82
+		$this->session_helper = $session_helper;
83
+		$this->user = $user;
84
+		$this->request = $request;
85
+		$this->config = $config;
86
+		$this->db = $db;
87 87
 		$this->template				= $template;
88
-		$this->php_ext				= $php_ext;
88
+		$this->php_ext = $php_ext;
89 89
 		$this->root_path			= $root_path;
90 90
 	}
91 91
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		}
128 128
 		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']))
129 129
 		{
130
-			$sql = 'SELECT module_id FROM ' . MODULES_TABLE . " WHERE module_langname = 'UCP_TFA' OR module_langname = 'UCP_TFA_MANAGE'";
130
+			$sql = 'SELECT module_id FROM '.MODULES_TABLE." WHERE module_langname = 'UCP_TFA' OR module_langname = 'UCP_TFA_MANAGE'";
131 131
 			$result = $this->db->sql_query($sql, 3600);
132 132
 			$allowed_i = array();
133 133
 
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
 			$ucp_mode = '-paul999-tfa-ucp-tfa_module';
140 140
 			$allowed_i[] = $ucp_mode;
141 141
 
142
-			if ($this->user->page['page_name'] === 'ucp.' . $this->php_ext && in_array($this->request->variable('i', ''), $allowed_i))
142
+			if ($this->user->page['page_name'] === 'ucp.'.$this->php_ext && in_array($this->request->variable('i', ''), $allowed_i))
143 143
 			{
144 144
 				return; // We are at our UCP page, so skip any other checks. This page is always available
145 145
 			}
146 146
 			$this->user->add_lang_ext('paul999/tfa', 'common');
147 147
 			$url = append_sid("{$this->root_path}ucp.{$this->php_ext}", "i={$ucp_mode}");
148
-			$msg_text = $this->user->lang('TFA_REQUIRED_KEY_MISSING', '<a href="' . $url . '">', '</a>');
149
-			$msg_title =  $this->user->lang['INFORMATION'];
148
+			$msg_text = $this->user->lang('TFA_REQUIRED_KEY_MISSING', '<a href="'.$url.'">', '</a>');
149
+			$msg_title = $this->user->lang['INFORMATION'];
150 150
 
151 151
 			page_header($msg_title);
152 152
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -193,8 +193,7 @@
 block discarded – undo
193 193
 					// We simply return and continue the login procedure (The normal way :)),
194 194
 					// and will disable all pages until he has added a 2FA key.
195 195
 					return $event;
196
-				}
197
-				else
196
+				} else
198 197
 				{
199 198
 					$this->session_helper->generate_page($event['login']['user_row']['user_id'], $event['admin'], $event['view_online'], !$this->request->is_set_post('viewonline'), $this->request->variable('redirect', ''));
200 199
 				}
Please login to merge, or discard this patch.
controller/main_controller.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -85,15 +85,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
 			if ($admin)
188 188
 			{
189 189
 				// the login array is used because the user ids do not differ for re-authentication
190
-				$sql = 'DELETE FROM ' . SESSIONS_TABLE . "
191
-					WHERE session_id = '" . $this->db->sql_escape($old_session_id) . "'
190
+				$sql = 'DELETE FROM '.SESSIONS_TABLE."
191
+					WHERE session_id = '" . $this->db->sql_escape($old_session_id)."'
192 192
 					AND session_user_id = " . (int) $user_id;
193 193
 				$this->db->sql_query($sql);
194 194
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -155,15 +155,13 @@
 block discarded – undo
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
 			if ($ex->getStatusCode() == 400)
162 161
 			{
163 162
 				$this->template->assign_var('S_ERROR', $this->user->lang($ex->getMessage()));
164 163
 				$this->session_helper->generate_page($user_id, $admin, $auto_login, $viewonline, $redirect);
165
-			}
166
-			else
164
+			} else
167 165
 			{
168 166
 				throw $ex;
169 167
 			}
Please login to merge, or discard this patch.