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
Pull Request — develop (#1942)
by
unknown
10:17
created
classes/file/FileHandler.class.php 1 patch
Spacing   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@  discard block
 block discarded – undo
17 17
 	 */
18 18
 	function getRealPath($source)
19 19
 	{
20
-		if(strlen($source) >= 2 && substr_compare($source, './', 0, 2) === 0)
20
+		if (strlen($source) >= 2 && substr_compare($source, './', 0, 2) === 0)
21 21
 		{
22
-			return _XE_PATH_ . substr($source, 2);
22
+			return _XE_PATH_.substr($source, 2);
23 23
 		}
24 24
 
25 25
 		return $source;
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	{
41 41
 		$source_dir = self::getRealPath($source_dir);
42 42
 		$target_dir = self::getRealPath($target_dir);
43
-		if(!is_dir($source_dir))
43
+		if (!is_dir($source_dir))
44 44
 		{
45 45
 			return FALSE;
46 46
 		}
@@ -48,44 +48,44 @@  discard block
 block discarded – undo
48 48
 		// generate when no target exists
49 49
 		self::makeDir($target_dir);
50 50
 
51
-		if(substr($source_dir, -1) != DIRECTORY_SEPARATOR)
51
+		if (substr($source_dir, -1) != DIRECTORY_SEPARATOR)
52 52
 		{
53 53
 			$source_dir .= DIRECTORY_SEPARATOR;
54 54
 		}
55 55
 
56
-		if(substr($target_dir, -1) != DIRECTORY_SEPARATOR)
56
+		if (substr($target_dir, -1) != DIRECTORY_SEPARATOR)
57 57
 		{
58 58
 			$target_dir .= DIRECTORY_SEPARATOR;
59 59
 		}
60 60
 
61 61
 		$oDir = dir($source_dir);
62
-		while($file = $oDir->read())
62
+		while ($file = $oDir->read())
63 63
 		{
64
-			if($file{0} == '.')
64
+			if ($file{0} == '.')
65 65
 			{
66 66
 				continue;
67 67
 			}
68 68
 
69
-			if($filter && preg_match($filter, $file))
69
+			if ($filter && preg_match($filter, $file))
70 70
 			{
71 71
 				continue;
72 72
 			}
73 73
 
74
-			if(is_dir($source_dir . $file))
74
+			if (is_dir($source_dir.$file))
75 75
 			{
76
-				self::copyDir($source_dir . $file, $target_dir . $file, $type);
76
+				self::copyDir($source_dir.$file, $target_dir.$file, $type);
77 77
 			}
78 78
 			else
79 79
 			{
80
-				if($type == 'force')
80
+				if ($type == 'force')
81 81
 				{
82
-					@unlink($target_dir . $file);
82
+					@unlink($target_dir.$file);
83 83
 				}
84 84
 				else
85 85
 				{
86
-					if(!file_exists($target_dir . $file))
86
+					if (!file_exists($target_dir.$file))
87 87
 					{
88
-						@copy($source_dir . $file, $target_dir . $file);
88
+						@copy($source_dir.$file, $target_dir.$file);
89 89
 					}
90 90
 				}
91 91
 			}
@@ -110,12 +110,12 @@  discard block
 block discarded – undo
110 110
 
111 111
 		self::makeDir($target_dir);
112 112
 
113
-		if($force == 'Y')
113
+		if ($force == 'Y')
114 114
 		{
115
-			@unlink($target_dir . DIRECTORY_SEPARATOR . $target);
115
+			@unlink($target_dir.DIRECTORY_SEPARATOR.$target);
116 116
 		}
117 117
 
118
-		@copy($source, $target_dir . DIRECTORY_SEPARATOR . $target);
118
+		@copy($source, $target_dir.DIRECTORY_SEPARATOR.$target);
119 119
 	}
120 120
 
121 121
 	/**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	function readFile($filename)
128 128
 	{
129
-		if(($filename = self::exists($filename)) === FALSE || filesize($filename) < 1)
129
+		if (($filename = self::exists($filename)) === FALSE || filesize($filename) < 1)
130 130
 		{
131 131
 			return;
132 132
 		}
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
 		self::makeDir($pathinfo['dirname']);
150 150
 
151 151
 		$flags = 0;
152
-		if(strtolower($mode) == 'a')
152
+		if (strtolower($mode) == 'a')
153 153
 		{
154 154
 			$flags = FILE_APPEND;
155 155
 		}
156 156
 
157
-		@file_put_contents($filename, $buff, $flags|LOCK_EX);
157
+		@file_put_contents($filename, $buff, $flags | LOCK_EX);
158 158
 		@chmod($filename, 0644);
159 159
 	}
160 160
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	 */
193 193
 	function moveFile($source, $target)
194 194
 	{
195
-		if(($source = self::exists($source)) !== FALSE)
195
+		if (($source = self::exists($source)) !== FALSE)
196 196
 		{
197 197
 			self::removeFile($target);
198 198
 			return self::rename($source, $target);
@@ -230,35 +230,35 @@  discard block
 block discarded – undo
230 230
 		$path = self::getRealPath($path);
231 231
 		$output = array();
232 232
 
233
-		if(substr($path, -1) != '/')
233
+		if (substr($path, -1) != '/')
234 234
 		{
235 235
 			$path .= '/';
236 236
 		}
237 237
 
238
-		if(!is_dir($path))
238
+		if (!is_dir($path))
239 239
 		{
240 240
 			return $output;
241 241
 		}
242 242
 
243 243
 		$files = scandir($path);
244
-		foreach($files as $file)
244
+		foreach ($files as $file)
245 245
 		{
246
-			if($file{0} == '.' || ($filter && !preg_match($filter, $file)))
246
+			if ($file{0} == '.' || ($filter && !preg_match($filter, $file)))
247 247
 			{
248 248
 				continue;
249 249
 			}
250 250
 
251
-			if($to_lower)
251
+			if ($to_lower)
252 252
 			{
253 253
 				$file = strtolower($file);
254 254
 			}
255 255
 
256
-			if($filter)
256
+			if ($filter)
257 257
 			{
258 258
 				$file = preg_replace($filter, '$1', $file);
259 259
 			}
260 260
 
261
-			if($concat_prefix)
261
+			if ($concat_prefix)
262 262
 			{
263 263
 				$file = sprintf('%s%s', str_replace(_XE_PATH_, '', $path), $file);
264 264
 			}
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
 	 */
280 280
 	function makeDir($path_string)
281 281
 	{
282
-		if(self::exists($path_string) !== FALSE)
282
+		if (self::exists($path_string) !== FALSE)
283 283
 		{
284 284
 			return TRUE;
285 285
 		}
286 286
 
287
-		if(!ini_get('safe_mode'))
287
+		if (!ini_get('safe_mode'))
288 288
 		{
289 289
 			@mkdir($path_string, 0755, TRUE);
290 290
 			@chmod($path_string, 0755);
@@ -295,35 +295,35 @@  discard block
 block discarded – undo
295 295
 			static $oFtp = NULL;
296 296
 
297 297
 			$ftp_info = Context::getFTPInfo();
298
-			if($oFtp == NULL)
298
+			if ($oFtp == NULL)
299 299
 			{
300
-				if(!Context::isFTPRegisted())
300
+				if (!Context::isFTPRegisted())
301 301
 				{
302 302
 					return;
303 303
 				}
304 304
 
305
-				require_once(_XE_PATH_ . 'libs/ftp.class.php');
305
+				require_once(_XE_PATH_.'libs/ftp.class.php');
306 306
 				$oFtp = new ftp();
307
-				if(!$ftp_info->ftp_host)
307
+				if (!$ftp_info->ftp_host)
308 308
 				{
309 309
 					$ftp_info->ftp_host = "127.0.0.1";
310 310
 				}
311
-				if(!$ftp_info->ftp_port)
311
+				if (!$ftp_info->ftp_port)
312 312
 				{
313 313
 					$ftp_info->ftp_port = 21;
314 314
 				}
315
-				if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port))
315
+				if (!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port))
316 316
 				{
317 317
 					return;
318 318
 				}
319
-				if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password))
319
+				if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password))
320 320
 				{
321 321
 					$oFtp->ftp_quit();
322 322
 					return;
323 323
 				}
324 324
 			}
325 325
 
326
-			if(!($ftp_path = $ftp_info->ftp_root_path))
326
+			if (!($ftp_path = $ftp_info->ftp_root_path))
327 327
 			{
328 328
 				$ftp_path = DIRECTORY_SEPARATOR;
329 329
 			}
@@ -332,19 +332,19 @@  discard block
 block discarded – undo
332 332
 			$path_list = explode(DIRECTORY_SEPARATOR, $path_string);
333 333
 
334 334
 			$path = _XE_PATH_;
335
-			for($i = 0, $c = count($path_list); $i < $c; $i++)
335
+			for ($i = 0, $c = count($path_list); $i < $c; $i++)
336 336
 			{
337
-				if(!$path_list[$i])
337
+				if (!$path_list[$i])
338 338
 				{
339 339
 					continue;
340 340
 				}
341 341
 
342
-				$path .= $path_list[$i] . DIRECTORY_SEPARATOR;
343
-				$ftp_path .= $path_list[$i] . DIRECTORY_SEPARATOR;
344
-				if(!is_dir($path))
342
+				$path .= $path_list[$i].DIRECTORY_SEPARATOR;
343
+				$ftp_path .= $path_list[$i].DIRECTORY_SEPARATOR;
344
+				if (!is_dir($path))
345 345
 				{
346 346
 					$oFtp->ftp_mkdir($ftp_path);
347
-					$oFtp->ftp_site("CHMOD 777 " . $ftp_path);
347
+					$oFtp->ftp_site("CHMOD 777 ".$ftp_path);
348 348
 				}
349 349
 			}
350 350
 		}
