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 (#1929)
by
unknown
35:39 queued 24:06
created
classes/file/FileHandler.class.php 2 patches
Spacing   +127 added lines, -127 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"])
530
+			if ($parsed_url["host"])
531 531
 			{
532 532
 				$oRequest = new HTTP_Request(__PROXY_SERVER__);
533 533
 				$oRequest->setMethod('POST');
@@ -537,64 +537,64 @@  discard block
 block discarded – undo
537 537
 			{
538 538
 				$oRequest = new HTTP_Request($url);
539 539
 
540
-				if(count($request_config) && method_exists($oRequest, 'setConfig'))
540
+				if (count($request_config) && method_exists($oRequest, 'setConfig'))
541 541
 				{
542
-					foreach($request_config as $key=>$val)
542
+					foreach ($request_config as $key=>$val)
543 543
 					{
544 544
 						$oRequest->setConfig($key, $val);
545 545
 					}
546 546
 				}
547
-				if(method_exists($oRequest, 'setConfig'))
547
+				if (method_exists($oRequest, 'setConfig'))
548 548
 				{
549
-					if(extension_loaded('curl'))
549
+					if (extension_loaded('curl'))
550 550
 					{
551 551
 						$oRequest->setConfig('adapter', 'curl');
552 552
 					}
553
-					elseif(version_compare(PHP_VERSION, '5.6', '<'))
553
+					elseif (version_compare(PHP_VERSION, '5.6', '<'))
554 554
 					{
555 555
 						$oRequest->setConfig('ssl_verify_host', false);
556 556
 					}
557
-					if(file_exists(_XE_PATH_ . 'libs/cacert/cacert.pem'))
557
+					if (file_exists(_XE_PATH_.'libs/cacert/cacert.pem'))
558 558
 					{
559
-						$oRequest->setConfig('ssl_cafile', _XE_PATH_ . 'libs/cacert/cacert.pem');
559
+						$oRequest->setConfig('ssl_cafile', _XE_PATH_.'libs/cacert/cacert.pem');
560 560
 					}
561 561
 				}
562 562
 
563
-				if(count($headers) > 0)
563
+				if (count($headers) > 0)
564 564
 				{
565
-					foreach($headers as $key => $val)
565
+					foreach ($headers as $key => $val)
566 566
 					{
567 567
 						$oRequest->addHeader($key, $val);
568 568
 					}
569 569
 				}
570
-				if($cookies[$host])
570
+				if ($cookies[$host])
571 571
 				{
572
-					foreach($cookies[$host] as $key => $val)
572
+					foreach ($cookies[$host] as $key => $val)
573 573
 					{
574 574
 						$oRequest->addCookie($key, $val);
575 575
 					}
576 576
 				}
577
-				if(count($post_data) > 0)
577
+				if (count($post_data) > 0)
578 578
 				{
579
-					foreach($post_data as $key => $val)
579
+					foreach ($post_data as $key => $val)
580 580
 					{
581 581
 						$oRequest->addPostData($key, $val);
582 582
 					}
583 583
 				}
584
-				if(!$content_type)
584
+				if (!$content_type)
585 585
 					$oRequest->addHeader('Content-Type', 'text/html');
586 586
 				else
587 587
 					$oRequest->addHeader('Content-Type', $content_type);
588 588
 				$oRequest->setMethod($method);
589
-				if($body)
589
+				if ($body)
590 590
 					$oRequest->setBody($body);
591 591
 			}
592 592
 			
593
-			if(method_exists($oRequest, 'setConfig'))
593
+			if (method_exists($oRequest, 'setConfig'))
594 594
 			{
595 595
 				$oRequest->setConfig('timeout', $timeout);
596 596
 			}
597
-			elseif(property_exists($oRequest, '_timeout'))
597
+			elseif (property_exists($oRequest, '_timeout'))
598 598
 			{
599 599
 				$oRequest->_timeout = $timeout;
600 600
 			}
@@ -604,25 +604,25 @@  discard block
 block discarded – undo
604 604
 			$code = $oRequest->getResponseCode();
605 605
 			$header = $oRequest->getResponseHeader();
606 606
 			$response = $oRequest->getResponseBody();
607
-			if($c = $oRequest->getResponseCookies())
607
+			if ($c = $oRequest->getResponseCookies())
608 608
 			{
609
-				foreach($c as $k => $v)
609
+				foreach ($c as $k => $v)
610 610
 				{
611 611
 					$cookies[$host][$v['name']] = $v['value'];
612 612
 				}
613 613
 			}
614 614
 
615
-			if($code > 300 && $code < 399 && $header['location'])
615
+			if ($code > 300 && $code < 399 && $header['location'])
616 616
 			{
617 617
 				return self::getRemoteResource($header['location'], $body, $timeout, $method, $content_type, $headers, $cookies, $post_data);
618 618
 			}
619 619
 
620
-			if($code != 200)
620
+			if ($code != 200)
621 621
 				return;
622 622
 
623 623
 			return $response;
624 624
 		}
625
-		catch(Exception $e)
625
+		catch (Exception $e)
626 626
 		{
627 627
 			return NULL;
628 628
 		}
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 	 */
643 643
 	function getRemoteFile($url, $target_filename, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array(), $request_config = array())
644 644
 	{
645
-		if(!($body = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers,$cookies,$post_data,$request_config)))
645
+		if (!($body = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers, $cookies, $post_data, $request_config)))
646 646
 		{
647 647
 			return FALSE;
648 648
 		}
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
 	function returnBytes($val)
