GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 99f185...656a22 )
by gyeong-won
12:40
created
classes/mail/Mail.class.php 3 patches
Braces   +12 added lines, -24 removed lines patch added patch discarded remove patch
@@ -151,8 +151,7 @@  discard block
 block discarded – undo
151 151
 		if($this->isVaildMailAddress($account_name))
152 152
 		{
153 153
 			$this->Username = $account_name;
154
-		}
155
-		else
154
+		} else
156 155
 		{
157 156
 			$this->Username = $account_name . '@gmail.com';
158 157
 		}
@@ -190,8 +189,7 @@  discard block
 block discarded – undo
190 189
 			$this->IsSMTP();
191 190
 			$this->AltBody = "To view the message, please use an HTML compatible email viewer!";
192 191
 			return TRUE;
193
-		}
194
-		else
192
+		} else
195 193
 		{
196 194
 			$this->IsMail();
197 195
 			return FALSE;
@@ -246,8 +244,7 @@  discard block
 block discarded – undo
246 244
 		{
247 245
 			$this->sender_name = $name;
248 246
 			$this->sender_email = $email;
249
-		}
250
-		else
247
+		} else
251 248
 		{
252 249
 			$this->SetFrom($email, $name);
253 250
 		}
@@ -280,8 +277,7 @@  discard block
 block discarded – undo
280 277
 		{
281 278
 			$this->receiptor_name = $name;
282 279
 			$this->receiptor_email = $email;
283
-		}
284
-		else
280
+		} else
285 281
 		{
286 282
 			$this->AddAddress($email, $name);
287 283
 		}
@@ -312,8 +308,7 @@  discard block
 block discarded – undo
312 308
 		if($this->Mailer == "mail")
313 309
 		{
314 310
 			$this->title = $title;
315
-		}
316
-		else
311
+		} else
317 312
 		{
318 313
 			$this->Subject = $title;
319 314
 		}
@@ -340,8 +335,7 @@  discard block
 block discarded – undo
340 335
 		if($this->Mailer == "mail")
341 336
 		{
342 337
 			$this->bcc = $bcc;
343
-		}
344
-		else
338
+		} else
345 339
 		{
346 340
 			$this->AddBCC($bcc);
347 341
 		}
@@ -380,8 +374,7 @@  discard block
 block discarded – undo
380 374
 		if($this->Mailer == "mail")
381 375
 		{
382 376
 			$this->replyTo = $replyTo;
383
-		}
384
-		else
377
+		} else
385 378
 		{
386 379
 			$this->AddReplyTo($replyTo);
387 380
 		}
@@ -399,8 +392,7 @@  discard block
 block discarded – undo
399 392
 		if($this->Mailer == "mail")
400 393
 		{
401 394
 			$this->content = $content;
402
-		}
403
-		else
395
+		} else
404 396
 		{
405 397
 			$this->MsgHTML($content);
406 398
 		}
@@ -486,8 +478,7 @@  discard block
 block discarded – undo
486 478
 				$this->body = implode("", $res);
487 479
 				$this->body .= "--" . $boundary . "--";
488 480
 			}
489
-		}
490
-		else
481
+		} else
491 482
 		{
492 483
 			if(count($this->attachments) > 0)
493 484
 			{
@@ -578,8 +569,7 @@  discard block
 block discarded – undo
578 569
 				return mail($this->getReceiptor(), $this->getTitle(), $this->body, $headers, $this->additional_params);
579 570
 			}
580 571
 			return mail($this->getReceiptor(), $this->getTitle(), $this->body, $headers);
581
-		}
582
-		else
572
+		} else
583 573
 		{
584 574
 			$this->procAttachments();
585 575
 			return parent::Send();
@@ -604,8 +594,7 @@  discard block
 block discarded – undo
604 594
 			if(checkdnsrr($host, "MX") || checkdnsrr($host, "A"))
605 595
 			{
606 596
 				return TRUE;
607
-			}
608
-			else
597
+			} else
609 598
 			{
610 599
 				return FALSE;
611 600
 			}
@@ -624,8 +613,7 @@  discard block
 block discarded – undo
624 613
 		if(preg_match("/([a-z0-9\_\-\.]+)@([a-z0-9\_\-\.]+)/i", $email_address))
625 614
 		{
626 615
 			return $email_address;
627
-		}
628
-		else
616
+		} else
629 617
 		{
630 618
 			return '';
631 619
 		}
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 
26 26
 	/**
27 27
 	 * constructor
28
-	 * @return void
28
+	 * @return string
29 29
 	 */
30 30
 	public function __construct()