@@ -360,23 +360,23 @@  discard block
 block discarded – undo
360 360
 	 */
361 361
 	function removeDir($path)
362 362
 	{
363
-		if(($path = self::isDir($path)) === FALSE)
363
+		if (($path = self::isDir($path)) === FALSE)
364 364
 		{
365 365
 			return;
366 366
 		}
367 367
 
368
-		if(self::isDir($path))
368
+		if (self::isDir($path))
369 369
 		{
370 370
 			$files = array_diff(scandir($path), array('..', '.'));
371 371
 
372
-			foreach($files as $file)
372
+			foreach ($files as $file)
373 373
 			{
374
-				if(($target = self::getRealPath($path . DIRECTORY_SEPARATOR . $file)) === FALSE)
374
+				if (($target = self::getRealPath($path.DIRECTORY_SEPARATOR.$file)) === FALSE)
375 375
 				{
376 376
 					continue;
377 377
 				}
378 378
 
379
-				if(is_dir($target))
379
+				if (is_dir($target))
380 380
 				{
381 381
 					self::removeDir($target);
382 382
 				}
@@ -401,22 +401,22 @@  discard block
 block discarded – undo
401 401
 	 */
402 402
 	function removeBlankDir($path)
403 403
 	{
404
-		if(($path = self::isDir($path)) === FALSE)
404
+		if (($path = self::isDir($path)) === FALSE)
405 405
 		{
406 406
 			return;
407 407
 		}
408 408
 
409 409
 		$files = array_diff(scandir($path), array('..', '.'));
410 410
 
411
-		if(count($files) < 1)
411
+		if (count($files) < 1)
412 412
 		{
413 413
 			rmdir($path);
414 414
 			return;
415 415
 		}
416 416
 
417
-		foreach($files as $file)
417
+		foreach ($files as $file)
418 418
 		{
419
-			if(($target = self::isDir($path . DIRECTORY_SEPARATOR . $file)) === FALSE)
419
+			if (($target = self::isDir($path.DIRECTORY_SEPARATOR.$file)) === FALSE)
420 420
 			{
421 421
 				continue;
422 422
 			}
@@ -435,23 +435,23 @@  discard block
 block discarded – undo
435 435
 	 */
436 436
 	function removeFilesInDir($path)
437 437
 	{
438
-		if(($path = self::getRealPath($path)) === FALSE)
438
+		if (($path = self::getRealPath($path)) === FALSE)
439 439
 		{
440 440
 			return;
441 441
 		}
442 442
 
443
-		if(is_dir($path))
443
+		if (is_dir($path))
444 444
 		{
445 445
 			$files = array_diff(scandir($path), array('..', '.'));
446 446
 
447
-			foreach($files as $file)
447
+			foreach ($files as $file)
448 448
 			{
449
-				if(($target = self::getRealPath($path . DIRECTORY_SEPARATOR . $file)) === FALSE)
449
+				if (($target = self::getRealPath($path.DIRECTORY_SEPARATOR.$file)) === FALSE)
450 450
 				{
451 451
 					continue;
452 452
 				}
453 453
 
454
-				if(is_dir($target))
454
+				if (is_dir($target))
455 455
 				{
456 456
 					self::removeFilesInDir($target);
457 457
 				}
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 		}
464 464
 		else
465 465
 		{
466
-			if(self::exists($path)) unlink($path);
466
+			if (self::exists($path)) unlink($path);
467 467
 		}
468 468
 
469 469
 	}
@@ -477,22 +477,22 @@  discard block
 block discarded – undo
477 477
 	 */
478 478
 	function filesize($size)
479 479
 	{
480
-		if(!$size)
480
+		if (!$size)
481 481
 		{
482 482
 			return '0Byte';
483 483
 		}
484 484
 
485
-		if($size === 1)
485
+		if ($size === 1)
486 486
 		{
487 487
 			return '1Byte';
488 488
 		}
489 489
 
490
-		if($size < 1024)
490
+		if ($size < 1024)
491 491
 		{
492
-			return $size . 'Bytes';
492
+			return $size.'Bytes';
493 493
 		}
494 494
 
495
-		if($size >= 1024 && $size < 1024 * 1024)
495
+		if ($size >= 1024 && $size < 1024 * 1024)
496 496
 		{
497 497
 			return sprintf("%0.1fKB", $size / 1024);
498 498
 		}
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 	 */
518 518
 	function getRemoteResource($url, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array(), $request_config = array())
519 519
 	{
520
-		require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php');
520
+		require_once(_XE_PATH_.'libs/idna_convert/idna_convert.class.php');
521 521
 		$IDN = new idna_convert(array('idn_version' => 2008));
522 522
 		$url = $IDN->encode($url);
523 523
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 			require_once('HTTP/Request.php');
528 528
 
529 529
 			$parsed_url = parse_url(__PROXY_SERVER__);
530
-			if($parsed_url["host"] && $parsed_url["path"])
530
+			if ($parsed_url["host"] && $parsed_url["path"])
531 531
 			{
532 532
 				// Old style proxy server support (POST payload to proxy script)
533 533
 				$oRequest = new HTTP_Request(__PROXY_SERVER__);
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 				$oRequest = new HTTP_Request($url);
540 540
 
541 541
 				// New style proxy server support (Use HTTP_Request2 native config format)
542
-				if($parsed_url['host'])
542
+				if ($parsed_url['host'])
543 543
 				{
544 544
 					$request_config['proxy_host'] = $parsed_url['host'];
545 545
 					$request_config['proxy_port'] = $parsed_url['port'] ? $parsed_url['port'] : '';
@@ -548,13 +548,13 @@  discard block
 block discarded – undo
548 548
 					$request_config['proxy_type'] = $parsed_url['scheme'] ? $parsed_url['scheme'] : 'http';
549 549
 				}
550 550
 
551
-				if(count($request_config) && method_exists($oRequest, 'setConfig'))
551
+				if (count($request_config) && method_exists($oRequest, 'setConfig'))
552 552
 				{
553
-					foreach($request_config as $key=>$val)
553
+					foreach ($request_config as $key=>$val)
554 554
 					{
555
-						if($key === 'observers')
555
+						if ($key === 'observers')
556 556
 						{
557
-							foreach($val as $observer)
557
+							foreach ($val as $observer)
558 558
 							{
559 559
 								$oRequest->attach($observer);
560 560
 							}
@@ -565,58 +565,58 @@  discard block
 block discarded – undo
565 565
 						}
566 566
 					}
567 567
 				}
568
-				if(method_exists($oRequest, 'setConfig'))
568
+				if (method_exists($oRequest, 'setConfig'))
569 569
 				{
570
-					if(extension_loaded('curl'))
570
+					if (extension_loaded('curl'))
571 571
 					{
572 572
 						$oRequest->setConfig('adapter', 'curl');
573 573
 					}
574
-					elseif(version_compare(PHP_VERSION, '5.6', '<'))
574
+					elseif (version_compare(PHP_VERSION, '5.6', '<'))
575 575
 					{
576 576
 						$oRequest->setConfig('ssl_verify_host', false);
577 577
 					}
578
-					if(file_exists(_XE_PATH_ . 'libs/cacert/cacert.pem'))
578
+					if (file_exists(_XE_PATH_.'libs/cacert/cacert.pem'))
579 579
 					{
580
-						$oRequest->setConfig('ssl_cafile', _XE_PATH_ . 'libs/cacert/cacert.pem');
580
+						$oRequest->setConfig('ssl_cafile', _XE_PATH_.'libs/cacert/cacert.pem');
581 581
 					}
582 582
 				}
583 583
 
584
-				if(count($headers) > 0)
584
+				if (count($headers) > 0)
585 585
 				{
586
-					foreach($headers as $key => $val)
586
+					foreach ($headers as $key => $val)
587 587
 					{
588 588
 						$oRequest->addHeader($key, $val);
589 589
 					}
590 590
 				}
591 591
 				$host = parse_url($url, PHP_URL_HOST);
592
-				if($cookies[$host])
592
+				if ($cookies[$host])
593 593
 				{
594
-					foreach($cookies[$host] as $key => $val)
594
+					foreach ($cookies[$host] as $key => $val)
595 595
 					{
596 596
 						$oRequest->addCookie($key, $val);
597 597
 					}
598 598
 				}
599
-				if(count($post_data) > 0)
599
+				if (count($post_data) > 0)
600 600
 				{
601
-					foreach($post_data as $key => $val)
601
+					foreach ($post_data as $key => $val)
602 602
 					{
603 603
 						$oRequest->addPostData($key, $val);
604 604
 					}
605 605
 				}
606
-				if(!$content_type)
606
+				if (!$content_type)
607 607
 					$oRequest->addHeader('Content-Type', 'text/html');
608 608
 				else
609 609
 					$oRequest->addHeader('Content-Type', $content_type);
610 610
 				$oRequest->setMethod($method);
611
-				if($body)
611
+				if ($body)
612 612
 					$oRequest->setBody($body);
613 613
 			}
614 614
 			
615
-			if(method_exists($oRequest, 'setConfig'))
615
+			if (method_exists($oRequest, 'setConfig'))
616 616
 			{
617 617
 				$oRequest->setConfig('timeout', $timeout);
618 618
 			}
619
-			elseif(property_exists($oRequest, '_timeout'))
619
+			elseif (property_exists($oRequest, '_timeout'))
620 620
 			{
621 621
 				$oRequest->_timeout = $timeout;
622 622
 			}
@@ -626,25 +626,25 @@  discard block
 block discarded – undo
626 626
 			$code = $oRequest->getResponseCode();
627 627
 			$header = $oRequest->getResponseHeader();
628 628
 			$response = $oRequest->getResponseBody();
629
-			if($c = $oRequest->getResponseCookies())
629
+			if ($c = $oRequest->getResponseCookies())
630 630
 			{
631
-				foreach($c as $k => $v)
631
+				foreach ($c as $k => $v)
632 632
 				{
633 633
 					$cookies[$host][$v['name']] = $v['value'];
634 634
 				}
635 635
 			}
636 636
 
637
-			if($code > 300 && $code < 399 && $header['location'])
637
+			if ($code > 300 && $code < 399 && $header['location'])
638 638
 			{
639 639
 				return self::getRemoteResource($header['location'], $body, $timeout, $method, $content_type, $headers, $cookies, $post_data);
640 640
 			}
641 641
 
642
-			if($code != 200)
642
+			if ($code != 200)
643 643
 			{
644 644
 				return;
645 645
 			}
646 646
 
647
-			if(isset($request_config['store_body']) && !$request_config['store_body'])
647
+			if (isset($request_config['store_body']) && !$request_config['store_body'])
648 648
 			{
649 649
 				return TRUE;
650 650
 			}
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 				return $response;
654 654
 			}
655 655
 		}
656
-		catch(Exception $e)
656
+		catch (Exception $e)
657 657
 		{
658 658
 			return NULL;
659 659
 		}
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
 		{
686 686
 			$result = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers, $cookies, $post_data, $request_config);
687 687
 		}
688
-		catch(Exception $e)
688
+		catch (Exception $e)
689 689
 		{
690 690
 			return FALSE;
691 691
 		}
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 	function returnBytes($val)
703 703
 	{
704 704
 		$unit = strtoupper(substr($val, -1));
705
-		$val = (float)$val;
705
+		$val = (float) $val;
706 706
 
707 707
 		switch ($unit)
708 708
 		{
@@ -725,13 +725,13 @@  discard block
 block discarded – undo
725 725
 		$K64 = 65536;
726 726
 		$TWEAKFACTOR = 2.0;
727 727
 		$channels = $imageInfo['channels'];
728
-		if(!$channels)
728
+		if (!$channels)
729 729
 		{
730 730
 			$channels = 6; //for png
731 731
 		}
732
-		$memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64 ) * $TWEAKFACTOR);
732
+		$memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64) * $TWEAKFACTOR);
733 733
 		$availableMemory = self::returnBytes(ini_get('memory_limit')) - memory_get_usage();
734
-		if($availableMemory < $memoryNeeded)
734
+		if ($availableMemory < $memoryNeeded)
735 735
 		{
736 736
 			return FALSE;
737 737
 		}
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 	function createImageFile($source_file, $target_file, $resize_width = 0, $resize_height = 0, $target_type = '', $thumbnail_type = 'crop')
753 753
 	{
754 754
 		// check if library is loaded
755
-		if(!extension_loaded('gd'))
755
+		if (!extension_loaded('gd'))
756 756
 		{
757 757
 			error_log("In function 'createImageFile', error occured during image processing : Library php-gd has not loaded properly. Check whether php-gd is installed and make sure to include extension, php_gd in php.ini");
758 758
 		}
@@ -764,30 +764,30 @@  discard block
 block discarded – undo
764 764
 		}
765 765
 
766 766
 		$target_file = self::getRealPath($target_file);
767
-		if(!$resize_width)
767
+		if (!$resize_width)
768 768
 		{
769 769
 			$resize_width = 100;
770 770
 		}
771 771
 
772
-		if(!$resize_height)
772
+		if (!$resize_height)
773 773
 		{
774 774
 			$resize_height = $resize_width;
775 775
 		}
776 776
 
777 777
 		// retrieve source image's information
778 778
 		$imageInfo = getimagesize($source_file);
779
-		if(!self::checkMemoryLoadImage($imageInfo))
779
+		if (!self::checkMemoryLoadImage($imageInfo))
780 780
 		{
781 781
 			return FALSE;
782 782
 		}
783 783
 
784 784
 		list($width, $height, $type, $attrs) = $imageInfo;
785
-		if($width < 1 || $height < 1)
785
+		if ($width < 1 || $height < 1)
786 786
 		{
787 787
 			return;
788 788
 		}
789 789
 
790
-		switch($type)
790
+		switch ($type)
791 791
 		{
792 792
 			case '1' :
793 793
 				$type = 'gif';
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 				return;
806 806
 		}
807 807
 
808
-		if(!$target_type)
808
+		if (!$target_type)
809 809
 		{
810 810
 			$target_type = $type;
811 811
 		}
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 		$height_per = ($resize_height > 0 && $height >= $resize_height) ? $resize_height / $height : 1;
817 817
 
818 818
 		$per = NULL;
819
-		if($thumbnail_type == 'ratio')
819
+		if ($thumbnail_type == 'ratio')
820 820
 		{
821 821
 			$per = ($width_per > $height_per) ? $height_per : $width_per;
822 822
 			$resize_width = $width * $per;
@@ -829,16 +829,16 @@  discard block
 block discarded – undo
829 829
 
830 830
 		// create temporary image with target size
831 831
 		$thumb = NULL;
832
-		if(function_exists('imagecreateTRUEcolor'))
832
+		if (function_exists('imagecreateTRUEcolor'))
833 833
 		{
834 834
 			$thumb = imagecreateTRUEcolor($resize_width, $resize_height);
835 835
 		}
836
-		else if(function_exists('imagecreate'))
836
+		else if (function_exists('imagecreate'))
837 837
 		{
838 838
 			$thumb = imagecreate($resize_width, $resize_height);
839 839
 		}
840 840
 
841
-		if(!$thumb)
841
+		if (!$thumb)
842 842
 		{
843 843
 			return FALSE;
844 844
 		}
@@ -847,37 +847,37 @@  discard block
 block discarded – undo
847 847
 
848 848
 		// create temporary image having original type
849 849
 		$source = NULL;
850
-		switch($type)
850
+		switch ($type)
851 851
 		{
852 852
 			case 'gif' :
853
-				if(function_exists('imagecreatefromgif'))
853
+				if (function_exists('imagecreatefromgif'))
854 854
 				{
855 855
 					$source = @imagecreatefromgif($source_file);
856 856
 				}
857 857
 				break;
858 858
 			case 'jpeg' :
859 859
 			case 'jpg' :
860
-				if(function_exists('imagecreatefromjpeg'))
860
+				if (function_exists('imagecreatefromjpeg'))
861 861
 				{
862 862
 					$source = @imagecreatefromjpeg($source_file);
863 863
 				}
864 864
 				break;
865 865
 			case 'png' :
866
-				if(function_exists('imagecreatefrompng'))
866
+				if (function_exists('imagecreatefrompng'))
867 867
 				{
868 868
 					$source = @imagecreatefrompng($source_file);
869 869
 				}
870 870
 				break;
871 871
 			case 'wbmp' :
872 872
 			case 'bmp' :
873
-				if(function_exists('imagecreatefromwbmp'))
873
+				if (function_exists('imagecreatefromwbmp'))
874 874
 				{
875 875
 					$source = @imagecreatefromwbmp($source_file);
876 876
 				}
877 877
 				break;
878 878
 		}
879 879
 
880
-		if(!$source)
880
+		if (!$source)
881 881
 		{
882 882
 			imagedestroy($thumb);
883 883
 			return FALSE;
@@ -889,13 +889,13 @@  discard block
 block discarded – undo
889 889
 
890 890
 		$x = 0;
891 891
 		$y = 0;
892
-		if($thumbnail_type == 'crop')
892
+		if ($thumbnail_type == 'crop')
893 893
 		{
894 894
 			$x = (int) ($resize_width / 2 - $new_width / 2);
895 895
 			$y = (int) ($resize_height / 2 - $new_height / 2);
896 896
 		}
897 897
 
898
-		if(function_exists('imagecopyresampled'))
898
+		if (function_exists('imagecopyresampled'))
899 899
 		{
900 900
 			imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height);
901 901
 		}
@@ -909,30 +909,30 @@  discard block
 block discarded – undo
909 909
 
910 910
 		// write into the file
911 911
 		$output = NULL;
912
-		switch($target_type)
912
+		switch ($target_type)
913 913
 		{
914 914
 			case 'gif' :
915
-				if(function_exists('imagegif'))
915
+				if (function_exists('imagegif'))
916 916
 				{
917 917
 					$output = imagegif($thumb, $target_file);
918 918
 				}
919 919
 				break;
920 920
 			case 'jpeg' :
921 921
 			case 'jpg' :
922
-				if(function_exists('imagejpeg'))
922
+				if (function_exists('imagejpeg'))
923 923
 				{
924 924
 					$output = imagejpeg($thumb, $target_file, 100);
925 925
 				}
926 926
 				break;
927 927
 			case 'png' :
928
-				if(function_exists('imagepng'))
928
+				if (function_exists('imagepng'))
929 929
 				{
930 930
 					$output = imagepng($thumb, $target_file, 9);
931 931
 				}
932 932
 				break;
933 933
 			case 'wbmp' :
934 934
 			case 'bmp' :
935
-				if(function_exists('imagewbmp'))
935
+				if (function_exists('imagewbmp'))
936 936
 				{
937 937
 					$output = imagewbmp($thumb, $target_file, 100);
938 938
 				}
@@ -942,7 +942,7 @@  discard block
 block discarded – undo
942 942
 		imagedestroy($thumb);
943 943
 		imagedestroy($source);
944 944
 
945
-		if(!$output)
945
+		if (!$output)
946 946
 		{
947 947
 			return FALSE;
948 948
 		}
@@ -960,12 +960,12 @@  discard block
 block discarded – undo
960 960
 	 */
961 961
 	function readIniFile($filename)
962 962
 	{
963
-		if(($filename = self::exists($filename)) === FALSE)
963
+		if (($filename = self::exists($filename)) === FALSE)
964 964
 		{
965 965
 			return FALSE;
966 966
 		}
967 967
 		$arr = parse_ini_file($filename, TRUE);
968
-		if(is_array($arr) && count($arr) > 0)
968
+		if (is_array($arr) && count($arr) > 0)
969 969
 		{
970 970
 			return $arr;
971 971
 		}
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
 	 */
992 992
 	function writeIniFile($filename, $arr)
993 993
 	{
994
-		if(!is_array($arr) || count($arr) == 0)
994
+		if (!is_array($arr) || count($arr) == 0)
995 995
 		{
996 996
 			return FALSE;
997 997
 		}
@@ -1008,19 +1008,19 @@  discard block
 block discarded – undo
1008 1008
 	function _makeIniBuff($arr)
1009 1009
 	{
1010 1010
 		$return = array();
1011
-		foreach($arr as $key => $val)
1011
+		foreach ($arr as $key => $val)
1012 1012
 		{
1013 1013
 			// section
1014
-			if(is_array($val))
1014
+			if (is_array($val))
1015 1015
 			{
1016 1016
 				$return[] = sprintf("[%s]", $key);
1017
-				foreach($val as $k => $v)
1017
+				foreach ($val as $k => $v)
1018 1018
 				{
1019 1019
 					$return[] = sprintf("%s=\"%s\"", $k, $v);
1020 1020
 				}
1021 1021
 				// value
1022 1022
 			}
1023
-			else if(is_object($val))
1023
+			else if (is_object($val))
1024 1024
 			{
1025 1025
 				continue;
1026 1026
 			}
@@ -1095,15 +1095,15 @@  discard block
 block discarded – undo
1095 1095
 	function isWritableDir($path)
1096 1096
 	{
1097 1097
 		$path = self::getRealPath($path);
1098
-		if(is_dir($path)==FALSE)
1098
+		if (is_dir($path) == FALSE)
1099 1099
 		{
1100 1100
 			return FALSE;
1101 1101
 		}
1102 1102
 
1103
-		$checkFile = $path . '/_CheckWritableDir';
1103
+		$checkFile = $path.'/_CheckWritableDir';
1104 1104
 
1105 1105
 		$fp = fopen($checkFile, 'w');
1106
-		if(!is_resource($fp))
1106
+		if (!is_resource($fp))
1107 1107
 		{
1108 1108
 			return FALSE;
1109 1109
 		}
Please login to merge, or discard this patch.