662 662
 	{
663 663
 		$unit = strtoupper(substr($val, -1));
664
-		$val = (float)$val;
664
+		$val = (float) $val;
665 665
 
666 666
 		switch ($unit)
667 667
 		{
@@ -684,13 +684,13 @@  discard block
 block discarded – undo
684 684
 		$K64 = 65536;
685 685
 		$TWEAKFACTOR = 2.0;
686 686
 		$channels = $imageInfo['channels'];
687
-		if(!$channels)
687
+		if (!$channels)
688 688
 		{
689 689
 			$channels = 6; //for png
690 690
 		}
691
-		$memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64 ) * $TWEAKFACTOR);
691
+		$memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64) * $TWEAKFACTOR);
692 692
 		$availableMemory = self::returnBytes(ini_get('memory_limit')) - memory_get_usage();
693
-		if($availableMemory < $memoryNeeded)
693
+		if ($availableMemory < $memoryNeeded)
694 694
 		{
695 695
 			return FALSE;
696 696
 		}
@@ -717,30 +717,30 @@  discard block
 block discarded – undo
717 717
 		}
718 718
 
719 719
 		$target_file = self::getRealPath($target_file);
720
-		if(!$resize_width)
720
+		if (!$resize_width)
721 721
 		{
722 722
 			$resize_width = 100;
723 723
 		}
724 724
 
725
-		if(!$resize_height)
725
+		if (!$resize_height)
726 726
 		{
727 727
 			$resize_height = $resize_width;
728 728
 		}
729 729
 
730 730
 		// retrieve source image's information
731 731
 		$imageInfo = getimagesize($source_file);
732
-		if(!self::checkMemoryLoadImage($imageInfo))
732
+		if (!self::checkMemoryLoadImage($imageInfo))
733 733
 		{
734 734
 			return FALSE;
735 735
 		}
736 736
 
737 737
 		list($width, $height, $type, $attrs) = $imageInfo;
738
-		if($width < 1 || $height < 1)
738
+		if ($width < 1 || $height < 1)
739 739
 		{
740 740
 			return;
741 741
 		}
742 742
 
743
-		switch($type)
743
+		switch ($type)
744 744
 		{
745 745
 			case '1' :
746 746
 				$type = 'gif';
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 				return;
759 759
 		}
760 760
 
761
-		if(!$target_type)
761
+		if (!$target_type)
762 762
 		{
763 763
 			$target_type = $type;
764 764
 		}
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 		$height_per = ($resize_height > 0 && $height >= $resize_height) ? $resize_height / $height : 1;
770 770
 
771 771
 		$per = NULL;
