Completed
Push — master ( ab0a6e...a28d98 )
by Paul
03:42
created
modules/u2f.php 2 patches
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -50,10 +50,10 @@  discard block
 block discarded – undo
50 50
 	 */
51 51
 	private $registration_table;
52 52
 
53
-    /**
54
-     * @var string
55
-     */
56
-    private $root_path;
53
+	/**
54
+	 * @var string
55
+	 */
56
+	private $root_path;
57 57
 
58 58
 	/**
59 59
 	 * @var \paul999\u2f\U2F
@@ -65,22 +65,22 @@  discard block
 block discarded – undo
65 65
 	 */
66 66
 	private $reg_data;
67 67
 
68
-    /**
69
-     * u2f constructor.
70
-     * @param driver_interface $db
71
-     * @param user $user
72
-     * @param request_interface $request
73
-     * @param template $template
74
-     * @param string $registration_table
75
-     * @param string $root_path
76
-     */
68
+	/**
69
+	 * u2f constructor.
70
+	 * @param driver_interface $db
71
+	 * @param user $user
72
+	 * @param request_interface $request
73
+	 * @param template $template
74
+	 * @param string $registration_table
75
+	 * @param string $root_path
76
+	 */
77 77
 	public function __construct(driver_interface $db, user $user, request_interface $request, template $template, $registration_table, $root_path)
78 78
 	{
79 79
 		$this->db       = $db;
80 80
 		$this->user     = $user;
81 81
 		$this->request  = $request;
82 82
 		$this->template = $template;
83
-        $this->root_path= $root_path;
83
+		$this->root_path= $root_path;
84 84
 
85 85
 		$this->registration_table	= $registration_table;
86 86
 
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	/**
289 289
 	 * Start of registration
290 290
 	 * @return string
291
-     */
291
+	 */
292 292
 	public function register_start()
293 293
 	{
294 294
 		$data = $this->u2f->getRegisterData($this->reg_data);
@@ -318,13 +318,13 @@  discard block
 block discarded – undo
318 318
 			'U2F_SIGN'          => json_encode($data[1], JSON_UNESCAPED_SLASHES),
319 319
 		));
320 320
 
321
-        return 'tfa_u2f_ucp_new';
321
+		return 'tfa_u2f_ucp_new';
322 322
 	}
323 323
 
324 324
 	/**
325 325
 	 * Actual registration
326 326
 	 * @return void
327
-     * @throws BadRequestHttpException
327
+	 * @throws BadRequestHttpException
328 328
 	 */
329 329
 	public function register()