31 31
 	{
Please login to merge, or discard this patch.
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 3
 
4
-require_once _XE_PATH_ . "libs/phpmailer/phpmailer.php";
4
+require_once _XE_PATH_."libs/phpmailer/phpmailer.php";
5 5
 
6 6
 /**
7 7
  * Mailing class for XpressEngine
@@ -148,13 +148,13 @@  discard block
 block discarded – undo
148 148
 		$this->SMTPSecure = "tls";
149 149
 		$this->Host = 'smtp.gmail.com';
150 150
 		$this->Port = '587';
151
-		if($this->isVaildMailAddress($account_name))
151
+		if ($this->isVaildMailAddress($account_name))
152 152
 		{
153 153
 			$this->Username = $account_name;
154 154
 		}
155 155
 		else
156 156
 		{
157
-			$this->Username = $account_name . '@gmail.com';
157
+			$this->Username = $account_name.'@gmail.com';
158 158
 		}
159 159
 		$this->Password = $account_passwd;
160 160
 		$this->IsSMTP();
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
 		$this->Password = $pass;
181 181
 		$this->Port = $port;
182 182
 
183
-		if($secure == 'ssl' || $secure == 'tls')
183
+		if ($secure == 'ssl' || $secure == 'tls')
184 184
 		{
185 185
 			$this->SMTPSecure = $secure;
186 186
 		}
187 187
 
188
-		if(($this->SMTPAuth !== NULL && $this->Host !== NULL && $this->Username !== NULL && $this->Password !== NULL) || ($this->SMTPAuth === NULL && $this->Host !== NULL))
188
+		if (($this->SMTPAuth !== NULL && $this->Host !== NULL && $this->Username !== NULL && $this->Password !== NULL) || ($this->SMTPAuth === NULL && $this->Host !== NULL))
189 189
 		{
190 190
 			$this->IsSMTP();
191 191
 			$this->AltBody = "To view the message, please use an HTML compatible email viewer!";
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 */
243 243
 	function setSender($name, $email)
244 244
 	{
245
-		if($this->Mailer == "mail")
245
+		if ($this->Mailer == "mail")
246 246
 		{
247 247
 			$this->sender_name = $name;
248 248
 			$this->sender_email = $email;
@@ -260,9 +260,9 @@  discard block
 block discarded – undo
260 260
 	 */
261 261
 	function getSender()
262 262
 	{
263
-		if(!stristr(PHP_OS, 'win') && $this->sender_name)
263
+		if (!stristr(PHP_OS, 'win') && $this->sender_name)
264 264
 		{
265
-			return sprintf("%s <%s>", '=?utf-8?b?' . base64_encode($this->sender_name) . '?=', $this->sender_email);
265
+			return sprintf("%s <%s>", '=?utf-8?b?'.base64_encode($this->sender_name).'?=', $this->sender_email);
266 266
 		}
267 267
 		return $this->sender_email;
268 268
 	}
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 */
277 277
 	function setReceiptor($name, $email)
278 278
 	{
279
-		if($this->Mailer == "mail")
279
+		if ($this->Mailer == "mail")
280 280
 		{
281 281
 			$this->receiptor_name = $name;
282 282
 			$this->receiptor_email = $email;
@@ -294,9 +294,9 @@  discard block
 block discarded – undo
294 294
 	 */
295 295
 	function getReceiptor()
296 296
 	{
297
-		if(!stristr(PHP_OS, 'win') && $this->receiptor_name && $this->receiptor_name != $this->receiptor_email)
297
+		if (!stristr(PHP_OS, 'win') && $this->receiptor_name && $this->receiptor_name != $this->receiptor_email)
298 298
 		{
299
-			return sprintf("%s <%s>", '=?utf-8?b?' . base64_encode($this->receiptor_name) . '?=', $this->receiptor_email);
299
+			return sprintf("%s <%s>", '=?utf-8?b?'.base64_encode($this->receiptor_name).'?=', $this->receiptor_email);
300 300
 		}
301 301
 		return $this->receiptor_email;
302 302
 	}
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 */
310 310
 	function setTitle($title)
311 311
 	{
312
-		if($this->Mailer == "mail")
312
+		if ($this->Mailer == "mail")
313 313
 		{
314 314
 			$this->title = $title;
315 315
 		}
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	 */
327 327
 	function getTitle()
328 328
 	{
329
-		return '=?utf-8?b?' . base64_encode($this->title) . '?=';
329
+		return '=?utf-8?b?'.base64_encode($this->title).'?=';
330 330
 	}
331 331
 
332 332
 	/**
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 	 */
338 338
 	function setBCC($bcc)
339 339
 	{
340
-		if($this->Mailer == "mail")
340
+		if ($this->Mailer == "mail")
341 341
 		{
342 342
 			$this->bcc = $bcc;
343 343
 		}
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 	 */
378 378
 	function setReplyTo($replyTo)
379 379
 	{
380
-		if($this->Mailer == "mail")
380
+		if ($this->Mailer == "mail")
381 381
 		{
382 382
 			$this->replyTo = $replyTo;
383 383
 		}
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 	function setContent($content)
397 397
 	{
398 398
 		$content = preg_replace_callback('/<img([^>]+)>/i', array($this, 'replaceResourceRealPath'), $content);
399
-		if($this->Mailer == "mail")
399
+		if ($this->Mailer == "mail")
400 400
 		{
401 401
 			$this->content = $content;
402 402
 		}
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
 	 */
416 416
 	function replaceResourceRealPath($matches)
417 417
 	{
418
-		return preg_replace('/src=(["\']?)files/i', 'src=$1' . Context::getRequestUri() . 'files', $matches[0]);
418
+		return preg_replace('/src=(["\']?)files/i', 'src=$1'.Context::getRequestUri().'files', $matches[0]);
419 419
 	}
420 420
 
421 421
 	/**
@@ -456,42 +456,42 @@  discard block
 block discarded – undo
456 456
 	 */
457 457
 	function procAttachments()
458 458
 	{
459
-		if($this->Mailer == "mail")
459
+		if ($this->Mailer == "mail")
460 460
 		{
461
-			if(count($this->attachments) > 0)
461
+			if (count($this->attachments) > 0)
462 462
 			{
463
-				$this->body = $this->header . $this->body;
464
-				$boundary = '----==' . uniqid(rand(), TRUE);
465
-				$this->header = "Content-Type: multipart/mixed;" . $this->eol . "\tboundary=\"" . $boundary . "\"" . $this->eol . $this->eol;
466
-				$this->body = "--" . $boundary . $this->eol . $this->body . $this->eol . $this->eol;
463
+				$this->body = $this->header.$this->body;
464
+				$boundary = '----=='.uniqid(rand(), TRUE);
465
+				$this->header = "Content-Type: multipart/mixed;".$this->eol."\tboundary=\"".$boundary."\"".$this->eol.$this->eol;
466
+				$this->body = "--".$boundary.$this->eol.$this->body.$this->eol.$this->eol;
467 467
 				$res = array();
468 468
 				$res[] = $this->body;
469
-				foreach($this->attachments as $filename => $attachment)
469
+				foreach ($this->attachments as $filename => $attachment)
470 470
 				{
471 471
 					$type = $this->returnMIMEType($filename);
472 472
 					$file_handler = new FileHandler();
473 473
 					$file_str = $file_handler->readFile($attachment);
474 474
 					$chunks = chunk_split(base64_encode($file_str));
475 475
 					$tempBody = sprintf(
476
-							"--" . $boundary . $this->eol .
477
-							"Content-Type: %s;" . $this->eol .
478
-							"\tname=\"%s\"" . $this->eol .
479
-							"Content-Transfer-Encoding: base64" . $this->eol .
480
-							"Content-Description: %s" . $this->eol .
481
-							"Content-Disposition: attachment;" . $this->eol .
482
-							"\tfilename=\"%s\"" . $this->eol . $this->eol .
483
-							"%s" . $this->eol . $this->eol, $type, $filename, $filename, $filename, $chunks);
476
+							"--".$boundary.$this->eol.
477
+							"Content-Type: %s;".$this->eol.
478
+							"\tname=\"%s\"".$this->eol.
479
+							"Content-Transfer-Encoding: base64".$this->eol.
480
+							"Content-Description: %s".$this->eol.
481
+							"Content-Disposition: attachment;".$this->eol.
482
+							"\tfilename=\"%s\"".$this->eol.$this->eol.
483
+							"%s".$this->eol.$this->eol, $type, $filename, $filename, $filename, $chunks);
484 484
 					$res[] = $tempBody;
485 485
 				}
486 486
 				$this->body = implode("", $res);
487
-				$this->body .= "--" . $boundary . "--";
487
+				$this->body .= "--".$boundary."--";
488 488
 			}
489 489
 		}
490 490
 		else
491 491
 		{
492
-			if(count($this->attachments) > 0)
492
+			if (count($this->attachments) > 0)
493 493
 			{
494
-				foreach($this->attachments as $filename => $attachment)
494
+				foreach ($this->attachments as $filename => $attachment)
495 495
 				{
496 496
 					parent::AddAttachment($attachment);
497 497
 				}
@@ -506,33 +506,33 @@  discard block
 block discarded – undo
506 506
 	 */
507 507
 	function procCidAttachments()
508 508
 	{
509
-		if(count($this->cidAttachments) > 0)
509
+		if (count($this->cidAttachments) > 0)
510 510
 		{
511
-			$this->body = $this->header . $this->body;
512
-			$boundary = '----==' . uniqid(rand(), TRUE);
513
-			$this->header = "Content-Type: multipart/relative;" . $this->eol . "\ttype=\"multipart/alternative\";" . $this->eol . "\tboundary=\"" . $boundary . "\"" . $this->eol . $this->eol;
514
-			$this->body = "--" . $boundary . $this->eol . $this->body . $this->eol . $this->eol;
511
+			$this->body = $this->header.$this->body;
512
+			$boundary = '----=='.uniqid(rand(), TRUE);
513
+			$this->header = "Content-Type: multipart/relative;".$this->eol."\ttype=\"multipart/alternative\";".$this->eol."\tboundary=\"".$boundary."\"".$this->eol.$this->eol;
514
+			$this->body = "--".$boundary.$this->eol.$this->body.$this->eol.$this->eol;
515 515
 			$res = array();
516 516
 			$res[] = $this->body;
517
-			foreach($this->cidAttachments as $cid => $attachment)
517
+			foreach ($this->cidAttachments as $cid => $attachment)
518 518
 			{
519 519
 				$filename = basename($attachment);
520 520
 				$type = $this->returnMIMEType(FileHandler::getRealPath($attachment));
521 521
 				$file_str = FileHandler::readFile($attachment);
522 522
 				$chunks = chunk_split(base64_encode($file_str));
523 523
 				$tempBody = sprintf(
524
-						"--" . $boundary . $this->eol .
525
-						"Content-Type: %s;" . $this->eol .
526
-						"\tname=\"%s\"" . $this->eol .
527
-						"Content-Transfer-Encoding: base64" . $this->eol .
528
-						"Content-ID: <%s>" . $this->eol .
529
-						"Content-Description: %s" . $this->eol .
530
-						"Content-Location: %s" . $this->eol . $this->eol .
531
-						"%s" . $this->eol . $this->eol, $type, $filename, $cid, $filename, $filename, $chunks);
524
+						"--".$boundary.$this->eol.
525
+						"Content-Type: %s;".$this->eol.
526
+						"\tname=\"%s\"".$this->eol.
527
+						"Content-Transfer-Encoding: base64".$this->eol.
528
+						"Content-ID: <%s>".$this->eol.
529
+						"Content-Description: %s".$this->eol.
530
+						"Content-Location: %s".$this->eol.$this->eol.
531
+						"%s".$this->eol.$this->eol, $type, $filename, $cid, $filename, $filename, $chunks);
532 532
 				$res[] = $tempBody;
533 533
 			}
534 534
 			$this->body = implode("", $res);
535
-			$this->body .= "--" . $boundary . "--";
535
+			$this->body .= "--".$boundary."--";
536 536
 		}
537 537
 	}
538 538
 
@@ -543,37 +543,37 @@  discard block
 block discarded – undo
543 543
 	 */
544 544
 	function send()
545 545
 	{
546
-		if($this->Mailer == "mail")
546
+		if ($this->Mailer == "mail")
547 547
 		{
548
-			$boundary = '----==' . uniqid(rand(), TRUE);
548
+			$boundary = '----=='.uniqid(rand(), TRUE);
549 549
 			$this->eol = $GLOBALS['_qmail_compatibility'] == "Y" ? "\n" : "\r\n";
550
-			$this->header = "Content-Type: multipart/alternative;" . $this->eol . "\tboundary=\"" . $boundary . "\"" . $this->eol . $this->eol;
550
+			$this->header = "Content-Type: multipart/alternative;".$this->eol."\tboundary=\"".$boundary."\"".$this->eol.$this->eol;
551 551
 			$this->body = sprintf(
552
-					"--%s" . $this->eol .
553
-					"Content-Type: text/plain; charset=utf-8; format=flowed" . $this->eol .
554
-					"Content-Transfer-Encoding: base64" . $this->eol .
555
-					"Content-Disposition: inline" . $this->eol . $this->eol .
556
-					"%s" .
557
-					"--%s" . $this->eol .
558
-					"Content-Type: text/html; charset=utf-8" . $this->eol .
559
-					"Content-Transfer-Encoding: base64" . $this->eol .
560
-					"Content-Disposition: inline" . $this->eol . $this->eol .
561
-					"%s" .
562
-					"--%s--" .
552
+					"--%s".$this->eol.
553
+					"Content-Type: text/plain; charset=utf-8; format=flowed".$this->eol.
554
+					"Content-Transfer-Encoding: base64".$this->eol.
555
+					"Content-Disposition: inline".$this->eol.$this->eol.
556
+					"%s".
557
+					"--%s".$this->eol.
558
+					"Content-Type: text/html; charset=utf-8".$this->eol.
559
+					"Content-Transfer-Encoding: base64".$this->eol.
560
+					"Content-Disposition: inline".$this->eol.$this->eol.
561
+					"%s".
562
+					"--%s--".
563 563
 					"", $boundary, $this->getPlainContent(), $boundary, $this->getHTMLContent(), $boundary
564 564
 			);
565 565
 			$this->procCidAttachments();
566 566
 			$this->procAttachments();
567 567
 			$headers = sprintf(
568
-					"From: %s" . $this->eol .
569
-					"%s" .
570
-					"%s" .
571
-					"%s" .
572
-					"%s" .
573
-					"MIME-Version: 1.0" . $this->eol . "", $this->getSender(), $this->messageId ? ("Message-ID: <" . $this->messageId . ">" . $this->eol) : "", $this->replyTo ? ("Reply-To: <" . $this->replyTo . ">" . $this->eol) : "", $this->bcc ? ("Bcc: " . $this->bcc . $this->eol) : "", $this->references ? ("References: <" . $this->references . ">" . $this->eol . "In-Reply-To: <" . $this->references . ">" . $this->eol) : ""
568
+					"From: %s".$this->eol.
569
+					"%s".
570
+					"%s".
571
+					"%s".
572
+					"%s".
573
+					"MIME-Version: 1.0".$this->eol."", $this->getSender(), $this->messageId ? ("Message-ID: <".$this->messageId.">".$this->eol) : "", $this->replyTo ? ("Reply-To: <".$this->replyTo.">".$this->eol) : "", $this->bcc ? ("Bcc: ".$this->bcc.$this->eol) : "", $this->references ? ("References: <".$this->references.">".$this->eol."In-Reply-To: <".$this->references.">".$this->eol) : ""
574 574
 			);
575 575
 			$headers .= $this->header;
576
-			if($this->additional_params)
576
+			if ($this->additional_params)
577 577
 			{
578 578
 				return mail($this->getReceiptor(), $this->getTitle(), $this->body, $headers, $this->additional_params);
579 579
 			}
@@ -594,14 +594,14 @@  discard block
 block discarded – undo
594 594
 	 */
595 595
 	function checkMailMX($email_address)
596 596
 	{
597
-		if(!Mail::isVaildMailAddress($email_address))
597
+		if (!Mail::isVaildMailAddress($email_address))
598 598
 		{
599 599
 			return FALSE;
600 600
 		}
601 601
 		list($user, $host) = explode("@", $email_address);
602
-		if(function_exists('checkdnsrr'))
602
+		if (function_exists('checkdnsrr'))
603 603
 		{
604
-			if(checkdnsrr($host, "MX") || checkdnsrr($host, "A"))
604
+			if (checkdnsrr($host, "MX") || checkdnsrr($host, "A"))
605 605
 			{
606 606
 				return TRUE;
607 607
 			}
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 	 */
622 622
 	function isVaildMailAddress($email_address)
623 623
 	{
624
-		if(preg_match("/([a-z0-9\_\-\.]+)@([a-z0-9\_\-\.]+)/i", $email_address))
624
+		if (preg_match("/([a-z0-9\_\-\.]+)@([a-z0-9\_\-\.]+)/i", $email_address))
625 625
 		{
626 626
 			return $email_address;
627 627
 		}
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 	function returnMIMEType($filename)
641 641
 	{
642 642
 		preg_match("|\.([a-z0-9]{2,4})$|i", $filename, $fileSuffix);
643
-		switch(strtolower($fileSuffix[1]))
643
+		switch (strtolower($fileSuffix[1]))
644 644
 		{
645 645
 			case "js" :
646 646
 				return "application/x-javascript";
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
 			case "gif" :
655 655
 			case "bmp" :
656 656
 			case "tiff" :
657
-				return "image/" . strtolower($fileSuffix[1]);
657
+				return "image/".strtolower($fileSuffix[1]);
658 658
 			case "css" :
659 659
 				return "text/css";
660 660
 			case "xml" :
@@ -708,11 +708,11 @@  discard block
 block discarded – undo
708 708
 			case "swf" :
709 709
 				return "application/x-shockwave-flash";
710 710
 			default :
711
-				if(function_exists("mime_content_type"))
711
+				if (function_exists("mime_content_type"))
712 712
 				{
713 713
 					$fileSuffix = mime_content_type($filename);
714 714
 				}
715
-				return "unknown/" . trim($fileSuffix[0], ".");
715
+				return "unknown/".trim($fileSuffix[0], ".");
716 716
 		}
717 717
 	}
718 718
 
Please login to merge, or discard this patch.
classes/mobile/Mobile.class.php 2 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	function &getInstance()
24 24
 	{
25 25
 		static $theInstance;
26
-		if(!isset($theInstance))
26
+		if (!isset($theInstance))
27 27
 		{
28 28
 			$theInstance = new Mobile();
29 29
 		}
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
 	 */
49 49
 	function _isFromMobilePhone()
50 50
 	{
51
-		if($this->ismobile !== NULL)
51
+		if ($this->ismobile !== NULL)
52 52
 		{
53 53
 			return $this->ismobile;
54 54
 		}
55
-		if(Mobile::isMobileEnabled() === false || Context::get('full_browse') || $_COOKIE["FullBrowse"])
55
+		if (Mobile::isMobileEnabled() === false || Context::get('full_browse') || $_COOKIE["FullBrowse"])
56 56
 		{
57 57
 			return ($this->ismobile = false);
58 58
 		}
@@ -63,22 +63,22 @@  discard block
 block discarded – undo
63 63
 		$this->ismobile = FALSE;
64 64
 
65 65
 		$m = Context::get('m');
66
-		if(strlen($m) == 1)
66
+		if (strlen($m) == 1)
67 67
 		{
68
-			if($m == "1")
68
+			if ($m == "1")
69 69
 			{
70 70
 				$this->ismobile = TRUE;
71 71
 			}
72
-			elseif($m == "0")
72
+			elseif ($m == "0")
73 73
 			{
74 74
 				$this->ismobile = FALSE;
75 75
 			}
76 76
 		}
77
-		elseif(isset($_COOKIE['mobile']))
77
+		elseif (isset($_COOKIE['mobile']))
78 78
 		{
79
-			if($_COOKIE['user-agent'] == md5($_SERVER['HTTP_USER_AGENT']))
79
+			if ($_COOKIE['user-agent'] == md5($_SERVER['HTTP_USER_AGENT']))
80 80
 			{
81
-				if($_COOKIE['mobile'] == 'true')
81
+				if ($_COOKIE['mobile'] == 'true')
82 82
 				{
83 83
 					$this->ismobile = TRUE;
84 84
 				}
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 				$this->ismobile = FALSE;
93 93
 				setcookie("mobile", FALSE, 0, $xe_web_path);
94 94
 				setcookie("user-agent", FALSE, 0, $xe_web_path);
95
-				if(!$this->isMobilePadCheckByAgent() && $this->isMobileCheckByAgent())
95
+				if (!$this->isMobilePadCheckByAgent() && $this->isMobileCheckByAgent())
96 96
 				{
97 97
 					$this->ismobile = TRUE;
98 98
 				}
@@ -100,36 +100,36 @@  discard block
 block discarded – undo
100 100
 		}
101 101
 		else
102 102
 		{
103
-			if($this->isMobilePadCheckByAgent())
103
+			if ($this->isMobilePadCheckByAgent())
104 104
 			{
105 105
 				$this->ismobile = FALSE;
106 106
 			}
107 107
 			else
108 108
 			{
109
-				if($this->isMobileCheckByAgent())
109
+				if ($this->isMobileCheckByAgent())
110 110
 				{
111 111
 					$this->ismobile = TRUE;
112 112
 				}
113 113
 			}
114 114
 		}
115 115
 
116
-		if($this->ismobile !== NULL)
116
+		if ($this->ismobile !== NULL)
117 117
 		{
118
-			if($this->ismobile == TRUE)
118
+			if ($this->ismobile == TRUE)
119 119
 			{
120
-				if($_COOKIE['mobile'] != 'true')
120
+				if ($_COOKIE['mobile'] != 'true')
121 121
 				{
122 122
 					$_COOKIE['mobile'] = 'true';
123 123
 					setcookie("mobile", 'true', 0, $xe_web_path);
124 124
 				}
125 125
 			}
126
-			elseif($_COOKIE['mobile'] != 'false')
126
+			elseif ($_COOKIE['mobile'] != 'false')
127 127
 			{
128 128
 				$_COOKIE['mobile'] = 'false';
129 129
 				setcookie("mobile", 'false', 0, $xe_web_path);
130 130
 			}
131 131
 
132
-			if($_COOKIE['user-agent'] != md5($_SERVER['HTTP_USER_AGENT']))
132
+			if ($_COOKIE['user-agent'] != md5($_SERVER['HTTP_USER_AGENT']))
133 133
 			{
134 134
 				setcookie("user-agent", md5($_SERVER['HTTP_USER_AGENT']), 0, $xe_web_path);
135 135
 			}
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 	function isMobileCheckByAgent()
147 147
 	{
148 148
 		static $UACheck;
149
-		if(isset($UACheck))
149
+		if (isset($UACheck))
150 150
 		{
151 151
 			return $UACheck;
152 152
 		}
@@ -154,15 +154,15 @@  discard block
 block discarded – undo
154 154
 		$oMobile = Mobile::getInstance();
155 155
 		$mobileAgent = array('iPod', 'iPhone', 'Android', 'BlackBerry', 'SymbianOS', 'Bada', 'Tizen', 'Kindle', 'Wii', 'SCH-', 'SPH-', 'CANU-', 'Windows Phone', 'Windows CE', 'POLARIS', 'Palm', 'Dorothy Browser', 'Mobile', 'Opera Mobi', 'Opera Mini', 'Minimo', 'AvantGo', 'NetFront', 'Nokia', 'LGPlayer', 'SonyEricsson', 'HTC');
156 156
 
157
-		if($oMobile->isMobilePadCheckByAgent())
157
+		if ($oMobile->isMobilePadCheckByAgent())
158 158
 		{
159 159
 			$UACheck = TRUE;
160 160
 			return TRUE;
161 161
 		}
162 162
 
163
-		foreach($mobileAgent as $agent)
163
+		foreach ($mobileAgent as $agent)
164 164
 		{
165
-			if(stripos($_SERVER['HTTP_USER_AGENT'], $agent) !== FALSE)
165
+			if (stripos($_SERVER['HTTP_USER_AGENT'], $agent) !== FALSE)
166 166
 			{
167 167
 				$UACheck = TRUE;
168 168
 				return TRUE;
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	function isMobilePadCheckByAgent()
181 181
 	{
182 182
 		static $UACheck;
183
-		if(isset($UACheck))
183
+		if (isset($UACheck))
184 184
 		{
185 185
 			return $UACheck;
186 186
 		}
@@ -190,21 +190,21 @@  discard block
 block discarded – undo
190 190
 		// $exceptionAgent[0] contains exception agents for all exceptions.
191 191
 		$exceptionAgent = array(0 => array('Opera Mini', 'Opera Mobi'), 'Android' => 'Mobile');
192 192
 
193
-		foreach($padAgent as $agent)
193
+		foreach ($padAgent as $agent)
194 194
 		{
195
-			if(strpos($_SERVER['HTTP_USER_AGENT'], $agent) !== FALSE)
195
+			if (strpos($_SERVER['HTTP_USER_AGENT'], $agent) !== FALSE)
196 196
 			{
197
-				if(!isset($exceptionAgent[$agent]))
197
+				if (!isset($exceptionAgent[$agent]))
198 198
 				{
199 199
 					$UACheck = TRUE;
200 200
 					return TRUE;
201 201
 				}
202
-				elseif(strpos($_SERVER['HTTP_USER_AGENT'], $exceptionAgent[$agent]) === FALSE)
202
+				elseif (strpos($_SERVER['HTTP_USER_AGENT'], $exceptionAgent[$agent]) === FALSE)
203 203
 				{
204 204
 					// If the agent is the Android, that can be either tablet and mobile phone.
205
-					foreach($exceptionAgent[0] as $val)
205
+					foreach ($exceptionAgent[0] as $val)
206 206
 					{
207
-						if(strpos($_SERVER['HTTP_USER_AGENT'], $val) !== FALSE)
207
+						if (strpos($_SERVER['HTTP_USER_AGENT'], $val) !== FALSE)
208 208
 						{
209 209
 							$UACheck = FALSE;
210 210
 							return FALSE;
Please login to merge, or discard this patch.
Braces   +8 added lines, -16 removed lines patch added patch discarded remove patch
@@ -68,26 +68,22 @@  discard block
 block discarded – undo
68 68
 			if($m == "1")
69 69
 			{
70 70
 				$this->ismobile = TRUE;
71
-			}
72
-			elseif($m == "0")
71
+			} elseif($m == "0")
73 72
 			{
74 73
 				$this->ismobile = FALSE;
75 74
 			}
76
-		}
77
-		elseif(isset($_COOKIE['mobile']))
75
+		} elseif(isset($_COOKIE['mobile']))
78 76
 		{
79 77
 			if($_COOKIE['user-agent'] == md5($_SERVER['HTTP_USER_AGENT']))
80 78
 			{
81 79
 				if($_COOKIE['mobile'] == 'true')
82 80
 				{
83 81
 					$this->ismobile = TRUE;
84
-				}
85
-				else
82
+				} else
86 83
 				{
87 84
 					$this->ismobile = FALSE;
88 85
 				}
89
-			}
90
-			else
86
+			} else
91 87
 			{
92 88
 				$this->ismobile = FALSE;
93 89
 				setcookie("mobile", FALSE, 0, $xe_web_path);
@@ -97,14 +93,12 @@  discard block
 block discarded – undo
97 93
 					$this->ismobile = TRUE;
98 94
 				}
99 95
 			}
100
-		}
101
-		else
96
+		} else
102 97
 		{
103 98
 			if($this->isMobilePadCheckByAgent())
104 99
 			{
105 100
 				$this->ismobile = FALSE;
106
-			}
107
-			else
101
+			} else
108 102
 			{
109 103
 				if($this->isMobileCheckByAgent())
110 104
 				{
@@ -122,8 +116,7 @@  discard block
 block discarded – undo
122 116
 					$_COOKIE['mobile'] = 'true';
123 117
 					setcookie("mobile", 'true', 0, $xe_web_path);
124 118
 				}
125
-			}
126
-			elseif($_COOKIE['mobile'] != 'false')
119
+			} elseif($_COOKIE['mobile'] != 'false')
127 120
 			{
128 121
 				$_COOKIE['mobile'] = 'false';
129 122
 				setcookie("mobile", 'false', 0, $xe_web_path);
@@ -198,8 +191,7 @@  discard block
 block discarded – undo
198 191
 				{
199 192
 					$UACheck = TRUE;
200 193
 					return TRUE;
201
-				}
202
-				elseif(strpos($_SERVER['HTTP_USER_AGENT'], $exceptionAgent[$agent]) === FALSE)
194
+				} elseif(strpos($_SERVER['HTTP_USER_AGENT'], $exceptionAgent[$agent]) === FALSE)
203 195
 				{
204 196
 					// If the agent is the Android, that can be either tablet and mobile phone.
205 197
 					foreach($exceptionAgent[0] as $val)
Please login to merge, or discard this patch.
classes/page/PageHandler.class.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
 		$this->point = 0;
40 40
 
41 41
 		$first_page = $cur_page - (int) ($page_count / 2);
42
-		if($first_page < 1)
42
+		if ($first_page < 1)
43 43
 		{
44 44
 			$first_page = 1;
45 45
 		}
46 46
 
47
-		if($total_page > $page_count && $first_page + $page_count - 1 > $total_page)
47
+		if ($total_page > $page_count && $first_page + $page_count - 1 > $total_page)
48 48
 		{
49 49
 			$first_page -= $first_page + $page_count - 1 - $total_page;
50 50
 		}
51 51
 
52 52
 		$last_page = $total_page;
53
-		if($last_page > $total_page)
53
+		if ($last_page > $total_page)
54 54
 		{
55 55
 			$last_page = $total_page;
56 56
 		}
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 		$this->first_page = $first_page;
59 59
 		$this->last_page = $last_page;
60 60
 
61
-		if($total_page < $this->page_count)
61
+		if ($total_page < $this->page_count)
62 62
 		{
63 63
 			$this->page_count = $total_page;
64 64
 		}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	function getNextPage()
72 72
 	{
73 73
 		$page = $this->first_page + $this->point++;
74
-		if($this->point > $this->page_count || $page > $this->last_page)
74
+		if ($this->point > $this->page_count || $page > $this->last_page)
75 75
 		{
76 76
 			$page = 0;
77 77
 		}
Please login to merge, or discard this patch.
classes/security/IpFilter.class.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,24 +5,24 @@  discard block
 block discarded – undo
5 5
 {
6 6
 	public function filter($ip_list, $ip = NULL)
7 7
 	{
8
-		if(!$ip) $ip = $_SERVER['REMOTE_ADDR'];
8
+		if (!$ip) $ip = $_SERVER['REMOTE_ADDR'];
9 9
 		$long_ip = ip2long($ip);
10
-		foreach($ip_list as $filter_ip)
10
+		foreach ($ip_list as $filter_ip)
11 11
 		{	
12 12
 			$range = explode('-', $filter_ip);
13
-			if(!$range[1]) // single address type
13
+			if (!$range[1]) // single address type
14 14
 			{
15 15
 				$star_pos = strpos($filter_ip, '*');
16
-				if($star_pos !== FALSE ) // wild card exist 
16
+				if ($star_pos !== FALSE) // wild card exist 
17 17
 				{
18
-					if(strncmp($filter_ip, $ip, $star_pos)===0) return true;
18
+					if (strncmp($filter_ip, $ip, $star_pos) === 0) return true;
19 19
 				}
20
-				else if(strcmp($filter_ip, $ip)===0)
20
+				else if (strcmp($filter_ip, $ip) === 0)
21 21
 				{
22 22
 					return true;
23 23
 				}
24 24
 			}
25
-			else if(ip2long($range[0]) <= $long_ip && ip2long($range[1]) >= $long_ip)
25
+			else if (ip2long($range[0]) <= $long_ip && ip2long($range[1]) >= $long_ip)
26 26
 			{
27 27
 				return true;
28 28
 			}
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
 					)
75 75
 				)
76 76
 			$/";
77
-		$regex = str_replace(array("\r\n", "\n", "\r","\t"," "), '', $regex);
77
+		$regex = str_replace(array("\r\n", "\n", "\r", "\t", " "), '', $regex);
78 78
 		
79
-		foreach($ip_list as $i => $ip)
79
+		foreach ($ip_list as $i => $ip)
80 80
 		{
81 81
 			preg_match($regex, $ip, $matches);
82
-			if(!count($matches)) return false;
82
+			if (!count($matches)) return false;
83 83
 		}
84 84
 		
85 85
 		return true;
Please login to merge, or discard this patch.
Braces   +13 added lines, -7 removed lines patch added patch discarded remove patch
@@ -5,24 +5,28 @@  discard block
 block discarded – undo
5 5
 {
6 6
 	public function filter($ip_list, $ip = NULL)
7 7
 	{
8
-		if(!$ip) $ip = $_SERVER['REMOTE_ADDR'];
8
+		if(!$ip) {
9
+			$ip = $_SERVER['REMOTE_ADDR'];
10
+		}
9 11
 		$long_ip = ip2long($ip);
10 12
 		foreach($ip_list as $filter_ip)
11 13
 		{	
12 14
 			$range = explode('-', $filter_ip);
13
-			if(!$range[1]) // single address type
15
+			if(!$range[1]) {
16
+				// single address type
14 17
 			{
15 18
 				$star_pos = strpos($filter_ip, '*');
16
-				if($star_pos !== FALSE ) // wild card exist 
19
+			}
20
+				if($star_pos !== FALSE ) {
21
+					// wild card exist 
17 22
 				{
18 23
 					if(strncmp($filter_ip, $ip, $star_pos)===0) return true;
19 24
 				}
20
-				else if(strcmp($filter_ip, $ip)===0)
25
+				} else if(strcmp($filter_ip, $ip)===0)
21 26
 				{
22 27
 					return true;
23 28
 				}
24
-			}
25
-			else if(ip2long($range[0]) <= $long_ip && ip2long($range[1]) >= $long_ip)
29
+			} else if(ip2long($range[0]) <= $long_ip && ip2long($range[1]) >= $long_ip)
26 30
 			{
27 31
 				return true;
28 32
 			}
@@ -79,7 +83,9 @@  discard block
 block discarded – undo
79 83
 		foreach($ip_list as $i => $ip)
80 84
 		{
81 85
 			preg_match($regex, $ip, $matches);
82
-			if(!count($matches)) return false;
86
+			if(!count($matches)) {
87
+				return false;
88
+			}
83 89
 		}
84 90
 		
85 91
 		return true;
Please login to merge, or discard this patch.
classes/security/Password.class.php 2 patches
Braces   +17 added lines, -29 removed lines patch added patch discarded remove patch
@@ -55,8 +55,7 @@  discard block
 block discarded – undo
55 55
 			{
56 56
 				$algorithm = 'md5';  // Historical default for XE
57 57
 			}
58
-		}
59
-		else
58
+		} else
60 59
 		{
61 60
 			$algorithm = 'md5';
62 61
 		}
@@ -77,8 +76,7 @@  discard block
 block discarded – undo
77 76
 			{
78 77
 				$work_factor = 8;  // Reasonable default
79 78
 			}
80
-		}
81
-		else
79
+		} else
82 80
 		{
83 81
 			$work_factor = 8;
84 82
 		}
@@ -176,24 +174,19 @@  discard block
 block discarded – undo
176 174
 		if(preg_match('/^\$2[axy]\$([0-9]{2})\$/', $hash, $matches))
177 175
 		{
178 176
 			return 'bcrypt';
179
-		}
180
-		elseif(preg_match('/^sha[0-9]+:([0-9]+):/', $hash, $matches))
177
+		} elseif(preg_match('/^sha[0-9]+:([0-9]+):/', $hash, $matches))
181 178
 		{
182 179
 			return 'pbkdf2';
183
-		}
184
-		elseif(strlen($hash) === 32 && ctype_xdigit($hash))
180
+		} elseif(strlen($hash) === 32 && ctype_xdigit($hash))
185 181
 		{
186 182
 			return 'md5';
187
-		}
188
-		elseif(strlen($hash) === 16 && ctype_xdigit($hash))
183
+		} elseif(strlen($hash) === 16 && ctype_xdigit($hash))
189 184
 		{
190 185
 			return 'mysql_old_password';
191
-		}
192
-		elseif(strlen($hash) === 41 && $hash[0] === '*')
186
+		} elseif(strlen($hash) === 41 && $hash[0] === '*')
193 187
 		{
194 188
 			return 'mysql_password';
195
-		}
196
-		else
189
+		} else
197 190
 		{
198 191
 			return false;
199 192
 		}
@@ -209,12 +202,10 @@  discard block
 block discarded – undo
209 202
 		if(preg_match('/^\$2[axy]\$([0-9]{2})\$/', $hash, $matches))
210 203
 		{
211 204
 			return intval($matches[1], 10);
212
-		}
213
-		elseif(preg_match('/^sha[0-9]+:([0-9]+):/', $hash, $matches))
205
+		} elseif(preg_match('/^sha[0-9]+:([0-9]+):/', $hash, $matches))
214 206
 		{
215 207
 			return max(0, round(log($matches[1], 2)) - 5);
216
-		}
217
-		else
208
+		} else
218 209
 		{
219 210
 			return false;
220 211
 		}
@@ -250,22 +241,18 @@  discard block
 block discarded – undo
250 241
 		if(function_exists('openssl_random_pseudo_bytes') && (!$is_windows || version_compare(PHP_VERSION, '5.4', '>=')))
251 242
 		{
252 243
 			$entropy = openssl_random_pseudo_bytes($entropy_capped_bytes);
253
-		}
254
-		elseif(function_exists('mcrypt_create_iv') && (!$is_windows || version_compare(PHP_VERSION, '5.3.7', '>=')))
244
+		} elseif(function_exists('mcrypt_create_iv') && (!$is_windows || version_compare(PHP_VERSION, '5.3.7', '>=')))
255 245
 		{
256 246
 			$entropy = mcrypt_create_iv($entropy_capped_bytes, MCRYPT_DEV_URANDOM);
257
-		}
258
-		elseif(function_exists('mcrypt_create_iv') && $is_windows)
247
+		} elseif(function_exists('mcrypt_create_iv') && $is_windows)
259 248
 		{
260 249
 			$entropy = mcrypt_create_iv($entropy_capped_bytes, MCRYPT_RAND);
261
-		}
262
-		elseif(!$is_windows && @is_readable('/dev/urandom'))
250
+		} elseif(!$is_windows && @is_readable('/dev/urandom'))
263 251
 		{
264 252
 			$fp = fopen('/dev/urandom', 'rb');
265 253
 			$entropy = fread($fp, $entropy_capped_bytes);
266 254
 			fclose($fp);
267
-		}
268
-		else
255
+		} else
269 256
 		{
270 257
 			$entropy = '';
271 258
 			for($i = 0; $i < $entropy_capped_bytes; $i += 2)
@@ -341,8 +328,7 @@  discard block
 block discarded – undo
341 328
 		if(function_exists('hash_pbkdf2'))
342 329
 		{
343 330
 			return hash_pbkdf2($algorithm, $password, $salt, $iterations, $length, true);
344
-		}
345
-		else
331
+		} else
346 332
 		{
347 333
 			$output = '';
348 334
 			$block_count = ceil($length / strlen(hash($algorithm, '', true)));  // key length divided by the length of one hash
@@ -350,10 +336,12 @@  discard block
 block discarded – undo
350 336
 			{
351 337
 				$last = $salt . pack('N', $i);  // $i encoded as 4 bytes, big endian
352 338
 				$last = $xorsum = hash_hmac($algorithm, $last, $password, true);  // first iteration
353
-				for($j = 1; $j < $iterations; $j++)  // The other $count - 1 iterations
339
+				for($j = 1; $j < $iterations; $j++) {
340
+					// The other $count - 1 iterations
354 341
 				{
355 342
 					$xorsum ^= ($last = hash_hmac($algorithm, $last, $password, true));
356 343
 				}
344
+				}
357 345
 				$output .= $xorsum;
358 346
 			}
359 347
 			return substr($output, 0, $length);
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
 	public function getSupportedAlgorithms()
20 20
 	{
21 21
 		$retval = array();
22
-		if(function_exists('hash_hmac') && in_array('sha256', hash_algos()))
22
+		if (function_exists('hash_hmac') && in_array('sha256', hash_algos()))
23 23
 		{
24 24
 			$retval['pbkdf2'] = 'pbkdf2';
25 25
 		}
26
-		if(version_compare(PHP_VERSION, '5.3.7', '>=') && defined('CRYPT_BLOWFISH'))
26
+		if (version_compare(PHP_VERSION, '5.3.7', '>=') && defined('CRYPT_BLOWFISH'))
27 27
 		{
28 28
 			$retval['bcrypt'] = 'bcrypt';
29 29
 		}
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
 	 */
48 48
 	public function getCurrentlySelectedAlgorithm()
49 49
 	{
50
-		if(function_exists('getModel'))
50
+		if (function_exists('getModel'))
51 51
 		{
52 52
 			$config = getModel('member')->getMemberConfig();
53 53
 			$algorithm = $config->password_hashing_algorithm;
54
-			if(strval($algorithm) === '')
54
+			if (strval($algorithm) === '')
55 55
 			{
56
-				$algorithm = 'md5';  // Historical default for XE
56
+				$algorithm = 'md5'; // Historical default for XE
57 57
 			}
58 58
 		}
59 59
 		else
@@ -69,13 +69,13 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function getWorkFactor()
71 71
 	{
72
-		if(function_exists('getModel'))
72
+		if (function_exists('getModel'))
73 73
 		{
74 74
 			$config = getModel('member')->getMemberConfig();
75 75
 			$work_factor = $config->password_hashing_work_factor;
76
-			if(!$work_factor || $work_factor < 4 || $work_factor > 31)
76
+			if (!$work_factor || $work_factor < 4 || $work_factor > 31)
77 77
 			{
78
-				$work_factor = 8;  // Reasonable default
78
+				$work_factor = 8; // Reasonable default
79 79
 			}
80 80
 		}
81 81
 		else
@@ -93,18 +93,18 @@  discard block
 block discarded – undo
93 93
 	 */
94 94
 	public function createHash($password, $algorithm = null)
95 95
 	{
96
-		if($algorithm === null)
96
+		if ($algorithm === null)
97 97
 		{
98 98
 			$algorithm = $this->getCurrentlySelectedAlgorithm();
99 99
 		}
100
-		if(!array_key_exists($algorithm, $this->getSupportedAlgorithms()))
100
+		if (!array_key_exists($algorithm, $this->getSupportedAlgorithms()))
101 101
 		{
102 102
 			return false;
103 103
 		}
104 104
 
105 105
 		$password = trim($password);
106 106
 
107
-		switch($algorithm)
107
+		switch ($algorithm)
108 108
 		{
109 109
 			case 'md5':
110 110
 				return md5($password);
@@ -132,14 +132,14 @@  discard block
 block discarded – undo
132 132
 	 */
133 133
 	public function checkPassword($password, $hash, $algorithm = null)
134 134
 	{
135
-		if($algorithm === null)
135
+		if ($algorithm === null)
136 136
 		{
137 137
 			$algorithm = $this->checkAlgorithm($hash);
138 138
 		}
139 139
 
140 140
 		$password = trim($password);
141 141
 
142
-		switch($algorithm)
142
+		switch ($algorithm)
143 143
 		{
144 144
 			case 'md5':
145 145
 				return md5($password) === $hash || md5(sha1(md5($password))) === $hash;
@@ -173,23 +173,23 @@  discard block
 block discarded – undo
173 173
 	 */
174 174
 	function checkAlgorithm($hash)
175 175
 	{
176
-		if(preg_match('/^\$2[axy]\$([0-9]{2})\$/', $hash, $matches))
176
+		if (preg_match('/^\$2[axy]\$([0-9]{2})\$/', $hash, $matches))
177 177
 		{
178 178
 			return 'bcrypt';
179 179
 		}
180
-		elseif(preg_match('/^sha[0-9]+:([0-9]+):/', $hash, $matches))
180
+		elseif (preg_match('/^sha[0-9]+:([0-9]+):/', $hash, $matches))
181 181
 		{
182 182
 			return 'pbkdf2';
183 183
 		}
184
-		elseif(strlen($hash) === 32 && ctype_xdigit($hash))
184
+		elseif (strlen($hash) === 32 && ctype_xdigit($hash))
185 185
 		{
186 186
 			return 'md5';
187 187
 		}
188
-		elseif(strlen($hash) === 16 && ctype_xdigit($hash))
188
+		elseif (strlen($hash) === 16 && ctype_xdigit($hash))
189 189
 		{
190 190
 			return 'mysql_old_password';
191 191
 		}
192
-		elseif(strlen($hash) === 41 && $hash[0] === '*')
192
+		elseif (strlen($hash) === 41 && $hash[0] === '*')
193 193
 		{
194 194
 			return 'mysql_password';
195 195
 		}
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	function checkWorkFactor($hash)
208 208
 	{
209
-		if(preg_match('/^\$2[axy]\$([0-9]{2})\$/', $hash, $matches))
209
+		if (preg_match('/^\$2[axy]\$([0-9]{2})\$/', $hash, $matches))
210 210
 		{
211 211
 			return intval($matches[1], 10);
212 212
 		}
213
-		elseif(preg_match('/^sha[0-9]+:([0-9]+):/', $hash, $matches))
213
+		elseif (preg_match('/^sha[0-9]+:([0-9]+):/', $hash, $matches))
214 214
 		{
215 215
 			return max(0, round(log($matches[1], 2)) - 5);
216 216
 		}
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 	public function createSecureSalt($length, $format = 'hex')
230 230
 	{
231 231
 		// Find out how many bytes of entropy we really need
232
-		switch($format)
232
+		switch ($format)
233 233
 		{
234 234
 			case 'hex':
235 235
 				$entropy_required_bytes = ceil($length / 2);
@@ -247,19 +247,19 @@  discard block
 block discarded – undo
247 247
 
248 248
 		// Find and use the most secure way to generate a random string
249 249
 		$is_windows = (defined('PHP_OS') && strtoupper(substr(PHP_OS, 0, 3)) === 'WIN');
250
-		if(function_exists('openssl_random_pseudo_bytes') && (!$is_windows || version_compare(PHP_VERSION, '5.4', '>=')))
250
+		if (function_exists('openssl_random_pseudo_bytes') && (!$is_windows || version_compare(PHP_VERSION, '5.4', '>=')))
251 251
 		{
252 252
 			$entropy = openssl_random_pseudo_bytes($entropy_capped_bytes);
253 253
 		}
254
-		elseif(function_exists('mcrypt_create_iv') && (!$is_windows || version_compare(PHP_VERSION, '5.3.7', '>=')))
254
+		elseif (function_exists('mcrypt_create_iv') && (!$is_windows || version_compare(PHP_VERSION, '5.3.7', '>=')))
255 255
 		{
256 256
 			$entropy = mcrypt_create_iv($entropy_capped_bytes, MCRYPT_DEV_URANDOM);
257 257
 		}
258
-		elseif(function_exists('mcrypt_create_iv') && $is_windows)
258
+		elseif (function_exists('mcrypt_create_iv') && $is_windows)
259 259
 		{
260 260
 			$entropy = mcrypt_create_iv($entropy_capped_bytes, MCRYPT_RAND);
261 261
 		}
262
-		elseif(!$is_windows && @is_readable('/dev/urandom'))
262
+		elseif (!$is_windows && @is_readable('/dev/urandom'))
263 263
 		{
264 264
 			$fp = fopen('/dev/urandom', 'rb');
265 265
 			$entropy = fread($fp, $entropy_capped_bytes);
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 		else
269 269
 		{
270 270
 			$entropy = '';
271
-			for($i = 0; $i < $entropy_capped_bytes; $i += 2)
271
+			for ($i = 0; $i < $entropy_capped_bytes; $i += 2)
272 272
 			{
273 273
 				$entropy .= pack('S', rand(0, 65536) ^ mt_rand(0, 65535));
274 274
 			}
@@ -276,13 +276,13 @@  discard block
 block discarded – undo
276 276
 
277 277
 		// Mixing (see RFC 4086 section 5)
278 278
 		$output = '';
279
-		for($i = 0; $i < $entropy_required_bytes; $i += 32)
279
+		for ($i = 0; $i < $entropy_required_bytes; $i += 32)
280 280
 		{
281
-			$output .= hash('sha256', $entropy . $i . rand(), true);
281
+			$output .= hash('sha256', $entropy.$i.rand(), true);
282 282
 		}
283 283
 
284 284
 		// Encode and return the random string
285
-		switch($format)
285
+		switch ($format)
286 286
 		{
287 287
 			case 'hex':
288 288
 				return substr(bin2hex($output), 0, $length);
@@ -290,15 +290,15 @@  discard block
 block discarded – undo
290 290
 				return substr($output, 0, $length);
291 291
 			case 'printable':
292 292
 				$salt = '';
293
-				for($i = 0; $i < $length; $i++)
293
+				for ($i = 0; $i < $length; $i++)
294 294
 				{
295
-					$salt .= chr(33 + (crc32(sha1($i . $output)) % 94));
295
+					$salt .= chr(33 + (crc32(sha1($i.$output)) % 94));
296 296
 				}
297 297
 				return $salt;
298 298
 			case 'alnum':
299 299
 			default:
300 300
 				$salt = substr(base64_encode($output), 0, $length);
301
-				$replacements = chr(rand(65, 90)) . chr(rand(97, 122)) . rand(0, 9);
301
+				$replacements = chr(rand(65, 90)).chr(rand(97, 122)).rand(0, 9);
302 302
 				return strtr($salt, '+/=', $replacements);
303 303
 		}
304 304
 	}
@@ -310,15 +310,15 @@  discard block
 block discarded – undo
310 310
 	 */
311 311
 	public function createTemporaryPassword($length = 16)
312 312
 	{
313
-		while(true)
313
+		while (true)
314 314
 		{
315 315
 			$source = base64_encode($this->createSecureSalt(64, 'binary'));
316 316
 			$source = strtr($source, 'iIoOjl10/', '@#$%&*-!?');
317 317
 			$source_length = strlen($source);
318
-			for($i = 0; $i < $source_length - $length; $i++)
318
+			for ($i = 0; $i < $source_length - $length; $i++)
319 319
 			{
320 320
 				$candidate = substr($source, $i, $length);
321
-				if(preg_match('/[a-z]/', $candidate) && preg_match('/[A-Z]/', $candidate) &&
321
+				if (preg_match('/[a-z]/', $candidate) && preg_match('/[A-Z]/', $candidate) &&
322 322
 					preg_match('/[0-9]/', $candidate) && preg_match('/[^a-zA-Z0-9]/', $candidate))
323 323
 				{
324 324
 					return $candidate;
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 		$key = self::getSecretKey();
338 338
 		$salt = self::createSecureSalt(8, 'alnum');
339 339
 		$hash = substr(base64_encode(hash_hmac('sha256', hash_hmac('sha256', $string, $salt), $key, true)), 0, 32);
340
-		return $salt . strtr($hash, '+/', '-_');
340
+		return $salt.strtr($hash, '+/', '-_');
341 341
 	}
342 342
 	
343 343
 	/**
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 	 */
349 349
 	public static function checkSignature($string, $signature)
350 350
 	{
351
-		if(strlen($signature) !== 40)
351
+		if (strlen($signature) !== 40)
352 352
 		{
353 353
 			return false;
354 354
 		}
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
 	{
368 368
 		// If the secret key does not exist, the config file needs to be updated
369 369
 		$db_info = Context::getDbInfo();
370
-		if(!isset($db_info->secret_key))
370
+		if (!isset($db_info->secret_key))
371 371
 		{
372 372
 			$db_info->secret_key = self::createSecureSalt(48, 'alnum');
373 373
 			Context::setDBInfo($db_info);
@@ -387,19 +387,19 @@  discard block
 block discarded – undo
387 387
 	 */
388 388
 	public function pbkdf2($password, $salt, $algorithm = 'sha256', $iterations = 8192, $length = 24)
389 389
 	{
390
-		if(function_exists('hash_pbkdf2'))
390
+		if (function_exists('hash_pbkdf2'))
391 391
 		{
392 392
 			return hash_pbkdf2($algorithm, $password, $salt, $iterations, $length, true);
393 393
 		}
394 394
 		else
395 395
 		{
396 396
 			$output = '';
397
-			$block_count = ceil($length / strlen(hash($algorithm, '', true)));  // key length divided by the length of one hash
398
-			for($i = 1; $i <= $block_count; $i++)
397
+			$block_count = ceil($length / strlen(hash($algorithm, '', true))); // key length divided by the length of one hash
398
+			for ($i = 1; $i <= $block_count; $i++)
399 399
 			{
400
-				$last = $salt . pack('N', $i);  // $i encoded as 4 bytes, big endian
401
-				$last = $xorsum = hash_hmac($algorithm, $last, $password, true);  // first iteration
402
-				for($j = 1; $j < $iterations; $j++)  // The other $count - 1 iterations
400
+				$last = $salt.pack('N', $i); // $i encoded as 4 bytes, big endian
401
+				$last = $xorsum = hash_hmac($algorithm, $last, $password, true); // first iteration
402
+				for ($j = 1; $j < $iterations; $j++)  // The other $count - 1 iterations
403 403
 				{
404 404
 					$xorsum ^= ($last = hash_hmac($algorithm, $last, $password, true));
405 405
 				}
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 	 */
418 418
 	public function bcrypt($password, $salt = null)
419 419
 	{
420
-		if($salt === null)
420
+		if ($salt === null)
421 421
 		{
422 422
 			$salt = '$2y$'.sprintf('%02d', $this->getWorkFactor()).'$'.$this->createSecureSalt(22, 'alnum');
423 423
 		}
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
 	{
435 435
 		$diff = strlen($a) ^ strlen($b);
436 436
 		$maxlen = min(strlen($a), strlen($b));
437
-		for($i = 0; $i < $maxlen; $i++)
437
+		for ($i = 0; $i < $maxlen; $i++)
438 438
 		{
439 439
 			$diff |= ord($a[$i]) ^ ord($b[$i]);
440 440
 		}
Please login to merge, or discard this patch.
classes/security/htmlpurifier/library/HTMLPurifier.autoload.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,20 +7,20 @@
 block discarded – undo
7 7
  */
8 8
 
9 9
 if (function_exists('spl_autoload_register') && function_exists('spl_autoload_unregister')) {
10
-    // We need unregister for our pre-registering functionality
11
-    HTMLPurifier_Bootstrap::registerAutoload();
12
-    if (function_exists('__autoload')) {
13
-        // Be polite and ensure that userland autoload gets retained
14
-        spl_autoload_register('__autoload');
15
-    }
10
+	// We need unregister for our pre-registering functionality
11
+	HTMLPurifier_Bootstrap::registerAutoload();
12
+	if (function_exists('__autoload')) {
13
+		// Be polite and ensure that userland autoload gets retained
14
+		spl_autoload_register('__autoload');
15
+	}
16 16
 } elseif (!function_exists('__autoload')) {
17
-    function __autoload($class) {
18
-        return HTMLPurifier_Bootstrap::autoload($class);
19
-    }
17
+	function __autoload($class) {
18
+		return HTMLPurifier_Bootstrap::autoload($class);
19
+	}
20 20
 }
21 21
 
22 22
 if (ini_get('zend.ze1_compatibility_mode')) {
23
-    trigger_error("HTML Purifier is not compatible with zend.ze1_compatibility_mode; please turn it off", E_USER_ERROR);
23
+	trigger_error("HTML Purifier is not compatible with zend.ze1_compatibility_mode; please turn it off", E_USER_ERROR);
24 24
 }
25 25
 
26 26
 // vim: et sw=4 sts=4
Please login to merge, or discard this patch.
classes/security/htmlpurifier/library/HTMLPurifier.func.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -13,11 +13,11 @@
 block discarded – undo
13 13
  *        HTMLPurifier_Config::create()
14 14
  */
15 15
 function HTMLPurifier($html, $config = null) {
16
-    static $purifier = false;
17
-    if (!$purifier) {
18
-        $purifier = new HTMLPurifier();
19
-    }
20
-    return $purifier->purify($html, $config);
16
+	static $purifier = false;
17
+	if (!$purifier) {
18
+		$purifier = new HTMLPurifier();
19
+	}
20
+	return $purifier->purify($html, $config);
21 21
 }
22 22
 
23 23
 // vim: et sw=4 sts=4
Please login to merge, or discard this patch.
classes/security/htmlpurifier/library/HTMLPurifier.kses.php 2 patches
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -8,23 +8,23 @@
 block discarded – undo
8 8
 require_once dirname(__FILE__) . '/HTMLPurifier.auto.php';
9 9
 
10 10
 function kses($string, $allowed_html, $allowed_protocols = null) {
11
-    $config = HTMLPurifier_Config::createDefault();
12
-    $allowed_elements = array();
13
-    $allowed_attributes = array();
14
-    foreach ($allowed_html as $element => $attributes) {
15
-        $allowed_elements[$element] = true;
16
-        foreach ($attributes as $attribute => $x) {
17
-            $allowed_attributes["$element.$attribute"] = true;
18
-        }
19
-    }
20
-    $config->set('HTML.AllowedElements', $allowed_elements);
21
-    $config->set('HTML.AllowedAttributes', $allowed_attributes);
22
-    $allowed_schemes = array();
23
-    if ($allowed_protocols !== null) {
24
-        $config->set('URI.AllowedSchemes', $allowed_protocols);
25
-    }
26
-    $purifier = new HTMLPurifier($config);
27
-    return $purifier->purify($string);
11
+	$config = HTMLPurifier_Config::createDefault();
12
+	$allowed_elements = array();
13
+	$allowed_attributes = array();
14
+	foreach ($allowed_html as $element => $attributes) {
15
+		$allowed_elements[$element] = true;
16
+		foreach ($attributes as $attribute => $x) {
17
+			$allowed_attributes["$element.$attribute"] = true;
18
+		}
19
+	}
20
+	$config->set('HTML.AllowedElements', $allowed_elements);
21
+	$config->set('HTML.AllowedAttributes', $allowed_attributes);
22
+	$allowed_schemes = array();
23
+	if ($allowed_protocols !== null) {
24
+		$config->set('URI.AllowedSchemes', $allowed_protocols);
25
+	}
26
+	$purifier = new HTMLPurifier($config);
27
+	return $purifier->purify($string);
28 28
 }
29 29
 
30 30
 // vim: et sw=4 sts=4
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@
 block discarded – undo
5 5
  * Emulation layer for code that used kses(), substituting in HTML Purifier.
6 6
  */
7 7
 
8
-require_once dirname(__FILE__) . '/HTMLPurifier.auto.php';
8
+require_once dirname(__FILE__).'/HTMLPurifier.auto.php';
9 9
 
10 10
 function kses($string, $allowed_html, $allowed_protocols = null) {
11 11
     $config = HTMLPurifier_Config::createDefault();
Please login to merge, or discard this patch.
classes/security/htmlpurifier/library/HTMLPurifier.php 3 patches
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -54,183 +54,183 @@
 block discarded – undo
54 54
 class HTMLPurifier
55 55
 {
56 56
 
57
-    /** Version of HTML Purifier */
58
-    public $version = '4.4.0';
59
-
60
-    /** Constant with version of HTML Purifier */
61
-    const VERSION = '4.4.0';
62
-
63
-    /** Global configuration object */
64
-    public $config;
65
-
66
-    /** Array of extra HTMLPurifier_Filter objects to run on HTML, for backwards compatibility */
67
-    private $filters = array();
68
-
69
-    /** Single instance of HTML Purifier */
70
-    private static $instance;
71
-
72
-    protected $strategy, $generator;
73
-
74
-    /**
75
-     * Resultant HTMLPurifier_Context of last run purification. Is an array
76
-     * of contexts if the last called method was purifyArray().
77
-     */
78
-    public $context;
79
-
80
-    /**
81
-     * Initializes the purifier.
82
-     * @param $config Optional HTMLPurifier_Config object for all instances of
83
-     *                the purifier, if omitted, a default configuration is
84
-     *                supplied (which can be overridden on a per-use basis).
85
-     *                The parameter can also be any type that
86
-     *                HTMLPurifier_Config::create() supports.
87
-     */
88
-    public function __construct($config = null) {
89
-
90
-        $this->config = HTMLPurifier_Config::create($config);
91
-
92
-        $this->strategy     = new HTMLPurifier_Strategy_Core();
93
-
94
-    }
95
-
96
-    /**
97
-     * Adds a filter to process the output. First come first serve
98
-     * @param $filter HTMLPurifier_Filter object
99
-     */
100
-    public function addFilter($filter) {
101
-        trigger_error('HTMLPurifier->addFilter() is deprecated, use configuration directives in the Filter namespace or Filter.Custom', E_USER_WARNING);
102
-        $this->filters[] = $filter;
103
-    }
104
-
105
-    /**
106
-     * Filters an HTML snippet/document to be XSS-free and standards-compliant.
107
-     *
108
-     * @param $html String of HTML to purify
109
-     * @param $config HTMLPurifier_Config object for this operation, if omitted,
110
-     *                defaults to the config object specified during this
111
-     *                object's construction. The parameter can also be any type
112
-     *                that HTMLPurifier_Config::create() supports.
113
-     * @return Purified HTML
114
-     */
115
-    public function purify($html, $config = null) {
116
-
117
-        // :TODO: make the config merge in, instead of replace
118
-        $config = $config ? HTMLPurifier_Config::create($config) : $this->config;
119
-
120
-        // implementation is partially environment dependant, partially
121
-        // configuration dependant
122
-        $lexer = HTMLPurifier_Lexer::create($config);
123
-
124
-        $context = new HTMLPurifier_Context();
125
-
126
-        // setup HTML generator
127
-        $this->generator = new HTMLPurifier_Generator($config, $context);
128
-        $context->register('Generator', $this->generator);
129
-
130
-        // set up global context variables
131
-        if ($config->get('Core.CollectErrors')) {
132
-            // may get moved out if other facilities use it
133
-            $language_factory = HTMLPurifier_LanguageFactory::instance();
134
-            $language = $language_factory->create($config, $context);
135
-            $context->register('Locale', $language);
136
-
137
-            $error_collector = new HTMLPurifier_ErrorCollector($context);
138
-            $context->register('ErrorCollector', $error_collector);
139
-        }
140
-
141
-        // setup id_accumulator context, necessary due to the fact that
142
-        // AttrValidator can be called from many places
143
-        $id_accumulator = HTMLPurifier_IDAccumulator::build($config, $context);
144
-        $context->register('IDAccumulator', $id_accumulator);
145
-
146
-        $html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context);
147
-
148
-        // setup filters
149
-        $filter_flags = $config->getBatch('Filter');
150
-        $custom_filters = $filter_flags['Custom'];
151
-        unset($filter_flags['Custom']);
152
-        $filters = array();
153
-        foreach ($filter_flags as $filter => $flag) {
154
-            if (!$flag) continue;
155
-            if (strpos($filter, '.') !== false) continue;
156
-            $class = "HTMLPurifier_Filter_$filter";
157
-            $filters[] = new $class;
158
-        }
159
-        foreach ($custom_filters as $filter) {
160
-            // maybe "HTMLPurifier_Filter_$filter", but be consistent with AutoFormat
161
-            $filters[] = $filter;
162
-        }
163
-        $filters = array_merge($filters, $this->filters);
164
-        // maybe prepare(), but later
165
-
166
-        for ($i = 0, $filter_size = count($filters); $i < $filter_size; $i++) {
167
-            $html = $filters[$i]->preFilter($html, $config, $context);
168
-        }
169
-
170
-        // purified HTML
171
-        $html =
172
-            $this->generator->generateFromTokens(
173
-                // list of tokens
174
-                $this->strategy->execute(
175
-                    // list of un-purified tokens
176
-                    $lexer->tokenizeHTML(
177
-                        // un-purified HTML
178
-                        $html, $config, $context
179
-                    ),
180
-                    $config, $context
181
-                )
182
-            );
183
-
184
-        for ($i = $filter_size - 1; $i >= 0; $i--) {
185
-            $html = $filters[$i]->postFilter($html, $config, $context);
186
-        }
187
-
188
-        $html = HTMLPurifier_Encoder::convertFromUTF8($html, $config, $context);
189
-        $this->context =& $context;
190
-        return $html;
191
-    }
192
-
193
-    /**
194
-     * Filters an array of HTML snippets
195
-     * @param $config Optional HTMLPurifier_Config object for this operation.
196
-     *                See HTMLPurifier::purify() for more details.
197
-     * @return Array of purified HTML
198
-     */
199
-    public function purifyArray($array_of_html, $config = null) {
200
-        $context_array = array();
201
-        foreach ($array_of_html as $key => $html) {
202
-            $array_of_html[$key] = $this->purify($html, $config);
203
-            $context_array[$key] = $this->context;
204
-        }
205
-        $this->context = $context_array;
206
-        return $array_of_html;
207
-    }
208
-
209
-    /**
210
-     * Singleton for enforcing just one HTML Purifier in your system
211
-     * @param $prototype Optional prototype HTMLPurifier instance to
212
-     *                   overload singleton with, or HTMLPurifier_Config
213
-     *                   instance to configure the generated version with.
214
-     */
215
-    public static function instance($prototype = null) {
216
-        if (!self::$instance || $prototype) {
217
-            if ($prototype instanceof HTMLPurifier) {
218
-                self::$instance = $prototype;
219
-            } elseif ($prototype) {
220
-                self::$instance = new HTMLPurifier($prototype);
221
-            } else {
222
-                self::$instance = new HTMLPurifier();
223
-            }
224
-        }
225
-        return self::$instance;
226
-    }
227
-
228
-    /**
229
-     * @note Backwards compatibility, see instance()
230
-     */
231
-    public static function getInstance($prototype = null) {
232
-        return HTMLPurifier::instance($prototype);
233
-    }
57
+	/** Version of HTML Purifier */
58
+	public $version = '4.4.0';
59
+
60
+	/** Constant with version of HTML Purifier */
61
+	const VERSION = '4.4.0';
62
+
63
+	/** Global configuration object */
64
+	public $config;
65
+
66
+	/** Array of extra HTMLPurifier_Filter objects to run on HTML, for backwards compatibility */
67
+	private $filters = array();
68
+
69
+	/** Single instance of HTML Purifier */
70
+	private static $instance;
71
+
72
+	protected $strategy, $generator;
73
+
74
+	/**
75
+	 * Resultant HTMLPurifier_Context of last run purification. Is an array
76
+	 * of contexts if the last called method was purifyArray().
77
+	 */
78
+	public $context;
79
+
80
+	/**
81
+	 * Initializes the purifier.
82
+	 * @param $config Optional HTMLPurifier_Config object for all instances of
83
+	 *                the purifier, if omitted, a default configuration is
84
+	 *                supplied (which can be overridden on a per-use basis).
85
+	 *                The parameter can also be any type that
86
+	 *                HTMLPurifier_Config::create() supports.
87
+	 */
88
+	public function __construct($config = null) {
89
+
90
+		$this->config = HTMLPurifier_Config::create($config);
91
+
92
+		$this->strategy     = new HTMLPurifier_Strategy_Core();
93
+
94
+	}
95
+
96
+	/**
97
+	 * Adds a filter to process the output. First come first serve
98
+	 * @param $filter HTMLPurifier_Filter object
99
+	 */
100
+	public function addFilter($filter) {
101
+		trigger_error('HTMLPurifier->addFilter() is deprecated, use configuration directives in the Filter namespace or Filter.Custom', E_USER_WARNING);
102
+		$this->filters[] = $filter;
103
+	}
104
+
105
+	/**
106
+	 * Filters an HTML snippet/document to be XSS-free and standards-compliant.
107
+	 *
108
+	 * @param $html String of HTML to purify
109
+	 * @param $config HTMLPurifier_Config object for this operation, if omitted,
110
+	 *                defaults to the config object specified during this
111
+	 *                object's construction. The parameter can also be any type
112
+	 *                that HTMLPurifier_Config::create() supports.
113
+	 * @return Purified HTML
114
+	 */
115
+	public function purify($html, $config = null) {
116
+
117
+		// :TODO: make the config merge in, instead of replace
118
+		$config = $config ? HTMLPurifier_Config::create($config) : $this->config;
119
+
120
+		// implementation is partially environment dependant, partially
121
+		// configuration dependant
122
+		$lexer = HTMLPurifier_Lexer::create($config);
123
+
124
+		$context = new HTMLPurifier_Context();
125
+
126
+		// setup HTML generator
127
+		$this->generator = new HTMLPurifier_Generator($config, $context);
128
+		$context->register('Generator', $this->generator);
129
+
130
+		// set up global context variables
131
+		if ($config->get('Core.CollectErrors')) {
132
+			// may get moved out if other facilities use it
133
+			$language_factory = HTMLPurifier_LanguageFactory::instance();
134
+			$language = $language_factory->create($config, $context);
135
+			$context->register('Locale', $language);
136
+
137
+			$error_collector = new HTMLPurifier_ErrorCollector($context);
138
+			$context->register('ErrorCollector', $error_collector);
139
+		}
140
+
141
+		// setup id_accumulator context, necessary due to the fact that
142
+		// AttrValidator can be called from many places
143
+		$id_accumulator = HTMLPurifier_IDAccumulator::build($config, $context);
144
+		$context->register('IDAccumulator', $id_accumulator);
145
+
146
+		$html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context);
147
+
148
+		// setup filters
149
+		$filter_flags = $config->getBatch('Filter');
150
+		$custom_filters = $filter_flags['Custom'];
151
+		unset($filter_flags['Custom']);
152
+		$filters = array();
153
+		foreach ($filter_flags as $filter => $flag) {
154
+			if (!$flag) continue;
155
+			if (strpos($filter, '.') !== false) continue;
156
+			$class = "HTMLPurifier_Filter_$filter";
157
+			$filters[] = new $class;
158
+		}
159
+		foreach ($custom_filters as $filter) {
160
+			// maybe "HTMLPurifier_Filter_$filter", but be consistent with AutoFormat
161
+			$filters[] = $filter;
162
+		}
163
+		$filters = array_merge($filters, $this->filters);
164
+		// maybe prepare(), but later
165
+
166
+		for ($i = 0, $filter_size = count($filters); $i < $filter_size; $i++) {
167
+			$html = $filters[$i]->preFilter($html, $config, $context);
168
+		}
169
+
170
+		// purified HTML
171
+		$html =
172
+			$this->generator->generateFromTokens(
173
+				// list of tokens
174
+				$this->strategy->execute(
175
+					// list of un-purified tokens
176
+					$lexer->tokenizeHTML(
177
+						// un-purified HTML
178
+						$html, $config, $context
179
+					),
180
+					$config, $context
181
+				)
182
+			);
183
+
184
+		for ($i = $filter_size - 1; $i >= 0; $i--) {
185
+			$html = $filters[$i]->postFilter($html, $config, $context);
186
+		}
187
+
188
+		$html = HTMLPurifier_Encoder::convertFromUTF8($html, $config, $context);
189
+		$this->context =& $context;
190
+		return $html;
191
+	}
192
+
193
+	/**
194
+	 * Filters an array of HTML snippets
195
+	 * @param $config Optional HTMLPurifier_Config object for this operation.
196
+	 *                See HTMLPurifier::purify() for more details.
197
+	 * @return Array of purified HTML
198
+	 */
199
+	public function purifyArray($array_of_html, $config = null) {
200
+		$context_array = array();
201
+		foreach ($array_of_html as $key => $html) {
202
+			$array_of_html[$key] = $this->purify($html, $config);
203
+			$context_array[$key] = $this->context;
204
+		}
205
+		$this->context = $context_array;
206
+		return $array_of_html;
207
+	}
208
+
209
+	/**
210
+	 * Singleton for enforcing just one HTML Purifier in your system
211
+	 * @param $prototype Optional prototype HTMLPurifier instance to
212
+	 *                   overload singleton with, or HTMLPurifier_Config
213
+	 *                   instance to configure the generated version with.
214
+	 */
215
+	public static function instance($prototype = null) {
216
+		if (!self::$instance || $prototype) {
217
+			if ($prototype instanceof HTMLPurifier) {
218
+				self::$instance = $prototype;
219
+			} elseif ($prototype) {
220
+				self::$instance = new HTMLPurifier($prototype);
221
+			} else {
222
+				self::$instance = new HTMLPurifier();
223
+			}
224
+		}
225
+		return self::$instance;
226
+	}
227
+
228
+	/**
229
+	 * @note Backwards compatibility, see instance()
230
+	 */
231
+	public static function getInstance($prototype = null) {
232
+		return HTMLPurifier::instance($prototype);
233
+	}
234 234
 
235 235
 }
236 236
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
         $this->config = HTMLPurifier_Config::create($config);
91 91
 
92
-        $this->strategy     = new HTMLPurifier_Strategy_Core();
92
+        $this->strategy = new HTMLPurifier_Strategy_Core();
93 93
 
94 94
     }
95 95
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
         }
187 187
 
188 188
         $html = HTMLPurifier_Encoder::convertFromUTF8($html, $config, $context);
189
-        $this->context =& $context;
189
+        $this->context = & $context;
190 190
         return $html;
191 191
     }
192 192
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -151,8 +151,12 @@
 block discarded – undo
151 151
         unset($filter_flags['Custom']);
152 152
         $filters = array();
153 153
         foreach ($filter_flags as $filter => $flag) {
154
-            if (!$flag) continue;
155
-            if (strpos($filter, '.') !== false) continue;
154
+            if (!$flag) {
155
+            	continue;
156
+            }
157
+            if (strpos($filter, '.') !== false) {
158
+            	continue;
159
+            }
156 160
             $class = "HTMLPurifier_Filter_$filter";
157 161
             $filters[] = new $class;
158 162
         }
Please login to merge, or discard this patch.