772
-		if($thumbnail_type == 'ratio')
772
+		if ($thumbnail_type == 'ratio')
773 773
 		{
774 774
 			$per = ($width_per > $height_per) ? $height_per : $width_per;
775 775
 			$resize_width = $width * $per;
@@ -782,16 +782,16 @@  discard block
 block discarded – undo
782 782
 
783 783
 		// create temporary image with target size
784 784
 		$thumb = NULL;
785
-		if(function_exists('imagecreateTRUEcolor'))
785
+		if (function_exists('imagecreateTRUEcolor'))
786 786
 		{
787 787
 			$thumb = imagecreateTRUEcolor($resize_width, $resize_height);
788 788
 		}
789
-		else if(function_exists('imagecreate'))
789
+		else if (function_exists('imagecreate'))
790 790
 		{
791 791
 			$thumb = imagecreate($resize_width, $resize_height);
792 792
 		}
793 793
 
794
-		if(!$thumb)
794
+		if (!$thumb)
795 795
 		{
796 796
 			return FALSE;
797 797
 		}
@@ -800,37 +800,37 @@  discard block
 block discarded – undo
800 800
 
801 801
 		// create temporary image having original type
802 802
 		$source = NULL;
803
-		switch($type)
803
+		switch ($type)
804 804
 		{
805 805
 			case 'gif' :
806
-				if(function_exists('imagecreatefromgif'))
806
+				if (function_exists('imagecreatefromgif'))
807 807
 				{
808 808
 					$source = @imagecreatefromgif($source_file);
809 809
 				}
810 810
 				break;
811 811
 			case 'jpeg' :
812 812
 			case 'jpg' :
813
-				if(function_exists('imagecreatefromjpeg'))
813
+				if (function_exists('imagecreatefromjpeg'))
814 814
 				{
815 815
 					$source = @imagecreatefromjpeg($source_file);
816 816
 				}
817 817
 				break;
818 818
 			case 'png' :
819
-				if(function_exists('imagecreatefrompng'))
819
+				if (function_exists('imagecreatefrompng'))
820 820
 				{
821 821
 					$source = @imagecreatefrompng($source_file);
822 822
 				}
823 823
 				break;
824 824
 			case 'wbmp' :
825 825
 			case 'bmp' :
826
-				if(function_exists('imagecreatefromwbmp'))
826
+				if (function_exists('imagecreatefromwbmp'))
827 827
 				{
828 828
 					$source = @imagecreatefromwbmp($source_file);
829 829
 				}
830 830
 				break;
831 831
 		}
832 832
 
833
-		if(!$source)
833
+		if (!$source)
834 834
 		{
835 835
 			imagedestroy($thumb);
836 836
 			return FALSE;
@@ -842,13 +842,13 @@  discard block
 block discarded – undo
842 842
 
843 843
 		$x = 0;
844 844
 		$y = 0;
845
-		if($thumbnail_type == 'crop')
845
+		if ($thumbnail_type == 'crop')
846 846
 		{
847 847
 			$x = (int) ($resize_width / 2 - $new_width / 2);
848 848
 			$y = (int) ($resize_height / 2 - $new_height / 2);
849 849
 		}
850 850
 
851
-		if(function_exists('imagecopyresampled'))
851
+		if (function_exists('imagecopyresampled'))
852 852
 		{
853 853
 			imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height);
854 854
 		}
@@ -862,30 +862,30 @@  discard block
 block discarded – undo
862 862
 
863 863
 		// write into the file
864 864
 		$output = NULL;
865
-		switch($target_type)
865
+		switch ($target_type)
866 866
 		{
867 867
 			case 'gif' :
868
-				if(function_exists('imagegif'))
868
+				if (function_exists('imagegif'))
869 869
 				{
870 870
 					$output = imagegif($thumb, $target_file);
871 871
 				}
872 872
 				break;
873 873
 			case 'jpeg' :
874 874
 			case 'jpg' :
875
-				if(function_exists('imagejpeg'))
875
+				if (function_exists('imagejpeg'))
876 876
 				{
877 877
 					$output = imagejpeg($thumb, $target_file, 100);
878 878
 				}
879 879
 				break;
880 880
 			case 'png' :
881
-				if(function_exists('imagepng'))
881
+				if (function_exists('imagepng'))
882 882
 				{
883 883
 					$output = imagepng($thumb, $target_file, 9);
884 884
 				}
885 885
 				break;
886 886
 			case 'wbmp' :
887 887
 			case 'bmp' :
888
-				if(function_exists('imagewbmp'))
888
+				if (function_exists('imagewbmp'))
889 889
 				{
890 890
 					$output = imagewbmp($thumb, $target_file, 100);
891 891
 				}
@@ -895,7 +895,7 @@  discard block
 block discarded – undo
895 895
 		imagedestroy($thumb);
896 896
 		imagedestroy($source);
897 897
 
898
-		if(!$output)
898
+		if (!$output)
899 899
 		{
900 900
 			return FALSE;
901 901
 		}
@@ -913,12 +913,12 @@  discard block
 block discarded – undo
913 913
 	 */
914 914
 	function readIniFile($filename)
915 915
 	{
916
-		if(($filename = self::exists($filename)) === FALSE)
916
+		if (($filename = self::exists($filename)) === FALSE)
917 917
 		{
918 918
 			return FALSE;
919 919
 		}
920 920
 		$arr = parse_ini_file($filename, TRUE);
921
-		if(is_array($arr) && count($arr) > 0)
921
+		if (is_array($arr) && count($arr) > 0)
922 922
 		{
923 923
 			return $arr;
924 924
 		}
@@ -944,7 +944,7 @@  discard block
 block discarded – undo
944 944
 	 */
945 945
 	function writeIniFile($filename, $arr)
946 946
 	{
947
-		if(!is_array($arr) || count($arr) == 0)
947
+		if (!is_array($arr) || count($arr) == 0)
948 948
 		{
949 949
 			return FALSE;
950 950
 		}
@@ -961,19 +961,19 @@  discard block
 block discarded – undo
961 961
 	function _makeIniBuff($arr)
962 962
 	{
963 963
 		$return = array();
964
-		foreach($arr as $key => $val)
964
+		foreach ($arr as $key => $val)
965 965
 		{
966 966
 			// section
967
-			if(is_array($val))
967
+			if (is_array($val))
968 968
 			{
969 969
 				$return[] = sprintf("[%s]", $key);
970
-				foreach($val as $k => $v)
970
+				foreach ($val as $k => $v)
971 971
 				{
972 972
 					$return[] = sprintf("%s=\"%s\"", $k, $v);
973 973
 				}
974 974
 				// value
975 975
 			}
976
-			else if(is_object($val))
976
+			else if (is_object($val))
977 977
 			{
978 978
 				continue;
979 979
 			}
@@ -1048,15 +1048,15 @@  discard block
 block discarded – undo
1048 1048
 	function isWritableDir($path)
1049 1049
 	{
1050 1050
 		$path = self::getRealPath($path);
1051
-		if(is_dir($path)==FALSE)
1051
+		if (is_dir($path) == FALSE)
1052 1052
 		{
1053 1053
 			return FALSE;
1054 1054
 		}
1055 1055
 
1056
-		$checkFile = $path . '/_CheckWritableDir';
1056
+		$checkFile = $path.'/_CheckWritableDir';
1057 1057
 
1058 1058
 		$fp = fopen($checkFile, 'w');
1059
-		if(!is_resource($fp))
1059
+		if (!is_resource($fp))
1060 1060
 		{
1061 1061
 			return FALSE;
1062 1062
 		}
Please login to merge, or discard this patch.
Braces   +30 added lines, -41 removed lines patch added patch discarded remove patch
@@ -74,14 +74,12 @@  discard block
 block discarded – undo
74 74
 			if(is_dir($source_dir . $file))
75 75
 			{
76 76
 				self::copyDir($source_dir . $file, $target_dir . $file, $type);
77
-			}
78
-			else
77
+			} else
79 78
 			{
80 79
 				if($type == 'force')
81 80
 				{
82 81
 					@unlink($target_dir . $file);
83
-				}
84
-				else
82
+				} else
85 83
 				{
86 84
 					if(!file_exists($target_dir . $file))
87 85
 					{
@@ -379,15 +377,13 @@  discard block
 block discarded – undo
379 377
 				if(is_dir($target))
380 378
 				{
381 379
 					self::removeDir($target);
382
-				}
383
-				else
380
+				} else
384 381
 				{
385 382
 					unlink($target);
386 383
 				}
387 384
 			}
388 385
 			rmdir($path);
389
-		}
390
-		else
386
+		} else
391 387
 		{
392 388
 			unlink($path);
393 389
 		}
@@ -454,16 +450,16 @@  discard block
 block discarded – undo
454 450
 				if(is_dir($target))
455 451
 				{
456 452
 					self::removeFilesInDir($target);
457
-				}
458
-				else
453
+				} else
459 454
 				{
460 455
 					unlink($target);
461 456
 				}
462 457
 			}
463
-		}
464
-		else
458
+		} else
465 459
 		{
466
-			if(self::exists($path)) unlink($path);
460
+			if(self::exists($path)) {
461
+				unlink($path);
462
+			}
467 463
 		}