330 330
 	{
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 		while ($row = $this->db->sql_fetchrow($result))
375 375
 		{
376 376
 			$this->template->assign_block_vars('keys', array(
377
-			    'CLASS'         => 'u2f',
377
+				'CLASS'         => 'u2f',
378 378
 				'ID'            => $row['registration_id'],
379 379
 				'REGISTERED'    => $this->user->format_date($row['registered']),
380 380
 				'LAST_USED'     => $this->user->format_date($row['last_used']),
@@ -411,24 +411,24 @@  discard block
 block discarded – undo
411 411
 		}
412 412
 	}
413 413
 
414
-    /**
415
-     * If this module can add new keys (Or other things)
416
-     *
417
-     * @return boolean
418
-     */
419
-    public function can_register()
420
-    {
421
-        return $this->is_potentially_usable(false);
422
-    }
423
-
424
-    /**
425
-     * Get a language key for this specific module.
426
-     * @return string
427
-     */
428
-    public function get_translatable_name()
429
-    {
430
-        return 'MODULE_U2F';
431
-    }
414
+	/**
415
+	 * If this module can add new keys (Or other things)
416
+	 *
417
+	 * @return boolean
418
+	 */
419
+	public function can_register()
420
+	{
421
+		return $this->is_potentially_usable(false);
422
+	}
423
+
424
+	/**
425
+	 * Get a language key for this specific module.
426
+	 * @return string
427
+	 */
428
+	public function get_translatable_name()
429
+	{
430
+		return 'MODULE_U2F';
431
+	}
432 432
 
433 433
 	/**
434 434
 	 * Select all registration objects from the database
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
 		$this->user     = $user;
81 81
 		$this->request  = $request;
82 82
 		$this->template = $template;
83
-        $this->root_path= $root_path;
83
+        $this->root_path = $root_path;
84 84
 
85
-		$this->registration_table	= $registration_table;
85
+		$this->registration_table = $registration_table;
86 86
 
87
-		$this->u2f = new \paul999\u2f\U2F('https://' . $this->request->server('HTTP_HOST'));
87
+		$this->u2f = new \paul999\u2f\U2F('https://'.$this->request->server('HTTP_HOST'));
88 88
 	}
89 89
 
90 90
 	/**
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 			return false;
118 118
 		}
119 119
 		$sql = 'SELECT COUNT(registration_id) as reg_id 
120
-					FROM ' . $this->registration_table . ' 
120
+					FROM ' . $this->registration_table.' 
121 121
 					WHERE 
122 122
 						user_id = ' . (int) $user_id;
123 123
 		$result = $this->db->sql_query($sql);
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 	 */
139 139
 	public function is_potentially_usable($user_id = false)
140 140
 	{
141
-		$browsercap = new Browscap($this->root_path . 'cache/');
141
+		$browsercap = new Browscap($this->root_path.'cache/');
142 142
 		$info = $browsercap->getBrowser();
143 143
 		return $info['Browser'] === 'chrome' && $this->is_ssl();
144 144
 	}
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
 			'u2f_request'	=> $registrations
192 192
 		);
193 193
 
194
-		$sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
194
+		$sql = 'UPDATE '.SESSIONS_TABLE.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary).'
195 195
 					WHERE
196
-						session_id = \'' . $this->db->sql_escape($this->user->data['session_id']) . '\' AND
196
+						session_id = \'' . $this->db->sql_escape($this->user->data['session_id']).'\' AND
197 197
 						session_user_id = ' . (int) $this->user->data['user_id'];
198 198
 		$this->db->sql_query($sql);
199 199
 		$count = $this->db->sql_affectedrows();
@@ -204,9 +204,9 @@  discard block
 block discarded – undo
204 204
 			{
205 205
 				// Reset sessions table. We had multiple sessions with same ID!!!
206 206
 				$sql_ary['u2f_request'] = '';
207
-				$sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
207
+				$sql = 'UPDATE '.SESSIONS_TABLE.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary).'
208 208
 					WHERE
209
-						session_id = \'' . $this->db->sql_escape($this->user->data['session_id']) . '\' AND
209
+						session_id = \'' . $this->db->sql_escape($this->user->data['session_id']).'\' AND
210 210
 						session_user_id = ' . (int) $this->user->data['user_id'];
211 211
 				$this->db->sql_query($sql);
212 212
 			}
@@ -226,9 +226,9 @@  discard block
 block discarded – undo
226 226
 		try
227 227
 		{
228 228
 			$sql = 'SELECT u2f_request 
229
-						FROM ' . SESSIONS_TABLE . ' 
229
+						FROM ' . SESSIONS_TABLE.' 
230 230
 						WHERE
231
-							session_id = \'' . $this->db->sql_escape($this->user->data['session_id']) . '\' AND
231
+							session_id = \'' . $this->db->sql_escape($this->user->data['session_id']).'\' AND
232 232
 							session_user_id = ' . (int) $this->user->data['user_id'];
233 233
 			$result = $this->db->sql_query($sql);
234 234
 			$row = $this->db->sql_fetchrow($result);
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 				'last_used' => time(),
259 259
 			);
260 260
 
261
-			$sql = 'UPDATE ' . $this->registration_table . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . ' WHERE registration_id = ' . (int) $reg->getId();
261
+			$sql = 'UPDATE '.$this->registration_table.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary).' WHERE registration_id = '.(int) $reg->getId();
262 262
 			$this->db->sql_query($sql);