468 464
 
469 465
 	}
@@ -532,8 +528,7 @@  discard block
 block discarded – undo
532 528
 				$oRequest = new HTTP_Request(__PROXY_SERVER__);
533 529
 				$oRequest->setMethod('POST');
534 530
 				$oRequest->addPostData('arg', serialize(array('Destination' => $url, 'method' => $method, 'body' => $body, 'content_type' => $content_type, "headers" => $headers, "post_data" => $post_data)));
535
-			}
536
-			else
531
+			} else
537 532
 			{
538 533
 				$oRequest = new HTTP_Request($url);
539 534
 
@@ -549,8 +544,7 @@  discard block
 block discarded – undo
549 544
 					if(extension_loaded('curl'))
550 545
 					{
551 546
 						$oRequest->setConfig('adapter', 'curl');
552
-					}
553
-					elseif(version_compare(PHP_VERSION, '5.6', '<'))
547
+					} elseif(version_compare(PHP_VERSION, '5.6', '<'))
554 548
 					{
555 549
 						$oRequest->setConfig('ssl_verify_host', false);
556 550
 					}
@@ -581,20 +575,21 @@  discard block
 block discarded – undo
581 575
 						$oRequest->addPostData($key, $val);
582 576
 					}
583 577
 				}
584
-				if(!$content_type)
585
-					$oRequest->addHeader('Content-Type', 'text/html');
586
-				else
587
-					$oRequest->addHeader('Content-Type', $content_type);
578
+				if(!$content_type) {
579
+									$oRequest->addHeader('Content-Type', 'text/html');
580
+				} else {
581
+									$oRequest->addHeader('Content-Type', $content_type);
582
+				}
588 583
 				$oRequest->setMethod($method);