263 263
 		}
264 264
 		catch (U2fError $error)
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 		}
268 268
 		catch (\InvalidArgumentException $invalid)
269 269
 		{
270
-			throw new BadRequestHttpException($this->user->lang('TFA_SOMETHING_WENT_WRONG') . '<br />' . $invalid->getMessage(), $invalid);
270
+			throw new BadRequestHttpException($this->user->lang('TFA_SOMETHING_WENT_WRONG').'<br />'.$invalid->getMessage(), $invalid);
271 271
 		}
272 272
 	}
273 273
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 				'last_used' => time(),
343 343
 			);
344 344
 
345
-			$sql = 'INSERT INTO ' . $this->registration_table . ' ' . $this->db->sql_build_array('INSERT', $sql_ary);
345
+			$sql = 'INSERT INTO '.$this->registration_table.' '.$this->db->sql_build_array('INSERT', $sql_ary);
346 346
 			$this->db->sql_query($sql);
347 347
 
348 348
 			$sql_ary = array(
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
 	public function show_ucp()
365 365
 	{
366 366
 		$sql = 'SELECT *
367
-			FROM ' . $this->registration_table . '
368
-			WHERE user_id = ' . (int) $this->user->data['user_id'] . '
367
+			FROM ' . $this->registration_table.'
368
+			WHERE user_id = ' . (int) $this->user->data['user_id'].'
369 369
 			ORDER BY registration_id ASC';
370 370
 
371 371
 		$result = $this->db->sql_query($sql);
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 		if (isset($data['keys']))
404 404
 		{
405 405
 			$sql_where = $this->db->sql_in_set('registration_id', $data['keys']);
406
-			$sql = 'DELETE FROM ' . $this->registration_table . '
407
-												WHERE user_id = ' . (int) $this->user->data['user_id'] . '
406
+			$sql = 'DELETE FROM '.$this->registration_table.'
407
+												WHERE user_id = ' . (int) $this->user->data['user_id'].'
408 408
 												AND ' . $sql_where;
409 409
 
410 410
 			$this->db->sql_query($sql);
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 	 */
438 438
 	private function getRegistrations($user_id)
439 439
 	{
440
-		$sql = 'SELECT * FROM ' . $this->registration_table . ' WHERE user_id = ' . (int) $user_id;
440
+		$sql = 'SELECT * FROM '.$this->registration_table.' WHERE user_id = '.(int) $user_id;
441 441
 		$result = $this->db->sql_query($sql);
442 442
 		$rows = array();
443 443
 
@@ -525,9 +525,9 @@  discard block
 block discarded – undo
525 525
 	 */
526 526
 	private function update_session($sql_ary)
527 527
 	{
528
-		$sql = 'UPDATE ' . SESSIONS_TABLE . ' SET ' . $this->db->sql_build_array('UPDATE', $sql_ary) . '
528
+		$sql = 'UPDATE '.SESSIONS_TABLE.' SET '.$this->db->sql_build_array('UPDATE', $sql_ary).'
529 529
 							WHERE
530
-								session_id = \'' . $this->db->sql_escape($this->user->data['session_id']) . '\' AND
530
+								session_id = \'' . $this->db->sql_escape($this->user->data['session_id']).'\' AND
531 531
 								session_user_id = ' . (int) $this->user->data['user_id'];
532 532
 		$this->db->sql_query($sql);
533 533
 
Please login to merge, or discard this patch.
helper/session_helper.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@
 block discarded – undo
180 180
 			return $this->user_array[$user_id];
181 181
 		}
182 182
 
183
-        $this->user_array[$user_id] = false; // Preset to false.
183
+		$this->user_array[$user_id] = false; // Preset to false.
184 184
 
185 185
 		/**
186 186
 		 * @var int $priority
Please login to merge, or discard this patch.