589
-				if($body)
590
-					$oRequest->setBody($body);
584
+				if($body) {
585
+									$oRequest->setBody($body);
586
+				}
591 587
 			}
592 588
 			
593 589
 			if(method_exists($oRequest, 'setConfig'))
594 590
 			{
595 591
 				$oRequest->setConfig('timeout', $timeout);
596
-			}
597
-			elseif(property_exists($oRequest, '_timeout'))
592
+			} elseif(property_exists($oRequest, '_timeout'))
598 593
 			{
599 594
 				$oRequest->_timeout = $timeout;
600 595
 			}
@@ -617,12 +612,12 @@  discard block
 block discarded – undo
617 612
 				return self::getRemoteResource($header['location'], $body, $timeout, $method, $content_type, $headers, $cookies, $post_data);
618 613
 			}
619 614
 
620
-			if($code != 200)
621
-				return;
615
+			if($code != 200) {
616
+							return;
617
+			}
622 618
 
623 619
 			return $response;
624
-		}
625
-		catch(Exception $e)
620
+		} catch(Exception $e)
626 621
 		{
627 622
 			return NULL;
628 623
 		}
@@ -774,8 +769,7 @@  discard block
 block discarded – undo
774 769
 			$per = ($width_per > $height_per) ? $height_per : $width_per;
775 770
 			$resize_width = $width * $per;
776 771
 			$resize_height = $height * $per;
777
-		}
778
-		else
772
+		} else
779 773
 		{
780 774
 			$per = ($width_per < $height_per) ? $height_per : $width_per;
781 775
 		}
@@ -785,8 +779,7 @@  discard block
 block discarded – undo
785 779
 		if(function_exists('imagecreateTRUEcolor'))
786 780
 		{
787 781
 			$thumb = imagecreateTRUEcolor($resize_width, $resize_height);
788
-		}
789
-		else if(function_exists('imagecreate'))
782
+		} else if(function_exists('imagecreate'))
790 783
 		{
791 784
 			$thumb = imagecreate($resize_width, $resize_height);
792 785
 		}
@@ -851,8 +844,7 @@  discard block
 block discarded – undo
851 844
 		if(function_exists('imagecopyresampled'))
852 845
 		{
853 846
 			imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height);
854
-		}
855
-		else
847
+		} else
856 848
 		{
857 849
 			imagecopyresized($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height);
858 850
 		}
@@ -921,8 +913,7 @@  discard block
 block discarded – undo
921 913
 		if(is_array($arr) && count($arr) > 0)
922 914
 		{
923 915
 			return $arr;
924
-		}
925
-		else
916
+		} else
926 917
 		{
927 918
 			return array();
928 919
 		}
@@ -972,12 +963,10 @@  discard block
 block discarded – undo
972 963
 					$return[] = sprintf("%s=\"%s\"", $k, $v);
973 964
 				}
974 965
 				// value
975
-			}
976
-			else if(is_object($val))
966
+			} else if(is_object($val))
977 967
 			{
978 968
 				continue;
979
-			}
980
-			else
969
+			} else
981 970
 			{
982 971
 				$return[] = sprintf("%s=\"%s\"", $key, $val);
983 972
 			}
Please login to merge, or discard this patch.