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 ( 636838...8041ee )
by gyeong-won
06:25
created
config/func.inc.php 1 patch
Spacing   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@  discard block
 block discarded – undo
6 6
  *
7 7
  * @author NAVER ([email protected])
8 8
  */
9
-if(!defined('__XE__'))
9
+if (!defined('__XE__'))
10 10
 {
11 11
 	exit();
12 12
 }
13 13
 
14 14
 // define an empty function to avoid errors when iconv function doesn't exist
15
-if(!function_exists('iconv'))
15
+if (!function_exists('iconv'))
16 16
 {
17 17
 	eval('
18 18
 		function iconv($in_charset, $out_charset, $str)
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 {
221 221
 	$oDB = DB::getInstance();
222 222
 	$output = $oDB->executeQuery($query_id, $args, $arg_columns);
223
-	if(!is_array($output->data) && count($output->data) > 0)
223
+	if (!is_array($output->data) && count($output->data) > 0)
224 224
 	{
225 225
 		$output->data = array($output->data);
226 226
 	}
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 function setUserSequence($seq)
251 251
 {
252 252
 	$arr_seq = array();
253
-	if(isset($_SESSION['seq']))
253
+	if (isset($_SESSION['seq']))
254 254
 	{
255
-		if(!is_array($_SESSION['seq'])) {
255
+		if (!is_array($_SESSION['seq'])) {
256 256
 			$_SESSION['seq'] = array($_SESSION['seq']);
257 257
 		}
258 258
 		$arr_seq = $_SESSION['seq'];
@@ -269,11 +269,11 @@  discard block
 block discarded – undo
269 269
  */
270 270
 function checkUserSequence($seq)
271 271
 {
272
-	if(!isset($_SESSION['seq']))
272
+	if (!isset($_SESSION['seq']))
273 273
 	{
274 274
 		return false;
275 275
 	}
276
-	if(!in_array($seq, $_SESSION['seq']))
276
+	if (!in_array($seq, $_SESSION['seq']))
277 277
 	{
278 278
 		return false;
279 279
 	}
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	$num_args = func_num_args();
300 300
 	$args_list = func_get_args();
301 301
 
302
-	if($num_args)
302
+	if ($num_args)
303 303
 		$url = Context::getUrl($num_args, $args_list);
304 304
 	else
305 305
 		$url = Context::getRequestUri();
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 	$num_args = func_num_args();
319 319
 	$args_list = func_get_args();
320 320
 
321
-	if($num_args)
321
+	if ($num_args)
322 322
 	{
323 323
 		$url = Context::getUrl($num_args, $args_list, NULL, FALSE);
324 324
 	}
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 	$num_args = func_num_args();
342 342
 	$args_list = func_get_args();
343 343
 
344
-	if($num_args)
344
+	if ($num_args)
345 345
 	{
346 346
 		$url = Context::getUrl($num_args, $args_list, NULL, TRUE, TRUE);
347 347
 	}
@@ -363,16 +363,16 @@  discard block
 block discarded – undo
363 363
 	$num_args = func_num_args();
364 364
 	$args_list = func_get_args();
365 365
 	$request_uri = Context::getRequestUri();
366
-	if(!$num_args)
366
+	if (!$num_args)
367 367
 	{
368 368
 		return $request_uri;
369 369
 	}
370 370
 
371 371
 	$url = Context::getUrl($num_args, $args_list);
372
-	if(strncasecmp('http', $url, 4) !== 0)
372
+	if (strncasecmp('http', $url, 4) !== 0)
373 373
 	{
374 374
 		preg_match('/^(http|https):\/\/([^\/]+)\//', $request_uri, $match);
375
-		return substr($match[0], 0, -1) . $url;
375
+		return substr($match[0], 0, -1).$url;
376 376
 	}
377 377
 	return $url;
378 378
 }
@@ -387,17 +387,17 @@  discard block
 block discarded – undo
387 387
 	$num_args = func_num_args();
388 388
 	$args_list = func_get_args();
389 389
 	$request_uri = Context::getRequestUri();
390
-	if(!$num_args)
390
+	if (!$num_args)
391 391
 	{
392 392
 		return $request_uri;
393 393
 	}
394 394
 
395 395
 	$url = Context::getUrl($num_args, $args_list, NULL, FALSE);
396
-	if(strncasecmp('http', $url, 4) !== 0)
396
+	if (strncasecmp('http', $url, 4) !== 0)
397 397
 	{
398 398
 		preg_match('/^(http|https):\/\/([^\/]+)\//', $request_uri, $match);
399 399
 		$url = Context::getUrl($num_args, $args_list, NULL, FALSE);
400
-		return substr($match[0], 0, -1) . $url;
400
+		return substr($match[0], 0, -1).$url;
401 401
 	}
402 402
 	return $url;
403 403
 }
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 	$num_args = func_num_args();
414 414
 	$args_list = func_get_args();
415 415
 
416
-	if(!$num_args)
416
+	if (!$num_args)
417 417
 	{
418 418
 		return Context::getRequestUri();
419 419
 	}
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	$num_args = func_num_args();
436 436
 	$args_list = func_get_args();
437 437
 
438
-	if(!$num_args)
438
+	if (!$num_args)
439 439
 	{
440 440
 		return Context::getRequestUri();
441 441
 	}
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
 	$args_list = func_get_args();
458 458
 
459 459
 	$request_uri = Context::getRequestUri();
460
-	if(!$num_args)
460
+	if (!$num_args)
461 461
 	{
462 462
 		return $request_uri;
463 463
 	}
@@ -466,10 +466,10 @@  discard block
 block discarded – undo
466 466
 	$num_args = count($args_list);
467 467
 
468 468
 	$url = Context::getUrl($num_args, $args_list, $domain);
469
-	if(strncasecmp('http', $url, 4) !== 0)
469
+	if (strncasecmp('http', $url, 4) !== 0)
470 470
 	{
471 471
 		preg_match('/^(http|https):\/\/([^\/]+)\//', $request_uri, $match);
472
-		return substr($match[0], 0, -1) . $url;
472
+		return substr($match[0], 0, -1).$url;
473 473
 	}
474 474
 	return $url;
475 475
 }
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
 function getCurrentPageUrl()
483 483
 {
484 484
 	$protocol = $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://';
485
-	$url = $protocol . $_SERVER['HTTP_HOST'] . preg_replace('/[<>"]/', '', $_SERVER['REQUEST_URI']);
485
+	$url = $protocol.$_SERVER['HTTP_HOST'].preg_replace('/[<>"]/', '', $_SERVER['REQUEST_URI']);
486 486
 	return htmlspecialchars($url, ENT_COMPAT, 'UTF-8', FALSE);
487 487
 }
488 488
 
@@ -507,12 +507,12 @@  discard block
 block discarded – undo
507 507
  */
508 508
 function cut_str($string, $cut_size = 0, $tail = '...')
509 509
 {
510
-	if($cut_size < 1 || !$string)
510
+	if ($cut_size < 1 || !$string)
511 511
 	{
512 512
 		return $string;
513 513
 	}
514 514
 
515
-	if($GLOBALS['use_mb_strimwidth'] || function_exists('mb_strimwidth'))
515
+	if ($GLOBALS['use_mb_strimwidth'] || function_exists('mb_strimwidth'))
516 516
 	{
517 517
 		$GLOBALS['use_mb_strimwidth'] = TRUE;
518 518
 		return mb_strimwidth($string, 0, $cut_size + 4, $tail, 'utf-8');
@@ -526,16 +526,16 @@  discard block
 block discarded – undo
526 526
 	$char_count = 0;
527 527
 
528 528
 	$idx = 0;
529
-	while($idx < $string_length && $char_count < $cut_size && $char_width <= $max_width)
529
+	while ($idx < $string_length && $char_count < $cut_size && $char_width <= $max_width)
530 530
 	{
531 531
 		$c = ord(substr($string, $idx, 1));
532 532
 		$char_count++;
533
-		if($c < 128)
533
+		if ($c < 128)
534 534
 		{
535 535
 			$char_width += (int) $chars[$c - 32];
536 536
 			$idx++;
537 537
 		}
538
-		else if(191 < $c && $c < 224)
538
+		else if (191 < $c && $c < 224)
539 539
 		{
540 540
 			$char_width += $chars[4];
541 541
 			$idx += 2;
@@ -548,7 +548,7 @@  discard block
 block discarded – undo
548 548
 	}
549 549
 
550 550
 	$output = substr($string, 0, $idx);
551
-	if(strlen($output) < $string_length)
551
+	if (strlen($output) < $string_length)
552 552
 	{
553 553
 		$output .= $tail;
554 554
 	}
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
 function zgap()
565 565
 {
566 566
 	$time_zone = $GLOBALS['_time_zone'];
567
-	if($time_zone < 0)
567
+	if ($time_zone < 0)
568 568
 	{
569 569
 		$to = -1;
570 570
 	}
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 	$t_min = substr($time_zone, 3, 2) * $to;
578 578
 
579 579
 	$server_time_zone = date("O");
580
-	if($server_time_zone < 0)
580
+	if ($server_time_zone < 0)
581 581
 	{
582 582
 		$so = -1;
583 583
 	}
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
  */
605 605
 function ztime($str)
606 606
 {
607
-	if(!$str)
607
+	if (!$str)
608 608
 	{
609 609
 		return;
610 610
 	}
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
 	$year = (int) substr($str, 0, 4);
620 620
 	$month = (int) substr($str, 4, 2);
621 621
 	$day = (int) substr($str, 6, 2);
622
-	if(strlen($str) <= 8)
622
+	if (strlen($str) <= 8)
623 623
 	{
624 624
 		$gap = 0;
625 625
 	}
@@ -643,19 +643,19 @@  discard block
 block discarded – undo
643 643
 	$gap = $_SERVER['REQUEST_TIME'] + zgap() - ztime($date);
644 644
 
645 645
 	$lang_time_gap = Context::getLang('time_gap');
646
-	if($gap < 60)
646
+	if ($gap < 60)
647 647
 	{
648 648
 		$buff = sprintf($lang_time_gap['min'], (int) ($gap / 60) + 1);
649 649
 	}
650
-	elseif($gap < 60 * 60)
650
+	elseif ($gap < 60 * 60)
651 651
 	{
652 652
 		$buff = sprintf($lang_time_gap['mins'], (int) ($gap / 60) + 1);
653 653
 	}
654
-	elseif($gap < 60 * 60 * 2)
654
+	elseif ($gap < 60 * 60 * 2)
655 655
 	{
656 656
 		$buff = sprintf($lang_time_gap['hour'], (int) ($gap / 60 / 60) + 1);
657 657
 	}
658
-	elseif($gap < 60 * 60 * 24)
658
+	elseif ($gap < 60 * 60 * 24)
659 659
 	{
660 660
 		$buff = sprintf($lang_time_gap['hours'], (int) ($gap / 60 / 60) + 1);
661 661
 	}
@@ -692,40 +692,40 @@  discard block
 block discarded – undo
692 692
 function zdate($str, $format = 'Y-m-d H:i:s', $conversion = TRUE)
693 693
 {
694 694
 	// return null if no target time is specified
695
-	if(!$str)
695
+	if (!$str)
696 696
 	{
697 697
 		return;
698 698
 	}
699 699
 	// convert the date format according to the language
700
-	if($conversion == TRUE)
700
+	if ($conversion == TRUE)
701 701
 	{
702
-		switch(Context::getLangType())
702
+		switch (Context::getLangType())
703 703
 		{
704 704
 			case 'en' :
705 705
 			case 'es' :
706
-				if($format == 'Y-m-d')
706
+				if ($format == 'Y-m-d')
707 707
 				{
708 708
 					$format = 'M d, Y';
709 709
 				}
710
-				elseif($format == 'Y-m-d H:i:s')
710
+				elseif ($format == 'Y-m-d H:i:s')
711 711
 				{
712 712
 					$format = 'M d, Y H:i:s';
713 713
 				}
714
-				elseif($format == 'Y-m-d H:i')
714
+				elseif ($format == 'Y-m-d H:i')
715 715
 				{
716 716
 					$format = 'M d, Y H:i';
717 717
 				}
718 718
 				break;
719 719
 			case 'vi' :
720
-				if($format == 'Y-m-d')
720
+				if ($format == 'Y-m-d')
721 721
 				{
722 722
 					$format = 'd-m-Y';
723 723
 				}
724
-				elseif($format == 'Y-m-d H:i:s')
724
+				elseif ($format == 'Y-m-d H:i:s')
725 725
 				{
726 726
 					$format = 'H:i:s d-m-Y';
727 727
 				}
728
-				elseif($format == 'Y-m-d H:i')
728
+				elseif ($format == 'Y-m-d H:i')
729 729
 				{
730 730
 					$format = 'H:i d-m-Y';
731 731
 				}
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 	}
735 735
 
736 736
 	// If year value is less than 1970, handle it separately.
737
-	if((int) substr($str, 0, 4) < 1970)
737
+	if ((int) substr($str, 0, 4) < 1970)
738 738
 	{
739 739
 		$hour = (int) substr($str, 8, 2);
740 740
 		$min = (int) substr($str, 10, 2);
@@ -784,9 +784,9 @@  discard block
 block discarded – undo
784 784
 function getEncodeEmailAddress($email)
785 785
 {
786 786
 	$return = '';
787
-	for($i = 0, $c = strlen($email); $i < $c; $i++)
787
+	for ($i = 0, $c = strlen($email); $i < $c; $i++)
788 788
 	{
789
-		$return .= '&#' . (rand(0, 1) == 0 ? ord($email[$i]) : 'X' . dechex(ord($email[$i]))) . ';';
789
+		$return .= '&#'.(rand(0, 1) == 0 ? ord($email[$i]) : 'X'.dechex(ord($email[$i]))).';';
790 790
 	}
791 791
 	return $return;
792 792
 }
@@ -806,25 +806,25 @@  discard block
 block discarded – undo
806 806
 {
807 807
 	static $debug_file;
808 808
 
809
-	if(!(__DEBUG__ & 1))
809
+	if (!(__DEBUG__ & 1))
810 810
 	{
811 811
 		return;
812 812
 	}
813 813
 
814 814
 	static $firephp;
815 815
 	$bt = debug_backtrace();
816
-	if(is_array($bt))
816
+	if (is_array($bt))
817 817
 	{
818 818
 		$bt_debug_print = array_shift($bt);
819 819
 		$bt_called_function = array_shift($bt);
820 820
 	}
821 821
 	$file_name = str_replace(_XE_PATH_, '', $bt_debug_print['file']);
822 822
 	$line_num = $bt_debug_print['line'];
823
-	$function = $bt_called_function['class'] . $bt_called_function['type'] . $bt_called_function['function'];
823
+	$function = $bt_called_function['class'].$bt_called_function['type'].$bt_called_function['function'];
824 824
 
825
-	if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1)
825
+	if (__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1)
826 826
 	{
827
-		if(!isset($firephp))
827
+		if (!isset($firephp))
828 828
 		{
829 829
 			$firephp = FirePHP::getInstance(TRUE);
830 830
 		}
@@ -833,16 +833,16 @@  discard block
 block discarded – undo
833 833
 		$label = sprintf('[%s:%d] %s() (Memory usage: current=%s, peak=%s)', $file_name, $line_num, $function, FileHandler::filesize(memory_get_usage()), FileHandler::filesize(memory_get_peak_usage()));
834 834
 
835 835
 		// Check a FirePHP option
836
-		if($display_option === 'TABLE')
836
+		if ($display_option === 'TABLE')
837 837
 		{
838 838
 			$label = $display_option;
839 839
 		}
840
-		if($display_option === 'ERROR')
840
+		if ($display_option === 'ERROR')
841 841
 		{
842 842
 			$type = $display_option;
843 843
 		}
844 844
 		// Check if the IP specified by __DEBUG_PROTECT__ option is same as the access IP.
845
-		if(__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
845
+		if (__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
846 846
 		{
847 847
 			$debug_output = 'The IP address is not allowed. Change the value of __DEBUG_PROTECT_IP__ into your IP address in config/config.user.inc.php or config/config.inc.php';
848 848
 			$label = NULL;
@@ -852,52 +852,52 @@  discard block
 block discarded – undo
852 852
 	}
853 853
 	else
854 854
 	{
855
-		if(__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
855
+		if (__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR'])
856 856
 		{
857 857
 			return;
858 858
 		}
859 859
 
860 860
 		$print = array();
861
-		if(!$debug_file)
861
+		if (!$debug_file)
862 862
 		{
863
-			$debug_file = _XE_PATH_ . 'files/' . $file;
863
+			$debug_file = _XE_PATH_.'files/'.$file;
864 864
 		}
865
-		if(!file_exists($debug_file)) $print[] = '<?php exit() ?>';
865
+		if (!file_exists($debug_file)) $print[] = '<?php exit() ?>';
866 866
 
867
-		if($display_option === TRUE || $display_option === 'ERROR')
867
+		if ($display_option === TRUE || $display_option === 'ERROR')
868 868
 		{
869
-			$print[] = sprintf("[%s %s:%d] %s() - mem(%s)", date('Y-m-d H:i:s'), $file_name, $line_num, $function, FileHandler::filesize(memory_get_usage()));;
869
+			$print[] = sprintf("[%s %s:%d] %s() - mem(%s)", date('Y-m-d H:i:s'), $file_name, $line_num, $function, FileHandler::filesize(memory_get_usage())); ;
870 870
 			$print[] = str_repeat('=', 80);
871 871
 		}
872 872
 		$type = gettype($debug_output);
873
-		if(!in_array($type, array('array', 'object', 'resource')))
873
+		if (!in_array($type, array('array', 'object', 'resource')))
874 874
 		{
875
-			if($display_option === 'ERROR')
875
+			if ($display_option === 'ERROR')
876 876
 			{
877
-				$print[] = 'ERROR : ' . var_export($debug_output, TRUE);
877
+				$print[] = 'ERROR : '.var_export($debug_output, TRUE);
878 878
 			}
879 879
 			else
880 880
 			{
881
-				$print[] = 'DEBUG : ' . $type . '(' . var_export($debug_output, TRUE) . ')';
881
+				$print[] = 'DEBUG : '.$type.'('.var_export($debug_output, TRUE).')';
882 882
 			}
883 883
 		}
884 884
 		else
885 885
 		{
886
-			$print[] = 'DEBUG : ' . trim(preg_replace('/\r?\n/', "\n" . '        ', print_r($debug_output, true)));
886
+			$print[] = 'DEBUG : '.trim(preg_replace('/\r?\n/', "\n".'        ', print_r($debug_output, true)));
887 887
 		}
888 888
 		$backtrace_args = defined('\DEBUG_BACKTRACE_IGNORE_ARGS') ? \DEBUG_BACKTRACE_IGNORE_ARGS : 0;
889 889
 		$backtrace = debug_backtrace($backtrace_args);
890 890
 
891
-		if(count($backtrace) > 1 && $backtrace[1]['function'] === 'debugPrint' && !$backtrace[1]['class'])
891
+		if (count($backtrace) > 1 && $backtrace[1]['function'] === 'debugPrint' && !$backtrace[1]['class'])
892 892
 		{
893 893
 			array_shift($backtrace);
894 894
 		}
895
-		foreach($backtrace as $val)
895
+		foreach ($backtrace as $val)
896 896
 		{
897
-			$print[] = '        - ' . $val['file'] . ' : ' . $val['line'];
897
+			$print[] = '        - '.$val['file'].' : '.$val['line'];
898 898
 		}
899 899
 		$print[] = PHP_EOL;
900
-		@file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND|LOCK_EX);
900
+		@file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND | LOCK_EX);
901 901
 	}
902 902
 }
903 903
 
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
  */
909 909
 function writeSlowlog($type, $elapsed_time, $obj)
910 910
 {
911
-	if(!__LOG_SLOW_TRIGGER__ && !__LOG_SLOW_ADDON__ && !__LOG_SLOW_WIDGET__ && !__LOG_SLOW_QUERY__) return;
911
+	if (!__LOG_SLOW_TRIGGER__ && !__LOG_SLOW_ADDON__ && !__LOG_SLOW_WIDGET__ && !__LOG_SLOW_QUERY__) return;
912 912
 
913 913
 	static $log_filename = array(
914 914
 		'query' => 'files/_slowlog_query.php',
@@ -918,47 +918,47 @@  discard block
 block discarded – undo
918 918
 	);
919 919
 	$write_file = true;
920 920
 
921
-	$log_file = _XE_PATH_ . $log_filename[$type];
921
+	$log_file = _XE_PATH_.$log_filename[$type];
922 922
 
923 923
 	$buff = array();
924 924
 	$buff[] = '<?php exit(); ?>';
925 925
 	$buff[] = date('c');
926 926
 
927
-	if($type == 'trigger' && __LOG_SLOW_TRIGGER__ > 0 && $elapsed_time > __LOG_SLOW_TRIGGER__)
927
+	if ($type == 'trigger' && __LOG_SLOW_TRIGGER__ > 0 && $elapsed_time > __LOG_SLOW_TRIGGER__)
928 928
 	{
929
-		$buff[] = "\tCaller : " . $obj->caller;
930
-		$buff[] = "\tCalled : " . $obj->called;
929
+		$buff[] = "\tCaller : ".$obj->caller;
930
+		$buff[] = "\tCalled : ".$obj->called;
931 931
 	}
932
-	else if($type == 'addon' && __LOG_SLOW_ADDON__ > 0 && $elapsed_time > __LOG_SLOW_ADDON__)
932
+	else if ($type == 'addon' && __LOG_SLOW_ADDON__ > 0 && $elapsed_time > __LOG_SLOW_ADDON__)
933 933
 	{
934
-		$buff[] = "\tAddon : " . $obj->called;
935
-		$buff[] = "\tCalled position : " . $obj->caller;
934
+		$buff[] = "\tAddon : ".$obj->called;
935
+		$buff[] = "\tCalled position : ".$obj->caller;
936 936
 	}
937
-	else if($type == 'widget' && __LOG_SLOW_WIDGET__ > 0 && $elapsed_time > __LOG_SLOW_WIDGET__)
937
+	else if ($type == 'widget' && __LOG_SLOW_WIDGET__ > 0 && $elapsed_time > __LOG_SLOW_WIDGET__)
938 938
 	{
939
-		$buff[] = "\tWidget : " . $obj->called;
939
+		$buff[] = "\tWidget : ".$obj->called;
940 940
 	}
941
-	else if($type == 'query' && __LOG_SLOW_QUERY__ > 0 && $elapsed_time > __LOG_SLOW_QUERY__)
941
+	else if ($type == 'query' && __LOG_SLOW_QUERY__ > 0 && $elapsed_time > __LOG_SLOW_QUERY__)
942 942
 	{
943 943
 
944 944
 		$buff[] = $obj->query;
945
-		$buff[] = "\tQuery ID   : " . $obj->query_id;
946
-		$buff[] = "\tCaller     : " . $obj->caller;
947
-		$buff[] = "\tConnection : " . $obj->connection;
945
+		$buff[] = "\tQuery ID   : ".$obj->query_id;
946
+		$buff[] = "\tCaller     : ".$obj->caller;
947
+		$buff[] = "\tConnection : ".$obj->connection;
948 948
 	}
949 949
 	else
950 950
 	{
951 951
 		$write_file = false;
952 952
 	}
953 953
 
954
-	if($write_file)
954
+	if ($write_file)
955 955
 	{
956 956
 		$buff[] = sprintf("\t%0.6f sec", $elapsed_time);
957
-		$buff[] = PHP_EOL . PHP_EOL;
957
+		$buff[] = PHP_EOL.PHP_EOL;
958 958
 		file_put_contents($log_file, implode(PHP_EOL, $buff), FILE_APPEND);
959 959
 	}
960 960
 
961
-	if($type != 'query')
961
+	if ($type != 'query')
962 962
 	{
963 963
 		$trigger_args = $obj;
964 964
 		$trigger_args->_log_type = $type;
@@ -998,11 +998,11 @@  discard block
 block discarded – undo
998 998
  */
999 999
 function delObjectVars($target_obj, $del_obj)
1000 1000
 {
1001
-	if(!is_object($target_obj))
1001
+	if (!is_object($target_obj))
1002 1002
 	{
1003 1003
 		return;
1004 1004
 	}
1005
-	if(!is_object($del_obj))
1005
+	if (!is_object($del_obj))
1006 1006
 	{
1007 1007
 		return;
1008 1008
 	}
@@ -1012,7 +1012,7 @@  discard block
 block discarded – undo
1012 1012
 
1013 1013
 	$target = array_keys($target_vars);
1014 1014
 	$del = array_keys($del_vars);
1015
-	if(!count($target) || !count($del))
1015
+	if (!count($target) || !count($del))
1016 1016
 	{
1017 1017
 		return $target_obj;
1018 1018
 	}
@@ -1020,10 +1020,10 @@  discard block
 block discarded – undo
1020 1020
 	$return_obj = new stdClass();
1021 1021
 
1022 1022
 	$target_count = count($target);
1023
-	for($i = 0; $i < $target_count; $i++)
1023
+	for ($i = 0; $i < $target_count; $i++)
1024 1024
 	{
1025 1025
 		$target_key = $target[$i];
1026
-		if(!in_array($target_key, $del))
1026
+		if (!in_array($target_key, $del))
1027 1027
 		{
1028 1028
 			$return_obj->{$target_key} = $target_obj->{$target_key};
1029 1029
 		}
@@ -1036,10 +1036,10 @@  discard block
 block discarded – undo
1036 1036
 {
1037 1037
 	$del_vars = array('error_return_url', 'success_return_url', 'ruleset', 'xe_validator_id');
1038 1038
 
1039
-	foreach($del_vars as $var)
1039
+	foreach ($del_vars as $var)
1040 1040
 	{
1041
-		if(is_array($vars)) unset($vars[$var]);
1042
-		else if(is_object($vars)) unset($vars->$var);
1041
+		if (is_array($vars)) unset($vars[$var]);
1042
+		else if (is_object($vars)) unset($vars->$var);
1043 1043
 	}
1044 1044
 
1045 1045
 	return $vars;
@@ -1056,12 +1056,12 @@  discard block
 block discarded – undo
1056 1056
  */
1057 1057
 function handleError($errno, $errstr, $file, $line)
1058 1058
 {
1059
-	if(!__DEBUG__)
1059
+	if (!__DEBUG__)
1060 1060
 	{
1061 1061
 		return;
1062 1062
 	}
1063 1063
 	$errors = array(E_USER_ERROR, E_ERROR, E_PARSE);
1064
-	if(!in_array($errno, $errors))
1064
+	if (!in_array($errno, $errors))
1065 1065
 	{
1066 1066
 		return;
1067 1067
 	}
@@ -1081,8 +1081,8 @@  discard block
 block discarded – undo
1081 1081
 function getNumberingPath($no, $size = 3)
1082 1082
 {
1083 1083
 	$mod = pow(10, $size);
1084
-	$output = sprintf('%0' . $size . 'd/', $no % $mod);
1085
-	if($no >= $mod)
1084
+	$output = sprintf('%0'.$size.'d/', $no % $mod);
1085
+	if ($no >= $mod)
1086 1086
 	{
1087 1087
 		$output .= getNumberingPath((int) $no / $mod, $size);
1088 1088
 	}
@@ -1102,12 +1102,12 @@  discard block
 block discarded – undo
1102 1102
 
1103 1103
 function purifierHtml(&$content)
1104 1104
 {
1105
-	require_once(_XE_PATH_ . 'classes/security/Purifier.class.php');
1105
+	require_once(_XE_PATH_.'classes/security/Purifier.class.php');
1106 1106
 	$oPurifier = Purifier::getInstance();
1107 1107
 
1108 1108
 	// @see https://github.com/xpressengine/xe-core/issues/2278
1109 1109
 	$logged_info = Context::get('logged_info');
1110
-	if($logged_info->is_admin !== 'Y') {
1110
+	if ($logged_info->is_admin !== 'Y') {
1111 1111
 		$oPurifier->setConfig('HTML.Nofollow', true);
1112 1112
 	}
1113 1113
 
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
  */
1123 1123
 function removeHackTag($content)
1124 1124
 {
1125
-	require_once(_XE_PATH_ . 'classes/security/EmbedFilter.class.php');
1125
+	require_once(_XE_PATH_.'classes/security/EmbedFilter.class.php');
1126 1126
 	$oEmbedFilter = EmbedFilter::getInstance();
1127 1127
 	$oEmbedFilter->check($content);
1128 1128
 
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
  */
1165 1165
 function checkUploadedFile($file, $filename = null)
1166 1166
 {
1167
-	require_once(_XE_PATH_ . 'classes/security/UploadFileFilter.class.php');
1167
+	require_once(_XE_PATH_.'classes/security/UploadFileFilter.class.php');
1168 1168
 	return UploadFileFilter::check($file, $filename);
1169 1169
 }
1170 1170
 
@@ -1178,13 +1178,13 @@  discard block
 block discarded – undo
1178 1178
 {
1179 1179
 	$content = preg_replace('@<(/?)xmp.*?>@i', '<\1xmp>', $content);
1180 1180
 
1181
-	if(($start_xmp = strrpos($content, '<xmp>')) !== FALSE)
1181
+	if (($start_xmp = strrpos($content, '<xmp>')) !== FALSE)
1182 1182
 	{
1183
-		if(($close_xmp = strrpos($content, '</xmp>')) === FALSE)
1183
+		if (($close_xmp = strrpos($content, '</xmp>')) === FALSE)
1184 1184
 		{
1185 1185
 			$content .= '</xmp>';
1186 1186
 		}
1187
-		else if($close_xmp < $start_xmp)
1187
+		else if ($close_xmp < $start_xmp)
1188 1188
 		{
1189 1189
 			$content .= '</xmp>';
1190 1190
 		}
@@ -1204,33 +1204,33 @@  discard block
 block discarded – undo
1204 1204
 	$tag = strtolower($match[2]);
1205 1205
 
1206 1206
 	// xmp tag ?뺣━
1207
-	if($tag == 'xmp')
1207
+	if ($tag == 'xmp')
1208 1208
 	{
1209 1209
 		return "<{$match[1]}xmp>";
1210 1210
 	}
1211
-	if($match[1])
1211
+	if ($match[1])
1212 1212
 	{
1213 1213
 		return $match[0];
1214 1214
 	}
1215
-	if($match[4])
1215
+	if ($match[4])
1216 1216
 	{
1217
-		$match[4] = ' ' . $match[4];
1217
+		$match[4] = ' '.$match[4];
1218 1218
 	}
1219 1219
 
1220 1220
 	$attrs = array();
1221
-	if(preg_match_all('/([\w:-]+)\s*=(?:\s*(["\']))?(?(2)(.*?)\2|([^ ]+))/s', $match[3], $m))
1221
+	if (preg_match_all('/([\w:-]+)\s*=(?:\s*(["\']))?(?(2)(.*?)\2|([^ ]+))/s', $match[3], $m))
1222 1222
 	{
1223
-		foreach($m[1] as $idx => $name)
1223
+		foreach ($m[1] as $idx => $name)
1224 1224
 		{
1225
-			if(strlen($name) >= 2 && substr_compare($name, 'on', 0, 2) === 0)
1225
+			if (strlen($name) >= 2 && substr_compare($name, 'on', 0, 2) === 0)
1226 1226
 			{
1227 1227
 				continue;
1228 1228
 			}
1229 1229
 
1230
-			$val = preg_replace_callback('/&#(?:x([a-fA-F0-9]+)|0*(\d+));/', function($n) {return chr($n[1] ? ('0x00' . $n[1]) : ($n[2] + 0)); }, $m[3][$idx] . $m[4][$idx]);
1230
+			$val = preg_replace_callback('/&#(?:x([a-fA-F0-9]+)|0*(\d+));/', function($n) {return chr($n[1] ? ('0x00'.$n[1]) : ($n[2] + 0)); }, $m[3][$idx].$m[4][$idx]);
1231 1231
 			$val = preg_replace('/^\s+|[\t\n\r]+/', '', $val);
1232 1232
 
1233
-			if(preg_match('/^[a-z]+script:/i', $val))
1233
+			if (preg_match('/^[a-z]+script:/i', $val))
1234 1234
 			{
1235 1235
 				continue;
1236 1236
 			}
@@ -1241,60 +1241,60 @@  discard block
 block discarded – undo
1241 1241
 
1242 1242
 	$filter_arrts = array('style', 'src', 'href');
1243 1243
 
1244
-	if($tag === 'object') array_push($filter_arrts, 'data');
1245
-	if($tag === 'param') array_push($filter_arrts, 'value');
1244
+	if ($tag === 'object') array_push($filter_arrts, 'data');
1245
+	if ($tag === 'param') array_push($filter_arrts, 'value');
1246 1246
 
1247
-	foreach($filter_arrts as $attr)
1247
+	foreach ($filter_arrts as $attr)
1248 1248
 	{
1249
-		if(!isset($attrs[$attr])) continue;
1249
+		if (!isset($attrs[$attr])) continue;
1250 1250
 
1251 1251
 		$attr_value = rawurldecode($attrs[$attr]);
1252 1252
 		$attr_value = htmlspecialchars_decode($attr_value, ENT_COMPAT);
1253 1253
 		$attr_value = preg_replace('/\s+|[\t\n\r]+/', '', $attr_value);
1254
-		if(preg_match('@(\?|&|;)(act=(\w+))@i', $attr_value, $m) && $m[3] !== 'procFileDownload')
1254
+		if (preg_match('@(\?|&|;)(act=(\w+))@i', $attr_value, $m) && $m[3] !== 'procFileDownload')
1255 1255
 		{
1256 1256
 			unset($attrs[$attr]);
1257 1257
 		}
1258 1258
 	}
1259 1259
 
1260
-	if(isset($attrs['style']) && preg_match('@(?:/\*|\*/|\n|:\s*expression\s*\()@i', $attrs['style']))
1260
+	if (isset($attrs['style']) && preg_match('@(?:/\*|\*/|\n|:\s*expression\s*\()@i', $attrs['style']))
1261 1261
 	{
1262 1262
 		unset($attrs['style']);
1263 1263
 	}
1264 1264
 
1265 1265
 	$attr = array();
1266
-	foreach($attrs as $name => $val)
1266
+	foreach ($attrs as $name => $val)
1267 1267
 	{
1268
-		if($tag == 'object' || $tag == 'embed' || $tag == 'a')
1268
+		if ($tag == 'object' || $tag == 'embed' || $tag == 'a')
1269 1269
 		{
1270 1270
 			$attribute = strtolower(trim($name));
1271
-			if($attribute == 'data' || $attribute == 'src' || $attribute == 'href')
1271
+			if ($attribute == 'data' || $attribute == 'src' || $attribute == 'href')
1272 1272
 			{
1273
-				if(stripos($val, 'data:') === 0)
1273
+				if (stripos($val, 'data:') === 0)
1274 1274
 				{
1275 1275
 					continue;
1276 1276
 				}
1277 1277
 			}
1278 1278
 		}
1279 1279
 
1280
-		if($tag == 'img')
1280
+		if ($tag == 'img')
1281 1281
 		{
1282 1282
 			$attribute = strtolower(trim($name));
1283
-			if(stripos($val, 'data:') === 0)
1283
+			if (stripos($val, 'data:') === 0)
1284 1284
 			{
1285 1285
 				continue;
1286 1286
 			}
1287 1287
 		}
1288 1288
 		$val = str_replace('"', '&quot;', $val);
1289
-		$attr[] = $name . "=\"{$val}\"";
1289
+		$attr[] = $name."=\"{$val}\"";
1290 1290
 	}
1291
-	$attr = count($attr) ? ' ' . implode(' ', $attr) : '';
1291
+	$attr = count($attr) ? ' '.implode(' ', $attr) : '';
1292 1292
 
1293 1293
 	return "<{$match[1]}{$tag}{$attr}{$match[4]}>";
1294 1294
 }
1295 1295
 
1296 1296
 // convert hexa value to RGB
1297
-if(!function_exists('hexrgb'))
1297
+if (!function_exists('hexrgb'))
1298 1298
 {
1299 1299
 
1300 1300
 	/**
@@ -1330,9 +1330,9 @@  discard block
 block discarded – undo
1330 1330
 
1331 1331
 	settype($password, "string");
1332 1332
 
1333
-	for($i = 0; $i < strlen($password); $i++)
1333
+	for ($i = 0; $i < strlen($password); $i++)
1334 1334
 	{
1335
-		if($password[$i] == ' ' || $password[$i] == '\t')
1335
+		if ($password[$i] == ' ' || $password[$i] == '\t')
1336 1336
 		{
1337 1337
 			continue;
1338 1338
 		}
@@ -1344,11 +1344,11 @@  discard block
 block discarded – undo
1344 1344
 	$result1 = sprintf("%08lx", $nr & ((1 << 31) - 1));
1345 1345
 	$result2 = sprintf("%08lx", $nr2 & ((1 << 31) - 1));
1346 1346
 
1347
-	if($result1 == '80000000')
1347
+	if ($result1 == '80000000')
1348 1348
 	{
1349 1349
 		$nr += 0x80000000;
1350 1350
 	}
1351
-	if($result2 == '80000000')
1351
+	if ($result2 == '80000000')
1352 1352
 	{
1353 1353
 		$nr2 += 0x80000000;
1354 1354
 	}
@@ -1364,7 +1364,7 @@  discard block
 block discarded – undo
1364 1364
 function getScriptPath()
1365 1365
 {
1366 1366
 	static $url = NULL;
1367
-	if($url == NULL)
1367
+	if ($url == NULL)
1368 1368
 	{
1369 1369
 		$script_path = filter_var($_SERVER['SCRIPT_NAME'], FILTER_SANITIZE_STRING);
1370 1370
 		$url = str_ireplace('/tools/', '/', preg_replace('/index.php.*/i', '', str_replace('\\', '/', $script_path)));
@@ -1395,14 +1395,14 @@  discard block
 block discarded – undo
1395 1395
 	$decodedStr = '';
1396 1396
 	$pos = 0;
1397 1397
 	$len = strlen($source);
1398
-	while($pos < $len)
1398
+	while ($pos < $len)
1399 1399
 	{
1400 1400
 		$charAt = substr($source, $pos, 1);
1401
-		if($charAt == '%')
1401
+		if ($charAt == '%')
1402 1402
 		{
1403 1403
 			$pos++;
1404 1404
 			$charAt = substr($source, $pos, 1);
1405
-			if($charAt == 'u')
1405
+			if ($charAt == 'u')
1406 1406
 			{
1407 1407
 				// we got a unicode character
1408 1408
 				$pos++;
@@ -1436,21 +1436,21 @@  discard block
 block discarded – undo
1436 1436
  */
1437 1437
 function _code2utf($num)
1438 1438
 {
1439
-	if($num < 128)
1439
+	if ($num < 128)
1440 1440
 	{
1441 1441
 		return chr($num);
1442 1442
 	}
1443
-	if($num < 2048)
1443
+	if ($num < 2048)
1444 1444
 	{
1445
-		return chr(($num >> 6) + 192) . chr(($num & 63) + 128);
1445
+		return chr(($num >> 6) + 192).chr(($num & 63) + 128);
1446 1446
 	}
1447
-	if($num < 65536)
1447
+	if ($num < 65536)
1448 1448
 	{
1449
-		return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
1449
+		return chr(($num >> 12) + 224).chr((($num >> 6) & 63) + 128).chr(($num & 63) + 128);
1450 1450
 	}
1451
-	if($num < 2097152)
1451
+	if ($num < 2097152)
1452 1452
 	{
1453
-		return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128);
1453
+		return chr(($num >> 18) + 240).chr((($num >> 12) & 63) + 128).chr((($num >> 6) & 63) + 128).chr(($num & 63) + 128);
1454 1454
 	}
1455 1455
 	return '';
1456 1456
 }
@@ -1465,7 +1465,7 @@  discard block
 block discarded – undo
1465 1465
  */
1466 1466
 function detectUTF8($string, $return_convert = FALSE, $urldecode = TRUE)
1467 1467
 {
1468
-	if($urldecode)
1468
+	if ($urldecode)
1469 1469
 	{
1470 1470
 		$string = urldecode($string);
1471 1471
 	}
@@ -1473,12 +1473,12 @@  discard block
 block discarded – undo
1473 1473
 	$sample = iconv('utf-8', 'utf-8', $string);
1474 1474
 	$is_utf8 = (md5($sample) === md5($string));
1475 1475
 
1476
-	if(!$urldecode)
1476
+	if (!$urldecode)
1477 1477
 	{
1478 1478
 		$string = urldecode($string);
1479 1479
 	}
1480 1480
 
1481
-	if($return_convert)
1481
+	if ($return_convert)
1482 1482
 	{
1483 1483
 		return ($is_utf8) ? $string : iconv('euc-kr', 'utf-8', $string);
1484 1484
 	}
@@ -1494,7 +1494,7 @@  discard block
 block discarded – undo
1494 1494
  */
1495 1495
 function json_encode2($data)
1496 1496
 {
1497
-	switch(gettype($data))
1497
+	switch (gettype($data))
1498 1498
 	{
1499 1499
 		case 'boolean':
1500 1500
 			return $data ? 'true' : 'false';
@@ -1502,15 +1502,15 @@  discard block
 block discarded – undo
1502 1502
 		case 'double':
1503 1503
 			return $data;
1504 1504
 		case 'string':
1505
-			return '"' . strtr($data, array('\\' => '\\\\', '"' => '\\"')) . '"';
1505
+			return '"'.strtr($data, array('\\' => '\\\\', '"' => '\\"')).'"';
1506 1506
 		case 'object':
1507 1507
 			$data = get_object_vars($data);
1508 1508
 		case 'array':
1509 1509
 			$rel = FALSE; // relative array?
1510 1510
 			$key = array_keys($data);
1511
-			foreach($key as $v)
1511
+			foreach ($key as $v)
1512 1512
 			{
1513
-				if(!is_int($v))
1513
+				if (!is_int($v))
1514 1514
 				{
1515 1515
 					$rel = TRUE;
1516 1516
 					break;
@@ -1518,12 +1518,12 @@  discard block
 block discarded – undo
1518 1518
 			}
1519 1519
 
1520 1520
 			$arr = array();
1521
-			foreach($data as $k => $v)
1521
+			foreach ($data as $k => $v)
1522 1522
 			{
1523
-				$arr[] = ($rel ? '"' . strtr($k, array('\\' => '\\\\', '"' => '\\"')) . '":' : '') . json_encode2($v);
1523
+				$arr[] = ($rel ? '"'.strtr($k, array('\\' => '\\\\', '"' => '\\"')).'":' : '').json_encode2($v);
1524 1524
 			}
1525 1525
 
1526
-			return $rel ? '{' . join(',', $arr) . '}' : '[' . join(',', $arr) . ']';
1526
+			return $rel ? '{'.join(',', $arr).'}' : '['.join(',', $arr).']';
1527 1527
 		default:
1528 1528
 			return '""';
1529 1529
 	}
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
  */
1538 1538
 function isCrawler($agent = NULL)
1539 1539
 {
1540
-	if(!$agent)
1540
+	if (!$agent)
1541 1541
 	{
1542 1542
 		$agent = $_SERVER['HTTP_USER_AGENT'];
1543 1543
 	}
@@ -1547,9 +1547,9 @@  discard block
 block discarded – undo
1547 1547
 		/*'211.245.21.110-211.245.21.119' mixsh is closed */
1548 1548
 	);
1549 1549
 
1550
-	foreach($check_agent as $str)
1550
+	foreach ($check_agent as $str)
1551 1551
 	{
1552
-		if(stristr($agent, $str) != FALSE)
1552
+		if (stristr($agent, $str) != FALSE)
1553 1553
 		{
1554 1554
 			return TRUE;
1555 1555
 		}
@@ -1567,7 +1567,7 @@  discard block
 block discarded – undo
1567 1567
  */
1568 1568
 function stripEmbedTagForAdmin(&$content, $writer_member_srl)
1569 1569
 {
1570
-	if(!Context::get('is_logged'))
1570
+	if (!Context::get('is_logged'))
1571 1571
 	{
1572 1572
 		return;
1573 1573
 	}
@@ -1575,18 +1575,18 @@  discard block
 block discarded – undo
1575 1575
 	$oModuleModel = getModel('module');
1576 1576
 	$logged_info = Context::get('logged_info');
1577 1577
 
1578
-	if($writer_member_srl != $logged_info->member_srl && ($logged_info->is_admin == "Y" || $oModuleModel->isSiteAdmin($logged_info)))
1578
+	if ($writer_member_srl != $logged_info->member_srl && ($logged_info->is_admin == "Y" || $oModuleModel->isSiteAdmin($logged_info)))
1579 1579
 	{
1580
-		if($writer_member_srl)
1580
+		if ($writer_member_srl)
1581 1581
 		{
1582 1582
 			$oMemberModel = getModel('member');
1583 1583
 			$member_info = $oMemberModel->getMemberInfoByMemberSrl($writer_member_srl);
1584
-			if($member_info->is_admin == "Y")
1584
+			if ($member_info->is_admin == "Y")
1585 1585
 			{
1586 1586
 				return;
1587 1587
 			}
1588 1588
 		}
1589
-		$security_msg = "<div style='border: 1px solid #DDD; background: #FAFAFA; text-align:center; margin: 1em 0;'><p style='margin: 1em;'>" . Context::getLang('security_warning_embed') . "</p></div>";
1589
+		$security_msg = "<div style='border: 1px solid #DDD; background: #FAFAFA; text-align:center; margin: 1em 0;'><p style='margin: 1em;'>".Context::getLang('security_warning_embed')."</p></div>";
1590 1590
 		$content = preg_replace('/<object[^>]+>(.*?<\/object>)?/is', $security_msg, $content);
1591 1591
 		$content = preg_replace('/<embed[^>]+>(\s*<\/embed>)?/is', $security_msg, $content);
1592 1592
 		$content = preg_replace('/<img[^>]+editor_component="multimedia_link"[^>]*>(\s*<\/img>)?/is', $security_msg, $content);
@@ -1603,18 +1603,18 @@  discard block
 block discarded – undo
1603 1603
 function requirePear()
1604 1604
 {
1605 1605
 	static $required = false;
1606
-	if($required)
1606
+	if ($required)
1607 1607
 	{
1608 1608
 		return;
1609 1609
 	}
1610 1610
 
1611
-	if(version_compare(PHP_VERSION, "5.3.0") < 0)
1611
+	if (version_compare(PHP_VERSION, "5.3.0") < 0)
1612 1612
 	{
1613
-		set_include_path(_XE_PATH_ . "libs/PEAR" . PATH_SEPARATOR . get_include_path());
1613
+		set_include_path(_XE_PATH_."libs/PEAR".PATH_SEPARATOR.get_include_path());
1614 1614
 	}
1615 1615
 	else
1616 1616
 	{
1617
-		set_include_path(_XE_PATH_ . "libs/PEAR.1.9.5" . PATH_SEPARATOR . get_include_path());
1617
+		set_include_path(_XE_PATH_."libs/PEAR.1.9.5".PATH_SEPARATOR.get_include_path());
1618 1618
 	}
1619 1619
 
1620 1620
 	$required = true;
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
 
1623 1623
 function checkCSRF()
1624 1624
 {
1625
-	if($_SERVER['REQUEST_METHOD'] != 'POST')
1625
+	if ($_SERVER['REQUEST_METHOD'] != 'POST')
1626 1626
 	{
1627 1627
 		return FALSE;
1628 1628
 	}
@@ -1630,9 +1630,9 @@  discard block
 block discarded – undo
1630 1630
 	$default_url = Context::getDefaultUrl();
1631 1631
 	$referer = $_SERVER["HTTP_REFERER"];
1632 1632
 
1633
-	if(strpos($default_url, 'xn--') !== FALSE && strpos($referer, 'xn--') === FALSE)
1633
+	if (strpos($default_url, 'xn--') !== FALSE && strpos($referer, 'xn--') === FALSE)
1634 1634
 	{
1635
-		require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php');
1635
+		require_once(_XE_PATH_.'libs/idna_convert/idna_convert.class.php');
1636 1636
 		$IDN = new idna_convert(array('idn_version' => 2008));
1637 1637
 		$referer = $IDN->encode($referer);
1638 1638
 	}
@@ -1643,9 +1643,9 @@  discard block
 block discarded – undo
1643 1643
 	$oModuleModel = getModel('module');
1644 1644
 	$siteModuleInfo = $oModuleModel->getDefaultMid();
1645 1645
 
1646
-	if($siteModuleInfo->site_srl == 0)
1646
+	if ($siteModuleInfo->site_srl == 0)
1647 1647
 	{
1648
-		if($default_url['host'] !== $referer['host'])
1648
+		if ($default_url['host'] !== $referer['host'])
1649 1649
 		{
1650 1650
 			return FALSE;
1651 1651
 		}
@@ -1653,7 +1653,7 @@  discard block
 block discarded – undo
1653 1653
 	else
1654 1654
 	{
1655 1655
 		$virtualSiteInfo = $oModuleModel->getSiteInfo($siteModuleInfo->site_srl);
1656
-		if(strtolower($virtualSiteInfo->domain) != strtolower(Context::get('vid')) && !strstr(strtolower($virtualSiteInfo->domain), strtolower($referer['host'])))
1656
+		if (strtolower($virtualSiteInfo->domain) != strtolower(Context::get('vid')) && !strstr(strtolower($virtualSiteInfo->domain), strtolower($referer['host'])))
1657 1657
 		{
1658 1658
 			return FALSE;
1659 1659
 		}
@@ -1669,15 +1669,15 @@  discard block
 block discarded – undo
1669 1669
  */
1670 1670
 function recurciveExposureCheck(&$menu)
1671 1671
 {
1672
-	if(is_array($menu))
1672
+	if (is_array($menu))
1673 1673
 	{
1674
-		foreach($menu AS $key=>$value)
1674
+		foreach ($menu AS $key=>$value)
1675 1675
 		{
1676
-			if(!$value['isShow'])
1676
+			if (!$value['isShow'])
1677 1677
 			{
1678 1678
 				unset($menu[$key]);
1679 1679
 			}
1680
-			if(is_array($value['list']) && count($value['list']) > 0)
1680
+			if (is_array($value['list']) && count($value['list']) > 0)
1681 1681
 			{
1682 1682
 				recurciveExposureCheck($menu[$key]['list']);
1683 1683
 			}
@@ -1687,14 +1687,14 @@  discard block
 block discarded – undo
1687 1687
 
1688 1688
 function changeValueInUrl($key, $requestKey, $dbKey, $urlName = 'success_return_url')
1689 1689
 {
1690
-	if($requestKey != $dbKey)
1690
+	if ($requestKey != $dbKey)
1691 1691
 	{
1692 1692
 		$arrayUrl = parse_url(Context::get('success_return_url'));
1693
-		if($arrayUrl['query'])
1693
+		if ($arrayUrl['query'])
1694 1694
 		{
1695 1695
 			parse_str($arrayUrl['query'], $parsedStr);
1696 1696
 
1697
-			if(isset($parsedStr[$key]))
1697
+			if (isset($parsedStr[$key]))
1698 1698
 			{
1699 1699
 				$parsedStr[$key] = $requestKey;
1700 1700
 				$successReturnUrl .= $arrayUrl['path'].'?'.http_build_query($parsedStr);
@@ -1737,14 +1737,14 @@  discard block
 block discarded – undo
1737 1737
  */
1738 1738
 function alertScript($msg)
1739 1739
 {
1740
-	if(!$msg)
1740
+	if (!$msg)
1741 1741
 	{
1742 1742
 		return;
1743 1743
 	}
1744 1744
 
1745 1745
 	echo '<script type="text/javascript">
1746 1746
 //<![CDATA[
1747
-alert("' . $msg . '");
1747
+alert("' . $msg.'");
1748 1748
 //]]>
1749 1749
 </script>';
1750 1750
 }
@@ -1775,7 +1775,7 @@  discard block
 block discarded – undo
1775 1775
 
1776 1776
 	echo '<script type="text/javascript">
1777 1777
 //<![CDATA[
1778
-' . $reloadScript . '
1778
+' . $reloadScript.'
1779 1779
 //]]>
1780 1780
 </script>';
1781 1781
 }
@@ -1798,7 +1798,7 @@  discard block
 block discarded – undo
1798 1798
  */
1799 1799
 function escape($str, $double_escape = true, $escape_defined_lang_code = false)
1800 1800
 {
1801
-	if(!$escape_defined_lang_code && isDefinedLangCode($str)) return $str;
1801
+	if (!$escape_defined_lang_code && isDefinedLangCode($str)) return $str;
1802 1802
 
1803 1803
 	$flags = ENT_QUOTES | ENT_SUBSTITUTE;
1804 1804
 	return htmlspecialchars($str, $flags, 'UTF-8', $double_escape);
@@ -1830,7 +1830,7 @@  discard block
 block discarded – undo
1830 1830
 function escape_js($str)
1831 1831
 {
1832 1832
 	$flags = JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_UNESCAPED_UNICODE;
1833
-	$str = json_encode((string)$str, $flags);
1833
+	$str = json_encode((string) $str, $flags);
1834 1834
 	return substr($str, 1, strlen($str) - 2);
1835 1835
 }
1836 1836
 
@@ -1882,12 +1882,12 @@  discard block
 block discarded – undo
1882 1882
 {
1883 1883
 	if ($limit < 1) $limit = null;
1884 1884
 	$result = array();
1885
-	$split = preg_split('/(?<!' . preg_quote($escape_char, '/') . ')' . preg_quote($delimiter, '/') . '/', $str, $limit);
1885
+	$split = preg_split('/(?<!'.preg_quote($escape_char, '/').')'.preg_quote($delimiter, '/').'/', $str, $limit);
1886 1886
 	foreach ($split as $piece)
1887 1887
 	{
1888 1888
 		if (trim($piece) !== '')
1889 1889
 		{
1890
-			$result[] = trim(str_replace($escape_char . $delimiter, $delimiter, $piece));
1890
+			$result[] = trim(str_replace($escape_char.$delimiter, $delimiter, $piece));
1891 1891
 		}
1892 1892
 	}
1893 1893
 	return $result;
Please login to merge, or discard this patch.
classes/security/UploadFileFilter.class.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@
 block discarded – undo
167 167
 		$mime_type = finfo_file($finfo, $file);
168 168
 		finfo_close($finfo);
169 169
 
170
-		if($trim_subtype)
170
+		if ($trim_subtype)
171 171
 		{
172 172
 			$mime_type = strstr($mime_type, '/', true);
173 173
 		}
Please login to merge, or discard this patch.
classes/context/Context.class.php 2 patches
Spacing   +313 added lines, -313 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 	function &getInstance()
163 163
 	{
164 164
 		static $theInstance = null;
165
-		if(!$theInstance)
165
+		if (!$theInstance)
166 166
 		{
167 167
 			$theInstance = new Context();
168 168
 		}
@@ -182,10 +182,10 @@  discard block
 block discarded – undo
182 182
 
183 183
 		// include ssl action cache file
184 184
 		$this->sslActionCacheFile = FileHandler::getRealPath($this->sslActionCacheFile);
185
-		if(is_readable($this->sslActionCacheFile))
185
+		if (is_readable($this->sslActionCacheFile))
186 186
 		{
187 187
 			require($this->sslActionCacheFile);
188
-			if(isset($sslActions))
188
+			if (isset($sslActions))
189 189
 			{
190 190
 				$this->ssl_actions = $sslActions;
191 191
 			}
@@ -201,12 +201,12 @@  discard block
 block discarded – undo
201 201
 	function init()
202 202
 	{
203 203
 		// fix missing HTTP_RAW_POST_DATA in PHP 5.6 and above
204
-		if(!isset($GLOBALS['HTTP_RAW_POST_DATA']) && version_compare(PHP_VERSION, '5.6.0', '>=') === TRUE)
204
+		if (!isset($GLOBALS['HTTP_RAW_POST_DATA']) && version_compare(PHP_VERSION, '5.6.0', '>=') === TRUE)
205 205
 		{
206 206
 			$GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input");
207 207
 
208 208
 			// If content is not XML JSON, unset
209
-			if(!preg_match('/^[\<\{\[]/', $GLOBALS['HTTP_RAW_POST_DATA']) && strpos($_SERVER['CONTENT_TYPE'], 'json') === FALSE && strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json') === FALSE)
209
+			if (!preg_match('/^[\<\{\[]/', $GLOBALS['HTTP_RAW_POST_DATA']) && strpos($_SERVER['CONTENT_TYPE'], 'json') === FALSE && strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json') === FALSE)
210 210
 			{
211 211
 				unset($GLOBALS['HTTP_RAW_POST_DATA']);
212 212
 			}
@@ -228,11 +228,11 @@  discard block
 block discarded – undo
228 228
 		$this->_setUploadedArgument();
229 229
 
230 230
 		$this->loadDBInfo();
231
-		if($this->db_info->use_sitelock == 'Y')
231
+		if ($this->db_info->use_sitelock == 'Y')
232 232
 		{
233
-			if(is_array($this->db_info->sitelock_whitelist)) $whitelist = $this->db_info->sitelock_whitelist;
233
+			if (is_array($this->db_info->sitelock_whitelist)) $whitelist = $this->db_info->sitelock_whitelist;
234 234
 
235
-			if(!IpFilter::filter($whitelist))
235
+			if (!IpFilter::filter($whitelist))
236 236
 			{
237 237
 				$title = ($this->db_info->sitelock_title) ? $this->db_info->sitelock_title : 'Maintenance in progress...';
238 238
 				$message = $this->db_info->sitelock_message;
@@ -242,52 +242,52 @@  discard block
 block discarded – undo
242 242
 				define('_XE_SITELOCK_MESSAGE_', $message);
243 243
 
244 244
 				header("HTTP/1.1 403 Forbidden");
245
-				if(FileHandler::exists(_XE_PATH_ . 'common/tpl/sitelock.user.html'))
245
+				if (FileHandler::exists(_XE_PATH_.'common/tpl/sitelock.user.html'))
246 246
 				{
247
-					include _XE_PATH_ . 'common/tpl/sitelock.user.html';
247
+					include _XE_PATH_.'common/tpl/sitelock.user.html';
248 248
 				}
249 249
 				else
250 250
 				{
251
-					include _XE_PATH_ . 'common/tpl/sitelock.html';
251
+					include _XE_PATH_.'common/tpl/sitelock.html';
252 252
 				}
253 253
 				exit;
254 254
 			}
255 255
 		}
256 256
 
257 257
 		// If XE is installed, get virtual site information
258
-		if(self::isInstalled())
258
+		if (self::isInstalled())
259 259
 		{
260 260
 			$oModuleModel = getModel('module');
261 261
 			$site_module_info = $oModuleModel->getDefaultMid();
262 262
 
263
-			if(!isset($site_module_info))
263
+			if (!isset($site_module_info))
264 264
 			{
265 265
 				$site_module_info = new stdClass();
266 266
 			}
267 267
 
268 268
 			// if site_srl of site_module_info is 0 (default site), compare the domain to default_url of db_config
269
-			if($site_module_info->site_srl == 0 && $site_module_info->domain != $this->db_info->default_url)
269
+			if ($site_module_info->site_srl == 0 && $site_module_info->domain != $this->db_info->default_url)
270 270
 			{
271 271
 				$site_module_info->domain = $this->db_info->default_url;
272 272
 			}
273 273
 
274 274
 			$this->set('site_module_info', $site_module_info);
275
-			if($site_module_info->site_srl && isSiteID($site_module_info->domain))
275
+			if ($site_module_info->site_srl && isSiteID($site_module_info->domain))
276 276
 			{
277 277
 				$this->set('vid', $site_module_info->domain, TRUE);
278 278
 			}
279 279
 
280
-			if(!isset($this->db_info))
280
+			if (!isset($this->db_info))
281 281
 			{
282 282
 				$this->db_info = new stdClass();
283 283
 			}
284 284
 
285 285
 			$this->db_info->lang_type = $site_module_info->default_language;
286
-			if(!$this->db_info->lang_type)
286
+			if (!$this->db_info->lang_type)
287 287
 			{
288 288
 				$this->db_info->lang_type = 'en';
289 289
 			}
290
-			if(!$this->db_info->use_db_session)
290
+			if (!$this->db_info->use_db_session)
291 291
 			{
292 292
 				$this->db_info->use_db_session = 'N';
293 293
 			}
@@ -297,30 +297,30 @@  discard block
 block discarded – undo
297 297
 		$lang_supported = $this->loadLangSelected();
298 298
 
299 299
 		// Retrieve language type set in user's cookie
300
-		if($this->lang_type = $this->get('l'))
300
+		if ($this->lang_type = $this->get('l'))
301 301
 		{
302
-			if($_COOKIE['lang_type'] != $this->lang_type)
302
+			if ($_COOKIE['lang_type'] != $this->lang_type)
303 303
 			{
304 304
 				setcookie('lang_type', $this->lang_type, $_SERVER['REQUEST_TIME'] + 3600 * 24 * 1000);
305 305
 			}
306 306
 		}
307
-		elseif($_COOKIE['lang_type'])
307
+		elseif ($_COOKIE['lang_type'])
308 308
 		{
309 309
 			$this->lang_type = $_COOKIE['lang_type'];
310 310
 		}
311 311
 
312 312
 		// If it's not exists, follow default language type set in db_info
313
-		if(!$this->lang_type)
313
+		if (!$this->lang_type)
314 314
 		{
315 315
 			$this->lang_type = $this->db_info->lang_type;
316 316
 		}
317 317
 
318 318
 		// if still lang_type has not been set or has not-supported type , set as English.
319
-		if(!$this->lang_type)
319
+		if (!$this->lang_type)
320 320
 		{
321 321
 			$this->lang_type = 'en';
322 322
 		}
323
-		if(is_array($lang_supported) && !isset($lang_supported[$this->lang_type]))
323
+		if (is_array($lang_supported) && !isset($lang_supported[$this->lang_type]))
324 324
 		{
325 325
 			$this->lang_type = 'en';
326 326
 		}
@@ -329,10 +329,10 @@  discard block
 block discarded – undo
329 329
 		$this->setLangType($this->lang_type);
330 330
 
331 331
 		// load module module's language file according to language setting
332
-		$this->loadLang(_XE_PATH_ . 'modules/module/lang');
332
+		$this->loadLang(_XE_PATH_.'modules/module/lang');
333 333
 
334 334
 		// set session handler
335
-		if(self::isInstalled() && $this->db_info->use_db_session == 'Y')
335
+		if (self::isInstalled() && $this->db_info->use_db_session == 'Y')
336 336
 		{
337 337
 			$oSessionModel = getModel('session');
338 338
 			$oSessionController = getController('session');
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
 			);
343 343
 		}
344 344
 
345
-		if($sess = $_POST[session_name()]) session_id($sess);
345
+		if ($sess = $_POST[session_name()]) session_id($sess);
346 346
 		session_start();
347 347
 
348 348
 		// set authentication information in Context and session
349
-		if(self::isInstalled())
349
+		if (self::isInstalled())
350 350
 		{
351 351
 			$oModuleModel = getModel('module');
352 352
 			$oModuleModel->loadModuleExtends();
@@ -354,15 +354,15 @@  discard block
 block discarded – undo
354 354
 			$oMemberModel = getModel('member');
355 355
 			$oMemberController = getController('member');
356 356
 
357
-			if($oMemberController && $oMemberModel)
357
+			if ($oMemberController && $oMemberModel)
358 358
 			{
359 359
 				// if signed in, validate it.
360
-				if($oMemberModel->isLogged())
360
+				if ($oMemberModel->isLogged())
361 361
 				{
362 362
 					$oMemberController->setSessionInfo();
363 363
 				}
364 364
 				// check auto sign-in
365
-				elseif($_COOKIE['xeak'])
365
+				elseif ($_COOKIE['xeak'])
366 366
 				{
367 367
 					$oMemberController->doAutologin();
368 368
 				}
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 
375 375
 		// load common language file
376 376
 		$this->lang = &$GLOBALS['lang'];
377
-		$this->loadLang(_XE_PATH_ . 'common/lang/');
377
+		$this->loadLang(_XE_PATH_.'common/lang/');
378 378
 
379 379
 		// check if using rewrite module
380 380
 		$this->allow_rewrite = ($this->db_info->use_rewrite == 'Y' ? TRUE : FALSE);
@@ -382,28 +382,28 @@  discard block
 block discarded – undo
382 382
 		// set locations for javascript use
383 383
 		$url = array();
384 384
 		$current_url = self::getRequestUri();
385
-		if($_SERVER['REQUEST_METHOD'] == 'GET')
385
+		if ($_SERVER['REQUEST_METHOD'] == 'GET')
386 386
 		{
387
-			if($this->get_vars)
387
+			if ($this->get_vars)
388 388
 			{
389 389
 				$url = array();
390
-				foreach($this->get_vars as $key => $val)
390
+				foreach ($this->get_vars as $key => $val)
391 391
 				{
392
-					if(is_array($val) && count($val) > 0)
392
+					if (is_array($val) && count($val) > 0)
393 393
 					{
394
-						foreach($val as $k => $v)
394
+						foreach ($val as $k => $v)
395 395
 						{
396
-							$url[] = $key . '[' . $k . ']=' . urlencode($v);
396
+							$url[] = $key.'['.$k.']='.urlencode($v);
397 397
 						}
398 398
 					}
399
-					elseif($val)
399
+					elseif ($val)
400 400
 					{
401
-						$url[] = $key . '=' . urlencode($val);
401
+						$url[] = $key.'='.urlencode($val);
402 402
 					}
403 403
 				}
404 404
 
405 405
 				$current_url = self::getRequestUri();
406
-				if($url) $current_url .= '?' . join('&', $url);
406
+				if ($url) $current_url .= '?'.join('&', $url);
407 407
 			}
408 408
 			else
409 409
 			{
@@ -418,12 +418,12 @@  discard block
 block discarded – undo
418 418
 		$this->set('current_url', $current_url);
419 419
 		$this->set('request_uri', self::getRequestUri());
420 420
 
421
-		if(strpos($current_url, 'xn--') !== FALSE)
421
+		if (strpos($current_url, 'xn--') !== FALSE)
422 422
 		{
423 423
 			$this->set('current_url', self::decodeIdna($current_url));
424 424
 		}
425 425
 
426
-		if(strpos(self::getRequestUri(), 'xn--') !== FALSE)
426
+		if (strpos(self::getRequestUri(), 'xn--') !== FALSE)
427 427
 		{
428 428
 			$this->set('request_uri', self::decodeIdna(self::getRequestUri()));
429 429
 		}
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 	{
449 449
 		$self = self::getInstance();
450 450
 
451
-		if(!$self->isInstalled())
451
+		if (!$self->isInstalled())
452 452
 		{
453 453
 			return;
454 454
 		}
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 		ob_end_clean();
459 459
 
460 460
 		// If master_db information does not exist, the config file needs to be updated
461
-		if(!isset($db_info->master_db))
461
+		if (!isset($db_info->master_db))
462 462
 		{
463 463
 			$db_info->master_db = array();
464 464
 			$db_info->master_db["db_type"] = $db_info->db_type;
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 			$db_info->master_db["db_table_prefix"] = $db_info->db_table_prefix;
477 477
 			unset($db_info->db_table_prefix);
478 478
 
479
-			if(isset($db_info->master_db["db_table_prefix"]) && substr_compare($db_info->master_db["db_table_prefix"], '_', -1) !== 0)
479
+			if (isset($db_info->master_db["db_table_prefix"]) && substr_compare($db_info->master_db["db_table_prefix"], '_', -1) !== 0)
480 480
 			{
481 481
 				$db_info->master_db["db_table_prefix"] .= '_';
482 482
 			}
@@ -488,42 +488,42 @@  discard block
 block discarded – undo
488 488
 			$oInstallController->makeConfigFile();
489 489
 		}
490 490
 
491
-		if(version_compare(PHP_VERSION, '7.0', '>='))
491
+		if (version_compare(PHP_VERSION, '7.0', '>='))
492 492
 		{
493 493
 			$db_info->master_db["db_type"] = preg_replace('/^mysql(_.+)?$/', 'mysqli$1', $db_info->master_db["db_type"]);
494
-			foreach($db_info->slave_db as &$slave_db_info)
494
+			foreach ($db_info->slave_db as &$slave_db_info)
495 495
 			{
496 496
 				$slave_db_info["db_type"] = preg_replace('/^mysql(_.+)?$/', 'mysqli$1', $slave_db_info["db_type"]);
497 497
 			}
498 498
 		}
499 499
 
500
-		if(!$db_info->use_prepared_statements)
500
+		if (!$db_info->use_prepared_statements)
501 501
 		{
502 502
 			$db_info->use_prepared_statements = 'Y';
503 503
 		}
504 504
 
505
-		if(!$db_info->time_zone)
505
+		if (!$db_info->time_zone)
506 506
 			$db_info->time_zone = date('O');
507 507
 		$GLOBALS['_time_zone'] = $db_info->time_zone;
508 508
 
509
-		if($db_info->qmail_compatibility != 'Y')
509
+		if ($db_info->qmail_compatibility != 'Y')
510 510
 			$db_info->qmail_compatibility = 'N';
511 511
 		$GLOBALS['_qmail_compatibility'] = $db_info->qmail_compatibility;
512 512
 
513
-		if(!$db_info->use_db_session)
513
+		if (!$db_info->use_db_session)
514 514
 			$db_info->use_db_session = 'N';
515
-		if(!$db_info->use_ssl)
515
+		if (!$db_info->use_ssl)
516 516
 			$db_info->use_ssl = 'none';
517 517
 		$this->set('_use_ssl', $db_info->use_ssl);
518 518
 
519 519
 		$self->set('_http_port', ($db_info->http_port) ? $db_info->http_port : NULL);
520 520
 		$self->set('_https_port', ($db_info->https_port) ? $db_info->https_port : NULL);
521 521
 
522
-		if(!$db_info->sitelock_whitelist) {
522
+		if (!$db_info->sitelock_whitelist) {
523 523
 			$db_info->sitelock_whitelist = '127.0.0.1';
524 524
 		}
525 525
 
526
-		if(is_string($db_info->sitelock_whitelist)) {
526
+		if (is_string($db_info->sitelock_whitelist)) {
527 527
 			$db_info->sitelock_whitelist = explode(',', $db_info->sitelock_whitelist);
528 528
 		}
529 529
 
@@ -594,10 +594,10 @@  discard block
 block discarded – undo
594 594
 	function loadLangSupported()
595 595
 	{
596 596
 		static $lang_supported = null;
597
-		if(!$lang_supported)
597
+		if (!$lang_supported)
598 598
 		{
599
-			$langs = file(_XE_PATH_ . 'common/lang/lang.info');
600
-			foreach($langs as $val)
599
+			$langs = file(_XE_PATH_.'common/lang/lang.info');
600
+			foreach ($langs as $val)
601 601
 			{
602 602
 				list($lang_prefix, $lang_text) = explode(',', $val);
603 603
 				$lang_text = trim($lang_text);
@@ -615,17 +615,17 @@  discard block
 block discarded – undo
615 615
 	function loadLangSelected()
616 616
 	{
617 617
 		static $lang_selected = null;
618
-		if(!$lang_selected)
618
+		if (!$lang_selected)
619 619
 		{
620
-			$orig_lang_file = _XE_PATH_ . 'common/lang/lang.info';
621
-			$selected_lang_file = _XE_PATH_ . 'files/config/lang_selected.info';
622
-			if(!FileHandler::hasContent($selected_lang_file))
620
+			$orig_lang_file = _XE_PATH_.'common/lang/lang.info';
621
+			$selected_lang_file = _XE_PATH_.'files/config/lang_selected.info';
622
+			if (!FileHandler::hasContent($selected_lang_file))
623 623
 			{
624
-				$old_selected_lang_file = _XE_PATH_ . 'files/cache/lang_selected.info';
624
+				$old_selected_lang_file = _XE_PATH_.'files/cache/lang_selected.info';
625 625
 				FileHandler::moveFile($old_selected_lang_file, $selected_lang_file);
626 626
 			}
627 627
 
628
-			if(!FileHandler::hasContent($selected_lang_file))
628
+			if (!FileHandler::hasContent($selected_lang_file))
629 629
 			{
630 630
 				$buff = FileHandler::readFile($orig_lang_file);
631 631
 				FileHandler::writeFile($selected_lang_file, $buff);
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 			else
635 635
 			{
636 636
 				$langs = file($selected_lang_file);
637
-				foreach($langs as $val)
637
+				foreach ($langs as $val)
638 638
 				{
639 639
 					list($lang_prefix, $lang_text) = explode(',', $val);
640 640
 					$lang_text = trim($lang_text);
@@ -653,56 +653,56 @@  discard block
 block discarded – undo
653 653
 	function checkSSO()
654 654
 	{
655 655
 		// pass if it's not GET request or XE is not yet installed
656
-		if($this->db_info->use_sso != 'Y' || isCrawler())
656
+		if ($this->db_info->use_sso != 'Y' || isCrawler())
657 657
 		{
658 658
 			return TRUE;
659 659
 		}
660 660
 		$checkActList = array('rss' => 1, 'atom' => 1);
661
-		if(self::getRequestMethod() != 'GET' || !self::isInstalled() || isset($checkActList[self::get('act')]))
661
+		if (self::getRequestMethod() != 'GET' || !self::isInstalled() || isset($checkActList[self::get('act')]))
662 662
 		{
663 663
 			return TRUE;
664 664
 		}
665 665
 
666 666
 		// pass if default URL is not set
667 667
 		$default_url = trim($this->db_info->default_url);
668
-		if(!$default_url)
668
+		if (!$default_url)
669 669
 		{
670 670
 			return TRUE;
671 671
 		}
672 672
 
673
-		if(substr_compare($default_url, '/', -1) !== 0)
673
+		if (substr_compare($default_url, '/', -1) !== 0)
674 674
 		{
675 675
 			$default_url .= '/';
676 676
 		}
677 677
 
678 678
 		// for sites recieving SSO valdiation
679
-		if($default_url == self::getRequestUri())
679
+		if ($default_url == self::getRequestUri())
680 680
 		{
681
-			if(self::get('url'))
681
+			if (self::get('url'))
682 682
 			{
683 683
 				$url = base64_decode(self::get('url'));
684 684
 				$url_info = parse_url($url);
685
-				if(!Password::checkSignature($url, self::get('sig')))
685
+				if (!Password::checkSignature($url, self::get('sig')))
686 686
 				{
687 687
 					echo self::get('lang')->msg_invalid_request;
688 688
 					return false;
689 689
 				}
690 690
 
691 691
 				$oModuleModel = getModel('module');
692
-				$domain = $url_info['host'] . $url_info['path'];
693
-				if(substr_compare($domain, '/', -1) === 0) $domain = substr($domain, 0, -1);
692
+				$domain = $url_info['host'].$url_info['path'];
693
+				if (substr_compare($domain, '/', -1) === 0) $domain = substr($domain, 0, -1);
694 694
 				$site_info = $oModuleModel->getSiteInfoByDomain($domain);
695 695
 
696
-				if($site_info->site_srl)
696
+				if ($site_info->site_srl)
697 697
 				{
698
-				$url_info['query'].= ($url_info['query'] ? '&' : '') . 'SSOID=' . urlencode(session_id()) . '&sig=' . urlencode(Password::createSignature(session_id()));
699
-				$redirect_url = sprintf('%s://%s%s%s?%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? ':' . $url_info['port'] : '', $url_info['path'], $url_info['query']);
698
+				$url_info['query'] .= ($url_info['query'] ? '&' : '').'SSOID='.urlencode(session_id()).'&sig='.urlencode(Password::createSignature(session_id()));
699
+				$redirect_url = sprintf('%s://%s%s%s?%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? ':'.$url_info['port'] : '', $url_info['path'], $url_info['query']);
700 700
 				}
701 701
 				else
702 702
 				{
703 703
 					$redirect_url = $url;
704 704
 				}
705
-				header('location:' . $redirect_url);
705
+				header('location:'.$redirect_url);
706 706
 
707 707
 				return FALSE;
708 708
 			}
@@ -711,9 +711,9 @@  discard block
 block discarded – undo
711 711
 		else
712 712
 		{
713 713
 			// result handling : set session_name()
714
-			if($session_name = self::get('SSOID'))
714
+			if ($session_name = self::get('SSOID'))
715 715
 			{
716
-				if(!Password::checkSignature($session_name, self::get('sig')))
716
+				if (!Password::checkSignature($session_name, self::get('sig')))
717 717
 				{
718 718
 					echo self::get('lang')->msg_invalid_request;
719 719
 					return false;
@@ -722,17 +722,17 @@  discard block
 block discarded – undo
722 722
 				setcookie(session_name(), $session_name);
723 723
 
724 724
 				$url = preg_replace('/[\?\&]SSOID=.+$/', '', self::getRequestUrl());
725
-				header('location:' . $url);
725
+				header('location:'.$url);
726 726
 				return FALSE;
727 727
 				// send SSO request
728 728
 			}
729
-			else if(!self::get('SSOID') && $_COOKIE['sso'] != md5(self::getRequestUri()))
729
+			else if (!self::get('SSOID') && $_COOKIE['sso'] != md5(self::getRequestUri()))
730 730
 			{
731 731
 				setcookie('sso', md5(self::getRequestUri()));
732 732
 				$origin_url = self::getRequestUrl();
733 733
 				$origin_sig = Password::createSignature($origin_url);
734 734
 				$url = sprintf("%s?url=%s&sig=%s", $default_url, urlencode(base64_encode($origin_url)), urlencode($origin_sig));
735
-				header('location:' . $url);
735
+				header('location:'.$url);
736 736
 				return FALSE;
737 737
 			}
738 738
 		}
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 	{
760 760
 		$self = self::getInstance();
761 761
 
762
-		if(!$self->isFTPRegisted())
762
+		if (!$self->isFTPRegisted())
763 763
 		{
764 764
 			return null;
765 765
 		}
@@ -777,15 +777,15 @@  discard block
 block discarded – undo
777 777
 	 */
778 778
 	function addBrowserTitle($site_title)
779 779
 	{
780
-		if(!$site_title)
780
+		if (!$site_title)
781 781
 		{
782 782
 			return;
783 783
 		}
784 784
 		$self = self::getInstance();
785 785
 
786
-		if($self->site_title)
786
+		if ($self->site_title)
787 787
 		{
788
-			$self->site_title .= ' - ' . $site_title;
788
+			$self->site_title .= ' - '.$site_title;
789 789
 		}
790 790
 		else
791 791
 		{
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
 	 */
802 802
 	function setBrowserTitle($site_title)
803 803
 	{
804
-		if(!$site_title)
804
+		if (!$site_title)
805 805
 		{
806 806
 			return;
807 807
 		}
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 		$oModuleModel = getModel('module');
834 834
 		$moduleConfig = $oModuleModel->getModuleConfig('module');
835 835
 
836
-		if(isset($moduleConfig->siteTitle))
836
+		if (isset($moduleConfig->siteTitle))
837 837
 		{
838 838
 			return $moduleConfig->siteTitle;
839 839
 		}
@@ -860,30 +860,30 @@  discard block
 block discarded – undo
860 860
 		global $lang;
861 861
 
862 862
 		$self = self::getInstance();
863
-		if(!$self->lang_type)
863
+		if (!$self->lang_type)
864 864
 		{
865 865
 			return;
866 866
 		}
867
-		if(!is_object($lang))
867
+		if (!is_object($lang))
868 868
 		{
869 869
 			$lang = new stdClass;
870 870
 		}
871 871
 
872
-		if(!($filename = $self->_loadXmlLang($path)))
872
+		if (!($filename = $self->_loadXmlLang($path)))
873 873
 		{
874 874
 			$filename = $self->_loadPhpLang($path);
875 875
 		}
876 876
 
877
-		if(!is_array($self->loaded_lang_files))
877
+		if (!is_array($self->loaded_lang_files))
878 878
 		{
879 879
 			$self->loaded_lang_files = array();
880 880
 		}
881
-		if(in_array($filename, $self->loaded_lang_files))
881
+		if (in_array($filename, $self->loaded_lang_files))
882 882
 		{
883 883
 			return;
884 884
 		}
885 885
 
886
-		if($filename && is_readable($filename))
886
+		if ($filename && is_readable($filename))
887 887
 		{
888 888
 			$self->loaded_lang_files[] = $filename;
889 889
 			include($filename);
@@ -904,24 +904,24 @@  discard block
 block discarded – undo
904 904
 	{
905 905
 		global $lang;
906 906
 
907
-		if(!$path) return;
907
+		if (!$path) return;
908 908
 
909
-		$_path = 'eval://' . $path;
909
+		$_path = 'eval://'.$path;
910 910
 
911
-		if(in_array($_path, $this->loaded_lang_files))
911
+		if (in_array($_path, $this->loaded_lang_files))
912 912
 		{
913 913
 			return;
914 914
 		}
915 915
 
916
-		if(substr_compare($path, '/', -1) !== 0)
916
+		if (substr_compare($path, '/', -1) !== 0)
917 917
 		{
918 918
 			$path .= '/';
919 919
 		}
920 920
 
921
-		$oXmlLangParser = new XmlLangParser($path . 'lang.xml', $this->lang_type);
921
+		$oXmlLangParser = new XmlLangParser($path.'lang.xml', $this->lang_type);
922 922
 		$content = $oXmlLangParser->getCompileContent();
923 923
 
924
-		if($content)
924
+		if ($content)
925 925
 		{
926 926
 			$this->loaded_lang_files[] = $_path;
927 927
 			eval($content);
@@ -936,9 +936,9 @@  discard block
 block discarded – undo
936 936
 	 */
937 937
 	function _loadXmlLang($path)
938 938
 	{
939
-		if(!$path) return;
939
+		if (!$path) return;
940 940
 
941
-		$oXmlLangParser = new XmlLangParser($path . ((substr_compare($path, '/', -1) !== 0) ? '/' : '') . 'lang.xml', $this->lang_type);
941
+		$oXmlLangParser = new XmlLangParser($path.((substr_compare($path, '/', -1) !== 0) ? '/' : '').'lang.xml', $this->lang_type);
942 942
 		return $oXmlLangParser->compile();
943 943
 	}
944 944
 
@@ -950,22 +950,22 @@  discard block
 block discarded – undo
950 950
 	 */
951 951
 	function _loadPhpLang($path)
952 952
 	{
953
-		if(!$path) return;
953
+		if (!$path) return;
954 954
 
955
-		if(substr_compare($path, '/', -1) !== 0)
955
+		if (substr_compare($path, '/', -1) !== 0)
956 956
 		{
957 957
 			$path .= '/';
958 958
 		}
959
-		$path_tpl = $path . '%s.lang.php';
959
+		$path_tpl = $path.'%s.lang.php';
960 960
 		$file = sprintf($path_tpl, $this->lang_type);
961 961
 
962 962
 		$langs = array('ko', 'en'); // this will be configurable.
963
-		while(!is_readable($file) && $langs[0])
963
+		while (!is_readable($file) && $langs[0])
964 964
 		{
965 965
 			$file = sprintf($path_tpl, array_shift($langs));
966 966
 		}
967 967
 
968
-		if(!is_readable($file))
968
+		if (!is_readable($file))
969 969
 		{
970 970
 			return FALSE;
971 971
 		}
@@ -1007,11 +1007,11 @@  discard block
 block discarded – undo
1007 1007
 	 */
1008 1008
 	function getLang($code)
1009 1009
 	{
1010
-		if(!$code)
1010
+		if (!$code)
1011 1011
 		{
1012 1012
 			return;
1013 1013
 		}
1014
-		if($GLOBALS['lang']->{$code})
1014
+		if ($GLOBALS['lang']->{$code})
1015 1015
 		{
1016 1016
 			return $GLOBALS['lang']->{$code};
1017 1017
 		}
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 	 */
1028 1028
 	function setLang($code, $val)
1029 1029
 	{
1030
-		if(!isset($GLOBALS['lang']))
1030
+		if (!isset($GLOBALS['lang']))
1031 1031
 		{
1032 1032
 			$GLOBALS['lang'] = new stdClass();
1033 1033
 		}
@@ -1052,17 +1052,17 @@  discard block
 block discarded – undo
1052 1052
 
1053 1053
 		$obj = clone $source_obj;
1054 1054
 
1055
-		foreach($charset_list as $charset)
1055
+		foreach ($charset_list as $charset)
1056 1056
 		{
1057
-			array_walk($obj,'Context::checkConvertFlag',$charset);
1057
+			array_walk($obj, 'Context::checkConvertFlag', $charset);
1058 1058
 			$flag = self::checkConvertFlag($flag = TRUE);
1059
-			if($flag)
1059
+			if ($flag)
1060 1060
 			{
1061
-				if($charset == 'UTF-8')
1061
+				if ($charset == 'UTF-8')
1062 1062
 				{
1063 1063
 					return $obj;
1064 1064
 				}
1065
-				array_walk($obj,'Context::doConvertEncoding',$charset);
1065
+				array_walk($obj, 'Context::doConvertEncoding', $charset);
1066 1066
 				return $obj;
1067 1067
 			}
1068 1068
 		}
@@ -1081,11 +1081,11 @@  discard block
 block discarded – undo
1081 1081
 	function checkConvertFlag(&$val, $key = null, $charset = null)
1082 1082
 	{
1083 1083
 		static $flag = TRUE;
1084
-		if($charset)
1084
+		if ($charset)
1085 1085
 		{
1086
-			if(is_array($val))
1087
-				array_walk($val,'Context::checkConvertFlag',$charset);
1088
-			else if($val && iconv($charset,$charset,$val)!=$val) $flag = FALSE;
1086
+			if (is_array($val))
1087
+				array_walk($val, 'Context::checkConvertFlag', $charset);
1088
+			else if ($val && iconv($charset, $charset, $val) != $val) $flag = FALSE;
1089 1089
 			else $flag = FALSE;
1090 1090
 		}
1091 1091
 		else
@@ -1109,9 +1109,9 @@  discard block
 block discarded – undo
1109 1109
 	{
1110 1110
 		if (is_array($val))
1111 1111
 		{
1112
-			array_walk($val,'Context::doConvertEncoding',$charset);
1112
+			array_walk($val, 'Context::doConvertEncoding', $charset);
1113 1113
 		}
1114
-		else $val = iconv($charset,'UTF-8',$val);
1114
+		else $val = iconv($charset, 'UTF-8', $val);
1115 1115
 	}
1116 1116
 
1117 1117
 	/**
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
 	 */
1123 1123
 	function convertEncodingStr($str)
1124 1124
 	{
1125
-        if(!$str) return null;
1125
+        if (!$str) return null;
1126 1126
 		$obj = new stdClass();
1127 1127
 		$obj->str = $str;
1128 1128
 		$obj = self::convertEncoding($obj);
@@ -1131,9 +1131,9 @@  discard block
 block discarded – undo
1131 1131
 
1132 1132
 	function decodeIdna($domain)
1133 1133
 	{
1134
-		if(strpos($domain, 'xn--') !== FALSE)
1134
+		if (strpos($domain, 'xn--') !== FALSE)
1135 1135
 		{
1136
-			require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php');
1136
+			require_once(_XE_PATH_.'libs/idna_convert/idna_convert.class.php');
1137 1137
 			$IDN = new idna_convert(array('idn_version' => 2008));
1138 1138
 			$domain = $IDN->decode($domain);
1139 1139
 		}
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
 	{
1165 1165
 		$self = self::getInstance();
1166 1166
 
1167
-		if($self->response_method)
1167
+		if ($self->response_method)
1168 1168
 		{
1169 1169
 			return $self->response_method;
1170 1170
 		}
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
 		$this->_recursiveCheckVar($_SERVER['HTTP_HOST']);
1205 1205
 
1206 1206
 		$pattern = "/[\,\"\'\{\}\[\]\(\);$]/";
1207
-		if(preg_match($pattern, $_SERVER['HTTP_HOST']))
1207
+		if (preg_match($pattern, $_SERVER['HTTP_HOST']))
1208 1208
 		{
1209 1209
 			$this->isSuccessInit = FALSE;
1210 1210
 		}
@@ -1217,30 +1217,30 @@  discard block
 block discarded – undo
1217 1217
 	 */
1218 1218
 	function _setRequestArgument()
1219 1219
 	{
1220
-		if(!count($_REQUEST))
1220
+		if (!count($_REQUEST))
1221 1221
 		{
1222 1222
 			return;
1223 1223
 		}
1224 1224
 
1225 1225
 		$requestMethod = $this->getRequestMethod();
1226
-		foreach($_REQUEST as $key => $val)
1226
+		foreach ($_REQUEST as $key => $val)
1227 1227
 		{
1228
-			if($val === '' || self::get($key))
1228
+			if ($val === '' || self::get($key))
1229 1229
 			{
1230 1230
 				continue;
1231 1231
 			}
1232 1232
 			$key = htmlentities($key);
1233 1233
 			$val = $this->_filterRequestVar($key, $val, false, ($requestMethod == 'GET'));
1234 1234
 
1235
-			if($requestMethod == 'GET' && isset($_GET[$key]))
1235
+			if ($requestMethod == 'GET' && isset($_GET[$key]))
1236 1236
 			{
1237 1237
 				$set_to_vars = TRUE;
1238 1238
 			}
1239
-			elseif($requestMethod == 'POST' && isset($_POST[$key]))
1239
+			elseif ($requestMethod == 'POST' && isset($_POST[$key]))
1240 1240
 			{
1241 1241
 				$set_to_vars = TRUE;
1242 1242
 			}
1243
-			elseif($requestMethod == 'JS_CALLBACK' && (isset($_GET[$key]) || isset($_POST[$key])))
1243
+			elseif ($requestMethod == 'JS_CALLBACK' && (isset($_GET[$key]) || isset($_POST[$key])))
1244 1244
 			{
1245 1245
 				$set_to_vars = TRUE;
1246 1246
 			}
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 				$set_to_vars = FALSE;
1250 1250
 			}
1251 1251
 
1252
-			if($set_to_vars)
1252
+			if ($set_to_vars)
1253 1253
 			{
1254 1254
 				$this->_recursiveCheckVar($val);
1255 1255
 			}
@@ -1260,20 +1260,20 @@  discard block
 block discarded – undo
1260 1260
 
1261 1261
 	function _recursiveCheckVar($val)
1262 1262
 	{
1263
-		if(is_string($val))
1263
+		if (is_string($val))
1264 1264
 		{
1265
-			foreach($this->patterns as $pattern)
1265
+			foreach ($this->patterns as $pattern)
1266 1266
 			{
1267
-				if(preg_match($pattern, $val))
1267
+				if (preg_match($pattern, $val))
1268 1268
 				{
1269 1269
 					$this->isSuccessInit = FALSE;
1270 1270
 					return;
1271 1271
 				}
1272 1272
 			}
1273 1273
 		}
1274
-		else if(is_array($val))
1274
+		else if (is_array($val))
1275 1275
 		{
1276
-			foreach($val as $val2)
1276
+			foreach ($val as $val2)
1277 1277
 			{
1278 1278
 				$this->_recursiveCheckVar($val2);
1279 1279
 			}
@@ -1287,7 +1287,7 @@  discard block
 block discarded – undo
1287 1287
 	 */
1288 1288
 	function _setJSONRequestArgument()
1289 1289
 	{
1290
-		if($this->getRequestMethod() != 'JSON')
1290
+		if ($this->getRequestMethod() != 'JSON')
1291 1291
 		{
1292 1292
 			return;
1293 1293
 		}
@@ -1295,7 +1295,7 @@  discard block
 block discarded – undo
1295 1295
 		$params = array();
1296 1296
 		parse_str($GLOBALS['HTTP_RAW_POST_DATA'], $params);
1297 1297
 
1298
-		foreach($params as $key => $val)
1298
+		foreach ($params as $key => $val)
1299 1299
 		{
1300 1300
 			$key = htmlentities($key);
1301 1301
 			$this->set($key, $this->_filterRequestVar($key, $val, 1), TRUE);
@@ -1309,13 +1309,13 @@  discard block
 block discarded – undo
1309 1309
 	 */
1310 1310
 	function _setXmlRpcArgument()
1311 1311
 	{
1312
-		if($this->getRequestMethod() != 'XMLRPC')
1312
+		if ($this->getRequestMethod() != 'XMLRPC')
1313 1313
 		{
1314 1314
 			return;
1315 1315
 		}
1316 1316
 
1317 1317
 		$xml = $GLOBALS['HTTP_RAW_POST_DATA'];
1318
-		if(Security::detectingXEE($xml))
1318
+		if (Security::detectingXEE($xml))
1319 1319
 		{
1320 1320
 			header("HTTP/1.0 400 Bad Request");
1321 1321
 			exit;
@@ -1327,12 +1327,12 @@  discard block
 block discarded – undo
1327 1327
 		$params = $xml_obj->methodcall->params;
1328 1328
 		unset($params->node_name, $params->attrs, $params->body);
1329 1329
 
1330
-		if(!count(get_object_vars($params)))
1330
+		if (!count(get_object_vars($params)))
1331 1331
 		{
1332 1332
 			return;
1333 1333
 		}
1334 1334
 
1335
-		foreach($params as $key => $val)
1335
+		foreach ($params as $key => $val)
1336 1336
 		{
1337 1337
 			$this->set($key, $this->_filterXmlVars($key, $val), TRUE);
1338 1338
 		}
@@ -1347,10 +1347,10 @@  discard block
 block discarded – undo
1347 1347
 	 */
1348 1348
 	function _filterXmlVars($key, $val)
1349 1349
 	{
1350
-		if(is_array($val))
1350
+		if (is_array($val))
1351 1351
 		{
1352 1352
 			$stack = array();
1353
-			foreach($val as $k => $v)
1353
+			foreach ($val as $k => $v)
1354 1354
 			{
1355 1355
 				$stack[$k] = $this->_filterXmlVars($k, $v);
1356 1356
 			}
@@ -1360,20 +1360,20 @@  discard block
 block discarded – undo
1360 1360
 
1361 1361
 		$body = $val->body;
1362 1362
 		unset($val->node_name, $val->attrs, $val->body);
1363
-		if(!count(get_object_vars($val)))
1363
+		if (!count(get_object_vars($val)))
1364 1364
 		{
1365 1365
 			return $this->_filterRequestVar($key, $body, 0);
1366 1366
 		}
1367 1367
 
1368 1368
 		$stack = new stdClass();
1369
-		foreach($val as $k => $v)
1369
+		foreach ($val as $k => $v)
1370 1370
 		{
1371 1371
 			$output = $this->_filterXmlVars($k, $v);
1372
-			if(is_object($v) && $v->attrs->type == 'array')
1372
+			if (is_object($v) && $v->attrs->type == 'array')
1373 1373
 			{
1374 1374
 				$output = array($output);
1375 1375
 			}
1376
-			if($k == 'value' && (is_array($v) || $v->attrs->type == 'array'))
1376
+			if ($k == 'value' && (is_array($v) || $v->attrs->type == 'array'))
1377 1377
 			{
1378 1378
 				return $output;
1379 1379
 			}
@@ -1381,7 +1381,7 @@  discard block
 block discarded – undo
1381 1381
 			$stack->{$k} = $output;
1382 1382
 		}
1383 1383
 
1384
-		if(!count(get_object_vars($stack)))
1384
+		if (!count(get_object_vars($stack)))
1385 1385
 		{
1386 1386
 			return NULL;
1387 1387
 		}
@@ -1400,16 +1400,16 @@  discard block
 block discarded – undo
1400 1400
 	 */
1401 1401
 	function _filterRequestVar($key, $val, $do_stripslashes = true, $remove_hack = false)
1402 1402
 	{
1403
-		if(!($isArray = is_array($val)))
1403
+		if (!($isArray = is_array($val)))
1404 1404
 		{
1405 1405
 			$val = array($val);
1406 1406
 		}
1407 1407
 
1408 1408
 		$result = array();
1409
-		foreach($val as $k => $v)
1409
+		foreach ($val as $k => $v)
1410 1410
 		{
1411
-			if($remove_hack && !is_array($v)) {
1412
-				if(stripos($v, '<script') || stripos($v, 'lt;script') || stripos($v, '%3Cscript'))
1411
+			if ($remove_hack && !is_array($v)) {
1412
+				if (stripos($v, '<script') || stripos($v, 'lt;script') || stripos($v, '%3Cscript'))
1413 1413
 				{
1414 1414
 					$result[$k] = escape($v);
1415 1415
 					continue;
@@ -1417,18 +1417,18 @@  discard block
 block discarded – undo
1417 1417
 			}
1418 1418
 
1419 1419
 			$k = htmlentities($k);
1420
-			if($key === 'page' || $key === 'cpage' || substr_compare($key, 'srl', -3) === 0)
1420
+			if ($key === 'page' || $key === 'cpage' || substr_compare($key, 'srl', -3) === 0)
1421 1421
 			{
1422 1422
 				$result[$k] = !preg_match('/^[0-9,]+$/', $v) ? (int) $v : $v;
1423 1423
 			}
1424
-			elseif(in_array($key, array('mid','search_keyword','search_target','xe_validator_id'))) {
1424
+			elseif (in_array($key, array('mid', 'search_keyword', 'search_target', 'xe_validator_id'))) {
1425 1425
 				$result[$k] = escape($v, false);
1426 1426
 			}
1427
-			elseif($key === 'vid')
1427
+			elseif ($key === 'vid')
1428 1428
 			{
1429 1429
 				$result[$k] = urlencode($v);
1430 1430
 			}
1431
-			elseif(stripos($key, 'XE_VALIDATOR', 0) === 0)
1431
+			elseif (stripos($key, 'XE_VALIDATOR', 0) === 0)
1432 1432
 			{
1433 1433
 				unset($result[$k]);
1434 1434
 			}
@@ -1436,7 +1436,7 @@  discard block
 block discarded – undo
1436 1436
 			{
1437 1437
 				$result[$k] = $v;
1438 1438
 
1439
-				if($do_stripslashes && version_compare(PHP_VERSION, '5.4.0', '<') && get_magic_quotes_gpc())
1439
+				if ($do_stripslashes && version_compare(PHP_VERSION, '5.4.0', '<') && get_magic_quotes_gpc())
1440 1440
 				{
1441 1441
 					if (is_array($result[$k]))
1442 1442
 					{
@@ -1448,7 +1448,7 @@  discard block
 block discarded – undo
1448 1448
 					}
1449 1449
 				}
1450 1450
 
1451
-				if(is_array($result[$k]))
1451
+				if (is_array($result[$k]))
1452 1452
 				{
1453 1453
 					array_walk_recursive($result[$k], function(&$val) { $val = trim($val); });
1454 1454
 				}
@@ -1457,7 +1457,7 @@  discard block
 block discarded – undo
1457 1457
 					$result[$k] = trim($result[$k]);
1458 1458
 				}
1459 1459
 
1460
-				if($remove_hack)
1460
+				if ($remove_hack)
1461 1461
 				{
1462 1462
 					$result[$k] = escape($result[$k], false);
1463 1463
 				}
@@ -1485,18 +1485,18 @@  discard block
 block discarded – undo
1485 1485
 	 */
1486 1486
 	function _setUploadedArgument()
1487 1487
 	{
1488
-		if($_SERVER['REQUEST_METHOD'] != 'POST' || !$_FILES || (stripos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') === FALSE && stripos($_SERVER['HTTP_CONTENT_TYPE'], 'multipart/form-data') === FALSE))
1488
+		if ($_SERVER['REQUEST_METHOD'] != 'POST' || !$_FILES || (stripos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') === FALSE && stripos($_SERVER['HTTP_CONTENT_TYPE'], 'multipart/form-data') === FALSE))
1489 1489
 		{
1490 1490
 			return;
1491 1491
 		}
1492 1492
 
1493
-		foreach($_FILES as $key => $val)
1493
+		foreach ($_FILES as $key => $val)
1494 1494
 		{
1495 1495
 			$tmp_name = $val['tmp_name'];
1496 1496
 
1497
-			if(!is_array($tmp_name))
1497
+			if (!is_array($tmp_name))
1498 1498
 			{
1499
-				if(!UploadFileFilter::check($tmp_name, $val['name']))
1499
+				if (!UploadFileFilter::check($tmp_name, $val['name']))
1500 1500
 				{
1501 1501
 					unset($_FILES[$key]);
1502 1502
 					continue;
@@ -1510,7 +1510,7 @@  discard block
 block discarded – undo
1510 1510
 				$files = array();
1511 1511
 				foreach ($tmp_name as $i => $j)
1512 1512
 				{
1513
-					if(!UploadFileFilter::check($val['tmp_name'][$i], $val['name'][$i]))
1513
+					if (!UploadFileFilter::check($val['tmp_name'][$i], $val['name'][$i]))
1514 1514
 					{
1515 1515
 						$files = array();
1516 1516
 						unset($_FILES[$key]);
@@ -1524,7 +1524,7 @@  discard block
 block discarded – undo
1524 1524
 					$file['size'] = $val['size'][$i];
1525 1525
 					$files[] = $file;
1526 1526
 				}
1527
-				if(count($files))
1527
+				if (count($files))
1528 1528
 				{
1529 1529
 					self::set($key, $files, true);
1530 1530
 				}
@@ -1549,16 +1549,16 @@  discard block
 block discarded – undo
1549 1549
 	function getRequestUrl()
1550 1550
 	{
1551 1551
 		static $url = null;
1552
-		if(is_null($url))
1552
+		if (is_null($url))
1553 1553
 		{
1554 1554
 			$url = self::getRequestUri();
1555
-			if(count($_GET) > 0)
1555
+			if (count($_GET) > 0)
1556 1556
 			{
1557
-				foreach($_GET as $key => $val)
1557
+				foreach ($_GET as $key => $val)
1558 1558
 				{
1559
-					$vars[] = $key . '=' . ($val ? urlencode(self::convertEncodingStr($val)) : '');
1559
+					$vars[] = $key.'='.($val ? urlencode(self::convertEncodingStr($val)) : '');
1560 1560
 				}
1561
-				$url .= '?' . join('&', $vars);
1561
+				$url .= '?'.join('&', $vars);
1562 1562
 			}
1563 1563
 		}
1564 1564
 		return $url;
@@ -1573,7 +1573,7 @@  discard block
 block discarded – undo
1573 1573
 		$self = self::getInstance();
1574 1574
 		$js_callback_func = isset($_GET['xe_js_callback']) ? $_GET['xe_js_callback'] : $_POST['xe_js_callback'];
1575 1575
 
1576
-		if(!preg_match('/^[a-z0-9\.]+$/i', $js_callback_func))
1576
+		if (!preg_match('/^[a-z0-9\.]+$/i', $js_callback_func))
1577 1577
 		{
1578 1578
 			unset($js_callback_func);
1579 1579
 			unset($_GET['xe_js_callback']);
@@ -1601,22 +1601,22 @@  discard block
 block discarded – undo
1601 1601
 		$self = self::getInstance();
1602 1602
 
1603 1603
 		// retrieve virtual site information
1604
-		if(is_null($site_module_info))
1604
+		if (is_null($site_module_info))
1605 1605
 		{
1606 1606
 			$site_module_info = self::get('site_module_info');
1607 1607
 		}
1608 1608
 
1609 1609
 		// If $domain is set, handle it (if $domain is vid type, remove $domain and handle with $vid)
1610
-		if($domain && isSiteID($domain))
1610
+		if ($domain && isSiteID($domain))
1611 1611
 		{
1612 1612
 			$vid = $domain;
1613 1613
 			$domain = '';
1614 1614
 		}
1615 1615
 
1616 1616
 		// If $domain, $vid are not set, use current site information
1617
-		if(!$domain && !$vid)
1617
+		if (!$domain && !$vid)
1618 1618
 		{
1619
-			if($site_module_info->domain && isSiteID($site_module_info->domain))
1619
+			if ($site_module_info->domain && isSiteID($site_module_info->domain))
1620 1620
 			{
1621 1621
 				$vid = $site_module_info->domain;
1622 1622
 			}
@@ -1627,21 +1627,21 @@  discard block
 block discarded – undo
1627 1627
 		}
1628 1628
 
1629 1629
 		// if $domain is set, compare current URL. If they are same, remove the domain, otherwise link to the domain.
1630
-		if($domain)
1630
+		if ($domain)
1631 1631
 		{
1632 1632
 			$domain_info = parse_url($domain);
1633
-			if(is_null($current_info))
1633
+			if (is_null($current_info))
1634 1634
 			{
1635
-				$current_info = parse_url(($_SERVER['HTTPS'] == 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . getScriptPath());
1635
+				$current_info = parse_url(($_SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].getScriptPath());
1636 1636
 			}
1637
-			if($domain_info['host'] . $domain_info['path'] == $current_info['host'] . $current_info['path'])
1637
+			if ($domain_info['host'].$domain_info['path'] == $current_info['host'].$current_info['path'])
1638 1638
 			{
1639 1639
 				unset($domain);
1640 1640
 			}
1641 1641
 			else
1642 1642
 			{
1643 1643
 				$domain = preg_replace('/^(http|https):\/\//i', '', trim($domain));
1644
-				if(substr_compare($domain, '/', -1) !== 0)
1644
+				if (substr_compare($domain, '/', -1) !== 0)
1645 1645
 				{
1646 1646
 					$domain .= '/';
1647 1647
 				}
@@ -1651,41 +1651,41 @@  discard block
 block discarded – undo
1651 1651
 		$get_vars = array();
1652 1652
 
1653 1653
 		// If there is no GET variables or first argument is '' to reset variables
1654
-		if(!$self->get_vars || $args_list[0] == '')
1654
+		if (!$self->get_vars || $args_list[0] == '')
1655 1655
 		{
1656 1656
 			// rearrange args_list
1657
-			if(is_array($args_list) && $args_list[0] == '')
1657
+			if (is_array($args_list) && $args_list[0] == '')
1658 1658
 			{
1659 1659
 				array_shift($args_list);
1660 1660
 			}
1661 1661
 		}
1662
-		elseif($_SERVER['REQUEST_METHOD'] == 'GET')
1662
+		elseif ($_SERVER['REQUEST_METHOD'] == 'GET')
1663 1663
 		{
1664 1664
 			// Otherwise, make GET variables into array
1665 1665
 			$get_vars = get_object_vars($self->get_vars);
1666 1666
 		}
1667 1667
 		else
1668 1668
 		{
1669
-			if(!!$self->get_vars->module) $get_vars['module'] = $self->get_vars->module;
1670
-			if(!!$self->get_vars->mid) $get_vars['mid'] = $self->get_vars->mid;
1671
-			if(!!$self->get_vars->act) $get_vars['act'] = $self->get_vars->act;
1672
-			if(!!$self->get_vars->page) $get_vars['page'] = $self->get_vars->page;
1673
-			if(!!$self->get_vars->search_target) $get_vars['search_target'] = $self->get_vars->search_target;
1674
-			if(!!$self->get_vars->search_keyword) $get_vars['search_keyword'] = $self->get_vars->search_keyword;
1675
-			if($get_vars['act'] == 'IS')
1669
+			if (!!$self->get_vars->module) $get_vars['module'] = $self->get_vars->module;
1670
+			if (!!$self->get_vars->mid) $get_vars['mid'] = $self->get_vars->mid;
1671
+			if (!!$self->get_vars->act) $get_vars['act'] = $self->get_vars->act;
1672
+			if (!!$self->get_vars->page) $get_vars['page'] = $self->get_vars->page;
1673
+			if (!!$self->get_vars->search_target) $get_vars['search_target'] = $self->get_vars->search_target;
1674
+			if (!!$self->get_vars->search_keyword) $get_vars['search_keyword'] = $self->get_vars->search_keyword;
1675
+			if ($get_vars['act'] == 'IS')
1676 1676
 			{
1677
-				if(!!$self->get_vars->is_keyword) $get_vars['is_keyword'] = $self->get_vars->is_keyword;
1677
+				if (!!$self->get_vars->is_keyword) $get_vars['is_keyword'] = $self->get_vars->is_keyword;
1678 1678
 			}
1679 1679
 		}
1680 1680
 
1681 1681
 		// arrange args_list
1682
-		for($i = 0, $c = count($args_list); $i < $c; $i += 2)
1682
+		for ($i = 0, $c = count($args_list); $i < $c; $i += 2)
1683 1683
 		{
1684 1684
 			$key = $args_list[$i];
1685 1685
 			$val = trim($args_list[$i + 1]);
1686 1686
 
1687 1687
 			// If value is not set, remove the key
1688
-			if(!isset($val) || !strlen($val))
1688
+			if (!isset($val) || !strlen($val))
1689 1689
 			{
1690 1690
 				unset($get_vars[$key]);
1691 1691
 				continue;
@@ -1696,7 +1696,7 @@  discard block
 block discarded – undo
1696 1696
 
1697 1697
 		// remove vid, rnd
1698 1698
 		unset($get_vars['rnd']);
1699
-		if($vid)
1699
+		if ($vid)
1700 1700
 		{
1701 1701
 			$get_vars['vid'] = $vid;
1702 1702
 		}
@@ -1713,17 +1713,17 @@  discard block
 block discarded – undo
1713 1713
 			'dispDocumentAdminManageDocument' => 'dispDocumentManageDocument',
1714 1714
 			'dispModuleAdminSelectList' => 'dispModuleSelectList'
1715 1715
 		);
1716
-		if($act_alias[$act])
1716
+		if ($act_alias[$act])
1717 1717
 		{
1718 1718
 			$get_vars['act'] = $act_alias[$act];
1719 1719
 		}
1720 1720
 
1721 1721
 		// organize URL
1722 1722
 		$query = '';
1723
-		if(count($get_vars) > 0)
1723
+		if (count($get_vars) > 0)
1724 1724
 		{
1725 1725
 			// if using rewrite mod
1726
-			if($self->allow_rewrite)
1726
+			if ($self->allow_rewrite)
1727 1727
 			{
1728 1728
 				$var_keys = array_keys($get_vars);
1729 1729
 				sort($var_keys);
@@ -1743,8 +1743,8 @@  discard block
 block discarded – undo
1743 1743
 					'vid' => $vid,
1744 1744
 					'mid' => $mid,
1745 1745
 					'mid.vid' => "$vid/$mid",
1746
-					'entry.mid' => "$mid/entry/" . $get_vars['entry'],
1747
-					'entry.mid.vid' => "$vid/$mid/entry/" . $get_vars['entry'],
1746
+					'entry.mid' => "$mid/entry/".$get_vars['entry'],
1747
+					'entry.mid.vid' => "$vid/$mid/entry/".$get_vars['entry'],
1748 1748
 					'document_srl' => $srl,
1749 1749
 					'document_srl.mid' => "$mid/$srl",
1750 1750
 					'document_srl.vid' => "$vid/$srl",
@@ -1761,66 +1761,66 @@  discard block
 block discarded – undo
1761 1761
 				$query = $target_map[$target];
1762 1762
 			}
1763 1763
 
1764
-			if(!$query)
1764
+			if (!$query)
1765 1765
 			{
1766 1766
 				$queries = array();
1767
-				foreach($get_vars as $key => $val)
1767
+				foreach ($get_vars as $key => $val)
1768 1768
 				{
1769
-					if(is_array($val) && count($val) > 0)
1769
+					if (is_array($val) && count($val) > 0)
1770 1770
 					{
1771
-						foreach($val as $k => $v)
1771
+						foreach ($val as $k => $v)
1772 1772
 						{
1773
-							$queries[] = $key . '[' . $k . ']=' . urlencode($v);
1773
+							$queries[] = $key.'['.$k.']='.urlencode($v);
1774 1774
 						}
1775 1775
 					}
1776
-					elseif(!is_array($val))
1776
+					elseif (!is_array($val))
1777 1777
 					{
1778
-						$queries[] = $key . '=' . urlencode($val);
1778
+						$queries[] = $key.'='.urlencode($val);
1779 1779
 					}
1780 1780
 				}
1781
-				if(count($queries) > 0)
1781
+				if (count($queries) > 0)
1782 1782
 				{
1783
-					$query = 'index.php?' . join('&', $queries);
1783
+					$query = 'index.php?'.join('&', $queries);
1784 1784
 				}
1785 1785
 			}
1786 1786
 		}
1787 1787
 
1788 1788
 		// If using SSL always
1789 1789
 		$_use_ssl = $self->get('_use_ssl');
1790
-		if($_use_ssl == 'always')
1790
+		if ($_use_ssl == 'always')
1791 1791
 		{
1792
-			$query = $self->getRequestUri(ENFORCE_SSL, $domain) . $query;
1792
+			$query = $self->getRequestUri(ENFORCE_SSL, $domain).$query;
1793 1793
 			// optional SSL use
1794 1794
 		}
1795
-		elseif($_use_ssl == 'optional')
1795
+		elseif ($_use_ssl == 'optional')
1796 1796
 		{
1797 1797
 			$ssl_mode = (($self->get('module') === 'admin') || ($get_vars['module'] === 'admin') || (isset($get_vars['act']) && $self->isExistsSSLAction($get_vars['act']))) ? ENFORCE_SSL : RELEASE_SSL;
1798
-			$query = $self->getRequestUri($ssl_mode, $domain) . $query;
1798
+			$query = $self->getRequestUri($ssl_mode, $domain).$query;
1799 1799
 			// no SSL
1800 1800
 		}
1801 1801
 		else
1802 1802
 		{
1803 1803
 			// currently on SSL but target is not based on SSL
1804
-			if($_SERVER['HTTPS'] == 'on')
1804
+			if ($_SERVER['HTTPS'] == 'on')
1805 1805
 			{
1806
-				$query = $self->getRequestUri(ENFORCE_SSL, $domain) . $query;
1806
+				$query = $self->getRequestUri(ENFORCE_SSL, $domain).$query;
1807 1807
 			}
1808
-			else if($domain) // if $domain is set
1808
+			else if ($domain) // if $domain is set
1809 1809
 			{
1810
-				$query = $self->getRequestUri(FOLLOW_REQUEST_SSL, $domain) . $query;
1810
+				$query = $self->getRequestUri(FOLLOW_REQUEST_SSL, $domain).$query;
1811 1811
 			}
1812 1812
 			else
1813 1813
 			{
1814
-				$query = getScriptPath() . $query;
1814
+				$query = getScriptPath().$query;
1815 1815
 			}
1816 1816
 		}
1817 1817
 
1818
-		if(!$encode)
1818
+		if (!$encode)
1819 1819
 		{
1820 1820
 			return $query;
1821 1821
 		}
1822 1822
 
1823
-		if(!$autoEncode)
1823
+		if (!$autoEncode)
1824 1824
 		{
1825 1825
 			return htmlspecialchars($query, ENT_COMPAT | ENT_HTML401, 'UTF-8', FALSE);
1826 1826
 		}
@@ -1829,16 +1829,16 @@  discard block
 block discarded – undo
1829 1829
 		$encode_queries = array();
1830 1830
 		$parsedUrl = parse_url($query);
1831 1831
 		parse_str($parsedUrl['query'], $output);
1832
-		foreach($output as $key => $value)
1832
+		foreach ($output as $key => $value)
1833 1833
 		{
1834
-			if(preg_match('/&([a-z]{2,}|#\d+);/', urldecode($value)))
1834
+			if (preg_match('/&([a-z]{2,}|#\d+);/', urldecode($value)))
1835 1835
 			{
1836 1836
 				$value = urlencode(htmlspecialchars_decode(urldecode($value)));
1837 1837
 			}
1838
-			$encode_queries[] = $key . '=' . $value;
1838
+			$encode_queries[] = $key.'='.$value;
1839 1839
 		}
1840 1840
 
1841
-		return htmlspecialchars($parsedUrl['path'] . '?' . join('&', $encode_queries), ENT_COMPAT | ENT_HTML401, 'UTF-8', FALSE);
1841
+		return htmlspecialchars($parsedUrl['path'].'?'.join('&', $encode_queries), ENT_COMPAT | ENT_HTML401, 'UTF-8', FALSE);
1842 1842
 	}
1843 1843
 
1844 1844
 	/**
@@ -1853,17 +1853,17 @@  discard block
 block discarded – undo
1853 1853
 		static $url = array();
1854 1854
 
1855 1855
 		// Check HTTP Request
1856
-		if(!isset($_SERVER['SERVER_PROTOCOL']))
1856
+		if (!isset($_SERVER['SERVER_PROTOCOL']))
1857 1857
 		{
1858 1858
 			return;
1859 1859
 		}
1860 1860
 
1861
-		if(self::get('_use_ssl') == 'always')
1861
+		if (self::get('_use_ssl') == 'always')
1862 1862
 		{
1863 1863
 			$ssl_mode = ENFORCE_SSL;
1864 1864
 		}
1865 1865
 
1866
-		if($domain)
1866
+		if ($domain)
1867 1867
 		{
1868 1868
 			$domain_key = md5($domain);
1869 1869
 		}
@@ -1872,14 +1872,14 @@  discard block
 block discarded – undo
1872 1872
 			$domain_key = 'default';
1873 1873
 		}
1874 1874
 
1875
-		if(isset($url[$ssl_mode][$domain_key]))
1875
+		if (isset($url[$ssl_mode][$domain_key]))
1876 1876
 		{
1877 1877
 			return $url[$ssl_mode][$domain_key];
1878 1878
 		}
1879 1879
 
1880 1880
 		$current_use_ssl = ($_SERVER['HTTPS'] == 'on');
1881 1881
 
1882
-		switch($ssl_mode)
1882
+		switch ($ssl_mode)
1883 1883
 		{
1884 1884
 			case FOLLOW_REQUEST_SSL: $use_ssl = $current_use_ssl;
1885 1885
 				break;
@@ -1889,34 +1889,34 @@  discard block
 block discarded – undo
1889 1889
 				break;
1890 1890
 		}
1891 1891
 
1892
-		if($domain)
1892
+		if ($domain)
1893 1893
 		{
1894 1894
 			$target_url = trim($domain);
1895
-			if(substr_compare($target_url, '/', -1) !== 0)
1895
+			if (substr_compare($target_url, '/', -1) !== 0)
1896 1896
 			{
1897
-				$target_url.= '/';
1897
+				$target_url .= '/';
1898 1898
 			}
1899 1899
 		}
1900 1900
 		else
1901 1901
 		{
1902
-			$target_url = $_SERVER['HTTP_HOST'] . getScriptPath();
1902
+			$target_url = $_SERVER['HTTP_HOST'].getScriptPath();
1903 1903
 		}
1904 1904
 
1905
-		$url_info = parse_url('http://' . $target_url);
1905
+		$url_info = parse_url('http://'.$target_url);
1906 1906
 
1907
-		if($current_use_ssl != $use_ssl)
1907
+		if ($current_use_ssl != $use_ssl)
1908 1908
 		{
1909 1909
 			unset($url_info['port']);
1910 1910
 		}
1911 1911
 
1912
-		if($use_ssl)
1912
+		if ($use_ssl)
1913 1913
 		{
1914 1914
 			$port = self::get('_https_port');
1915
-			if($port && $port != 443)
1915
+			if ($port && $port != 443)
1916 1916
 			{
1917 1917
 				$url_info['port'] = $port;
1918 1918
 			}
1919
-			elseif($url_info['port'] == 443)
1919
+			elseif ($url_info['port'] == 443)
1920 1920
 			{
1921 1921
 				unset($url_info['port']);
1922 1922
 			}
@@ -1924,17 +1924,17 @@  discard block
 block discarded – undo
1924 1924
 		else
1925 1925
 		{
1926 1926
 			$port = self::get('_http_port');
1927
-			if($port && $port != 80)
1927
+			if ($port && $port != 80)
1928 1928
 			{
1929 1929
 				$url_info['port'] = $port;
1930 1930
 			}
1931
-			elseif($url_info['port'] == 80)
1931
+			elseif ($url_info['port'] == 80)
1932 1932
 			{
1933 1933
 				unset($url_info['port']);
1934 1934
 			}
1935 1935
 		}
1936 1936
 
1937
-		$url[$ssl_mode][$domain_key] = sprintf('%s://%s%s%s', $use_ssl ? 'https' : $url_info['scheme'], $url_info['host'], $url_info['port'] && $url_info['port'] != 80 ? ':' . $url_info['port'] : '', $url_info['path']);
1937
+		$url[$ssl_mode][$domain_key] = sprintf('%s://%s%s%s', $use_ssl ? 'https' : $url_info['scheme'], $url_info['host'], $url_info['port'] && $url_info['port'] != 80 ? ':'.$url_info['port'] : '', $url_info['path']);
1938 1938
 
1939 1939
 		return $url[$ssl_mode][$domain_key];
1940 1940
 	}
@@ -1951,16 +1951,16 @@  discard block
 block discarded – undo
1951 1951
 	{
1952 1952
 		$self = self::getInstance();
1953 1953
 		$self->context->{$key} = $val;
1954
-		if($set_to_get_vars === FALSE)
1954
+		if ($set_to_get_vars === FALSE)
1955 1955
 		{
1956 1956
 			return;
1957 1957
 		}
1958
-		if($val === NULL || $val === '')
1958
+		if ($val === NULL || $val === '')
1959 1959
 		{
1960 1960
 			unset($self->get_vars->{$key});
1961 1961
 			return;
1962 1962
 		}
1963
-		if($set_to_get_vars || $self->get_vars->{$key})
1963
+		if ($set_to_get_vars || $self->get_vars->{$key})
1964 1964
 		{
1965 1965
 			$self->get_vars->{$key} = $val;
1966 1966
 		}
@@ -1976,7 +1976,7 @@  discard block
 block discarded – undo
1976 1976
 	{
1977 1977
 		$self = self::getInstance();
1978 1978
 
1979
-		if(!isset($self->context->{$key}))
1979
+		if (!isset($self->context->{$key}))
1980 1980
 		{
1981 1981
 			return null;
1982 1982
 		}
@@ -1991,7 +1991,7 @@  discard block
 block discarded – undo
1991 1991
 	function gets()
1992 1992
 	{
1993 1993
 		$num_args = func_num_args();
1994
-		if($num_args < 1)
1994
+		if ($num_args < 1)
1995 1995
 		{
1996 1996
 			return;
1997 1997
 		}
@@ -1999,7 +1999,7 @@  discard block
 block discarded – undo
1999 1999
 
2000 2000
 		$args_list = func_get_args();
2001 2001
 		$output = new stdClass();
2002
-		foreach($args_list as $v)
2002
+		foreach ($args_list as $v)
2003 2003
 		{
2004 2004
 			$output->{$v} = $self->get($v);
2005 2005
 		}
@@ -2025,7 +2025,7 @@  discard block
 block discarded – undo
2025 2025
 	function getRequestVars()
2026 2026
 	{
2027 2027
 		$self = self::getInstance();
2028
-		if($self->get_vars)
2028
+		if ($self->get_vars)
2029 2029
 		{
2030 2030
 			return clone($self->get_vars);
2031 2031
 		}
@@ -2042,13 +2042,13 @@  discard block
 block discarded – undo
2042 2042
 	{
2043 2043
 		$self = self::getInstance();
2044 2044
 
2045
-		if(!is_readable($self->sslActionCacheFile))
2045
+		if (!is_readable($self->sslActionCacheFile))
2046 2046
 		{
2047 2047
 			$buff = '<?php if(!defined("__XE__"))exit;';
2048 2048
 			FileHandler::writeFile($self->sslActionCacheFile, $buff);
2049 2049
 		}
2050 2050
 
2051
-		if(!isset($self->ssl_actions[$action]))
2051
+		if (!isset($self->ssl_actions[$action]))
2052 2052
 		{
2053 2053
 			$self->ssl_actions[$action] = 1;
2054 2054
 			$sslActionCacheString = sprintf('$sslActions[\'%s\'] = 1;', $action);
@@ -2066,16 +2066,16 @@  discard block
 block discarded – undo
2066 2066
 	{
2067 2067
 		$self = self::getInstance();
2068 2068
 
2069
-		if(!is_readable($self->sslActionCacheFile))
2069
+		if (!is_readable($self->sslActionCacheFile))
2070 2070
 		{
2071 2071
 			unset($self->ssl_actions);
2072 2072
 			$buff = '<?php if(!defined("__XE__"))exit;';
2073 2073
 			FileHandler::writeFile($self->sslActionCacheFile, $buff);
2074 2074
 		}
2075 2075
 
2076
-		foreach($action_array as $action)
2076
+		foreach ($action_array as $action)
2077 2077
 		{
2078
-			if(!isset($self->ssl_actions[$action]))
2078
+			if (!isset($self->ssl_actions[$action]))
2079 2079
 			{
2080 2080
 				$self->ssl_actions[$action] = 1;
2081 2081
 				$sslActionCacheString = sprintf('$sslActions[\'%s\'] = 1;', $action);
@@ -2094,7 +2094,7 @@  discard block
 block discarded – undo
2094 2094
 	{
2095 2095
 		$self = self::getInstance();
2096 2096
 
2097
-		if($self->isExistsSSLAction($action))
2097
+		if ($self->isExistsSSLAction($action))
2098 2098
 		{
2099 2099
 			$sslActionCacheString = sprintf('$sslActions[\'%s\'] = 1;', $action);
2100 2100
 			$buff = FileHandler::readFile($self->sslActionCacheFile);
@@ -2111,7 +2111,7 @@  discard block
 block discarded – undo
2111 2111
 	function getSSLActions()
2112 2112
 	{
2113 2113
 		$self = self::getInstance();
2114
-		if($self->getSslStatus() == 'optional')
2114
+		if ($self->getSslStatus() == 'optional')
2115 2115
 		{
2116 2116
 			return $self->ssl_actions;
2117 2117
 		}
@@ -2138,12 +2138,12 @@  discard block
 block discarded – undo
2138 2138
 	 */
2139 2139
 	function normalizeFilePath($file)
2140 2140
 	{
2141
-		if($file{0} != '/' && $file{0} != '.' && strpos($file, '://') === FALSE)
2141
+		if ($file{0} != '/' && $file{0} != '.' && strpos($file, '://') === FALSE)
2142 2142
 		{
2143
-			$file = './' . $file;
2143
+			$file = './'.$file;
2144 2144
 		}
2145 2145
 		$file = preg_replace('@/\./|(?<!:)\/\/@', '/', $file);
2146
-		while(strpos($file, '/../') !== FALSE)
2146
+		while (strpos($file, '/../') !== FALSE)
2147 2147
 		{
2148 2148
 			$file = preg_replace('/\/([^\/]+)\/\.\.\//s', '/', $file, 1);
2149 2149
 		}
@@ -2162,13 +2162,13 @@  discard block
 block discarded – undo
2162 2162
 	{
2163 2163
 		$file = self::normalizeFilePath($file);
2164 2164
 		$script_path = getScriptPath();
2165
-		if(strpos($file, './') === 0)
2165
+		if (strpos($file, './') === 0)
2166 2166
 		{
2167
-			$file = $script_path . substr($file, 2);
2167
+			$file = $script_path.substr($file, 2);
2168 2168
 		}
2169
-		elseif(strpos($file, '../') === 0)
2169
+		elseif (strpos($file, '../') === 0)
2170 2170
 		{
2171
-			$file = self::normalizeFilePath($script_path . $file);
2171
+			$file = self::normalizeFilePath($script_path.$file);
2172 2172
 		}
2173 2173
 
2174 2174
 		return $file;
@@ -2238,12 +2238,12 @@  discard block
 block discarded – undo
2238 2238
 	 */
2239 2239
 	function addJsFile($file, $optimized = FALSE, $targetie = '', $index = 0, $type = 'head', $isRuleset = FALSE, $autoPath = null)
2240 2240
 	{
2241
-		if($isRuleset)
2241
+		if ($isRuleset)
2242 2242
 		{
2243
-			if(strpos($file, '#') !== FALSE)
2243
+			if (strpos($file, '#') !== FALSE)
2244 2244
 			{
2245 2245
 				$file = str_replace('#', '', $file);
2246
-				if(!is_readable($file))
2246
+				if (!is_readable($file))
2247 2247
 				{
2248 2248
 					$file = $autoPath;
2249 2249
 				}
@@ -2308,9 +2308,9 @@  discard block
 block discarded – undo
2308 2308
 		ksort($files);
2309 2309
 		$files = array_values($files);
2310 2310
 		$filenames = array();
2311
-		for($i = 0, $c = count($files); $i < $c; ++$i)
2311
+		for ($i = 0, $c = count($files); $i < $c; ++$i)
2312 2312
 		{
2313
-			if(in_array($files[$i]['file'], $filenames))
2313
+			if (in_array($files[$i]['file'], $filenames))
2314 2314
 			{
2315 2315
 				unset($files[$i]);
2316 2316
 			}
@@ -2395,14 +2395,14 @@  discard block
 block discarded – undo
2395 2395
 	 */
2396 2396
 	function getJavascriptPluginInfo($pluginName)
2397 2397
 	{
2398
-		if($plugin_name == 'ui.datepicker')
2398
+		if ($plugin_name == 'ui.datepicker')
2399 2399
 		{
2400 2400
 			$plugin_name = 'ui';
2401 2401
 		}
2402 2402
 
2403
-		$plugin_path = './common/js/plugins/' . $pluginName . '/';
2404
-		$info_file = $plugin_path . 'plugin.load';
2405
-		if(!is_readable($info_file))
2403
+		$plugin_path = './common/js/plugins/'.$pluginName.'/';
2404
+		$info_file = $plugin_path.'plugin.load';
2405
+		if (!is_readable($info_file))
2406 2406
 		{
2407 2407
 			return;
2408 2408
 		}
@@ -2412,32 +2412,32 @@  discard block
 block discarded – undo
2412 2412
 		$result->jsList = array();
2413 2413
 		$result->cssList = array();
2414 2414
 
2415
-		foreach($list as $filename)
2415
+		foreach ($list as $filename)
2416 2416
 		{
2417 2417
 			$filename = trim($filename);
2418
-			if(!$filename)
2418
+			if (!$filename)
2419 2419
 			{
2420 2420
 				continue;
2421 2421
 			}
2422 2422
 
2423
-			if(strncasecmp('./', $filename, 2) === 0)
2423
+			if (strncasecmp('./', $filename, 2) === 0)
2424 2424
 			{
2425 2425
 				$filename = substr($filename, 2);
2426 2426
 			}
2427 2427
 
2428
-			if(substr_compare($filename, '.js', -3) === 0)
2428
+			if (substr_compare($filename, '.js', -3) === 0)
2429 2429
 			{
2430
-				$result->jsList[] = $plugin_path . $filename;
2430
+				$result->jsList[] = $plugin_path.$filename;
2431 2431
 			}
2432
-			elseif(substr_compare($filename, '.css', -4) === 0)
2432
+			elseif (substr_compare($filename, '.css', -4) === 0)
2433 2433
 			{
2434
-				$result->cssList[] = $plugin_path . $filename;
2434
+				$result->cssList[] = $plugin_path.$filename;
2435 2435
 			}
2436 2436
 		}
2437 2437
 
2438
-		if(is_dir($plugin_path . 'lang'))
2438
+		if (is_dir($plugin_path.'lang'))
2439 2439
 		{
2440
-			$result->langPath = $plugin_path . 'lang';
2440
+			$result->langPath = $plugin_path.'lang';
2441 2441
 		}
2442 2442
 
2443 2443
 		return $result;
@@ -2453,50 +2453,50 @@  discard block
 block discarded – undo
2453 2453
 		static $loaded_plugins = array();
2454 2454
 
2455 2455
 		$self = self::getInstance();
2456
-		if($plugin_name == 'ui.datepicker')
2456
+		if ($plugin_name == 'ui.datepicker')
2457 2457
 		{
2458 2458
 			$plugin_name = 'ui';
2459 2459
 		}
2460 2460
 
2461
-		if($loaded_plugins[$plugin_name])
2461
+		if ($loaded_plugins[$plugin_name])
2462 2462
 		{
2463 2463
 			return;
2464 2464
 		}
2465 2465
 		$loaded_plugins[$plugin_name] = TRUE;
2466 2466
 
2467
-		$plugin_path = './common/js/plugins/' . $plugin_name . '/';
2468
-		$info_file = $plugin_path . 'plugin.load';
2469
-		if(!is_readable($info_file))
2467
+		$plugin_path = './common/js/plugins/'.$plugin_name.'/';
2468
+		$info_file = $plugin_path.'plugin.load';
2469
+		if (!is_readable($info_file))
2470 2470
 		{
2471 2471
 			return;
2472 2472
 		}
2473 2473
 
2474 2474
 		$list = file($info_file);
2475
-		foreach($list as $filename)
2475
+		foreach ($list as $filename)
2476 2476
 		{
2477 2477
 			$filename = trim($filename);
2478
-			if(!$filename)
2478
+			if (!$filename)
2479 2479
 			{
2480 2480
 				continue;
2481 2481
 			}
2482 2482
 
2483
-			if(strncasecmp('./', $filename, 2) === 0)
2483
+			if (strncasecmp('./', $filename, 2) === 0)
2484 2484
 			{
2485 2485
 				$filename = substr($filename, 2);
2486 2486
 			}
2487
-			if(substr_compare($filename, '.js', -3) === 0)
2487
+			if (substr_compare($filename, '.js', -3) === 0)
2488 2488
 			{
2489
-				$self->loadFile(array($plugin_path . $filename, 'body', '', 0), TRUE);
2489
+				$self->loadFile(array($plugin_path.$filename, 'body', '', 0), TRUE);
2490 2490
 			}
2491
-			if(substr_compare($filename, '.css', -4) === 0)
2491
+			if (substr_compare($filename, '.css', -4) === 0)
2492 2492
 			{
2493
-				$self->loadFile(array($plugin_path . $filename, 'all', '', 0), TRUE);
2493
+				$self->loadFile(array($plugin_path.$filename, 'all', '', 0), TRUE);
2494 2494
 			}
2495 2495
 		}
2496 2496
 
2497
-		if(is_dir($plugin_path . 'lang'))
2497
+		if (is_dir($plugin_path.'lang'))
2498 2498
 		{
2499
-			$self->loadLang($plugin_path . 'lang');
2499
+			$self->loadLang($plugin_path.'lang');
2500 2500
 		}
2501 2501
 	}
2502 2502
 
@@ -2509,7 +2509,7 @@  discard block
 block discarded – undo
2509 2509
 	function addHtmlHeader($header)
2510 2510
 	{
2511 2511
 		$self = self::getInstance();
2512
-		$self->html_header .= "\n" . $header;
2512
+		$self->html_header .= "\n".$header;
2513 2513
 	}
2514 2514
 
2515 2515
 	function clearHtmlHeader()
@@ -2561,7 +2561,7 @@  discard block
 block discarded – undo
2561 2561
 	function addBodyHeader($header)
2562 2562
 	{
2563 2563
 		$self = self::getInstance();
2564
-		$self->body_header .= "\n" . $header;
2564
+		$self->body_header .= "\n".$header;
2565 2565
 	}
2566 2566
 
2567 2567
 	/**
@@ -2583,7 +2583,7 @@  discard block
 block discarded – undo
2583 2583
 	function addHtmlFooter($footer)
2584 2584
 	{
2585 2585
 		$self = self::getInstance();
2586
-		$self->html_footer .= ($self->Htmlfooter ? "\n" : '') . $footer;
2586
+		$self->html_footer .= ($self->Htmlfooter ? "\n" : '').$footer;
2587 2587
 	}
2588 2588
 
2589 2589
 	/**
@@ -2604,7 +2604,7 @@  discard block
 block discarded – undo
2604 2604
 	 */
2605 2605
 	function getConfigFile()
2606 2606
 	{
2607
-		return _XE_PATH_ . 'files/config/db.config.php';
2607
+		return _XE_PATH_.'files/config/db.config.php';
2608 2608
 	}
2609 2609
 
2610 2610
 	/**
@@ -2614,7 +2614,7 @@  discard block
 block discarded – undo
2614 2614
 	 */
2615 2615
 	function getFTPConfigFile()
2616 2616
 	{
2617
-		return _XE_PATH_ . 'files/config/ftp.config.php';
2617
+		return _XE_PATH_.'files/config/ftp.config.php';
2618 2618
 	}
2619 2619
 
2620 2620
 	/**
@@ -2666,14 +2666,14 @@  discard block
 block discarded – undo
2666 2666
 		$_path = explode('/', $path);
2667 2667
 		$_base = explode('/', $base_url);
2668 2668
 
2669
-		if(!$_base[count($_base) - 1])
2669
+		if (!$_base[count($_base) - 1])
2670 2670
 		{
2671 2671
 			array_pop($_base);
2672 2672
 		}
2673 2673
 
2674
-		foreach($_xe as $idx => $dir)
2674
+		foreach ($_xe as $idx => $dir)
2675 2675
 		{
2676
-			if($_path[0] != $dir)
2676
+			if ($_path[0] != $dir)
2677 2677
 			{
2678 2678
 				break;
2679 2679
 			}
@@ -2681,9 +2681,9 @@  discard block
 block discarded – undo
2681 2681
 		}
2682 2682
 
2683 2683
 		$idx = count($_xe) - $idx - 1;
2684
-		while($idx--)
2684
+		while ($idx--)
2685 2685
 		{
2686
-			if(count($_base) > 0)
2686
+			if (count($_base) > 0)
2687 2687
 			{
2688 2688
 				array_shift($_base);
2689 2689
 			}
@@ -2693,13 +2693,13 @@  discard block
 block discarded – undo
2693 2693
 			}
2694 2694
 		}
2695 2695
 
2696
-		if(count($_base) > 0)
2696
+		if (count($_base) > 0)
2697 2697
 		{
2698 2698
 			array_unshift($_path, join('/', $_base));
2699 2699
 		}
2700 2700
 
2701
-		$path = '/' . join('/', $_path);
2702
-		if(substr_compare($path, '/', -1) !== 0)
2701
+		$path = '/'.join('/', $_path);
2702
+		if (substr_compare($path, '/', -1) !== 0)
2703 2703
 		{
2704 2704
 			$path .= '/';
2705 2705
 		}
@@ -2714,13 +2714,13 @@  discard block
 block discarded – undo
2714 2714
 	{
2715 2715
 		$self = self::getInstance();
2716 2716
 
2717
-		if(!is_array($self->meta_tags))
2717
+		if (!is_array($self->meta_tags))
2718 2718
 		{
2719 2719
 			$self->meta_tags = array();
2720 2720
 		}
2721 2721
 
2722 2722
 		$ret = array();
2723
-		foreach($self->meta_tags as $key => $val)
2723
+		foreach ($self->meta_tags as $key => $val)
2724 2724
 		{
2725 2725
 			list($name, $is_http_equiv) = explode("\t", $key);
2726 2726
 			$ret[] = array('name' => $name, 'is_http_equiv' => $is_http_equiv, 'content' => $val);
@@ -2740,7 +2740,7 @@  discard block
 block discarded – undo
2740 2740
 	function addMetaTag($name, $content, $is_http_equiv = FALSE)
2741 2741
 	{
2742 2742
 		$self = self::getInstance();
2743
-		$self->meta_tags[$name . "\t" . ($is_http_equiv ? '1' : '0')] = $content;
2743
+		$self->meta_tags[$name."\t".($is_http_equiv ? '1' : '0')] = $content;
2744 2744
 	}
2745 2745
 
2746 2746
 }
Please login to merge, or discard this patch.
Braces   +108 added lines, -109 removed lines patch added patch discarded remove patch
@@ -230,7 +230,9 @@  discard block
 block discarded – undo
230 230
 		$this->loadDBInfo();
231 231
 		if($this->db_info->use_sitelock == 'Y')
232 232
 		{
233
-			if(is_array($this->db_info->sitelock_whitelist)) $whitelist = $this->db_info->sitelock_whitelist;
233
+			if(is_array($this->db_info->sitelock_whitelist)) {
234
+				$whitelist = $this->db_info->sitelock_whitelist;
235
+			}
234 236
 
235 237
 			if(!IpFilter::filter($whitelist))
236 238
 			{
@@ -245,8 +247,7 @@  discard block
 block discarded – undo
245 247
 				if(FileHandler::exists(_XE_PATH_ . 'common/tpl/sitelock.user.html'))
246 248
 				{
247 249
 					include _XE_PATH_ . 'common/tpl/sitelock.user.html';
248
-				}
249
-				else
250
+				} else
250 251
 				{
251 252
 					include _XE_PATH_ . 'common/tpl/sitelock.html';
252 253
 				}
@@ -303,8 +304,7 @@  discard block
 block discarded – undo
303 304
 			{
304 305
 				setcookie('lang_type', $this->lang_type, $_SERVER['REQUEST_TIME'] + 3600 * 24 * 1000);
305 306
 			}
306
-		}
307
-		elseif($_COOKIE['lang_type'])
307
+		} elseif($_COOKIE['lang_type'])
308 308
 		{
309 309
 			$this->lang_type = $_COOKIE['lang_type'];
310 310
 		}
@@ -342,7 +342,9 @@  discard block
 block discarded – undo
342 342
 			);
343 343
 		}
344 344
 
345
-		if($sess = $_POST[session_name()]) session_id($sess);
345
+		if($sess = $_POST[session_name()]) {
346
+			session_id($sess);
347
+		}
346 348
 		session_start();
347 349
 
348 350
 		// set authentication information in Context and session
@@ -395,22 +397,21 @@  discard block
 block discarded – undo
395 397
 						{
396 398
 							$url[] = $key . '[' . $k . ']=' . urlencode($v);
397 399
 						}
398
-					}
399
-					elseif($val)
400
+					} elseif($val)
400 401
 					{
401 402
 						$url[] = $key . '=' . urlencode($val);
402 403
 					}
403 404
 				}
404 405
 
405 406
 				$current_url = self::getRequestUri();
406
-				if($url) $current_url .= '?' . join('&', $url);
407
-			}
408
-			else
407
+				if($url) {
408
+					$current_url .= '?' . join('&', $url);
409
+				}
410
+			} else
409 411
 			{
410 412
 				$current_url = $this->getUrl();
411 413
 			}
412
-		}
413
-		else
414
+		} else
414 415
 		{
415 416
 			$current_url = self::getRequestUri();
416 417
 		}
@@ -502,18 +503,22 @@  discard block
 block discarded – undo
502 503
 			$db_info->use_prepared_statements = 'Y';
503 504
 		}
504 505
 
505
-		if(!$db_info->time_zone)
506
-			$db_info->time_zone = date('O');
506
+		if(!$db_info->time_zone) {
507
+					$db_info->time_zone = date('O');
508
+		}
507 509
 		$GLOBALS['_time_zone'] = $db_info->time_zone;
508 510
 
509
-		if($db_info->qmail_compatibility != 'Y')
510
-			$db_info->qmail_compatibility = 'N';
511
+		if($db_info->qmail_compatibility != 'Y') {
512
+					$db_info->qmail_compatibility = 'N';
513
+		}
511 514
 		$GLOBALS['_qmail_compatibility'] = $db_info->qmail_compatibility;
512 515
 
513
-		if(!$db_info->use_db_session)
514
-			$db_info->use_db_session = 'N';
515
-		if(!$db_info->use_ssl)
516
-			$db_info->use_ssl = 'none';
516
+		if(!$db_info->use_db_session) {
517
+					$db_info->use_db_session = 'N';
518
+		}
519
+		if(!$db_info->use_ssl) {
520
+					$db_info->use_ssl = 'none';
521
+		}
517 522
 		$this->set('_use_ssl', $db_info->use_ssl);
518 523
 
519 524
 		$self->set('_http_port', ($db_info->http_port) ? $db_info->http_port : NULL);
@@ -630,8 +635,7 @@  discard block
 block discarded – undo
630 635
 				$buff = FileHandler::readFile($orig_lang_file);
631 636
 				FileHandler::writeFile($selected_lang_file, $buff);
632 637
 				$lang_selected = self::loadLangSupported();
633
-			}
634
-			else
638
+			} else
635 639
 			{
636 640
 				$langs = file($selected_lang_file);
637 641
 				foreach($langs as $val)
@@ -690,15 +694,16 @@  discard block
 block discarded – undo
690 694
 
691 695
 				$oModuleModel = getModel('module');
692 696
 				$domain = $url_info['host'] . $url_info['path'];
693
-				if(substr_compare($domain, '/', -1) === 0) $domain = substr($domain, 0, -1);
697
+				if(substr_compare($domain, '/', -1) === 0) {
698
+					$domain = substr($domain, 0, -1);
699
+				}
694 700
 				$site_info = $oModuleModel->getSiteInfoByDomain($domain);
695 701
 
696 702
 				if($site_info->site_srl)
697 703
 				{
698 704
 				$url_info['query'].= ($url_info['query'] ? '&' : '') . 'SSOID=' . urlencode(session_id()) . '&sig=' . urlencode(Password::createSignature(session_id()));
699 705
 				$redirect_url = sprintf('%s://%s%s%s?%s', $url_info['scheme'], $url_info['host'], $url_info['port'] ? ':' . $url_info['port'] : '', $url_info['path'], $url_info['query']);
700
-				}
701
-				else
706
+				} else
702 707
 				{
703 708
 					$redirect_url = $url;
704 709
 				}
@@ -707,8 +712,7 @@  discard block
 block discarded – undo
707 712
 				return FALSE;
708 713
 			}
709 714
 			// for sites requesting SSO validation
710
-		}
711
-		else
715
+		} else
712 716
 		{
713 717
 			// result handling : set session_name()
714 718
 			if($session_name = self::get('SSOID'))
@@ -725,8 +729,7 @@  discard block
 block discarded – undo
725 729
 				header('location:' . $url);
726 730
 				return FALSE;
727 731
 				// send SSO request
728
-			}
729
-			else if(!self::get('SSOID') && $_COOKIE['sso'] != md5(self::getRequestUri()))
732
+			} else if(!self::get('SSOID') && $_COOKIE['sso'] != md5(self::getRequestUri()))
730 733
 			{
731 734
 				setcookie('sso', md5(self::getRequestUri()));
732 735
 				$origin_url = self::getRequestUrl();
@@ -786,8 +789,7 @@  discard block
 block discarded – undo
786 789
 		if($self->site_title)
787 790
 		{
788 791
 			$self->site_title .= ' - ' . $site_title;
789
-		}
790
-		else
792
+		} else
791 793
 		{
792 794
 			$self->site_title = $site_title;
793 795
 		}
@@ -887,8 +889,7 @@  discard block
 block discarded – undo
887 889
 		{
888 890
 			$self->loaded_lang_files[] = $filename;
889 891
 			include($filename);
890
-		}
891
-		else
892
+		} else
892 893
 		{
893 894
 			$self->_evalxmlLang($path);
894 895
 		}
@@ -904,7 +905,9 @@  discard block
 block discarded – undo
904 905
 	{
905 906
 		global $lang;
906 907
 
907
-		if(!$path) return;
908
+		if(!$path) {
909
+			return;
910
+		}
908 911
 
909 912
 		$_path = 'eval://' . $path;
910 913
 
@@ -936,7 +939,9 @@  discard block
 block discarded – undo
936 939
 	 */
937 940
 	function _loadXmlLang($path)
938 941
 	{
939
-		if(!$path) return;
942
+		if(!$path) {
943
+			return;
944
+		}
940 945
 
941 946
 		$oXmlLangParser = new XmlLangParser($path . ((substr_compare($path, '/', -1) !== 0) ? '/' : '') . 'lang.xml', $this->lang_type);
942 947
 		return $oXmlLangParser->compile();
@@ -950,7 +955,9 @@  discard block
 block discarded – undo
950 955
 	 */
951 956
 	function _loadPhpLang($path)
952 957
 	{
953
-		if(!$path) return;
958
+		if(!$path) {
959
+			return;
960
+		}
954 961
 
955 962
 		if(substr_compare($path, '/', -1) !== 0)
956 963
 		{
@@ -1083,12 +1090,14 @@  discard block
 block discarded – undo
1083 1090
 		static $flag = TRUE;
1084 1091
 		if($charset)
1085 1092
 		{
1086
-			if(is_array($val))
1087
-				array_walk($val,'Context::checkConvertFlag',$charset);
1088
-			else if($val && iconv($charset,$charset,$val)!=$val) $flag = FALSE;
1089
-			else $flag = FALSE;
1090
-		}
1091
-		else
1093
+			if(is_array($val)) {
1094
+							array_walk($val,'Context::checkConvertFlag',$charset);
1095
+			} else if($val && iconv($charset,$charset,$val)!=$val) {
1096
+				$flag = FALSE;
1097
+			} else {
1098
+				$flag = FALSE;
1099
+			}
1100
+		} else
1092 1101
 		{
1093 1102
 			$return = $flag;
1094 1103
 			$flag = TRUE;
@@ -1110,8 +1119,9 @@  discard block
 block discarded – undo
1110 1119
 		if (is_array($val))
1111 1120
 		{
1112 1121
 			array_walk($val,'Context::doConvertEncoding',$charset);
1122
+		} else {
1123
+			$val = iconv($charset,'UTF-8',$val);
1113 1124
 		}
1114
-		else $val = iconv($charset,'UTF-8',$val);
1115 1125
 	}
1116 1126
 
1117 1127
 	/**
@@ -1122,7 +1132,9 @@  discard block
 block discarded – undo
1122 1132
 	 */
1123 1133
 	function convertEncodingStr($str)
1124 1134
 	{
1125
-        if(!$str) return null;
1135
+        if(!$str) {
1136
+        	return null;
1137
+        }
1126 1138
 		$obj = new stdClass();
1127 1139
 		$obj->str = $str;
1128 1140
 		$obj = self::convertEncoding($obj);
@@ -1235,16 +1247,13 @@  discard block
 block discarded – undo
1235 1247
 			if($requestMethod == 'GET' && isset($_GET[$key]))
1236 1248
 			{
1237 1249
 				$set_to_vars = TRUE;
1238
-			}
1239
-			elseif($requestMethod == 'POST' && isset($_POST[$key]))
1250
+			} elseif($requestMethod == 'POST' && isset($_POST[$key]))
1240 1251
 			{
1241 1252
 				$set_to_vars = TRUE;
1242
-			}
1243
-			elseif($requestMethod == 'JS_CALLBACK' && (isset($_GET[$key]) || isset($_POST[$key])))
1253
+			} elseif($requestMethod == 'JS_CALLBACK' && (isset($_GET[$key]) || isset($_POST[$key])))
1244 1254
 			{
1245 1255
 				$set_to_vars = TRUE;
1246
-			}
1247
-			else
1256
+			} else
1248 1257
 			{
1249 1258
 				$set_to_vars = FALSE;
1250 1259
 			}
@@ -1270,8 +1279,7 @@  discard block
 block discarded – undo
1270 1279
 					return;
1271 1280
 				}
1272 1281
 			}
1273
-		}
1274
-		else if(is_array($val))
1282
+		} else if(is_array($val))
1275 1283
 		{
1276 1284
 			foreach($val as $val2)
1277 1285
 			{
@@ -1420,19 +1428,15 @@  discard block
 block discarded – undo
1420 1428
 			if($key === 'page' || $key === 'cpage' || substr_compare($key, 'srl', -3) === 0)
1421 1429
 			{
1422 1430
 				$result[$k] = !preg_match('/^[0-9,]+$/', $v) ? (int) $v : $v;
1423
-			}
1424
-			elseif(in_array($key, array('mid','search_keyword','search_target','xe_validator_id'))) {
1431
+			} elseif(in_array($key, array('mid','search_keyword','search_target','xe_validator_id'))) {
1425 1432
 				$result[$k] = escape($v, false);
1426
-			}
1427
-			elseif($key === 'vid')
1433
+			} elseif($key === 'vid')
1428 1434
 			{
1429 1435
 				$result[$k] = urlencode($v);
1430
-			}
1431
-			elseif(stripos($key, 'XE_VALIDATOR', 0) === 0)
1436
+			} elseif(stripos($key, 'XE_VALIDATOR', 0) === 0)
1432 1437
 			{
1433 1438
 				unset($result[$k]);
1434
-			}
1435
-			else
1439
+			} else
1436 1440
 			{
1437 1441
 				$result[$k] = $v;
1438 1442
 
@@ -1441,8 +1445,7 @@  discard block
 block discarded – undo
1441 1445
 					if (is_array($result[$k]))
1442 1446
 					{
1443 1447
 						array_walk_recursive($result[$k], function(&$val) { $val = stripslashes($val); });
1444
-					}
1445
-					else
1448
+					} else
1446 1449
 					{
1447 1450
 						$result[$k] = stripslashes($result[$k]);
1448 1451
 					}
@@ -1451,8 +1454,7 @@  discard block
 block discarded – undo
1451 1454
 				if(is_array($result[$k]))
1452 1455
 				{
1453 1456
 					array_walk_recursive($result[$k], function(&$val) { $val = trim($val); });
1454
-				}
1455
-				else
1457
+				} else
1456 1458
 				{
1457 1459
 					$result[$k] = trim($result[$k]);
1458 1460
 				}
@@ -1504,8 +1506,7 @@  discard block
 block discarded – undo
1504 1506
 				$val['name'] = escape($val['name'], FALSE);
1505 1507
 				$this->set($key, $val, TRUE);
1506 1508
 				$this->is_uploaded = TRUE;
1507
-			}
1508
-			else
1509
+			} else
1509 1510
 			{
1510 1511
 				$files = array();
1511 1512
 				foreach ($tmp_name as $i => $j)
@@ -1619,8 +1620,7 @@  discard block
 block discarded – undo
1619 1620
 			if($site_module_info->domain && isSiteID($site_module_info->domain))
1620 1621
 			{
1621 1622
 				$vid = $site_module_info->domain;
1622
-			}
1623
-			else
1623
+			} else
1624 1624
 			{
1625 1625
 				$domain = $site_module_info->domain;
1626 1626
 			}
@@ -1637,8 +1637,7 @@  discard block
 block discarded – undo
1637 1637
 			if($domain_info['host'] . $domain_info['path'] == $current_info['host'] . $current_info['path'])
1638 1638
 			{
1639 1639
 				unset($domain);
1640
-			}
1641
-			else
1640
+			} else
1642 1641
 			{
1643 1642
 				$domain = preg_replace('/^(http|https):\/\//i', '', trim($domain));
1644 1643
 				if(substr_compare($domain, '/', -1) !== 0)
@@ -1658,23 +1657,35 @@  discard block
 block discarded – undo
1658 1657
 			{
1659 1658
 				array_shift($args_list);
1660 1659
 			}
1661
-		}
1662
-		elseif($_SERVER['REQUEST_METHOD'] == 'GET')
1660
+		} elseif($_SERVER['REQUEST_METHOD'] == 'GET')
1663 1661
 		{
1664 1662
 			// Otherwise, make GET variables into array
1665 1663
 			$get_vars = get_object_vars($self->get_vars);
1666
-		}
1667
-		else
1664
+		} else
1668 1665
 		{
1669
-			if(!!$self->get_vars->module) $get_vars['module'] = $self->get_vars->module;
1670
-			if(!!$self->get_vars->mid) $get_vars['mid'] = $self->get_vars->mid;
1671
-			if(!!$self->get_vars->act) $get_vars['act'] = $self->get_vars->act;
1672
-			if(!!$self->get_vars->page) $get_vars['page'] = $self->get_vars->page;
1673
-			if(!!$self->get_vars->search_target) $get_vars['search_target'] = $self->get_vars->search_target;
1674
-			if(!!$self->get_vars->search_keyword) $get_vars['search_keyword'] = $self->get_vars->search_keyword;
1666
+			if(!!$self->get_vars->module) {
1667
+				$get_vars['module'] = $self->get_vars->module;
1668
+			}
1669
+			if(!!$self->get_vars->mid) {
1670
+				$get_vars['mid'] = $self->get_vars->mid;
1671
+			}
1672
+			if(!!$self->get_vars->act) {
1673
+				$get_vars['act'] = $self->get_vars->act;
1674
+			}
1675
+			if(!!$self->get_vars->page) {
1676
+				$get_vars['page'] = $self->get_vars->page;
1677
+			}
1678
+			if(!!$self->get_vars->search_target) {
1679
+				$get_vars['search_target'] = $self->get_vars->search_target;
1680
+			}
1681
+			if(!!$self->get_vars->search_keyword) {
1682
+				$get_vars['search_keyword'] = $self->get_vars->search_keyword;
1683
+			}
1675 1684
 			if($get_vars['act'] == 'IS')
1676 1685
 			{
1677
-				if(!!$self->get_vars->is_keyword) $get_vars['is_keyword'] = $self->get_vars->is_keyword;
1686
+				if(!!$self->get_vars->is_keyword) {
1687
+					$get_vars['is_keyword'] = $self->get_vars->is_keyword;
1688
+				}
1678 1689
 			}
1679 1690
 		}
1680 1691
 
@@ -1699,8 +1710,7 @@  discard block
 block discarded – undo
1699 1710
 		if($vid)
1700 1711
 		{
1701 1712
 			$get_vars['vid'] = $vid;
1702
-		}
1703
-		else
1713
+		} else
1704 1714
 		{
1705 1715
 			unset($get_vars['vid']);
1706 1716
 		}
@@ -1772,8 +1782,7 @@  discard block
 block discarded – undo
1772 1782
 						{
1773 1783
 							$queries[] = $key . '[' . $k . ']=' . urlencode($v);
1774 1784
 						}
1775
-					}
1776
-					elseif(!is_array($val))
1785
+					} elseif(!is_array($val))
1777 1786
 					{
1778 1787
 						$queries[] = $key . '=' . urlencode($val);
1779 1788
 					}
@@ -1791,25 +1800,23 @@  discard block
 block discarded – undo
1791 1800
 		{
1792 1801
 			$query = $self->getRequestUri(ENFORCE_SSL, $domain) . $query;
1793 1802
 			// optional SSL use
1794
-		}
1795
-		elseif($_use_ssl == 'optional')
1803
+		} elseif($_use_ssl == 'optional')
1796 1804
 		{
1797 1805
 			$ssl_mode = (($self->get('module') === 'admin') || ($get_vars['module'] === 'admin') || (isset($get_vars['act']) && $self->isExistsSSLAction($get_vars['act']))) ? ENFORCE_SSL : RELEASE_SSL;
1798 1806
 			$query = $self->getRequestUri($ssl_mode, $domain) . $query;
1799 1807
 			// no SSL
1800
-		}
1801
-		else
1808
+		} else
1802 1809
 		{
1803 1810
 			// currently on SSL but target is not based on SSL
1804 1811
 			if($_SERVER['HTTPS'] == 'on')
1805 1812
 			{
1806 1813
 				$query = $self->getRequestUri(ENFORCE_SSL, $domain) . $query;
1807
-			}
1808
-			else if($domain) // if $domain is set
1814
+			} else if($domain) {
1815
+				// if $domain is set
1809 1816
 			{
1810 1817
 				$query = $self->getRequestUri(FOLLOW_REQUEST_SSL, $domain) . $query;
1811 1818
 			}
1812
-			else
1819
+			} else
1813 1820
 			{
1814 1821
 				$query = getScriptPath() . $query;
1815 1822
 			}
@@ -1866,8 +1873,7 @@  discard block
 block discarded – undo
1866 1873
 		if($domain)
1867 1874
 		{
1868 1875
 			$domain_key = md5($domain);
1869
-		}
1870
-		else
1876
+		} else
1871 1877
 		{
1872 1878
 			$domain_key = 'default';
1873 1879
 		}
@@ -1896,8 +1902,7 @@  discard block
 block discarded – undo
1896 1902
 			{
1897 1903
 				$target_url.= '/';
1898 1904
 			}
1899
-		}
1900
-		else
1905
+		} else
1901 1906
 		{
1902 1907
 			$target_url = $_SERVER['HTTP_HOST'] . getScriptPath();
1903 1908
 		}
@@ -1915,20 +1920,17 @@  discard block
 block discarded – undo
1915 1920
 			if($port && $port != 443)
1916 1921
 			{
1917 1922
 				$url_info['port'] = $port;
1918
-			}
1919
-			elseif($url_info['port'] == 443)
1923
+			} elseif($url_info['port'] == 443)
1920 1924
 			{
1921 1925
 				unset($url_info['port']);
1922 1926
 			}
1923
-		}
1924
-		else
1927
+		} else
1925 1928
 		{
1926 1929
 			$port = self::get('_http_port');
1927 1930
 			if($port && $port != 80)
1928 1931
 			{
1929 1932
 				$url_info['port'] = $port;
1930
-			}
1931
-			elseif($url_info['port'] == 80)
1933
+			} elseif($url_info['port'] == 80)
1932 1934
 			{
1933 1935
 				unset($url_info['port']);
1934 1936
 			}
@@ -2165,8 +2167,7 @@  discard block
 block discarded – undo
2165 2167
 		if(strpos($file, './') === 0)
2166 2168
 		{
2167 2169
 			$file = $script_path . substr($file, 2);
2168
-		}
2169
-		elseif(strpos($file, '../') === 0)
2170
+		} elseif(strpos($file, '../') === 0)
2170 2171
 		{
2171 2172
 			$file = self::normalizeFilePath($script_path . $file);
2172 2173
 		}
@@ -2428,8 +2429,7 @@  discard block
 block discarded – undo
2428 2429
 			if(substr_compare($filename, '.js', -3) === 0)
2429 2430
 			{
2430 2431
 				$result->jsList[] = $plugin_path . $filename;
2431
-			}
2432
-			elseif(substr_compare($filename, '.css', -4) === 0)
2432
+			} elseif(substr_compare($filename, '.css', -4) === 0)
2433 2433
 			{
2434 2434
 				$result->cssList[] = $plugin_path . $filename;
2435 2435
 			}
@@ -2686,8 +2686,7 @@  discard block
 block discarded – undo
2686 2686
 			if(count($_base) > 0)
2687 2687
 			{
2688 2688
 				array_shift($_base);
2689
-			}
2690
-			else
2689
+			} else
2691 2690
 			{
2692 2691
 				array_unshift($_base, '..');
2693 2692
 			}
Please login to merge, or discard this patch.
classes/extravar/Extravar.class.php 1 patch
Spacing   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	function setExtraVarKeys($extra_keys)
53 53
 	{
54
-		if(!is_array($extra_keys) || count($extra_keys) < 1)
54
+		if (!is_array($extra_keys) || count($extra_keys) < 1)
55 55
 		{
56 56
 			return;
57 57
 		}
58 58
 
59
-		foreach($extra_keys as $val)
59
+		foreach ($extra_keys as $val)
60 60
 		{
61 61
 			$obj = new ExtraItem($val->module_srl, $val->idx, $val->name, $val->type, $val->default, $val->desc, $val->is_required, $val->search, $val->value, $val->eid);
62 62
 			$this->keys[$val->idx] = $obj;
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 	 */
160 160
 	function __construct($module_srl, $idx, $name, $type = 'text', $default = null, $desc = '', $is_required = 'N', $search = 'N', $value = null, $eid = '')
161 161
 	{
162
-		if(!$idx)
162
+		if (!$idx)
163 163
 		{
164 164
 			return;
165 165
 		}
@@ -197,36 +197,36 @@  discard block
 block discarded – undo
197 197
 	function _getTypeValue($type, $value)
198 198
 	{
199 199
 		$value = trim($value);
200
-		if(!isset($value))
200
+		if (!isset($value))
201 201
 		{
202 202
 			return;
203 203
 		}
204 204
 
205
-		switch($type)
205
+		switch ($type)
206 206
 		{
207 207
 			case 'homepage' :
208
-				if($value && !preg_match('/^([a-z]+):\/\//i', $value))
208
+				if ($value && !preg_match('/^([a-z]+):\/\//i', $value))
209 209
 				{
210
-					$value = 'http://' . $value;
210
+					$value = 'http://'.$value;
211 211
 				}
212 212
 				return escpe($value, false);
213 213
 
214 214
 			case 'tel' :
215
-				if(is_array($value))
215
+				if (is_array($value))
216 216
 				{
217 217
 					$values = $value;
218 218
 				}
219
-				elseif(strpos($value, '|@|') !== FALSE)
219
+				elseif (strpos($value, '|@|') !== FALSE)
220 220
 				{
221 221
 					$values = explode('|@|', $value);
222 222
 				}
223
-				elseif(strpos($value, ',') !== FALSE)
223
+				elseif (strpos($value, ',') !== FALSE)
224 224
 				{
225 225
 					$values = explode(',', $value);
226 226
 				}
227 227
 
228 228
 				$values = array_values($values);
229
-				for($i = 0, $c = count($values); $i < $c; $i++)
229
+				for ($i = 0, $c = count($values); $i < $c; $i++)
230 230
 				{
231 231
 					$values[$i] = trim(escpe($values[$i], false));
232 232
 				}
@@ -235,15 +235,15 @@  discard block
 block discarded – undo
235 235
 			case 'checkbox' :
236 236
 			case 'radio' :
237 237
 			case 'select' :
238
-				if(is_array($value))
238
+				if (is_array($value))
239 239
 				{
240 240
 					$values = $value;
241 241
 				}
242
-				elseif(strpos($value, '|@|') !== FALSE)
242
+				elseif (strpos($value, '|@|') !== FALSE)
243 243
 				{
244 244
 					$values = explode('|@|', $value);
245 245
 				}
246
-				elseif(strpos($value, ',') !== FALSE)
246
+				elseif (strpos($value, ',') !== FALSE)
247 247
 				{
248 248
 					$values = explode(',', $value);
249 249
 				}
@@ -253,18 +253,18 @@  discard block
 block discarded – undo
253 253
 				}
254 254
 
255 255
 				$values = array_values($values);
256
-				for($i = 0, $c = count($values); $i < $c; $i++)
256
+				for ($i = 0, $c = count($values); $i < $c; $i++)
257 257
 				{
258 258
 					$values[$i] = trim(escape($values[$i], false));
259 259
 				}
260 260
 				return $values;
261 261
 
262 262
 			case 'kr_zip' :
263
-				if(is_array($value))
263
+				if (is_array($value))
264 264
 				{
265 265
 					$values = $value;
266 266
 				}
267
-				elseif(strpos($value, '|@|') !== false)
267
+				elseif (strpos($value, '|@|') !== false)
268 268
 				{
269 269
 					$values = explode('|@|', $value);
270 270
 				}
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
 				}
275 275
 
276 276
 				$values = array_values($values);
277
-				for($i = 0, $c = count($values); $i < $c; $i++)
277
+				for ($i = 0, $c = count($values); $i < $c; $i++)
278 278
 				{
279 279
 					$values[$i] = trim(escape($values[$i], false));
280 280
 				}
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
 	{
309 309
 		$value = $this->_getTypeValue($this->type, $this->value);
310 310
 
311
-		switch($this->type)
311
+		switch ($this->type)
312 312
 		{
313 313
 			case 'homepage' :
314
-				return ($value) ? (sprintf('<a href="%s" target="_blank">%s</a>', escape($value, false), strlen($value) > 60 ? substr($value, 0, 40) . '...' . substr($value, -10) : $value)) : "";
314
+				return ($value) ? (sprintf('<a href="%s" target="_blank">%s</a>', escape($value, false), strlen($value) > 60 ? substr($value, 0, 40).'...'.substr($value, -10) : $value)) : "";
315 315
 
316 316
 			case 'email_address' :
317 317
 				return ($value) ? sprintf('<a href="mailto:%s">%s</a>', escape($value, false), $value) : "";
@@ -328,14 +328,14 @@  discard block
 block discarded – undo
328 328
 			case 'checkbox' :
329 329
 			case 'select' :
330 330
 			case 'radio' :
331
-				if(is_array($value))
331
+				if (is_array($value))
332 332
 				{
333 333
 					return implode(',', $value);
334 334
 				}
335 335
 				return $value;
336 336
 
337 337
 			case 'kr_zip' :
338
-				if(is_array($value))
338
+				if (is_array($value))
339 339
 				{
340 340
 					return implode(' ', $value);
341 341
 				}
@@ -360,77 +360,77 @@  discard block
 block discarded – undo
360 360
 		$name = $this->name;
361 361
 		$value = $this->_getTypeValue($this->type, $this->value);
362 362
 		$default = $this->_getTypeValue($this->type, $this->default);
363
-		$column_name = 'extra_vars' . $this->idx;
364
-		$tmp_id = $column_name . '-' . $id_num++;
363
+		$column_name = 'extra_vars'.$this->idx;
364
+		$tmp_id = $column_name.'-'.$id_num++;
365 365
 
366 366
 		$buff = array();
367
-		switch($type)
367
+		switch ($type)
368 368
 		{
369 369
 			// Homepage
370 370
 			case 'homepage' :
371
-				$buff[] = '<input type="text" name="' . $column_name . '" value="' . $value . '" class="homepage" />';
371
+				$buff[] = '<input type="text" name="'.$column_name.'" value="'.$value.'" class="homepage" />';
372 372
 				break;
373 373
 			// Email Address
374 374
 			case 'email_address' :
375
-				$buff[] = '<input type="text" name="' . $column_name . '" value="' . $value . '" class="email_address" />';
375
+				$buff[] = '<input type="text" name="'.$column_name.'" value="'.$value.'" class="email_address" />';
376 376
 				break;
377 377
 			// Phone Number
378 378
 			case 'tel' :
379
-				$buff[] = '<input type="text" name="' . $column_name . '[]" value="' . $value[0] . '" size="4" maxlength="4" class="tel" />';
380
-				$buff[] = '<input type="text" name="' . $column_name . '[]" value="' . $value[1] . '" size="4" maxlength="4" class="tel" />';
381
-				$buff[] = '<input type="text" name="' . $column_name . '[]" value="' . $value[2] . '" size="4" maxlength="4" class="tel" />';
379
+				$buff[] = '<input type="text" name="'.$column_name.'[]" value="'.$value[0].'" size="4" maxlength="4" class="tel" />';
380
+				$buff[] = '<input type="text" name="'.$column_name.'[]" value="'.$value[1].'" size="4" maxlength="4" class="tel" />';
381
+				$buff[] = '<input type="text" name="'.$column_name.'[]" value="'.$value[2].'" size="4" maxlength="4" class="tel" />';
382 382
 				break;
383 383
 			// textarea
384 384
 			case 'textarea' :
385
-				$buff[] = '<textarea name="' . $column_name . '" rows="8" cols="42">' . $value . '</textarea>';
385
+				$buff[] = '<textarea name="'.$column_name.'" rows="8" cols="42">'.$value.'</textarea>';
386 386
 				break;
387 387
 			// multiple choice
388 388
 			case 'checkbox' :
389 389
 				$buff[] = '<ul>';
390
-				foreach($default as $v)
390
+				foreach ($default as $v)
391 391
 				{
392 392
 					$checked = '';
393
-					if($value && in_array(trim($v), $value))
393
+					if ($value && in_array(trim($v), $value))
394 394
 					{
395 395
 						$checked = ' checked="checked"';
396 396
 					}
397 397
 
398 398
 					// Temporary ID for labeling
399
-					$tmp_id = $column_name . '-' . $id_num++;
399
+					$tmp_id = $column_name.'-'.$id_num++;
400 400
 
401
-					$buff[] ='  <li><input type="checkbox" name="' . $column_name . '[]" id="' . $tmp_id . '" value="' . htmlspecialchars($v, ENT_COMPAT | ENT_HTML401, 'UTF-8', false) . '" ' . $checked . ' /><label for="' . $tmp_id . '">' . $v . '</label></li>';
401
+					$buff[] = '  <li><input type="checkbox" name="'.$column_name.'[]" id="'.$tmp_id.'" value="'.htmlspecialchars($v, ENT_COMPAT | ENT_HTML401, 'UTF-8', false).'" '.$checked.' /><label for="'.$tmp_id.'">'.$v.'</label></li>';
402 402
 				}
403 403
 				$buff[] = '</ul>';
404 404
 				break;
405 405
 			// single choice
406 406
 			case 'select' :
407
-				$buff[] = '<select name="' . $column_name . '" class="select">';
408
-				foreach($default as $v)
407
+				$buff[] = '<select name="'.$column_name.'" class="select">';
408
+				foreach ($default as $v)
409 409
 				{
410 410
 					$selected = '';
411
-					if($value && in_array(trim($v), $value))
411
+					if ($value && in_array(trim($v), $value))
412 412
 					{
413 413
 						$selected = ' selected="selected"';
414 414
 					}
415
-					$buff[] = '  <option value="' . $v . '" ' . $selected . '>' . $v . '</option>';
415
+					$buff[] = '  <option value="'.$v.'" '.$selected.'>'.$v.'</option>';
416 416
 				}
417 417
 				$buff[] = '</select>';
418 418
 				break;
419 419
 			// radio
420 420
 			case 'radio' :
421 421
 				$buff[] = '<ul>';
422
-				foreach($default as $v)
422
+				foreach ($default as $v)
423 423
 				{
424 424
 					$checked = '';
425
-					if($value && in_array(trim($v), $value))
425
+					if ($value && in_array(trim($v), $value))
426 426
 					{
427 427
 						$checked = ' checked="checked"';
428 428
 					}
429 429
 
430 430
 					// Temporary ID for labeling
431
-					$tmp_id = $column_name . '-' . $id_num++;
431
+					$tmp_id = $column_name.'-'.$id_num++;
432 432
 
433
-					$buff[] = '<li><input type="radio" name="' . $column_name . '" id="' . $tmp_id . '" ' . $checked . ' value="' . $v . '"  class="radio" /><label for="' . $tmp_id . '">' . $v . '</label></li>';
433
+					$buff[] = '<li><input type="radio" name="'.$column_name.'" id="'.$tmp_id.'" '.$checked.' value="'.$v.'"  class="radio" /><label for="'.$tmp_id.'">'.$v.'</label></li>';
434 434
 				}
435 435
 				$buff[] = '</ul>';
436 436
 				break;
@@ -439,44 +439,44 @@  discard block
 block discarded – undo
439 439
 				// datepicker javascript plugin load
440 440
 				Context::loadJavascriptPlugin('ui.datepicker');
441 441
 
442
-				$buff[] = '<input type="hidden" name="' . $column_name . '" value="' . $value . '" />'; 
443
-				$buff[] =	'<input type="text" id="date_' . $column_name . '" value="' . zdate($value, 'Y-m-d') . '" class="date" />';
444
-				$buff[] =	'<input type="button" value="' . Context::getLang('cmd_delete') . '" class="btn" id="dateRemover_' . $column_name . '" />';
445
-				$buff[] =	'<script type="text/javascript">';
442
+				$buff[] = '<input type="hidden" name="'.$column_name.'" value="'.$value.'" />'; 
443
+				$buff[] = '<input type="text" id="date_'.$column_name.'" value="'.zdate($value, 'Y-m-d').'" class="date" />';
444
+				$buff[] = '<input type="button" value="'.Context::getLang('cmd_delete').'" class="btn" id="dateRemover_'.$column_name.'" />';
445
+				$buff[] = '<script type="text/javascript">';
446 446
 				$buff[] = '//<![CDATA[';
447
-				$buff[] =	'(function($){';
448
-				$buff[] =	'$(function(){';
449
-				$buff[] =	'  var option = { dateFormat: "yy-mm-dd", changeMonth:true, changeYear:true, gotoCurrent:false, yearRange:\'-100:+10\', onSelect:function(){';
450
-				$buff[] =	'    $(this).prev(\'input[type="hidden"]\').val(this.value.replace(/-/g,""))}';
451
-				$buff[] =	'  };';
452
-				$buff[] =	'  $.extend(option,$.datepicker.regional[\'' . Context::getLangType() . '\']);';
453
-				$buff[] =	'  $("#date_' . $column_name . '").datepicker(option);';
454
-				$buff[] =	'  $("#date_' . $column_name . '").datepicker("option", "dateFormat", "yy-mm-dd");';
455
-				$buff[] =	'  $("#dateRemover_' . $column_name . '").click(function(){';
456
-				$buff[] =	'    $(this).siblings("input").val("");';
457
-				$buff[] =	'    return false;';
458
-				$buff[] =	'  })';
459
-				$buff[] =	'});';
460
-				$buff[] =	'})(jQuery);';
447
+				$buff[] = '(function($){';
448
+				$buff[] = '$(function(){';
449
+				$buff[] = '  var option = { dateFormat: "yy-mm-dd", changeMonth:true, changeYear:true, gotoCurrent:false, yearRange:\'-100:+10\', onSelect:function(){';
450
+				$buff[] = '    $(this).prev(\'input[type="hidden"]\').val(this.value.replace(/-/g,""))}';
451
+				$buff[] = '  };';
452
+				$buff[] = '  $.extend(option,$.datepicker.regional[\''.Context::getLangType().'\']);';
453
+				$buff[] = '  $("#date_'.$column_name.'").datepicker(option);';
454
+				$buff[] = '  $("#date_'.$column_name.'").datepicker("option", "dateFormat", "yy-mm-dd");';
455
+				$buff[] = '  $("#dateRemover_'.$column_name.'").click(function(){';
456
+				$buff[] = '    $(this).siblings("input").val("");';
457
+				$buff[] = '    return false;';
458
+				$buff[] = '  })';
459
+				$buff[] = '});';
460
+				$buff[] = '})(jQuery);';
461 461
 				$buff[] = '//]]>';
462 462
 				$buff[] = '</script>';
463 463
 				break;
464 464
 			// address
465 465
 			case "kr_zip" :
466
-				if(($oKrzipModel = getModel('krzip')) && method_exists($oKrzipModel , 'getKrzipCodeSearchHtml' ))
466
+				if (($oKrzipModel = getModel('krzip')) && method_exists($oKrzipModel, 'getKrzipCodeSearchHtml'))
467 467
 				{
468
-					$buff[] =  $oKrzipModel->getKrzipCodeSearchHtml($column_name, $value);
468
+					$buff[] = $oKrzipModel->getKrzipCodeSearchHtml($column_name, $value);
469 469
 				}
470 470
 				break;
471 471
 			// General text
472 472
 			default :
473
-				$buff[] =' <input type="text" name="' . $column_name . '" value="' . ($value ? $value : $default) . '" class="text" />';
473
+				$buff[] = ' <input type="text" name="'.$column_name.'" value="'.($value ? $value : $default).'" class="text" />';
474 474
 		}
475
-		if($this->desc)
475
+		if ($this->desc)
476 476
 		{
477 477
 			$oModuleController = getController('module');
478 478
 			$oModuleController->replaceDefinedLangCode($this->desc);
479
-			$buff[] = '<p>' . htmlspecialchars($this->desc, ENT_COMPAT | ENT_HTML401, 'UTF-8', false) . '</p>';
479
+			$buff[] = '<p>'.htmlspecialchars($this->desc, ENT_COMPAT | ENT_HTML401, 'UTF-8', false).'</p>';
480 480
 		}
481 481
 		
482 482
 		return join(PHP_EOL, $buff);
Please login to merge, or discard this patch.
modules/document/document.item.php 2 patches
Spacing   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	function _loadFromDB($load_extra_vars = true)
81 81
 	{
82
-		if(!$this->document_srl) return;
82
+		if (!$this->document_srl) return;
83 83
 
84 84
 		$document_item = false;
85 85
 		$cache_put = false;
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
 
89 89
 		// cache controll
90 90
 		$oCacheHandler = CacheHandler::getInstance('object');
91
-		if($oCacheHandler->isSupport())
91
+		if ($oCacheHandler->isSupport())
92 92
 		{
93
-			$cache_key = 'document_item:' . getNumberingPath($this->document_srl) . $this->document_srl;
93
+			$cache_key = 'document_item:'.getNumberingPath($this->document_srl).$this->document_srl;
94 94
 			$document_item = $oCacheHandler->get($cache_key);
95
-			if($document_item !== false)
95
+			if ($document_item !== false)
96 96
 			{
97 97
 				$columnList = array('readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count');
98 98
 			}
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
 		$args->document_srl = $this->document_srl;
103 103
 		$output = executeQuery('document.getDocument', $args, $columnList);
104 104
 
105
-		if($document_item === false)
105
+		if ($document_item === false)
106 106
 		{
107 107
 			$document_item = $output->data;
108 108
 
109 109
 				//insert in cache
110
-			if($document_item && $oCacheHandler->isSupport())
110
+			if ($document_item && $oCacheHandler->isSupport())
111 111
 			{
112 112
 				$oCacheHandler->put($cache_key, $document_item);
113 113
 			}
@@ -124,9 +124,9 @@  discard block
 block discarded – undo
124 124
 		$this->setAttribute($document_item, $load_extra_vars);
125 125
 	}
126 126
 
127
-	function setAttribute($attribute, $load_extra_vars=true)
127
+	function setAttribute($attribute, $load_extra_vars = true)
128 128
 	{
129
-		if(!$attribute->document_srl)
129
+		if (!$attribute->document_srl)
130 130
 		{
131 131
 			$this->document_srl = null;
132 132
 			return;
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		$this->adds($attribute);
137 137
 
138 138
 		// Tags
139
-		if($this->get('tags'))
139
+		if ($this->get('tags'))
140 140
 		{
141 141
 			$tag_list = explode(',', $this->get('tags'));
142 142
 			$tag_list = array_map('trim', $tag_list);
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		}
145 145
 
146 146
 		$oDocumentModel = getModel('document');
147
-		if($load_extra_vars)
147
+		if ($load_extra_vars)
148 148
 		{
149 149
 			$GLOBALS['XE_DOCUMENT_LIST'][$attribute->document_srl] = $this;
150 150
 			$oDocumentModel->setToAllDocumentExtraVars();
@@ -159,23 +159,23 @@  discard block
 block discarded – undo
159 159
 
160 160
 	function isGranted()
161 161
 	{
162
-		if($_SESSION['own_document'][$this->document_srl]) return $this->grant_cache = true;
162
+		if ($_SESSION['own_document'][$this->document_srl]) return $this->grant_cache = true;
163 163
 
164
-		if($this->grant_cache !== null)
164
+		if ($this->grant_cache !== null)
165 165
 		{
166 166
 			return $this->grant_cache;
167 167
 		}
168 168
 
169
-		if(!Context::get('is_logged')) return $this->grant_cache = false;
169
+		if (!Context::get('is_logged')) return $this->grant_cache = false;
170 170
 
171 171
 		$logged_info = Context::get('logged_info');
172
-		if($logged_info->is_admin == 'Y') return $this->grant_cache = true;
172
+		if ($logged_info->is_admin == 'Y') return $this->grant_cache = true;
173 173
 
174 174
 		$oModuleModel = getModel('module');
175 175
 		$grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info);
176
-		if($grant->manager) return $this->grant_cache = true;
176
+		if ($grant->manager) return $this->grant_cache = true;
177 177
 
178
-		if($this->get('member_srl') && abs($this->get('member_srl')) == $logged_info->member_srl)
178
+		if ($this->get('member_srl') && abs($this->get('member_srl')) == $logged_info->member_srl)
179 179
 		{
180 180
 			return $this->grant_cache = true;
181 181
 		}
@@ -191,13 +191,13 @@  discard block
 block discarded – undo
191 191
 
192 192
 	function isAccessible()
193 193
 	{
194
-		return $_SESSION['accessible'][$this->document_srl]==true?true:false;
194
+		return $_SESSION['accessible'][$this->document_srl] == true ?true:false;
195 195
 	}
196 196
 
197 197
 	function allowComment()
198 198
 	{
199 199
 		// init write, document is not exists. so allow comment status is true
200
-		if(!$this->isExists()) return true;
200
+		if (!$this->isExists()) return true;
201 201
 
202 202
 		return $this->get('comment_status') == 'ALLOW' ? true : false;
203 203
 	}
@@ -205,11 +205,11 @@  discard block
 block discarded – undo
205 205
 	function allowTrackback()
206 206
 	{
207 207
 		static $allow_trackback_status = null;
208
-		if(is_null($allow_trackback_status))
208
+		if (is_null($allow_trackback_status))
209 209
 		{
210 210
 			
211 211
 			// Check the tarckback module exist
212
-			if(!getClass('trackback'))
212
+			if (!getClass('trackback'))
213 213
 			{
214 214
 				$allow_trackback_status = false;
215 215
 			}
@@ -219,20 +219,20 @@  discard block
 block discarded – undo
219 219
 				$oModuleModel = getModel('module');
220 220
 				$trackback_config = $oModuleModel->getModuleConfig('trackback');
221 221
 				
222
-				if(!$trackback_config)
222
+				if (!$trackback_config)
223 223
 				{
224 224
 					$trackback_config = new stdClass();
225 225
 				}
226 226
 				
227
-				if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y';
228
-				if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false;
227
+				if (!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y';
228
+				if ($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false;
229 229
 				else
230 230
 				{
231 231
 					$module_srl = $this->get('module_srl');
232 232
 					// Check settings of each module
233 233
 					$module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl);
234
-					if($module_config->enable_trackback == 'N') $allow_trackback_status = false;
235
-					else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true;
234
+					if ($module_config->enable_trackback == 'N') $allow_trackback_status = false;
235
+					else if ($this->get('allow_trackback') == 'Y' || !$this->isExists()) $allow_trackback_status = true;
236 236
 				}
237 237
 			}
238 238
 		}
@@ -241,14 +241,14 @@  discard block
 block discarded – undo
241 241
 
242 242
 	function isLocked()
243 243
 	{
244
-		if(!$this->isExists()) return false;
244
+		if (!$this->isExists()) return false;
245 245
 
246 246
 		return $this->get('comment_status') == 'ALLOW' ? false : true;
247 247
 	}
248 248
 
249 249
 	function isEditable()
250 250
 	{
251
-		if($this->isGranted() || !$this->get('member_srl')) return true;
251
+		if ($this->isGranted() || !$this->get('member_srl')) return true;
252 252
 		return false;
253 253
 	}
254 254
 
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
 
266 266
 	function useNotify()
267 267
 	{
268
-		return $this->get('notify_message')=='Y' ? true : false;
268
+		return $this->get('notify_message') == 'Y' ? true : false;
269 269
 	}
270 270
 
271 271
 	function doCart()
272 272
 	{
273
-		if(!$this->document_srl) return false;
274
-		if($this->isCarted()) $this->removeCart();
273
+		if (!$this->document_srl) return false;
274
+		if ($this->isCarted()) $this->removeCart();
275 275
 		else $this->addCart();
276 276
 	}
277 277
 
@@ -298,18 +298,18 @@  discard block
 block discarded – undo
298 298
 	 */
299 299
 	function notify($type, $content)
300 300
 	{
301
-		if(!$this->document_srl) return;
301
+		if (!$this->document_srl) return;
302 302
 		// return if it is not useNotify
303
-		if(!$this->useNotify()) return;
303
+		if (!$this->useNotify()) return;
304 304
 		// Pass if an author is not a logged-in user
305
-		if(!$this->get('member_srl')) return;
305
+		if (!$this->get('member_srl')) return;
306 306
 		// Return if the currently logged-in user is an author
307 307
 		$logged_info = Context::get('logged_info');
308
-		if($logged_info->member_srl == $this->get('member_srl')) return;
308
+		if ($logged_info->member_srl == $this->get('member_srl')) return;
309 309
 		// List variables
310
-		if($type) $title = "[".$type."] ";
310
+		if ($type) $title = "[".$type."] ";
311 311
 		$title .= cut_str(strip_tags($content), 10, '...');
312
-		$content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>',$content, getFullUrl('','document_srl',$this->document_srl), getFullUrl('','document_srl',$this->document_srl));
312
+		$content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>', $content, getFullUrl('', 'document_srl', $this->document_srl), getFullUrl('', 'document_srl', $this->document_srl));
313 313
 		$receiver_srl = $this->get('member_srl');
314 314
 		$sender_member_srl = $logged_info->member_srl;
315 315
 		// Send a message
@@ -324,26 +324,26 @@  discard block
 block discarded – undo
324 324
 
325 325
 	function getIpAddress()
326 326
 	{
327
-		if($this->isGranted())
327
+		if ($this->isGranted())
328 328
 		{
329 329
 			return $this->get('ipaddress');
330 330
 		}
331 331
 
332
-		return '*' . strstr($this->get('ipaddress'), '.');
332
+		return '*'.strstr($this->get('ipaddress'), '.');
333 333
 	}
334 334
 
335 335
 	function isExistsHomepage()
336 336
 	{
337
-		if(trim($this->get('homepage'))) return true;
337
+		if (trim($this->get('homepage'))) return true;
338 338
 		return false;
339 339
 	}
340 340
 
341 341
 	function getHomepageUrl()
342 342
 	{
343 343
 		$url = trim($this->get('homepage'));
344
-		if(!$url) return;
344
+		if (!$url) return;
345 345
 
346
-		if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0)  $url = 'http://' . $url;
346
+		if (strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0)  $url = 'http://'.$url;
347 347
 
348 348
 		return escape($url, false);
349 349
 	}
@@ -373,52 +373,52 @@  discard block
 block discarded – undo
373 373
 		return htmlspecialchars($this->get('last_updater'), ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
374 374
 	}
375 375
 
376
-	function getTitleText($cut_size = 0, $tail='...')
376
+	function getTitleText($cut_size = 0, $tail = '...')
377 377
 	{
378
-		if(!$this->document_srl) return;
378
+		if (!$this->document_srl) return;
379 379
 
380
-		if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail);
380
+		if ($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail);
381 381
 		else $title = $this->get('title');
382 382
 
383 383
 		return $title;
384 384
 	}
385 385
 
386
-	function getTitle($cut_size = 0, $tail='...')
386
+	function getTitle($cut_size = 0, $tail = '...')
387 387
 	{
388
-		if(!$this->document_srl) return;
388
+		if (!$this->document_srl) return;
389 389
 
390 390
 		$title = $this->getTitleText($cut_size, $tail);
391 391
 
392 392
 		$attrs = array();
393 393
 		$this->add('title_color', trim($this->get('title_color')));
394
-		if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;";
395
-		if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color');
394
+		if ($this->get('title_bold') == 'Y') $attrs[] = "font-weight:bold;";
395
+		if ($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color');
396 396
 
397
-		if(count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
397
+		if (count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';', $attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
398 398
 		else return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
399 399
 	}
400 400
 
401 401
 	function getContentText($strlen = 0)
402 402
 	{
403
-		if(!$this->document_srl) return;
403
+		if (!$this->document_srl) return;
404 404
 
405
-		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
405
+		if ($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
406 406
 
407 407
 		$result = $this->_checkAccessibleFromStatus();
408
-		if($result) $_SESSION['accessible'][$this->document_srl] = true;
408
+		if ($result) $_SESSION['accessible'][$this->document_srl] = true;
409 409
 
410 410
 		$content = $this->get('content');
411 411
 		$content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content);
412 412
 		$content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content);
413 413
 
414
-		if($strlen) return cut_str(strip_tags($content),$strlen,'...');
414
+		if ($strlen) return cut_str(strip_tags($content), $strlen, '...');
415 415
 
416 416
 		return htmlspecialchars($content);
417 417
 	}
418 418
 
419 419
 	function _addAllowScriptAccess($m)
420 420
 	{
421
-		if($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1)
421
+		if ($this->allowscriptaccessList[$this->allowscriptaccessKey] == 1)
422 422
 		{
423 423
 			$m[0] = $m[0].'<param name="allowscriptaccess" value="never"></param>';
424 424
 		}
@@ -428,26 +428,26 @@  discard block
 block discarded – undo
428 428
 
429 429
 	function _checkAllowScriptAccess($m)
430 430
 	{
431
-		if($m[1] == 'object')
431
+		if ($m[1] == 'object')
432 432
 		{
433 433
 			$this->allowscriptaccessList[] = 1;
434 434
 		}
435 435
 
436
-		if($m[1] == 'param')
436
+		if ($m[1] == 'param')
437 437
 		{
438
-			if(stripos($m[0], 'allowscriptaccess'))
438
+			if (stripos($m[0], 'allowscriptaccess'))
439 439
 			{
440 440
 				$m[0] = '<param name="allowscriptaccess" value="never"';
441
-				if(substr($m[0], -1) == '/')
441
+				if (substr($m[0], -1) == '/')
442 442
 				{
443 443
 					$m[0] .= '/';
444 444
 				}
445
-				$this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--;
445
+				$this->allowscriptaccessList[count($this->allowscriptaccessList) - 1]--;
446 446
 			}
447 447
 		}
448
-		else if($m[1] == 'embed')
448
+		else if ($m[1] == 'embed')
449 449
 		{
450
-			if(stripos($m[0], 'allowscriptaccess'))
450
+			if (stripos($m[0], 'allowscriptaccess'))
451 451
 			{
452 452
 				$m[0] = preg_replace('/always|samedomain/i', 'never', $m[0]);
453 453
 			}
@@ -461,24 +461,24 @@  discard block
 block discarded – undo
461 461
 
462 462
 	function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false)
463 463
 	{
464
-		if(!$this->document_srl) return;
464
+		if (!$this->document_srl) return;
465 465
 
466
-		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
466
+		if ($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
467 467
 
468 468
 		$result = $this->_checkAccessibleFromStatus();
469
-		if($result) $_SESSION['accessible'][$this->document_srl] = true;
469
+		if ($result) $_SESSION['accessible'][$this->document_srl] = true;
470 470
 
471 471
 		$content = $this->get('content');
472
-		if(!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl'));
472
+		if (!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl'));
473 473
 
474 474
 		// Define a link if using a rewrite module
475 475
 		$oContext = &Context::getInstance();
476
-		if($oContext->allow_rewrite)
476
+		if ($oContext->allow_rewrite)
477 477
 		{
478
-			$content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i',"<a href=\\2". Context::getRequestUri() ."?", $content);
478
+			$content = preg_replace('/<a([ \t]+)href=("|\')\.\/\?/i', "<a href=\\2".Context::getRequestUri()."?", $content);
479 479
 		}
480 480
 		// To display a pop-up menu
481
-		if($add_popup_menu)
481
+		if ($add_popup_menu)
482 482
 		{
483 483
 			$content = sprintf(
484 484
 				'%s<div class="document_popup_menu"><a href="#popup_menu_area" class="document_%d" onclick="return false">%s</a></div>',
@@ -487,10 +487,10 @@  discard block
 block discarded – undo
487 487
 			);
488 488
 		}
489 489
 		// If additional content information is set
490
-		if($add_content_info)
490
+		if ($add_content_info)
491 491
 		{
492 492
 			$memberSrl = $this->get('member_srl');
493
-			if($memberSrl < 0)
493
+			if ($memberSrl < 0)
494 494
 			{
495 495
 				$memberSrl = 0;
496 496
 			}
@@ -506,12 +506,12 @@  discard block
 block discarded – undo
506 506
 		}
507 507
 		else
508 508
 		{
509
-			if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content);
509
+			if ($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content);
510 510
 		}
511 511
 		// Change the image path to a valid absolute path if resource_realpath is true
512
-		if($resource_realpath)
512
+		if ($resource_realpath)
513 513
 		{
514
-			$content = preg_replace_callback('/<img([^>]+)>/i',array($this,'replaceResourceRealPath'), $content);
514
+			$content = preg_replace_callback('/<img([^>]+)>/i', array($this, 'replaceResourceRealPath'), $content);
515 515
 		}
516 516
 
517 517
 		return $content;
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 		$content = trim(cut_str($content, $str_size, $tail));
561 561
 
562 562
 		// Replace back < , <, "
563
-		$content = str_replace(array('<', '>', '"'),array('&lt;', '&gt;', '&quot;'), $content);
563
+		$content = str_replace(array('<', '>', '"'), array('&lt;', '&gt;', '&quot;'), $content);
564 564
 
565 565
 		return $content;
566 566
 	}
@@ -573,13 +573,13 @@  discard block
 block discarded – undo
573 573
 	function getRegdateTime()
574 574
 	{
575 575
 		$regdate = $this->get('regdate');
576
-		$year = substr($regdate,0,4);
577
-		$month = substr($regdate,4,2);
578
-		$day = substr($regdate,6,2);
579
-		$hour = substr($regdate,8,2);
580
-		$min = substr($regdate,10,2);
581
-		$sec = substr($regdate,12,2);
582
-		return mktime($hour,$min,$sec,$month,$day,$year);
576
+		$year = substr($regdate, 0, 4);
577
+		$month = substr($regdate, 4, 2);
578
+		$day = substr($regdate, 6, 2);
579
+		$hour = substr($regdate, 8, 2);
580
+		$min = substr($regdate, 10, 2);
581
+		$sec = substr($regdate, 12, 2);
582
+		return mktime($hour, $min, $sec, $month, $day, $year);
583 583
 	}
584 584
 
585 585
 	function getRegdateGM()
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 
590 590
 	function getRegdateDT()
591 591
 	{
592
-		return $this->getRegdate('Y-m-d').'T'.$this->getRegdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2);
592
+		return $this->getRegdate('Y-m-d').'T'.$this->getRegdate('H:i:s').substr($GLOBALS['_time_zone'], 0, 3).':'.substr($GLOBALS['_time_zone'], 3, 2);
593 593
 	}
594 594
 
595 595
 	function getUpdate($format = 'Y.m.d H:i:s')
@@ -599,13 +599,13 @@  discard block
 block discarded – undo
599 599
 
600 600
 	function getUpdateTime()
601 601
 	{
602
-		$year = substr($this->get('last_update'),0,4);
603
-		$month = substr($this->get('last_update'),4,2);
604
-		$day = substr($this->get('last_update'),6,2);
605
-		$hour = substr($this->get('last_update'),8,2);
606
-		$min = substr($this->get('last_update'),10,2);
607
-		$sec = substr($this->get('last_update'),12,2);
608
-		return mktime($hour,$min,$sec,$month,$day,$year);
602
+		$year = substr($this->get('last_update'), 0, 4);
603
+		$month = substr($this->get('last_update'), 4, 2);
604
+		$day = substr($this->get('last_update'), 6, 2);
605
+		$hour = substr($this->get('last_update'), 8, 2);
606
+		$min = substr($this->get('last_update'), 10, 2);
607
+		$sec = substr($this->get('last_update'), 12, 2);
608
+		return mktime($hour, $min, $sec, $month, $day, $year);
609 609
 	}
610 610
 
611 611
 	function getUpdateGM()
@@ -615,21 +615,21 @@  discard block
 block discarded – undo
615 615
 
616 616
 	function getUpdateDT()
617 617
 	{
618
-		return $this->getUpdate('Y-m-d').'T'.$this->getUpdate('H:i:s').substr($GLOBALS['_time_zone'],0,3).':'.substr($GLOBALS['_time_zone'],3,2);
618
+		return $this->getUpdate('Y-m-d').'T'.$this->getUpdate('H:i:s').substr($GLOBALS['_time_zone'], 0, 3).':'.substr($GLOBALS['_time_zone'], 3, 2);
619 619
 	}
620 620
 
621 621
 	function getPermanentUrl()
622 622
 	{
623
-		return getFullUrl('','mid', $this->getDocumentMid('document_srl'), 'document_srl', $this->get('document_srl'));
623
+		return getFullUrl('', 'mid', $this->getDocumentMid('document_srl'), 'document_srl', $this->get('document_srl'));
624 624
 	}
625 625
 
626 626
 	function getTrackbackUrl()
627 627
 	{
628
-		if(!$this->document_srl) return;
628
+		if (!$this->document_srl) return;
629 629
 
630 630
 		// Generate a key to prevent spams
631 631
 		$oTrackbackModel = getModel('trackback');
632
-		if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid());
632
+		if ($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid());
633 633
 	}
634 634
 
635 635
 	/**
@@ -639,24 +639,24 @@  discard block
 block discarded – undo
639 639
 	function updateReadedCount()
640 640
 	{
641 641
 		$oDocumentController = getController('document');
642
-		if($oDocumentController->updateReadedCount($this))
642
+		if ($oDocumentController->updateReadedCount($this))
643 643
 		{
644 644
 			$readed_count = $this->get('readed_count');
645
-			$this->add('readed_count', $readed_count+1);
645
+			$this->add('readed_count', $readed_count + 1);
646 646
 		}
647 647
 	}
648 648
 
649 649
 	function isExtraVarsExists()
650 650
 	{
651
-		if(!$this->get('module_srl')) return false;
651
+		if (!$this->get('module_srl')) return false;
652 652
 		$oDocumentModel = getModel('document');
653 653
 		$extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl'));
654
-		return count($extra_keys)?true:false;
654
+		return count($extra_keys) ?true:false;
655 655
 	}
656 656
 
657 657
 	function getExtraVars()
658 658
 	{
659
-		if(!$this->get('module_srl') || !$this->document_srl) return null;
659
+		if (!$this->get('module_srl') || !$this->document_srl) return null;
660 660
 
661 661
 		$oDocumentModel = getModel('document');
662 662
 		return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl);
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 	function getExtraValue($idx)
666 666
 	{
667 667
 		$extra_vars = $this->getExtraVars();
668
-		if(is_array($extra_vars) && array_key_exists($idx,$extra_vars))
668
+		if (is_array($extra_vars) && array_key_exists($idx, $extra_vars))
669 669
 		{
670 670
 			return $extra_vars[$idx]->getValue();
671 671
 		}
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 	function getExtraValueHTML($idx)
679 679
 	{
680 680
 		$extra_vars = $this->getExtraVars();
681
-		if(is_array($extra_vars) && array_key_exists($idx,$extra_vars))
681
+		if (is_array($extra_vars) && array_key_exists($idx, $extra_vars))
682 682
 		{
683 683
 			return $extra_vars[$idx]->getValueHTML();
684 684
 		}
@@ -692,16 +692,16 @@  discard block
 block discarded – undo
692 692
 	{
693 693
 		$extra_vars = $this->getExtraVars();
694 694
 
695
-		if($extra_vars)
695
+		if ($extra_vars)
696 696
 		{
697 697
 			// Handle extra variable(eid)
698
-			foreach($extra_vars as $idx => $key)
698
+			foreach ($extra_vars as $idx => $key)
699 699
 			{
700 700
 				$extra_eid[$key->eid] = $key;
701 701
 			}
702 702
 		}
703 703
 		
704
-		if(is_array($extra_eid) && array_key_exists($eid,$extra_eid))
704
+		if (is_array($extra_eid) && array_key_exists($eid, $extra_eid))
705 705
 		{
706 706
 			return $extra_eid[$eid]->getValue();
707 707
 		}
@@ -715,12 +715,12 @@  discard block
 block discarded – undo
715 715
 	{
716 716
 		$extra_vars = $this->getExtraVars();
717 717
 		// Handle extra variable(eid)
718
-		foreach($extra_vars as $idx => $key)
718
+		foreach ($extra_vars as $idx => $key)
719 719
 		{
720 720
 			$extra_eid[$key->eid] = $key;
721 721
 		}
722 722
 		
723
-		if(is_array($extra_eid) && array_key_exists($eid,$extra_eid))
723
+		if (is_array($extra_eid) && array_key_exists($eid, $extra_eid))
724 724
 		{
725 725
 			return $extra_eid[$eid]->getValueHTML();
726 726
 		}
@@ -744,13 +744,13 @@  discard block
 block discarded – undo
744 744
 
745 745
 	function getComments()
746 746
 	{
747
-		if(!$this->getCommentCount()) return;
748
-		if(!$this->isGranted() && $this->isSecret()) return;
747
+		if (!$this->getCommentCount()) return;
748
+		if (!$this->isGranted() && $this->isSecret()) return;
749 749
 		// cpage is a number of comment pages
750 750
 		$cpageStr = sprintf('%d_cpage', $this->document_srl);
751 751
 		$cpage = Context::get($cpageStr);
752 752
 
753
-		if(!$cpage)
753
+		if (!$cpage)
754 754
 		{
755 755
 			$cpage = Context::get('cpage');
756 756
 		}
@@ -758,19 +758,19 @@  discard block
 block discarded – undo
758 758
 		// Get a list of comments
759 759
 		$oCommentModel = getModel('comment');
760 760
 		$output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin);
761
-		if(!$output->toBool() || !count($output->data)) return;
761
+		if (!$output->toBool() || !count($output->data)) return;
762 762
 		// Create commentItem object from a comment list
763 763
 		// If admin priviledge is granted on parent posts, you can read its child posts.
764 764
 		$accessible = array();
765 765
 		$comment_list = array();
766
-		foreach($output->data as $key => $val)
766
+		foreach ($output->data as $key => $val)
767 767
 		{
768 768
 			$oCommentItem = new commentItem();
769 769
 			$oCommentItem->setAttribute($val);
770 770
 			// If permission is granted to the post, you can access it temporarily
771
-			if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true;
771
+			if ($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true;
772 772
 			// If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post
773
-			if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true)
773
+			if ($val->parent_srl > 0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl] === true)
774 774
 			{
775 775
 				$oCommentItem->setAccessible();
776 776
 			}
@@ -779,7 +779,7 @@  discard block
 block discarded – undo
779 779
 		// Variable setting to be displayed on the skin
780 780
 		Context::set($cpageStr, $output->page_navigation->cur_page);
781 781
 		Context::set('cpage', $output->page_navigation->cur_page);
782
-		if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation;
782
+		if ($output->total_page > 1) $this->comment_page_navigation = $output->page_navigation;
783 783
 
784 784
 		// Call trigger (after)
785 785
 		$output = ModuleHandler::triggerCall('document.getComments', 'after', $comment_list);
@@ -794,9 +794,9 @@  discard block
 block discarded – undo
794 794
 
795 795
 	function getTrackbacks()
796 796
 	{
797
-		if(!$this->document_srl) return;
797
+		if (!$this->document_srl) return;
798 798
 
799
-		if(!$this->allowTrackback() || !$this->get('trackback_count')) return;
799
+		if (!$this->allowTrackback() || !$this->get('trackback_count')) return;
800 800
 
801 801
 		$oTrackbackModel = getModel('trackback');
802 802
 		return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin);
@@ -804,47 +804,47 @@  discard block
 block discarded – undo
804 804
 
805 805
 	function thumbnailExists($width = 80, $height = 0, $type = '')
806 806
 	{
807
-		if(!$this->document_srl) return false;
808
-		if(!$this->getThumbnail($width, $height, $type)) return false;
807
+		if (!$this->document_srl) return false;
808
+		if (!$this->getThumbnail($width, $height, $type)) return false;
809 809
 		return true;
810 810
 	}
811 811
 
812 812
 	function getThumbnail($width = 80, $height = 0, $thumbnail_type = '')
813 813
 	{
814 814
 		// Return false if the document doesn't exist
815
-		if(!$this->document_srl) return;
815
+		if (!$this->document_srl) return;
816 816
 
817
-		if($this->isSecret() && !$this->isGranted())
817
+		if ($this->isSecret() && !$this->isGranted())
818 818
 		{
819 819
 			return;
820 820
 		}
821 821
 
822 822
 		// If not specify its height, create a square
823
-		if(!$height) $height = $width;
823
+		if (!$height) $height = $width;
824 824
 
825 825
 		// Return false if neither attachement nor image files in the document
826 826
 		$content = $this->get('content');
827
-		if(!$this->get('uploaded_count'))
827
+		if (!$this->get('uploaded_count'))
828 828
 		{
829
-			if(!$content)
829
+			if (!$content)
830 830
 			{
831 831
 				$args = new stdClass();
832 832
 				$args->document_srl = $this->document_srl;
833 833
 				$output = executeQuery('document.getDocument', $args, array('content'));
834
-				if($output->toBool() && $output->data)
834
+				if ($output->toBool() && $output->data)
835 835
 				{
836 836
 					$content = $output->data->content;
837 837
 					$this->add('content', $content);
838 838
 				}
839 839
 			}
840 840
 
841
-			if(!preg_match("!<img!is", $content)) return;
841
+			if (!preg_match("!<img!is", $content)) return;
842 842
 		}
843 843
 		// Get thumbnai_type information from document module's configuration
844
-		if(!in_array($thumbnail_type, array('crop','ratio')))
844
+		if (!in_array($thumbnail_type, array('crop', 'ratio')))
845 845
 		{
846 846
 			$config = $GLOBALS['__document_config__'];
847
-			if(!$config)
847
+			if (!$config)
848 848
 			{
849 849
 				$oDocumentModel = getModel('document');
850 850
 				$config = $oDocumentModel->getDocumentConfig();
@@ -854,21 +854,21 @@  discard block
 block discarded – undo
854 854
 		}
855 855
 
856 856
 		// Define thumbnail information
857
-		$thumbnail_path = sprintf('files/thumbnails/%s',getNumberingPath($this->document_srl, 3));
857
+		$thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($this->document_srl, 3));
858 858
 		$thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type);
859 859
 		$thumbnail_lockfile = sprintf('%s%dx%d.%s.lock', $thumbnail_path, $width, $height, $thumbnail_type);
860 860
 		$thumbnail_url  = Context::getRequestUri().$thumbnail_file;
861 861
 
862 862
 		// Return false if thumbnail file exists and its size is 0. Otherwise, return its path
863
-		if(file_exists($thumbnail_file) || file_exists($thumbnail_lockfile))
863
+		if (file_exists($thumbnail_file) || file_exists($thumbnail_lockfile))
864 864
 		{
865
-			if(filesize($thumbnail_file) < 1)
865
+			if (filesize($thumbnail_file) < 1)
866 866
 			{
867 867
 				return FALSE;
868 868
 			}
869 869
 			else
870 870
 			{
871
-				return $thumbnail_url . '?' . date('YmdHis', filemtime($thumbnail_file));
871
+				return $thumbnail_url.'?'.date('YmdHis', filemtime($thumbnail_file));
872 872
 			}
873 873
 		}
874 874
 
@@ -880,64 +880,64 @@  discard block
 block discarded – undo
880 880
 		$is_tmp_file = false;
881 881
 
882 882
 		// Find an iamge file among attached files if exists
883
-		if($this->hasUploadedFiles())
883
+		if ($this->hasUploadedFiles())
884 884
 		{
885 885
 			$file_list = $this->getUploadedFiles();
886 886
 
887 887
 			$first_image = null;
888
-			foreach($file_list as $file)
888
+			foreach ($file_list as $file)
889 889
 			{
890
-				if($file->direct_download !== 'Y') continue;
890
+				if ($file->direct_download !== 'Y') continue;
891 891
 
892
-				if($file->cover_image === 'Y' && file_exists($file->uploaded_filename))
892
+				if ($file->cover_image === 'Y' && file_exists($file->uploaded_filename))
893 893
 				{
894 894
 					$source_file = $file->uploaded_filename;
895 895
 					break;
896 896
 				}
897 897
 
898
-				if($first_image) continue;
898
+				if ($first_image) continue;
899 899
 
900
-				if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename))
900
+				if (preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename))
901 901
 				{
902
-					if(file_exists($file->uploaded_filename))
902
+					if (file_exists($file->uploaded_filename))
903 903
 					{
904 904
 						$first_image = $file->uploaded_filename;
905 905
 					}
906 906
 				}
907 907
 			}
908 908
 
909
-			if(!$source_file && $first_image)
909
+			if (!$source_file && $first_image)
910 910
 			{
911 911
 				$source_file = $first_image;
912 912
 			}
913 913
 		}
914 914
 		// If not exists, file an image file from the content
915 915
 		$is_tmp_file = false;
916
-		if(!$source_file)
916
+		if (!$source_file)
917 917
 		{
918 918
 			$random = new Password();
919 919
 
920 920
 			preg_match_all("!<img[^>]*src=(?:\"|\')([^\"\']*?)(?:\"|\')!is", $content, $matches, PREG_SET_ORDER);
921 921
 
922
-			foreach($matches as $target_image)
922
+			foreach ($matches as $target_image)
923 923
 			{
924 924
 				$target_src = trim($target_image[1]);
925
-				if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue;
925
+				if (preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue;
926 926
 
927
-				if(!preg_match('/^(http|https):\/\//i',$target_src))
927
+				if (!preg_match('/^(http|https):\/\//i', $target_src))
928 928
 				{
929 929
 					$target_src = Context::getRequestUri().$target_src;
930 930
 				}
931 931
 
932 932
 				$target_src = htmlspecialchars_decode($target_src);
933 933
 
934
-				$tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex');
934
+				$tmp_file = _XE_PATH_.'files/cache/tmp/'.$random->createSecureSalt(32, 'hex');
935 935
 				FileHandler::getRemoteFile($target_src, $tmp_file);
936
-				if(!file_exists($tmp_file)) continue;
936
+				if (!file_exists($tmp_file)) continue;
937 937
 
938 938
 				$imageinfo = getimagesize($tmp_file);
939 939
 				list($_w, $_h) = $imageinfo;
940
-				if($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) {
940
+				if ($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) {
941 941
 					FileHandler::removeFile($tmp_file);
942 942
 					continue;
943 943
 				}
@@ -948,13 +948,13 @@  discard block
 block discarded – undo
948 948
 			}
949 949
 		}
950 950
 
951
-		if($source_file)
951
+		if ($source_file)
952 952
 		{
953 953
 			$output_file = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type);
954 954
 		}
955 955
 
956 956
 		// Remove source file if it was temporary
957
-		if($is_tmp_file)
957
+		if ($is_tmp_file)
958 958
 		{
959 959
 			FileHandler::removeFile($source_file);
960 960
 		}
@@ -963,12 +963,12 @@  discard block
 block discarded – undo
963 963
 		FileHandler::removeFile($thumbnail_lockfile);
964 964
 
965 965
 		// Create an empty file if thumbnail generation failed
966
-		if(!$output_file)
966
+		if (!$output_file)
967 967
 		{
968
-			FileHandler::writeFile($thumbnail_file, '','w');
968
+			FileHandler::writeFile($thumbnail_file, '', 'w');
969 969
 		}
970 970
 
971
-		return $thumbnail_url . '?' . date('YmdHis', filemtime($thumbnail_file));
971
+		return $thumbnail_url.'?'.date('YmdHis', filemtime($thumbnail_file));
972 972
 	}
973 973
 
974 974
 	/**
@@ -979,21 +979,21 @@  discard block
 block discarded – undo
979 979
 	 */
980 980
 	function getExtraImages($time_interval = 43200)
981 981
 	{
982
-		if(!$this->document_srl) return;
982
+		if (!$this->document_srl) return;
983 983
 		// variables for icon list
984 984
 		$buffs = array();
985 985
 
986 986
 		$check_files = false;
987 987
 
988 988
 		// Check if secret post is
989
-		if($this->isSecret()) $buffs[] = "secret";
989
+		if ($this->isSecret()) $buffs[] = "secret";
990 990
 
991 991
 		// Set the latest time
992
-		$time_check = date("YmdHis", $_SERVER['REQUEST_TIME']-$time_interval);
992
+		$time_check = date("YmdHis", $_SERVER['REQUEST_TIME'] - $time_interval);
993 993
 
994 994
 		// Check new post
995
-		if($this->get('regdate')>$time_check) $buffs[] = "new";
996
-		else if($this->get('last_update')>$time_check) $buffs[] = "update";
995
+		if ($this->get('regdate') > $time_check) $buffs[] = "new";
996
+		else if ($this->get('last_update') > $time_check) $buffs[] = "update";
997 997
 
998 998
 		/*
999 999
 		   $content = $this->get('content');
@@ -1016,14 +1016,14 @@  discard block
 block discarded – undo
1016 1016
 		 */
1017 1017
 
1018 1018
 		// Check the attachment
1019
-		if($this->hasUploadedFiles()) $buffs[] = "file";
1019
+		if ($this->hasUploadedFiles()) $buffs[] = "file";
1020 1020
 
1021 1021
 		return $buffs;
1022 1022
 	}
1023 1023
 
1024 1024
 	function getStatus()
1025 1025
 	{
1026
-		if(!$this->get('status')) {
1026
+		if (!$this->get('status')) {
1027 1027
 			$oDocumentClass = getClass('document');
1028 1028
 			return $oDocumentClass->getDefaultStatus();
1029 1029
 		}
@@ -1037,11 +1037,11 @@  discard block
 block discarded – undo
1037 1037
 	 */
1038 1038
 	function printExtraImages($time_check = 43200)
1039 1039
 	{
1040
-		if(!$this->document_srl) return;
1040
+		if (!$this->document_srl) return;
1041 1041
 
1042 1042
 		$oDocumentModel = getModel('document');
1043 1043
 		$documentConfig = $oDocumentModel->getDocumentConfig();
1044
-		if(Mobile::isFromMobilePhone())
1044
+		if (Mobile::isFromMobilePhone())
1045 1045
 		{
1046 1046
 			$iconSkin = $documentConfig->micons;
1047 1047
 		}
@@ -1049,13 +1049,13 @@  discard block
 block discarded – undo
1049 1049
 		{
1050 1050
 			$iconSkin = $documentConfig->icons;
1051 1051
 		}
1052
-		$path = sprintf('%s%s',getUrl(), "modules/document/tpl/icons/$iconSkin/");
1052
+		$path = sprintf('%s%s', getUrl(), "modules/document/tpl/icons/$iconSkin/");
1053 1053
 
1054 1054
 		$buffs = $this->getExtraImages($time_check);
1055
-		if(!count($buffs)) return;
1055
+		if (!count($buffs)) return;
1056 1056
 
1057 1057
 		$buff = array();
1058
-		foreach($buffs as $key => $val)
1058
+		foreach ($buffs as $key => $val)
1059 1059
 		{
1060 1060
 			$buff[] = sprintf('<img src="%s%s.gif" alt="%s" title="%s" style="margin-right:2px;" />', $path, $val, $val, $val);
1061 1061
 		}
@@ -1064,20 +1064,20 @@  discard block
 block discarded – undo
1064 1064
 
1065 1065
 	function hasUploadedFiles()
1066 1066
 	{
1067
-		if(!$this->document_srl) return;
1067
+		if (!$this->document_srl) return;
1068 1068
 
1069
-		if($this->isSecret() && !$this->isGranted()) return false;
1070
-		return $this->get('uploaded_count')? true : false;
1069
+		if ($this->isSecret() && !$this->isGranted()) return false;
1070
+		return $this->get('uploaded_count') ? true : false;
1071 1071
 	}
1072 1072
 
1073 1073
 	function getUploadedFiles($sortIndex = 'file_srl')
1074 1074
 	{
1075
-		if(!$this->document_srl) return;
1075
+		if (!$this->document_srl) return;
1076 1076
 
1077
-		if($this->isSecret() && !$this->isGranted()) return;
1078
-		if(!$this->get('uploaded_count')) return;
1077
+		if ($this->isSecret() && !$this->isGranted()) return;
1078
+		if (!$this->get('uploaded_count')) return;
1079 1079
 
1080
-		if(!$this->uploadedFiles[$sortIndex])
1080
+		if (!$this->uploadedFiles[$sortIndex])
1081 1081
 		{
1082 1082
 			$oFileModel = getModel('file');
1083 1083
 			$this->uploadedFiles[$sortIndex] = $oFileModel->getFiles($this->document_srl, array(), $sortIndex, true);
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
 	function getEditor()
1094 1094
 	{
1095 1095
 		$module_srl = $this->get('module_srl');
1096
-		if(!$module_srl) $module_srl = Context::get('module_srl');
1096
+		if (!$module_srl) $module_srl = Context::get('module_srl');
1097 1097
 
1098 1098
 		$oEditorModel = getModel('editor');
1099 1099
 		return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content');
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
 	{
1109 1109
 		// Return false if not authorized, if a secret document, if the document is set not to allow any comment
1110 1110
 		if (!$this->allowComment()) return false;
1111
-		if(!$this->isGranted() && $this->isSecret()) return false;
1111
+		if (!$this->isGranted() && $this->isSecret()) return false;
1112 1112
 
1113 1113
 		return true;
1114 1114
 	}
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 	 */
1120 1120
 	function getCommentEditor()
1121 1121
 	{
1122
-		if(!$this->isEnableComment()) return;
1122
+		if (!$this->isEnableComment()) return;
1123 1123
 
1124 1124
 		$oEditorModel = getModel('editor');
1125 1125
 		return $oEditorModel->getModuleEditor('comment', $this->get('module_srl'), $comment_srl, 'comment_srl', 'content');
@@ -1131,10 +1131,10 @@  discard block
 block discarded – undo
1131 1131
 	 */
1132 1132
 	function getProfileImage()
1133 1133
 	{
1134
-		if(!$this->isExists() || !$this->get('member_srl')) return;
1134
+		if (!$this->isExists() || !$this->get('member_srl')) return;
1135 1135
 		$oMemberModel = getModel('member');
1136 1136
 		$profile_info = $oMemberModel->getProfileImage($this->get('member_srl'));
1137
-		if(!$profile_info) return;
1137
+		if (!$profile_info) return;
1138 1138
 
1139 1139
 		return $profile_info->src;
1140 1140
 	}
@@ -1146,21 +1146,21 @@  discard block
 block discarded – undo
1146 1146
 	function getSignature()
1147 1147
 	{
1148 1148
 		// Pass if a document doesn't exist
1149
-		if(!$this->isExists() || !$this->get('member_srl')) return;
1149
+		if (!$this->isExists() || !$this->get('member_srl')) return;
1150 1150
 		// Get signature information
1151 1151
 		$oMemberModel = getModel('member');
1152 1152
 		$signature = $oMemberModel->getSignature($this->get('member_srl'));
1153 1153
 		// Check if a maximum height of signiture is set in the member module
1154
-		if(!isset($GLOBALS['__member_signature_max_height']))
1154
+		if (!isset($GLOBALS['__member_signature_max_height']))
1155 1155
 		{
1156 1156
 			$oModuleModel = getModel('module');
1157 1157
 			$member_config = $oModuleModel->getModuleConfig('member');
1158 1158
 			$GLOBALS['__member_signature_max_height'] = $member_config->signature_max_height;
1159 1159
 		}
1160
-		if($signature)
1160
+		if ($signature)
1161 1161
 		{
1162 1162
 			$max_signature_height = $GLOBALS['__member_signature_max_height'];
1163
-			if($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature);
1163
+			if ($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature);
1164 1164
 		}
1165 1165
 
1166 1166
 		return $signature;
@@ -1173,7 +1173,7 @@  discard block
 block discarded – undo
1173 1173
 	 */
1174 1174
 	function replaceResourceRealPath($matches)
1175 1175
 	{
1176
-		return preg_replace('/src=(["\']?)files/i','src=$1'.Context::getRequestUri().'files', $matches[0]);
1176
+		return preg_replace('/src=(["\']?)files/i', 'src=$1'.Context::getRequestUri().'files', $matches[0]);
1177 1177
 	}
1178 1178
 
1179 1179
 	/**
@@ -1184,19 +1184,19 @@  discard block
 block discarded – undo
1184 1184
 	function _checkAccessibleFromStatus()
1185 1185
 	{
1186 1186
 		$logged_info = Context::get('logged_info');
1187
-		if($logged_info->is_admin == 'Y') return true;
1187
+		if ($logged_info->is_admin == 'Y') return true;
1188 1188
 
1189 1189
 		$status = $this->get('status');
1190
-		if(empty($status)) return false;
1190
+		if (empty($status)) return false;
1191 1191
 
1192 1192
 		$oDocumentModel = getModel('document');
1193 1193
 		$configStatusList = $oDocumentModel->getStatusList();
1194 1194
 
1195
-		if($status == $configStatusList['public'] || $status == $configStatusList['publish'])
1195
+		if ($status == $configStatusList['public'] || $status == $configStatusList['publish'])
1196 1196
 			return true;
1197
-		else if($status == $configStatusList['private'] || $status == $configStatusList['secret'])
1197
+		else if ($status == $configStatusList['private'] || $status == $configStatusList['secret'])
1198 1198
 		{
1199
-			if($this->get('member_srl') == $logged_info->member_srl)
1199
+			if ($this->get('member_srl') == $logged_info->member_srl)
1200 1200
 				return true;
1201 1201
 		}
1202 1202
 		return false;
Please login to merge, or discard this patch.
Braces   +258 added lines, -110 removed lines patch added patch discarded remove patch
@@ -79,7 +79,9 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	function _loadFromDB($load_extra_vars = true)
81 81
 	{
82
-		if(!$this->document_srl) return;
82
+		if(!$this->document_srl) {
83
+			return;
84
+		}
83 85
 
84 86
 		$document_item = false;
85 87
 		$cache_put = false;
@@ -111,8 +113,7 @@  discard block
 block discarded – undo
111 113
 			{
112 114
 				$oCacheHandler->put($cache_key, $document_item);
113 115
 			}
114
-		}
115
-		else
116
+		} else
116 117
 		{
117 118
 			$document_item->readed_count = $output->data->readed_count;
118 119
 			$document_item->voted_count = $output->data->voted_count;
@@ -159,21 +160,29 @@  discard block
 block discarded – undo
159 160
 
160 161
 	function isGranted()
161 162
 	{
162
-		if($_SESSION['own_document'][$this->document_srl]) return $this->grant_cache = true;
163
+		if($_SESSION['own_document'][$this->document_srl]) {
164
+			return $this->grant_cache = true;
165
+		}
163 166
 
164 167
 		if($this->grant_cache !== null)
165 168
 		{
166 169
 			return $this->grant_cache;
167 170
 		}
168 171
 
169
-		if(!Context::get('is_logged')) return $this->grant_cache = false;
172
+		if(!Context::get('is_logged')) {
173
+			return $this->grant_cache = false;
174
+		}
170 175
 
171 176
 		$logged_info = Context::get('logged_info');
172
-		if($logged_info->is_admin == 'Y') return $this->grant_cache = true;
177
+		if($logged_info->is_admin == 'Y') {
178
+			return $this->grant_cache = true;
179
+		}
173 180
 
174 181
 		$oModuleModel = getModel('module');
175 182
 		$grant = $oModuleModel->getGrant($oModuleModel->getModuleInfoByModuleSrl($this->get('module_srl')), $logged_info);
176
-		if($grant->manager) return $this->grant_cache = true;
183
+		if($grant->manager) {
184
+			return $this->grant_cache = true;
185
+		}
177 186
 
178 187
 		if($this->get('member_srl') && abs($this->get('member_srl')) == $logged_info->member_srl)
179 188
 		{
@@ -197,7 +206,9 @@  discard block
 block discarded – undo
197 206
 	function allowComment()
198 207
 	{
199 208
 		// init write, document is not exists. so allow comment status is true
200
-		if(!$this->isExists()) return true;
209
+		if(!$this->isExists()) {
210
+			return true;
211
+		}
201 212
 
202 213
 		return $this->get('comment_status') == 'ALLOW' ? true : false;
203 214
 	}
@@ -212,8 +223,7 @@  discard block
 block discarded – undo
212 223
 			if(!getClass('trackback'))
213 224
 			{
214 225
 				$allow_trackback_status = false;
215
-			}
216
-			else
226
+			} else
217 227
 			{
218 228
 				// If the trackback module is configured to be disabled, do not allow. Otherwise, check the setting of each module.
219 229
 				$oModuleModel = getModel('module');
@@ -224,15 +234,21 @@  discard block
 block discarded – undo
224 234
 					$trackback_config = new stdClass();
225 235
 				}
226 236
 				
227
-				if(!isset($trackback_config->enable_trackback)) $trackback_config->enable_trackback = 'Y';
228
-				if($trackback_config->enable_trackback != 'Y') $allow_trackback_status = false;
229
-				else
237
+				if(!isset($trackback_config->enable_trackback)) {
238
+					$trackback_config->enable_trackback = 'Y';
239
+				}
240
+				if($trackback_config->enable_trackback != 'Y') {
241
+					$allow_trackback_status = false;
242
+				} else
230 243
 				{
231 244
 					$module_srl = $this->get('module_srl');
232 245
 					// Check settings of each module
233 246
 					$module_config = $oModuleModel->getModulePartConfig('trackback', $module_srl);
234
-					if($module_config->enable_trackback == 'N') $allow_trackback_status = false;
235
-					else if($this->get('allow_trackback')=='Y' || !$this->isExists()) $allow_trackback_status = true;
247
+					if($module_config->enable_trackback == 'N') {
248
+						$allow_trackback_status = false;
249
+					} else if($this->get('allow_trackback')=='Y' || !$this->isExists()) {
250
+						$allow_trackback_status = true;
251
+					}
236 252
 				}
237 253
 			}
238 254
 		}
@@ -241,14 +257,18 @@  discard block
 block discarded – undo
241 257
 
242 258
 	function isLocked()
243 259
 	{
244
-		if(!$this->isExists()) return false;
260
+		if(!$this->isExists()) {
261
+			return false;
262
+		}
245 263
 
246 264
 		return $this->get('comment_status') == 'ALLOW' ? false : true;
247 265
 	}
248 266
 
249 267
 	function isEditable()
250 268
 	{
251
-		if($this->isGranted() || !$this->get('member_srl')) return true;
269
+		if($this->isGranted() || !$this->get('member_srl')) {
270
+			return true;
271
+		}
252 272
 		return false;
253 273
 	}
254 274
 
@@ -270,9 +290,14 @@  discard block
 block discarded – undo
270 290
 
271 291
 	function doCart()
272 292
 	{
273
-		if(!$this->document_srl) return false;
274
-		if($this->isCarted()) $this->removeCart();
275
-		else $this->addCart();
293
+		if(!$this->document_srl) {
294
+			return false;
295
+		}
296
+		if($this->isCarted()) {
297
+			$this->removeCart();
298
+		} else {
299
+			$this->addCart();
300
+		}
276 301
 	}
277 302
 
278 303
 	function addCart()
@@ -298,16 +323,26 @@  discard block
 block discarded – undo
298 323
 	 */
299 324
 	function notify($type, $content)
300 325
 	{
301
-		if(!$this->document_srl) return;
326
+		if(!$this->document_srl) {
327
+			return;
328
+		}
302 329
 		// return if it is not useNotify
303
-		if(!$this->useNotify()) return;
330
+		if(!$this->useNotify()) {
331
+			return;
332
+		}
304 333
 		// Pass if an author is not a logged-in user
305
-		if(!$this->get('member_srl')) return;
334
+		if(!$this->get('member_srl')) {
335
+			return;
336
+		}
306 337
 		// Return if the currently logged-in user is an author
307 338
 		$logged_info = Context::get('logged_info');
308
-		if($logged_info->member_srl == $this->get('member_srl')) return;
339
+		if($logged_info->member_srl == $this->get('member_srl')) {
340
+			return;
341
+		}
309 342
 		// List variables
310
-		if($type) $title = "[".$type."] ";
343
+		if($type) {
344
+			$title = "[".$type."] ";
345
+		}
311 346
 		$title .= cut_str(strip_tags($content), 10, '...');
312 347
 		$content = sprintf('%s<br /><br />from : <a href="%s" target="_blank">%s</a>',$content, getFullUrl('','document_srl',$this->document_srl), getFullUrl('','document_srl',$this->document_srl));
313 348
 		$receiver_srl = $this->get('member_srl');
@@ -334,16 +369,22 @@  discard block
 block discarded – undo
334 369
 
335 370
 	function isExistsHomepage()
336 371
 	{
337
-		if(trim($this->get('homepage'))) return true;
372
+		if(trim($this->get('homepage'))) {
373
+			return true;
374
+		}
338 375
 		return false;
339 376
 	}
340 377
 
341 378
 	function getHomepageUrl()
342 379
 	{
343 380
 		$url = trim($this->get('homepage'));
344
-		if(!$url) return;
381
+		if(!$url) {
382
+			return;
383
+		}
345 384
 
346
-		if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0)  $url = 'http://' . $url;
385
+		if(strncasecmp('http://', $url, 7) !== 0 && strncasecmp('https://', $url, 8) !== 0) {
386
+			$url = 'http://' . $url;
387
+		}
347 388
 
348 389
 		return escape($url, false);
349 390
 	}
@@ -375,43 +416,65 @@  discard block
 block discarded – undo
375 416
 
376 417
 	function getTitleText($cut_size = 0, $tail='...')
377 418
 	{
378
-		if(!$this->document_srl) return;
419
+		if(!$this->document_srl) {
420
+			return;
421
+		}
379 422
 
380
-		if($cut_size) $title = cut_str($this->get('title'), $cut_size, $tail);
381
-		else $title = $this->get('title');
423
+		if($cut_size) {
424
+			$title = cut_str($this->get('title'), $cut_size, $tail);
425
+		} else {
426
+			$title = $this->get('title');
427
+		}
382 428
 
383 429
 		return $title;
384 430
 	}
385 431
 
386 432
 	function getTitle($cut_size = 0, $tail='...')
387 433
 	{
388
-		if(!$this->document_srl) return;
434
+		if(!$this->document_srl) {
435
+			return;
436
+		}
389 437
 
390 438
 		$title = $this->getTitleText($cut_size, $tail);
391 439
 
392 440
 		$attrs = array();
393 441
 		$this->add('title_color', trim($this->get('title_color')));
394
-		if($this->get('title_bold')=='Y') $attrs[] = "font-weight:bold;";
395
-		if($this->get('title_color') && $this->get('title_color') != 'N') $attrs[] = "color:#".$this->get('title_color');
442
+		if($this->get('title_bold')=='Y') {
443
+			$attrs[] = "font-weight:bold;";
444
+		}
445
+		if($this->get('title_color') && $this->get('title_color') != 'N') {
446
+			$attrs[] = "color:#".$this->get('title_color');
447
+		}
396 448
 
397
-		if(count($attrs)) return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
398
-		else return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
449
+		if(count($attrs)) {
450
+			return sprintf("<span style=\"%s\">%s</span>", implode(';',$attrs), htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false));
451
+		} else {
452
+			return htmlspecialchars($title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
453
+		}
399 454
 	}
400 455
 
401 456
 	function getContentText($strlen = 0)
402 457
 	{
403
-		if(!$this->document_srl) return;
458
+		if(!$this->document_srl) {
459
+			return;
460
+		}
404 461
 
405
-		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
462
+		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) {
463
+			return Context::getLang('msg_is_secret');
464
+		}
406 465
 
407 466
 		$result = $this->_checkAccessibleFromStatus();
408
-		if($result) $_SESSION['accessible'][$this->document_srl] = true;
467
+		if($result) {
468
+			$_SESSION['accessible'][$this->document_srl] = true;
469
+		}
409 470
 
410 471
 		$content = $this->get('content');
411 472
 		$content = preg_replace_callback('/<(object|param|embed)[^>]*/is', array($this, '_checkAllowScriptAccess'), $content);
412 473
 		$content = preg_replace_callback('/<object[^>]*>/is', array($this, '_addAllowScriptAccess'), $content);
413 474
 
414
-		if($strlen) return cut_str(strip_tags($content),$strlen,'...');
475
+		if($strlen) {
476
+			return cut_str(strip_tags($content),$strlen,'...');
477
+		}
415 478
 
416 479
 		return htmlspecialchars($content);
417 480
 	}
@@ -444,14 +507,12 @@  discard block
 block discarded – undo
444 507
 				}
445 508
 				$this->allowscriptaccessList[count($this->allowscriptaccessList)-1]--;
446 509
 			}
447
-		}
448
-		else if($m[1] == 'embed')
510
+		} else if($m[1] == 'embed')
449 511
 		{
450 512
 			if(stripos($m[0], 'allowscriptaccess'))
451 513
 			{
452 514
 				$m[0] = preg_replace('/always|samedomain/i', 'never', $m[0]);
453
-			}
454
-			else
515
+			} else
455 516
 			{
456 517
 				$m[0] = preg_replace('/\<embed/i', '<embed allowscriptaccess="never"', $m[0]);
457 518
 			}
@@ -461,15 +522,23 @@  discard block
 block discarded – undo
461 522
 
462 523
 	function getContent($add_popup_menu = true, $add_content_info = true, $resource_realpath = false, $add_xe_content_class = true, $stripEmbedTagException = false)
463 524
 	{
464
-		if(!$this->document_srl) return;
525
+		if(!$this->document_srl) {
526
+			return;
527
+		}
465 528
 
466
-		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) return Context::getLang('msg_is_secret');
529
+		if($this->isSecret() && !$this->isGranted() && !$this->isAccessible()) {
530
+			return Context::getLang('msg_is_secret');
531
+		}
467 532
 
468 533
 		$result = $this->_checkAccessibleFromStatus();
469
-		if($result) $_SESSION['accessible'][$this->document_srl] = true;
534
+		if($result) {
535
+			$_SESSION['accessible'][$this->document_srl] = true;
536
+		}
470 537
 
471 538
 		$content = $this->get('content');
472
-		if(!$stripEmbedTagException) stripEmbedTagForAdmin($content, $this->get('member_srl'));
539
+		if(!$stripEmbedTagException) {
540
+			stripEmbedTagForAdmin($content, $this->get('member_srl'));
541
+		}
473 542
 
474 543
 		// Define a link if using a rewrite module
475 544
 		$oContext = &Context::getInstance();
@@ -503,10 +572,11 @@  discard block
 block discarded – undo
503 572
 				$this->document_srl, $memberSrl
504 573
 			);
505 574
 			// Add xe_content class although accessing content is not required
506
-		}
507
-		else
575
+		} else
508 576
 		{
509
-			if($add_xe_content_class) $content = sprintf('<div class="xe_content">%s</div>', $content);
577
+			if($add_xe_content_class) {
578
+				$content = sprintf('<div class="xe_content">%s</div>', $content);
579
+			}
510 580
 		}
511 581
 		// Change the image path to a valid absolute path if resource_realpath is true
512 582
 		if($resource_realpath)
@@ -625,11 +695,15 @@  discard block
 block discarded – undo
625 695
 
626 696
 	function getTrackbackUrl()
627 697
 	{
628
-		if(!$this->document_srl) return;
698
+		if(!$this->document_srl) {
699
+			return;
700
+		}
629 701
 
630 702
 		// Generate a key to prevent spams
631 703
 		$oTrackbackModel = getModel('trackback');
632
-		if($oTrackbackModel) return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid());
704
+		if($oTrackbackModel) {
705
+			return $oTrackbackModel->getTrackbackUrl($this->document_srl, $this->getDocumentMid());
706
+		}
633 707
 	}
634 708
 
635 709
 	/**
@@ -648,7 +722,9 @@  discard block
 block discarded – undo
648 722
 
649 723
 	function isExtraVarsExists()
650 724
 	{
651
-		if(!$this->get('module_srl')) return false;
725
+		if(!$this->get('module_srl')) {
726
+			return false;
727
+		}
652 728
 		$oDocumentModel = getModel('document');
653 729
 		$extra_keys = $oDocumentModel->getExtraKeys($this->get('module_srl'));
654 730
 		return count($extra_keys)?true:false;
@@ -656,7 +732,9 @@  discard block
 block discarded – undo
656 732
 
657 733
 	function getExtraVars()
658 734
 	{
659
-		if(!$this->get('module_srl') || !$this->document_srl) return null;
735
+		if(!$this->get('module_srl') || !$this->document_srl) {
736
+			return null;
737
+		}
660 738
 
661 739
 		$oDocumentModel = getModel('document');
662 740
 		return $oDocumentModel->getExtraVars($this->get('module_srl'), $this->document_srl);
@@ -668,8 +746,7 @@  discard block
 block discarded – undo
668 746
 		if(is_array($extra_vars) && array_key_exists($idx,$extra_vars))
669 747
 		{
670 748
 			return $extra_vars[$idx]->getValue();
671
-		}
672
-		else
749
+		} else
673 750
 		{
674 751
 			return '';
675 752
 		}
@@ -681,8 +758,7 @@  discard block
 block discarded – undo
681 758
 		if(is_array($extra_vars) && array_key_exists($idx,$extra_vars))
682 759
 		{
683 760
 			return $extra_vars[$idx]->getValueHTML();
684
-		}
685
-		else
761
+		} else
686 762
 		{
687 763
 			return '';
688 764
 		}
@@ -704,8 +780,7 @@  discard block
 block discarded – undo
704 780
 		if(is_array($extra_eid) && array_key_exists($eid,$extra_eid))
705 781
 		{
706 782
 			return $extra_eid[$eid]->getValue();
707
-		}
708
-		else
783
+		} else
709 784
 		{
710 785
 			return '';
711 786
 		}
@@ -723,8 +798,7 @@  discard block
 block discarded – undo
723 798
 		if(is_array($extra_eid) && array_key_exists($eid,$extra_eid))
724 799
 		{
725 800
 			return $extra_eid[$eid]->getValueHTML();
726
-		}
727
-		else
801
+		} else
728 802
 		{
729 803
 			return '';
730 804
 		}
@@ -744,8 +818,12 @@  discard block
 block discarded – undo
744 818
 
745 819
 	function getComments()
746 820
 	{
747
-		if(!$this->getCommentCount()) return;
748
-		if(!$this->isGranted() && $this->isSecret()) return;
821
+		if(!$this->getCommentCount()) {
822
+			return;
823
+		}
824
+		if(!$this->isGranted() && $this->isSecret()) {
825
+			return;
826
+		}
749 827
 		// cpage is a number of comment pages
750 828
 		$cpageStr = sprintf('%d_cpage', $this->document_srl);
751 829
 		$cpage = Context::get($cpageStr);
@@ -758,7 +836,9 @@  discard block
 block discarded – undo
758 836
 		// Get a list of comments
759 837
 		$oCommentModel = getModel('comment');
760 838
 		$output = $oCommentModel->getCommentList($this->document_srl, $cpage, $is_admin);
761
-		if(!$output->toBool() || !count($output->data)) return;
839
+		if(!$output->toBool() || !count($output->data)) {
840
+			return;
841
+		}
762 842
 		// Create commentItem object from a comment list
763 843
 		// If admin priviledge is granted on parent posts, you can read its child posts.
764 844
 		$accessible = array();
@@ -768,7 +848,9 @@  discard block
 block discarded – undo
768 848
 			$oCommentItem = new commentItem();
769 849
 			$oCommentItem->setAttribute($val);
770 850
 			// If permission is granted to the post, you can access it temporarily
771
-			if($oCommentItem->isGranted()) $accessible[$val->comment_srl] = true;
851
+			if($oCommentItem->isGranted()) {
852
+				$accessible[$val->comment_srl] = true;
853
+			}
772 854
 			// If the comment is set to private and it belongs child post, it is allowable to read the comment for who has a admin privilege on its parent post
773 855
 			if($val->parent_srl>0 && $val->is_secret == 'Y' && !$oCommentItem->isAccessible() && $accessible[$val->parent_srl]===true)
774 856
 			{
@@ -779,7 +861,9 @@  discard block
 block discarded – undo
779 861
 		// Variable setting to be displayed on the skin
780 862
 		Context::set($cpageStr, $output->page_navigation->cur_page);
781 863
 		Context::set('cpage', $output->page_navigation->cur_page);
782
-		if($output->total_page>1) $this->comment_page_navigation = $output->page_navigation;
864
+		if($output->total_page>1) {
865
+			$this->comment_page_navigation = $output->page_navigation;
866
+		}
783 867
 
784 868
 		// Call trigger (after)
785 869
 		$output = ModuleHandler::triggerCall('document.getComments', 'after', $comment_list);
@@ -794,9 +878,13 @@  discard block
 block discarded – undo
794 878
 
795 879
 	function getTrackbacks()
796 880
 	{
797
-		if(!$this->document_srl) return;
881
+		if(!$this->document_srl) {
882
+			return;
883
+		}
798 884
 
799
-		if(!$this->allowTrackback() || !$this->get('trackback_count')) return;
885
+		if(!$this->allowTrackback() || !$this->get('trackback_count')) {
886
+			return;
887
+		}
800 888
 
801 889
 		$oTrackbackModel = getModel('trackback');
802 890
 		return $oTrackbackModel->getTrackbackList($this->document_srl, $is_admin);
@@ -804,15 +892,21 @@  discard block
 block discarded – undo
804 892
 
805 893
 	function thumbnailExists($width = 80, $height = 0, $type = '')
806 894
 	{
807
-		if(!$this->document_srl) return false;
808
-		if(!$this->getThumbnail($width, $height, $type)) return false;
895
+		if(!$this->document_srl) {
896
+			return false;
897
+		}
898
+		if(!$this->getThumbnail($width, $height, $type)) {
899
+			return false;
900
+		}
809 901
 		return true;
810 902
 	}
811 903
 
812 904
 	function getThumbnail($width = 80, $height = 0, $thumbnail_type = '')
813 905
 	{
814 906
 		// Return false if the document doesn't exist
815
-		if(!$this->document_srl) return;
907
+		if(!$this->document_srl) {
908
+			return;
909
+		}
816 910
 
817 911
 		if($this->isSecret() && !$this->isGranted())
818 912
 		{
@@ -820,7 +914,9 @@  discard block
 block discarded – undo
820 914
 		}
821 915
 
822 916
 		// If not specify its height, create a square
823
-		if(!$height) $height = $width;
917
+		if(!$height) {
918
+			$height = $width;
919
+		}
824 920
 
825 921
 		// Return false if neither attachement nor image files in the document
826 922
 		$content = $this->get('content');
@@ -838,7 +934,9 @@  discard block
 block discarded – undo
838 934
 				}
839 935
 			}
840 936
 
841
-			if(!preg_match("!<img!is", $content)) return;
937
+			if(!preg_match("!<img!is", $content)) {
938
+				return;
939
+			}
842 940
 		}
843 941
 		// Get thumbnai_type information from document module's configuration
844 942
 		if(!in_array($thumbnail_type, array('crop','ratio')))
@@ -865,8 +963,7 @@  discard block
 block discarded – undo
865 963
 			if(filesize($thumbnail_file) < 1)
866 964
 			{
867 965
 				return FALSE;
868
-			}
869
-			else
966
+			} else
870 967
 			{
871 968
 				return $thumbnail_url . '?' . date('YmdHis', filemtime($thumbnail_file));
872 969
 			}
@@ -887,7 +984,9 @@  discard block
 block discarded – undo
887 984
 			$first_image = null;
888 985
 			foreach($file_list as $file)
889 986
 			{
890
-				if($file->direct_download !== 'Y') continue;
987
+				if($file->direct_download !== 'Y') {
988
+					continue;
989
+				}
891 990
 
892 991
 				if($file->cover_image === 'Y' && file_exists($file->uploaded_filename))
893 992
 				{
@@ -895,7 +994,9 @@  discard block
 block discarded – undo
895 994
 					break;
896 995
 				}
897 996
 
898
-				if($first_image) continue;
997
+				if($first_image) {
998
+					continue;
999
+				}
899 1000
 
900 1001
 				if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename))
901 1002
 				{
@@ -922,7 +1023,9 @@  discard block
 block discarded – undo
922 1023
 			foreach($matches as $target_image)
923 1024
 			{
924 1025
 				$target_src = trim($target_image[1]);
925
-				if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue;
1026
+				if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) {
1027
+					continue;
1028
+				}
926 1029
 
927 1030
 				if(!preg_match('/^(http|https):\/\//i',$target_src))
928 1031
 				{
@@ -933,7 +1036,9 @@  discard block
 block discarded – undo
933 1036
 
934 1037
 				$tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex');
935 1038
 				FileHandler::getRemoteFile($target_src, $tmp_file);
936
-				if(!file_exists($tmp_file)) continue;
1039
+				if(!file_exists($tmp_file)) {
1040
+					continue;
1041
+				}
937 1042
 
938 1043
 				$imageinfo = getimagesize($tmp_file);
939 1044
 				list($_w, $_h) = $imageinfo;
@@ -979,21 +1084,28 @@  discard block
 block discarded – undo
979 1084
 	 */
980 1085
 	function getExtraImages($time_interval = 43200)
981 1086
 	{
982
-		if(!$this->document_srl) return;
1087
+		if(!$this->document_srl) {
1088
+			return;
1089
+		}
983 1090
 		// variables for icon list
984 1091
 		$buffs = array();
985 1092
 
986 1093
 		$check_files = false;
987 1094
 
988 1095
 		// Check if secret post is
989
-		if($this->isSecret()) $buffs[] = "secret";
1096
+		if($this->isSecret()) {
1097
+			$buffs[] = "secret";
1098
+		}
990 1099
 
991 1100
 		// Set the latest time
992 1101
 		$time_check = date("YmdHis", $_SERVER['REQUEST_TIME']-$time_interval);
993 1102
 
994 1103
 		// Check new post
995
-		if($this->get('regdate')>$time_check) $buffs[] = "new";
996
-		else if($this->get('last_update')>$time_check) $buffs[] = "update";
1104
+		if($this->get('regdate')>$time_check) {
1105
+			$buffs[] = "new";
1106
+		} else if($this->get('last_update')>$time_check) {
1107
+			$buffs[] = "update";
1108
+		}
997 1109
 
998 1110
 		/*
999 1111
 		   $content = $this->get('content');
@@ -1016,7 +1128,9 @@  discard block
 block discarded – undo
1016 1128
 		 */
1017 1129
 
1018 1130
 		// Check the attachment
1019
-		if($this->hasUploadedFiles()) $buffs[] = "file";
1131
+		if($this->hasUploadedFiles()) {
1132
+			$buffs[] = "file";
1133
+		}
1020 1134
 
1021 1135
 		return $buffs;
1022 1136
 	}
@@ -1037,22 +1151,25 @@  discard block
 block discarded – undo
1037 1151
 	 */
1038 1152
 	function printExtraImages($time_check = 43200)
1039 1153
 	{
1040
-		if(!$this->document_srl) return;
1154
+		if(!$this->document_srl) {
1155
+			return;
1156
+		}
1041 1157
 
1042 1158
 		$oDocumentModel = getModel('document');
1043 1159
 		$documentConfig = $oDocumentModel->getDocumentConfig();
1044 1160
 		if(Mobile::isFromMobilePhone())
1045 1161
 		{
1046 1162
 			$iconSkin = $documentConfig->micons;
1047
-		}
1048
-		else
1163
+		} else
1049 1164
 		{
1050 1165
 			$iconSkin = $documentConfig->icons;
1051 1166
 		}
1052 1167
 		$path = sprintf('%s%s',getUrl(), "modules/document/tpl/icons/$iconSkin/");
1053 1168
 
1054 1169
 		$buffs = $this->getExtraImages($time_check);
1055
-		if(!count($buffs)) return;
1170
+		if(!count($buffs)) {
1171
+			return;
1172
+		}
1056 1173
 
1057 1174
 		$buff = array();
1058 1175
 		foreach($buffs as $key => $val)
@@ -1064,18 +1181,28 @@  discard block
 block discarded – undo
1064 1181
 
1065 1182
 	function hasUploadedFiles()
1066 1183
 	{
1067
-		if(!$this->document_srl) return;
1184
+		if(!$this->document_srl) {
1185
+			return;
1186
+		}
1068 1187
 
1069
-		if($this->isSecret() && !$this->isGranted()) return false;
1188
+		if($this->isSecret() && !$this->isGranted()) {
1189
+			return false;
1190
+		}
1070 1191
 		return $this->get('uploaded_count')? true : false;
1071 1192
 	}
1072 1193
 
1073 1194
 	function getUploadedFiles($sortIndex = 'file_srl')
1074 1195
 	{
1075
-		if(!$this->document_srl) return;
1196
+		if(!$this->document_srl) {
1197
+			return;
1198
+		}
1076 1199
 
1077
-		if($this->isSecret() && !$this->isGranted()) return;
1078
-		if(!$this->get('uploaded_count')) return;
1200
+		if($this->isSecret() && !$this->isGranted()) {
1201
+			return;
1202
+		}
1203
+		if(!$this->get('uploaded_count')) {
1204
+			return;
1205
+		}
1079 1206
 
1080 1207
 		if(!$this->uploadedFiles[$sortIndex])
1081 1208
 		{
@@ -1093,7 +1220,9 @@  discard block
 block discarded – undo
1093 1220
 	function getEditor()
1094 1221
 	{
1095 1222
 		$module_srl = $this->get('module_srl');
1096
-		if(!$module_srl) $module_srl = Context::get('module_srl');
1223
+		if(!$module_srl) {
1224
+			$module_srl = Context::get('module_srl');
1225
+		}
1097 1226
 
1098 1227
 		$oEditorModel = getModel('editor');
1099 1228
 		return $oEditorModel->getModuleEditor('document', $module_srl, $this->document_srl, 'document_srl', 'content');
@@ -1107,8 +1236,12 @@  discard block
 block discarded – undo
1107 1236
 	function isEnableComment()
1108 1237
 	{
1109 1238
 		// Return false if not authorized, if a secret document, if the document is set not to allow any comment
1110
-		if (!$this->allowComment()) return false;
1111
-		if(!$this->isGranted() && $this->isSecret()) return false;
1239
+		if (!$this->allowComment()) {
1240
+			return false;
1241
+		}
1242
+		if(!$this->isGranted() && $this->isSecret()) {
1243
+			return false;
1244
+		}
1112 1245
 
1113 1246
 		return true;
1114 1247
 	}
@@ -1119,7 +1252,9 @@  discard block
 block discarded – undo
1119 1252
 	 */
1120 1253
 	function getCommentEditor()
1121 1254
 	{
1122
-		if(!$this->isEnableComment()) return;
1255
+		if(!$this->isEnableComment()) {
1256
+			return;
1257
+		}
1123 1258
 
1124 1259
 		$oEditorModel = getModel('editor');
1125 1260
 		return $oEditorModel->getModuleEditor('comment', $this->get('module_srl'), $comment_srl, 'comment_srl', 'content');
@@ -1131,10 +1266,14 @@  discard block
 block discarded – undo
1131 1266
 	 */
1132 1267
 	function getProfileImage()
1133 1268
 	{
1134
-		if(!$this->isExists() || !$this->get('member_srl')) return;
1269
+		if(!$this->isExists() || !$this->get('member_srl')) {
1270
+			return;
1271
+		}
1135 1272
 		$oMemberModel = getModel('member');
1136 1273
 		$profile_info = $oMemberModel->getProfileImage($this->get('member_srl'));
1137
-		if(!$profile_info) return;
1274
+		if(!$profile_info) {
1275
+			return;
1276
+		}
1138 1277
 
1139 1278
 		return $profile_info->src;
1140 1279
 	}
@@ -1146,7 +1285,9 @@  discard block
 block discarded – undo
1146 1285
 	function getSignature()
1147 1286
 	{
1148 1287
 		// Pass if a document doesn't exist
1149
-		if(!$this->isExists() || !$this->get('member_srl')) return;
1288
+		if(!$this->isExists() || !$this->get('member_srl')) {
1289
+			return;
1290
+		}
1150 1291
 		// Get signature information
1151 1292
 		$oMemberModel = getModel('member');
1152 1293
 		$signature = $oMemberModel->getSignature($this->get('member_srl'));
@@ -1160,7 +1301,9 @@  discard block
 block discarded – undo
1160 1301
 		if($signature)
1161 1302
 		{
1162 1303
 			$max_signature_height = $GLOBALS['__member_signature_max_height'];
1163
-			if($max_signature_height) $signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature);
1304
+			if($max_signature_height) {
1305
+				$signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature);
1306
+			}
1164 1307
 		}
1165 1308
 
1166 1309
 		return $signature;
@@ -1184,20 +1327,25 @@  discard block
 block discarded – undo
1184 1327
 	function _checkAccessibleFromStatus()
1185 1328
 	{
1186 1329
 		$logged_info = Context::get('logged_info');
1187
-		if($logged_info->is_admin == 'Y') return true;
1330
+		if($logged_info->is_admin == 'Y') {
1331
+			return true;
1332
+		}
1188 1333
 
1189 1334
 		$status = $this->get('status');
1190
-		if(empty($status)) return false;
1335
+		if(empty($status)) {
1336
+			return false;
1337
+		}
1191 1338
 
1192 1339
 		$oDocumentModel = getModel('document');
1193 1340
 		$configStatusList = $oDocumentModel->getStatusList();
1194 1341
 
1195
-		if($status == $configStatusList['public'] || $status == $configStatusList['publish'])
1196
-			return true;
1197
-		else if($status == $configStatusList['private'] || $status == $configStatusList['secret'])
1342
+		if($status == $configStatusList['public'] || $status == $configStatusList['publish']) {
1343
+					return true;
1344
+		} else if($status == $configStatusList['private'] || $status == $configStatusList['secret'])
1198 1345
 		{
1199
-			if($this->get('member_srl') == $logged_info->member_srl)
1200
-				return true;
1346
+			if($this->get('member_srl') == $logged_info->member_srl) {
1347
+							return true;
1348
+			}
1201 1349
 		}
1202 1350
 		return false;
1203 1351
 	}
Please login to merge, or discard this patch.
modules/document/document.controller.php 2 patches
Spacing   +369 added lines, -369 removed lines patch added patch discarded remove patch
@@ -24,19 +24,19 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	function procDocumentVoteUp()
26 26
 	{
27
-		if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request');
27
+		if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request');
28 28
 
29 29
 		$document_srl = Context::get('target_srl');
30
-		if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request');
30
+		if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request');
31 31
 
32 32
 		$oDocumentModel = getModel('document');
33 33
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
34 34
 		$module_srl = $oDocument->get('module_srl');
35
-		if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request');
35
+		if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request');
36 36
 
37 37
 		$oModuleModel = getModel('module');
38
-		$document_config = $oModuleModel->getModulePartConfig('document',$module_srl);
39
-		if($document_config->use_vote_up=='N') return new BaseObject(-1, 'msg_invalid_request');
38
+		$document_config = $oModuleModel->getModulePartConfig('document', $module_srl);
39
+		if ($document_config->use_vote_up == 'N') return new BaseObject(-1, 'msg_invalid_request');
40 40
 
41 41
 		$point = 1;
42 42
 		$output = $this->updateVotedCount($document_srl, $point);
@@ -69,19 +69,19 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	function procDocumentVoteDown()
71 71
 	{
72
-		if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request');
72
+		if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request');
73 73
 
74 74
 		$document_srl = Context::get('target_srl');
75
-		if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request');
75
+		if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request');
76 76
 
77 77
 		$oDocumentModel = getModel('document');
78 78
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
79 79
 		$module_srl = $oDocument->get('module_srl');
80
-		if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request');
80
+		if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request');
81 81
 
82 82
 		$oModuleModel = getModel('module');
83
-		$document_config = $oModuleModel->getModulePartConfig('document',$module_srl);
84
-		if($document_config->use_vote_down=='N') return new BaseObject(-1, 'msg_invalid_request');
83
+		$document_config = $oModuleModel->getModulePartConfig('document', $module_srl);
84
+		if ($document_config->use_vote_down == 'N') return new BaseObject(-1, 'msg_invalid_request');
85 85
 
86 86
 		$point = -1;
87 87
 		$output = $this->updateVotedCount($document_srl, $point);
@@ -95,10 +95,10 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	function procDocumentDeclare()
97 97
 	{
98
-		if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request');
98
+		if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request');
99 99
 
100 100
 		$document_srl = Context::get('target_srl');
101
-		if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request');
101
+		if (!$document_srl) return new BaseObject(-1, 'msg_invalid_request');
102 102
 
103 103
 		return $this->declaredDocument($document_srl);
104 104
 	}
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		$args->history_srl = $history_srl;
141 141
 		$args->module_srl = $module_srl;
142 142
 		$args->document_srl = $document_srl;
143
-		if(!$args->history_srl && !$args->module_srl && !$args->document_srl) return;
143
+		if (!$args->history_srl && !$args->module_srl && !$args->document_srl) return;
144 144
 		executeQuery("document.deleteHistory", $args);
145 145
 	}
146 146
 
@@ -152,15 +152,15 @@  discard block
 block discarded – undo
152 152
 	function triggerDeleteModuleDocuments(&$obj)
153 153
 	{
154 154
 		$module_srl = $obj->module_srl;
155
-		if(!$module_srl) return new BaseObject();
155
+		if (!$module_srl) return new BaseObject();
156 156
 		// Delete the document
157 157
 		$oDocumentAdminController = getAdminController('document');
158 158
 		$output = $oDocumentAdminController->deleteModuleDocument($module_srl);
159
-		if(!$output->toBool()) return $output;
159
+		if (!$output->toBool()) return $output;
160 160
 		// Delete the category
161 161
 		$oDocumentController = getController('document');
162 162
 		$output = $oDocumentController->deleteModuleCategory($module_srl);
163
-		if(!$output->toBool()) return $output;
163
+		if (!$output->toBool()) return $output;
164 164
 		// Delete extra key and variable, because module deleted
165 165
 		$this->deleteDocumentExtraKeys($module_srl);
166 166
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 */
194 194
 	function insertDocument($obj, $manual_inserted = false, $isRestore = false, $isLatest = true)
195 195
 	{
196
-		if(!$manual_inserted && !checkCSRF())
196
+		if (!$manual_inserted && !checkCSRF())
197 197
 		{
198 198
 			return new BaseObject(-1, 'msg_invalid_request');
199 199
 		}
@@ -202,32 +202,32 @@  discard block
 block discarded – undo
202 202
 		$oDB = &DB::getInstance();
203 203
 		$oDB->begin();
204 204
 		// List variables
205
-		if($obj->comment_status) $obj->commentStatus = $obj->comment_status;
206
-		if(!$obj->commentStatus) $obj->commentStatus = 'DENY';
207
-		if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj);
208
-		if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N';
209
-		if($obj->homepage) 
205
+		if ($obj->comment_status) $obj->commentStatus = $obj->comment_status;
206
+		if (!$obj->commentStatus) $obj->commentStatus = 'DENY';
207
+		if ($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj);
208
+		if ($obj->allow_trackback != 'Y') $obj->allow_trackback = 'N';
209
+		if ($obj->homepage) 
210 210
 		{
211 211
 			$obj->homepage = escape($obj->homepage);
212
-			if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage))
212
+			if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage))
213 213
 			{
214 214
 				$obj->homepage = 'http://'.$obj->homepage;
215 215
 			}
216 216
 		}
217 217
 		
218
-		if($obj->notify_message != 'Y') $obj->notify_message = 'N';
219
-		if(!$obj->email_address) $obj->email_address = '';
220
-		if(!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR'];
218
+		if ($obj->notify_message != 'Y') $obj->notify_message = 'N';
219
+		if (!$obj->email_address) $obj->email_address = '';
220
+		if (!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR'];
221 221
 
222 222
                 // can modify regdate only manager
223 223
                 $grant = Context::get('grant');
224
-		if(!$grant->manager)
224
+		if (!$grant->manager)
225 225
 		{
226 226
 			unset($obj->regdate);
227 227
 		}
228 228
 		
229 229
 		// Serialize the $extra_vars, check the extra_vars type, because duplicate serialized avoid
230
-		if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars);
230
+		if (!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars);
231 231
 		// Remove the columns for automatic saving
232 232
 		unset($obj->_saved_doc_srl);
233 233
 		unset($obj->_saved_doc_title);
@@ -235,34 +235,34 @@  discard block
 block discarded – undo
235 235
 		unset($obj->_saved_doc_message);
236 236
 		// Call a trigger (before)
237 237
 		$output = ModuleHandler::triggerCall('document.insertDocument', 'before', $obj);
238
-		if(!$output->toBool()) return $output;
238
+		if (!$output->toBool()) return $output;
239 239
 		// Register it if no given document_srl exists
240
-		if(!$obj->document_srl) $obj->document_srl = getNextSequence();
241
-		elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new BaseObject(-1, 'msg_not_permitted');
240
+		if (!$obj->document_srl) $obj->document_srl = getNextSequence();
241
+		elseif (!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new BaseObject(-1, 'msg_not_permitted');
242 242
 
243 243
 		$oDocumentModel = getModel('document');
244 244
 		// Set to 0 if the category_srl doesn't exist
245
-		if($obj->category_srl)
245
+		if ($obj->category_srl)
246 246
 		{
247 247
 			$category_list = $oDocumentModel->getCategoryList($obj->module_srl);
248
-			if(count($category_list) > 0 && !$category_list[$obj->category_srl]->grant)
248
+			if (count($category_list) > 0 && !$category_list[$obj->category_srl]->grant)
249 249
 			{
250 250
 				return new BaseObject(-1, 'msg_not_permitted');
251 251
 			}
252
-			if(count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0;
252
+			if (count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0;
253 253
 		}
254 254
 		// Set the read counts and update order.
255
-		if(!$obj->readed_count) $obj->readed_count = 0;
256
-		if($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1;
255
+		if (!$obj->readed_count) $obj->readed_count = 0;
256
+		if ($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1;
257 257
 		else $obj->update_order = $obj->list_order;
258 258
 		// Check the status of password hash for manually inserting. Apply hashing for otherwise.
259
-		if($obj->password && !$obj->password_is_hashed)
259
+		if ($obj->password && !$obj->password_is_hashed)
260 260
 		{
261 261
 			$obj->password = getModel('member')->hashPassword($obj->password);
262 262
 		}
263 263
 		// Insert member's information only if the member is logged-in and not manually registered.
264 264
 		$logged_info = Context::get('logged_info');
265
-		if(Context::get('is_logged') && !$manual_inserted && !$isRestore)
265
+		if (Context::get('is_logged') && !$manual_inserted && !$isRestore)
266 266
 		{
267 267
 			$obj->member_srl = $logged_info->member_srl;
268 268
 
@@ -276,61 +276,61 @@  discard block
 block discarded – undo
276 276
 		// If the tile is empty, extract string from the contents.
277 277
 		$obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
278 278
 		settype($obj->title, "string");
279
-		if($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...');
279
+		if ($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))), 20, '...');
280 280
 		// If no tile extracted from the contents, leave it untitled.
281
-		if($obj->title == '') $obj->title = 'Untitled';
281
+		if ($obj->title == '') $obj->title = 'Untitled';
282 282
 		// Remove XE's own tags from the contents.
283 283
 		$obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content);
284
-		if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y')
284
+		if (Mobile::isFromMobilePhone() && $obj->use_editor != 'Y')
285 285
 		{
286
-			if($obj->use_html != 'Y')
286
+			if ($obj->use_html != 'Y')
287 287
 			{
288 288
 				$obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
289 289
 			}
290 290
 			$obj->content = nl2br($obj->content);
291 291
 		}
292 292
 		// Remove iframe and script if not a top adminisrator in the session.
293
-		if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content);
293
+		if ($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content);
294 294
 		// An error appears if both log-in info and user name don't exist.
295
-		if(!$logged_info->member_srl && !$obj->nick_name) return new BaseObject(-1,'msg_invalid_request');
295
+		if (!$logged_info->member_srl && !$obj->nick_name) return new BaseObject(-1, 'msg_invalid_request');
296 296
 
297 297
 		$obj->lang_code = Context::getLangType();
298 298
 		// Insert data into the DB
299
-		if(!$obj->status) $this->_checkDocumentStatusForOldVersion($obj);
299
+		if (!$obj->status) $this->_checkDocumentStatusForOldVersion($obj);
300 300
 		$output = executeQuery('document.insertDocument', $obj);
301
-		if(!$output->toBool())
301
+		if (!$output->toBool())
302 302
 		{
303 303
 			$oDB->rollback();
304 304
 			return $output;
305 305
 		}
306 306
 		// Insert extra variables if the document successfully inserted.
307 307
 		$extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl);
308
-		if(count($extra_keys))
308
+		if (count($extra_keys))
309 309
 		{
310
-			foreach($extra_keys as $idx => $extra_item)
310
+			foreach ($extra_keys as $idx => $extra_item)
311 311
 			{
312 312
 				$value = NULL;
313
-				if(isset($obj->{'extra_vars'.$idx}))
313
+				if (isset($obj->{'extra_vars'.$idx}))
314 314
 				{
315 315
 					$tmp = $obj->{'extra_vars'.$idx};
316
-					if(is_array($tmp))
316
+					if (is_array($tmp))
317 317
 						$value = implode('|@|', $tmp);
318 318
 					else
319 319
 						$value = trim($tmp);
320 320
 				}
321
-				else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name});
322
-				if($value == NULL) continue;
321
+				else if (isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name});
322
+				if ($value == NULL) continue;
323 323
 
324 324
 				$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid);
325 325
 			}
326 326
 		}
327 327
 		// Update the category if the category_srl exists.
328
-		if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl);
328
+		if ($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl);
329 329
 		// Call a trigger (after)
330
-		if($output->toBool())
330
+		if ($output->toBool())
331 331
 		{
332 332
 			$trigger_output = ModuleHandler::triggerCall('document.insertDocument', 'after', $obj);
333
-			if(!$trigger_output->toBool())
333
+			if (!$trigger_output->toBool())
334 334
 			{
335 335
 				$oDB->rollback();
336 336
 				return $trigger_output;
@@ -341,12 +341,12 @@  discard block
 block discarded – undo
341 341
 		$oDB->commit();
342 342
 
343 343
 		// return
344
-		if(!$manual_inserted)
344
+		if (!$manual_inserted)
345 345
 		{
346 346
 			$this->addGrant($obj->document_srl);
347 347
 		}
348
-		$output->add('document_srl',$obj->document_srl);
349
-		$output->add('category_srl',$obj->category_srl);
348
+		$output->add('document_srl', $obj->document_srl);
349
+		$output->add('category_srl', $obj->category_srl);
350 350
 
351 351
 		return $output;
352 352
 	}
@@ -362,41 +362,41 @@  discard block
 block discarded – undo
362 362
 	{
363 363
 		$logged_info = Context::get('logged_info');
364 364
 
365
-		if(!$manual_updated && !checkCSRF())
365
+		if (!$manual_updated && !checkCSRF())
366 366
 		{
367 367
 			return new BaseObject(-1, 'msg_invalid_request');
368 368
 		}
369 369
 
370
-		if(!$source_obj->document_srl || !$obj->document_srl) return new BaseObject(-1,'msg_invalied_request');
371
-		if(!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET';
372
-		if(!$obj->status) $obj->status = 'PUBLIC';
370
+		if (!$source_obj->document_srl || !$obj->document_srl) return new BaseObject(-1, 'msg_invalied_request');
371
+		if (!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET';
372
+		if (!$obj->status) $obj->status = 'PUBLIC';
373 373
 
374 374
 		// Call a trigger (before)
375 375
 		$output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj);
376
-		if(!$output->toBool()) return $output;
376
+		if (!$output->toBool()) return $output;
377 377
 
378 378
 		// begin transaction
379 379
 		$oDB = &DB::getInstance();
380 380
 		$oDB->begin();
381 381
 
382 382
 		$oModuleModel = getModel('module');
383
-		if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl');
383
+		if (!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl');
384 384
 		$module_srl = $obj->module_srl;
385 385
 		$document_config = $oModuleModel->getModulePartConfig('document', $module_srl);
386
-		if(!$document_config)
386
+		if (!$document_config)
387 387
 		{
388 388
 			$document_config = new stdClass();
389 389
 		}
390
-		if(!isset($document_config->use_history)) $document_config->use_history = 'N';
390
+		if (!isset($document_config->use_history)) $document_config->use_history = 'N';
391 391
 		$bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace';
392 392
 
393
-		if($bUseHistory)
393
+		if ($bUseHistory)
394 394
 		{
395 395
 			$args = new stdClass;
396 396
 			$args->history_srl = getNextSequence();
397 397
 			$args->document_srl = $obj->document_srl;
398 398
 			$args->module_srl = $module_srl;
399
-			if($document_config->use_history == 'Y') $args->content = $source_obj->get('content');
399
+			if ($document_config->use_history == 'Y') $args->content = $source_obj->get('content');
400 400
 			$args->nick_name = $source_obj->get('nick_name');
401 401
 			$args->member_srl = $source_obj->get('member_srl');
402 402
 			$args->regdate = $source_obj->get('last_update');
@@ -408,30 +408,30 @@  discard block
 block discarded – undo
408 408
 			$obj->ipaddress = $source_obj->get('ipaddress');
409 409
 		}
410 410
 		// List variables
411
-		if($obj->comment_status) $obj->commentStatus = $obj->comment_status;
412
-		if(!$obj->commentStatus) $obj->commentStatus = 'DENY';
413
-		if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj);
414
-		if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N';
415
-		if($obj->homepage)
411
+		if ($obj->comment_status) $obj->commentStatus = $obj->comment_status;
412
+		if (!$obj->commentStatus) $obj->commentStatus = 'DENY';
413
+		if ($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj);
414
+		if ($obj->allow_trackback != 'Y') $obj->allow_trackback = 'N';
415
+		if ($obj->homepage)
416 416
 		{
417 417
 			$obj->homepage = escape($obj->homepage);
418
-			if(!preg_match('/^[a-z]+:\/\//i',$obj->homepage))
418
+			if (!preg_match('/^[a-z]+:\/\//i', $obj->homepage))
419 419
 			{
420 420
 				$obj->homepage = 'http://'.$obj->homepage;
421 421
 			}
422 422
 		}
423 423
 		
424
-		if($obj->notify_message != 'Y') $obj->notify_message = 'N';
424
+		if ($obj->notify_message != 'Y') $obj->notify_message = 'N';
425 425
 		
426 426
 		// can modify regdate only manager
427 427
                 $grant = Context::get('grant');
428
-		if(!$grant->manager)
428
+		if (!$grant->manager)
429 429
 		{
430 430
 			unset($obj->regdate);
431 431
 		}
432 432
 		
433 433
 		// Serialize the $extra_vars
434
-		if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars);
434
+		if (!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars);
435 435
 		// Remove the columns for automatic saving
436 436
 		unset($obj->_saved_doc_srl);
437 437
 		unset($obj->_saved_doc_title);
@@ -440,23 +440,23 @@  discard block
 block discarded – undo
440 440
 
441 441
 		$oDocumentModel = getModel('document');
442 442
 		// Set the category_srl to 0 if the changed category is not exsiting.
443
-		if($source_obj->get('category_srl')!=$obj->category_srl)
443
+		if ($source_obj->get('category_srl') != $obj->category_srl)
444 444
 		{
445 445
 			$category_list = $oDocumentModel->getCategoryList($obj->module_srl);
446
-			if(!$category_list[$obj->category_srl]) $obj->category_srl = 0;
446
+			if (!$category_list[$obj->category_srl]) $obj->category_srl = 0;
447 447
 		}
448 448
 		// Change the update order
449 449
 		$obj->update_order = getNextSequence() * -1;
450 450
 		// Hash the password if it exists
451
-		if($obj->password)
451
+		if ($obj->password)
452 452
 		{
453 453
 			$obj->password = getModel('member')->hashPassword($obj->password);
454 454
 		}
455 455
 
456 456
 		// If an author is identical to the modifier or history is used, use the logged-in user's information.
457
-		if(Context::get('is_logged') && !$manual_updated)
457
+		if (Context::get('is_logged') && !$manual_updated)
458 458
 		{
459
-			if($source_obj->get('member_srl')==$logged_info->member_srl)
459
+			if ($source_obj->get('member_srl') == $logged_info->member_srl)
460 460
 			{
461 461
 				$obj->member_srl = $logged_info->member_srl;
462 462
 				$obj->user_name = htmlspecialchars_decode($logged_info->user_name);
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
 		}
468 468
 
469 469
 		// For the document written by logged-in user however no nick_name exists
470
-		if($source_obj->get('member_srl')&& !$obj->nick_name)
470
+		if ($source_obj->get('member_srl') && !$obj->nick_name)
471 471
 		{
472 472
 			$obj->member_srl = $source_obj->get('member_srl');
473 473
 			$obj->user_name = $source_obj->get('user_name');
@@ -478,24 +478,24 @@  discard block
 block discarded – undo
478 478
 		// If the tile is empty, extract string from the contents.
479 479
 		$obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
480 480
 		settype($obj->title, "string");
481
-		if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...');
481
+		if ($obj->title == '') $obj->title = cut_str(strip_tags($obj->content), 20, '...');
482 482
 		// If no tile extracted from the contents, leave it untitled.
483
-		if($obj->title == '') $obj->title = 'Untitled';
483
+		if ($obj->title == '') $obj->title = 'Untitled';
484 484
 		// Remove XE's own tags from the contents.
485 485
 		$obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content);
486
-		if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y')
486
+		if (Mobile::isFromMobilePhone() && $obj->use_editor != 'Y')
487 487
 		{
488
-			if($obj->use_html != 'Y')
488
+			if ($obj->use_html != 'Y')
489 489
 			{
490 490
 				$obj->content = htmlspecialchars($obj->content, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
491 491
 			}
492 492
 			$obj->content = nl2br($obj->content);
493 493
 		}
494 494
 		// Change not extra vars but language code of the original document if document's lang_code is different from author's setting.
495
-		if($source_obj->get('lang_code') != Context::getLangType())
495
+		if ($source_obj->get('lang_code') != Context::getLangType())
496 496
 		{
497 497
 			// Change not extra vars but language code of the original document if document's lang_code doesn't exist.
498
-			if(!$source_obj->get('lang_code'))
498
+			if (!$source_obj->get('lang_code'))
499 499
 			{
500 500
 				$lang_code_args->document_srl = $source_obj->get('document_srl');
501 501
 				$lang_code_args->lang_code = Context::getLangType();
@@ -515,59 +515,59 @@  discard block
 block discarded – undo
515 515
 			}
516 516
 		}
517 517
 		// Remove iframe and script if not a top adminisrator in the session.
518
-		if($logged_info->is_admin != 'Y')
518
+		if ($logged_info->is_admin != 'Y')
519 519
 		{
520 520
 			$obj->content = removeHackTag($obj->content);
521 521
 		}
522 522
 		// if temporary document, regdate is now setting
523
-		if($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis');
523
+		if ($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis');
524 524
 
525 525
 		// Insert data into the DB
526 526
 		$output = executeQuery('document.updateDocument', $obj);
527
-		if(!$output->toBool())
527
+		if (!$output->toBool())
528 528
 		{
529 529
 			$oDB->rollback();
530 530
 			return $output;
531 531
 		}
532 532
 		// Remove all extra variables
533
-		if(Context::get('act')!='procFileDelete')
533
+		if (Context::get('act') != 'procFileDelete')
534 534
 		{
535 535
 			$this->deleteDocumentExtraVars($source_obj->get('module_srl'), $obj->document_srl, null, Context::getLangType());
536 536
 			// Insert extra variables if the document successfully inserted.
537 537
 			$extra_keys = $oDocumentModel->getExtraKeys($obj->module_srl);
538
-			if(count($extra_keys))
538
+			if (count($extra_keys))
539 539
 			{
540
-				foreach($extra_keys as $idx => $extra_item)
540
+				foreach ($extra_keys as $idx => $extra_item)
541 541
 				{
542 542
 					$value = NULL;
543
-					if(isset($obj->{'extra_vars'.$idx}))
543
+					if (isset($obj->{'extra_vars'.$idx}))
544 544
 					{
545 545
 						$tmp = $obj->{'extra_vars'.$idx};
546
-						if(is_array($tmp))
546
+						if (is_array($tmp))
547 547
 							$value = implode('|@|', $tmp);
548 548
 						else
549 549
 							$value = trim($tmp);
550 550
 					}
551
-					else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name});
552
-					if($value == NULL) continue;
551
+					else if (isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name});
552
+					if ($value == NULL) continue;
553 553
 					$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid);
554 554
 				}
555 555
 			}
556 556
 			// Inert extra vars for multi-language support of title and contents.
557
-			if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType());
558
-			if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType());
557
+			if ($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType());
558
+			if ($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType());
559 559
 		}
560 560
 		// Update the category if the category_srl exists.
561
-		if($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl)
561
+		if ($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl)
562 562
 		{
563
-			if($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl'));
564
-			if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl);
563
+			if ($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl'));
564
+			if ($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl);
565 565
 		}
566 566
 		// Call a trigger (after)
567
-		if($output->toBool())
567
+		if ($output->toBool())
568 568
 		{
569 569
 			$trigger_output = ModuleHandler::triggerCall('document.updateDocument', 'after', $obj);
570
-			if(!$trigger_output->toBool())
570
+			if (!$trigger_output->toBool())
571 571
 			{
572 572
 				$oDB->rollback();
573 573
 				return $trigger_output;
@@ -577,15 +577,15 @@  discard block
 block discarded – undo
577 577
 		// commit
578 578
 		$oDB->commit();
579 579
 		// Remove the thumbnail file
580
-		FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3)));
580
+		FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3)));
581 581
 
582
-		$output->add('document_srl',$obj->document_srl);
582
+		$output->add('document_srl', $obj->document_srl);
583 583
 		//remove from cache
584 584
 		$oCacheHandler = CacheHandler::getInstance('object');
585
-		if($oCacheHandler->isSupport())
585
+		if ($oCacheHandler->isSupport())
586 586
 		{
587 587
 			//remove document item from cache
588
-			$cache_key = 'document_item:'. getNumberingPath($obj->document_srl) . $obj->document_srl;
588
+			$cache_key = 'document_item:'.getNumberingPath($obj->document_srl).$obj->document_srl;
589 589
 			$oCacheHandler->delete($cache_key);
590 590
 		}
591 591
 
@@ -606,33 +606,33 @@  discard block
 block discarded – undo
606 606
 		$trigger_obj = new stdClass();
607 607
 		$trigger_obj->document_srl = $document_srl;
608 608
 		$output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj);
609
-		if(!$output->toBool()) return $output;
609
+		if (!$output->toBool()) return $output;
610 610
 
611 611
 		// begin transaction
612 612
 		$oDB = &DB::getInstance();
613 613
 		$oDB->begin();
614 614
 
615
-		if(!$isEmptyTrash)
615
+		if (!$isEmptyTrash)
616 616
 		{
617 617
 			// get model object of the document
618 618
 			$oDocumentModel = getModel('document');
619 619
 			// Check if the documnet exists
620 620
 			$oDocument = $oDocumentModel->getDocument($document_srl, $is_admin);
621 621
 		}
622
-		else if($isEmptyTrash && $oDocument == null) return new BaseObject(-1, 'document is not exists');
622
+		else if ($isEmptyTrash && $oDocument == null) return new BaseObject(-1, 'document is not exists');
623 623
 
624
-		if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new BaseObject(-1, 'msg_invalid_document');
624
+		if (!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new BaseObject(-1, 'msg_invalid_document');
625 625
 		// Check if a permossion is granted
626
-		if(!$oDocument->isGranted()) return new BaseObject(-1, 'msg_not_permitted');
626
+		if (!$oDocument->isGranted()) return new BaseObject(-1, 'msg_not_permitted');
627 627
 
628 628
 		//if empty trash, document already deleted, therefore document not delete
629 629
 		$args = new stdClass();
630 630
 		$args->document_srl = $document_srl;
631
-		if(!$isEmptyTrash)
631
+		if (!$isEmptyTrash)
632 632
 		{
633 633
 			// Delete the document
634 634
 			$output = executeQuery('document.deleteDocument', $args);
635
-			if(!$output->toBool())
635
+			if (!$output->toBool())
636 636
 			{
637 637
 				$oDB->rollback();
638 638
 				return $output;
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
 
644 644
 		$this->deleteDocumentHistory(null, $document_srl, null);
645 645
 		// Update category information if the category_srl exists.
646
-		if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl'));
646
+		if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl'));
647 647
 		// Delete a declared list
648 648
 		executeQuery('document.deleteDeclared', $args);
649 649
 		// Delete extra variable
@@ -651,11 +651,11 @@  discard block
 block discarded – undo
651 651
 
652 652
 		//this
653 653
 		// Call a trigger (after)
654
-		if($output->toBool())
654
+		if ($output->toBool())
655 655
 		{
656 656
 			$trigger_obj = $oDocument->getObjectVars();
657 657
 			$trigger_output = ModuleHandler::triggerCall('document.deleteDocument', 'after', $trigger_obj);
658
-			if(!$trigger_output->toBool())
658
+			if (!$trigger_output->toBool())
659 659
 			{
660 660
 				$oDB->rollback();
661 661
 				return $trigger_output;
@@ -667,16 +667,16 @@  discard block
 block discarded – undo
667 667
 		$this->_deleteDocumentVotedLog($args);
668 668
 
669 669
 		// Remove the thumbnail file
670
-		FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($document_srl, 3)));
670
+		FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($document_srl, 3)));
671 671
 
672 672
 		// commit
673 673
 		$oDB->commit();
674 674
 
675 675
 		//remove from cache
676 676
 		$oCacheHandler = CacheHandler::getInstance('object');
677
-		if($oCacheHandler->isSupport())
677
+		if ($oCacheHandler->isSupport())
678 678
 		{
679
-			$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
679
+			$cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl;
680 680
 			$oCacheHandler->delete($cache_key);
681 681
 		}
682 682
 
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
 	{
724 724
 		$trash_args = new stdClass();
725 725
 		// Get trash_srl if a given trash_srl doesn't exist
726
-		if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence();
726
+		if (!$obj->trash_srl) $trash_args->trash_srl = getNextSequence();
727 727
 		else $trash_args->trash_srl = $obj->trash_srl;
728 728
 		// Get its module_srl which the document belongs to
729 729
 		$oDocumentModel = getModel('document');
@@ -732,12 +732,12 @@  discard block
 block discarded – undo
732 732
 		$trash_args->module_srl = $oDocument->get('module_srl');
733 733
 		$obj->module_srl = $oDocument->get('module_srl');
734 734
 		// Cannot throw data from the trash to the trash
735
-		if($trash_args->module_srl == 0) return false;
735
+		if ($trash_args->module_srl == 0) return false;
736 736
 		// Data setting
737 737
 		$trash_args->document_srl = $obj->document_srl;
738 738
 		$trash_args->description = $obj->description;
739 739
 		// Insert member's information only if the member is logged-in and not manually registered.
740
-		if(Context::get('is_logged')&&!$manual_inserted)
740
+		if (Context::get('is_logged') && !$manual_inserted)
741 741
 		{
742 742
 			$logged_info = Context::get('logged_info');
743 743
 			$trash_args->member_srl = $logged_info->member_srl;
@@ -773,14 +773,14 @@  discard block
 block discarded – undo
773 773
 
774 774
 		$oTrashAdminController = getAdminController('trash');
775 775
 		$output = $oTrashAdminController->insertTrash($oTrashVO);
776
-		if(!$output->toBool())
776
+		if (!$output->toBool())
777 777
 		{
778 778
 			$oDB->rollback();
779 779
 			return $output;
780 780
 		}
781 781
 
782 782
 		$output = executeQuery('document.deleteDocument', $trash_args);
783
-		if(!$output->toBool())
783
+		if (!$output->toBool())
784 784
 		{
785 785
 			$oDB->rollback();
786 786
 			return $output;
@@ -793,12 +793,12 @@  discard block
 block discarded – undo
793 793
 		  }*/
794 794
 
795 795
 		// update category
796
-		if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl'));
796
+		if ($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'), $oDocument->get('category_srl'));
797 797
 
798 798
 		// remove thumbnails
799
-		FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3)));
799
+		FileHandler::removeDir(sprintf('files/thumbnails/%s', getNumberingPath($obj->document_srl, 3)));
800 800
 		// Set the attachment to be invalid state
801
-		if($oDocument->hasUploadedFiles())
801
+		if ($oDocument->hasUploadedFiles())
802 802
 		{
803 803
 			$args = new stdClass();
804 804
 			$args->upload_target_srl = $oDocument->document_srl;
@@ -806,10 +806,10 @@  discard block
 block discarded – undo
806 806
 			executeQuery('file.updateFileValid', $args);
807 807
 		}
808 808
 		// Call a trigger (after)
809
-		if($output->toBool())
809
+		if ($output->toBool())
810 810
 		{
811 811
 			$trigger_output = ModuleHandler::triggerCall('document.moveDocumentToTrash', 'after', $obj);
812
-			if(!$trigger_output->toBool())
812
+			if (!$trigger_output->toBool())
813 813
 			{
814 814
 				$oDB->rollback();
815 815
 				return $trigger_output;
@@ -821,9 +821,9 @@  discard block
 block discarded – undo
821 821
 
822 822
 		// Clear cache
823 823
 		$oCacheHandler = CacheHandler::getInstance('object');
824
-		if($oCacheHandler->isSupport())
824
+		if ($oCacheHandler->isSupport())
825 825
 		{
826
-			$cache_key = 'document_item:'. getNumberingPath($oDocument->document_srl) . $oDocument->document_srl;
826
+			$cache_key = 'document_item:'.getNumberingPath($oDocument->document_srl).$oDocument->document_srl;
827 827
 			$oCacheHandler->delete($cache_key);
828 828
 		}
829 829
 
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 	function updateReadedCount(&$oDocument)
839 839
 	{
840 840
 		// Pass if Crawler access
841
-		if(isCrawler()) return false;
841
+		if (isCrawler()) return false;
842 842
 		
843 843
 		$document_srl = $oDocument->document_srl;
844 844
 		$member_srl = $oDocument->get('member_srl');
@@ -846,19 +846,19 @@  discard block
 block discarded – undo
846 846
 
847 847
 		// Call a trigger when the read count is updated (before)
848 848
 		$trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument);
849
-		if(!$trigger_output->toBool()) return $trigger_output;
849
+		if (!$trigger_output->toBool()) return $trigger_output;
850 850
 
851 851
 		// Pass if read count is increaded on the session information
852
-		if($_SESSION['readed_document'][$document_srl]) return false;
852
+		if ($_SESSION['readed_document'][$document_srl]) return false;
853 853
 
854 854
 		// Pass if the author's IP address is as same as visitor's.
855
-		if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
855
+		if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
856 856
 		{
857 857
 			$_SESSION['readed_document'][$document_srl] = true;
858 858
 			return false;
859 859
 		}
860 860
 		// Pass ater registering sesscion if the author is a member and has same information as the currently logged-in user.
861
-		if($member_srl && $logged_info->member_srl == $member_srl)
861
+		if ($member_srl && $logged_info->member_srl == $member_srl)
862 862
 		{
863 863
 			$_SESSION['readed_document'][$document_srl] = true;
864 864
 			return false;
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 
875 875
 		// Call a trigger when the read count is updated (after)
876 876
 		$trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'after', $oDocument);
877
-		if(!$trigger_output->toBool())
877
+		if (!$trigger_output->toBool())
878 878
 		{
879 879
 			$oDB->rollback();
880 880
 			return $trigger_output;
@@ -883,15 +883,15 @@  discard block
 block discarded – undo
883 883
 		$oDB->commit();
884 884
 
885 885
 		$oCacheHandler = CacheHandler::getInstance('object');
886
-		if($oCacheHandler->isSupport())
886
+		if ($oCacheHandler->isSupport())
887 887
 		{
888 888
 			//remove document item from cache
889
-			$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
889
+			$cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl;
890 890
 			$oCacheHandler->delete($cache_key);
891 891
 		}
892 892
 
893 893
 		// Register session
894
-		if(!$_SESSION['banned_document'][$document_srl]) 
894
+		if (!$_SESSION['banned_document'][$document_srl]) 
895 895
 		{
896 896
 			$_SESSION['readed_document'][$document_srl] = true;
897 897
 		}
@@ -914,21 +914,21 @@  discard block
 block discarded – undo
914 914
 	 */
915 915
 	function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid)
916 916
 	{
917
-		if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new BaseObject(-1,'msg_invalid_request');
917
+		if (!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new BaseObject(-1, 'msg_invalid_request');
918 918
 
919 919
 		$obj = new stdClass();
920 920
 		$obj->module_srl = $module_srl;
921 921
 		$obj->var_idx = $var_idx;
922 922
 		$obj->var_name = $var_name;
923 923
 		$obj->var_type = $var_type;
924
-		$obj->var_is_required = $var_is_required=='Y'?'Y':'N';
925
-		$obj->var_search = $var_search=='Y'?'Y':'N';
924
+		$obj->var_is_required = $var_is_required == 'Y' ? 'Y' : 'N';
925
+		$obj->var_search = $var_search == 'Y' ? 'Y' : 'N';
926 926
 		$obj->var_default = $var_default;
927 927
 		$obj->var_desc = $var_desc;
928 928
 		$obj->eid = $eid;
929 929
 
930 930
 		$output = executeQuery('document.getDocumentExtraKeys', $obj);
931
-		if(!$output->data)
931
+		if (!$output->data)
932 932
 		{
933 933
 			$output = executeQuery('document.insertDocumentExtraKey', $obj);
934 934
 		}
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 		}
941 941
 
942 942
 		$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
943
-		if($oCacheHandler->isSupport())
943
+		if ($oCacheHandler->isSupport())
944 944
 		{
945 945
 			$object_key = 'module_document_extra_keys:'.$module_srl;
946 946
 			$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
@@ -958,42 +958,42 @@  discard block
 block discarded – undo
958 958
 	 */
959 959
 	function deleteDocumentExtraKeys($module_srl, $var_idx = null)
960 960
 	{
961
-		if(!$module_srl) return new BaseObject(-1,'msg_invalid_request');
961
+		if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request');
962 962
 		$obj = new stdClass();
963 963
 		$obj->module_srl = $module_srl;
964
-		if(!is_null($var_idx)) $obj->var_idx = $var_idx;
964
+		if (!is_null($var_idx)) $obj->var_idx = $var_idx;
965 965
 
966 966
 		$oDB = DB::getInstance();
967 967
 		$oDB->begin();
968 968
 
969 969
 		$output = $oDB->executeQuery('document.deleteDocumentExtraKeys', $obj);
970
-		if(!$output->toBool())
970
+		if (!$output->toBool())
971 971
 		{
972 972
 			$oDB->rollback();
973 973
 			return $output;
974 974
 		}
975 975
 
976
-		if($var_idx != NULL)
976
+		if ($var_idx != NULL)
977 977
 		{
978 978
 			$output = $oDB->executeQuery('document.updateDocumentExtraKeyIdxOrder', $obj);
979
-			if(!$output->toBool())
979
+			if (!$output->toBool())
980 980
 			{
981 981
 				$oDB->rollback();
982 982
 				return $output;
983 983
 			}
984 984
 		}
985 985
 
986
-		$output =  executeQuery('document.deleteDocumentExtraVars', $obj);
987
-		if(!$output->toBool())
986
+		$output = executeQuery('document.deleteDocumentExtraVars', $obj);
987
+		if (!$output->toBool())
988 988
 		{
989 989
 			$oDB->rollback();
990 990
 			return $output;
991 991
 		}
992 992
 
993
-		if($var_idx != NULL)
993
+		if ($var_idx != NULL)
994 994
 		{
995 995
 			$output = $oDB->executeQuery('document.updateDocumentExtraVarIdxOrder', $obj);
996
-			if(!$output->toBool())
996
+			if (!$output->toBool())
997 997
 			{
998 998
 				$oDB->rollback();
999 999
 				return $output;
@@ -1003,7 +1003,7 @@  discard block
 block discarded – undo
1003 1003
 		$oDB->commit();
1004 1004
 
1005 1005
 		$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
1006
-		if($oCacheHandler->isSupport())
1006
+		if ($oCacheHandler->isSupport())
1007 1007
 		{
1008 1008
 			$object_key = 'module_document_extra_keys:'.$module_srl;
1009 1009
 			$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
@@ -1025,8 +1025,8 @@  discard block
 block discarded – undo
1025 1025
 	 */
1026 1026
 	function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '')
1027 1027
 	{
1028
-		if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new BaseObject(-1,'msg_invalid_request');
1029
-		if(!$lang_code) $lang_code = Context::getLangType();
1028
+		if (!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new BaseObject(-1, 'msg_invalid_request');
1029
+		if (!$lang_code) $lang_code = Context::getLangType();
1030 1030
 
1031 1031
 		$obj = new stdClass;
1032 1032
 		$obj->module_srl = $module_srl;
@@ -1052,10 +1052,10 @@  discard block
 block discarded – undo
1052 1052
 	{
1053 1053
 		$obj = new stdClass();
1054 1054
 		$obj->module_srl = $module_srl;
1055
-		if(!is_null($document_srl)) $obj->document_srl = $document_srl;
1056
-		if(!is_null($var_idx)) $obj->var_idx = $var_idx;
1057
-		if(!is_null($lang_code)) $obj->lang_code = $lang_code;
1058
-		if(!is_null($eid)) $obj->eid = $eid;
1055
+		if (!is_null($document_srl)) $obj->document_srl = $document_srl;
1056
+		if (!is_null($var_idx)) $obj->var_idx = $var_idx;
1057
+		if (!is_null($lang_code)) $obj->lang_code = $lang_code;
1058
+		if (!is_null($eid)) $obj->eid = $eid;
1059 1059
 		$output = executeQuery('document.deleteDocumentExtraVars', $obj);
1060 1060
 		return $output;
1061 1061
 	}
@@ -1069,10 +1069,10 @@  discard block
 block discarded – undo
1069 1069
 	 */
1070 1070
 	function updateVotedCount($document_srl, $point = 1)
1071 1071
 	{
1072
-		if($point > 0) $failed_voted = 'failed_voted';
1072
+		if ($point > 0) $failed_voted = 'failed_voted';
1073 1073
 		else $failed_voted = 'failed_blamed';
1074 1074
 		// Return fail if session already has information about votes
1075
-		if($_SESSION['voted_document'][$document_srl])
1075
+		if ($_SESSION['voted_document'][$document_srl])
1076 1076
 		{
1077 1077
 			return new BaseObject(-1, $failed_voted);
1078 1078
 		}
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
 		$oDocumentModel = getModel('document');
1081 1081
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
1082 1082
 		// Pass if the author's IP address is as same as visitor's.
1083
-		if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
1083
+		if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
1084 1084
 		{
1085 1085
 			$_SESSION['voted_document'][$document_srl] = true;
1086 1086
 			return new BaseObject(-1, $failed_voted);
@@ -1091,10 +1091,10 @@  discard block
 block discarded – undo
1091 1091
 		$member_srl = $oMemberModel->getLoggedMemberSrl();
1092 1092
 
1093 1093
 		// Check if document's author is a member.
1094
-		if($oDocument->get('member_srl'))
1094
+		if ($oDocument->get('member_srl'))
1095 1095
 		{
1096 1096
 			// Pass after registering a session if author's information is same as the currently logged-in user's.
1097
-			if($member_srl && $member_srl == abs($oDocument->get('member_srl')))
1097
+			if ($member_srl && $member_srl == abs($oDocument->get('member_srl')))
1098 1098
 			{
1099 1099
 				$_SESSION['voted_document'][$document_srl] = true;
1100 1100
 				return new BaseObject(-1, $failed_voted);
@@ -1103,7 +1103,7 @@  discard block
 block discarded – undo
1103 1103
 
1104 1104
 		// Use member_srl for logged-in members and IP address for non-members.
1105 1105
 		$args = new stdClass;
1106
-		if($member_srl)
1106
+		if ($member_srl)
1107 1107
 		{
1108 1108
 			$args->member_srl = $member_srl;
1109 1109
 		}
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
 		$args->document_srl = $document_srl;
1115 1115
 		$output = executeQuery('document.getDocumentVotedLogInfo', $args);
1116 1116
 		// Pass after registering a session if log information has vote-up logs
1117
-		if($output->data->count)
1117
+		if ($output->data->count)
1118 1118
 		{
1119 1119
 			$_SESSION['voted_document'][$document_srl] = true;
1120 1120
 			return new BaseObject(-1, $failed_voted);
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
 		$trigger_obj->before_point = ($point < 0) ? $oDocument->get('blamed_count') : $oDocument->get('voted_count');
1131 1131
 		$trigger_obj->after_point = $trigger_obj->before_point + $point;
1132 1132
 		$trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'before', $trigger_obj);
1133
-		if(!$trigger_output->toBool())
1133
+		if (!$trigger_output->toBool())
1134 1134
 		{
1135 1135
 			return $trigger_output;
1136 1136
 		}
@@ -1140,7 +1140,7 @@  discard block
 block discarded – undo
1140 1140
 		$oDB->begin();
1141 1141
 
1142 1142
 		// Update the voted count
1143
-		if($trigger_obj->update_target === 'blamed_count')
1143
+		if ($trigger_obj->update_target === 'blamed_count')
1144 1144
 		{
1145 1145
 			$args->blamed_count = $trigger_obj->after_point;
1146 1146
 			$output = executeQuery('document.updateBlamedCount', $args);
@@ -1150,16 +1150,16 @@  discard block
 block discarded – undo
1150 1150
 			$args->voted_count = $trigger_obj->after_point;
1151 1151
 			$output = executeQuery('document.updateVotedCount', $args);
1152 1152
 		}
1153
-		if(!$output->toBool()) return $output;
1153
+		if (!$output->toBool()) return $output;
1154 1154
 
1155 1155
 		// Leave logs
1156 1156
 		$args->point = $trigger_obj->point;
1157 1157
 		$output = executeQuery('document.insertDocumentVotedLog', $args);
1158
-		if(!$output->toBool()) return $output;
1158
+		if (!$output->toBool()) return $output;
1159 1159
 
1160 1160
 		// Call a trigger (after)
1161 1161
 		$trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'after', $trigger_obj);
1162
-		if(!$trigger_output->toBool())
1162
+		if (!$trigger_output->toBool())
1163 1163
 		{
1164 1164
 			$oDB->rollback();
1165 1165
 			return $trigger_output;
@@ -1168,10 +1168,10 @@  discard block
 block discarded – undo
1168 1168
 		$oDB->commit();
1169 1169
 
1170 1170
 		$oCacheHandler = CacheHandler::getInstance('object');
1171
-		if($oCacheHandler->isSupport())
1171
+		if ($oCacheHandler->isSupport())
1172 1172
 		{
1173 1173
 			//remove document item from cache
1174
-			$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
1174
+			$cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl;
1175 1175
 			$oCacheHandler->delete($cache_key);
1176 1176
 		}
1177 1177
 
@@ -1180,7 +1180,7 @@  discard block
 block discarded – undo
1180 1180
 
1181 1181
 		// Return result
1182 1182
 		$output = new BaseObject();
1183
-		if($trigger_obj->update_target === 'voted_count')
1183
+		if ($trigger_obj->update_target === 'voted_count')
1184 1184
 		{
1185 1185
 			$output->setMessage('success_voted');
1186 1186
 			$output->add('voted_count', $trigger_obj->after_point);
@@ -1202,13 +1202,13 @@  discard block
 block discarded – undo
1202 1202
 	function declaredDocument($document_srl)
1203 1203
 	{
1204 1204
 		// Fail if session information already has a reported document
1205
-		if($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared');
1205
+		if ($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared');
1206 1206
 
1207 1207
 		// Check if previously reported
1208 1208
 		$args = new stdClass();
1209 1209
 		$args->document_srl = $document_srl;
1210 1210
 		$output = executeQuery('document.getDeclaredDocument', $args);
1211
-		if(!$output->toBool()) return $output;
1211
+		if (!$output->toBool()) return $output;
1212 1212
 
1213 1213
 		$declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0;
1214 1214
 
@@ -1218,7 +1218,7 @@  discard block
 block discarded – undo
1218 1218
 
1219 1219
 		// Call a trigger (before)
1220 1220
 		$trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'before', $trigger_obj);
1221
-		if(!$trigger_output->toBool())
1221
+		if (!$trigger_output->toBool())
1222 1222
 		{
1223 1223
 			return $trigger_output;
1224 1224
 		}
@@ -1228,19 +1228,19 @@  discard block
 block discarded – undo
1228 1228
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
1229 1229
 
1230 1230
 		// Pass if the author's IP address is as same as visitor's.
1231
-		if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) {
1231
+		if ($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) {
1232 1232
 			$_SESSION['declared_document'][$document_srl] = true;
1233 1233
 			return new BaseObject(-1, 'failed_declared');
1234 1234
 		}
1235 1235
 
1236 1236
 		// Check if document's author is a member.
1237
-		if($oDocument->get('member_srl'))
1237
+		if ($oDocument->get('member_srl'))
1238 1238
 		{
1239 1239
 			// Create a member model object
1240 1240
 			$oMemberModel = getModel('member');
1241 1241
 			$member_srl = $oMemberModel->getLoggedMemberSrl();
1242 1242
 			// Pass after registering a session if author's information is same as the currently logged-in user's.
1243
-			if($member_srl && $member_srl == abs($oDocument->get('member_srl')))
1243
+			if ($member_srl && $member_srl == abs($oDocument->get('member_srl')))
1244 1244
 			{
1245 1245
 				$_SESSION['declared_document'][$document_srl] = true;
1246 1246
 				return new BaseObject(-1, 'failed_declared');
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
 
1250 1250
 		// Use member_srl for logged-in members and IP address for non-members.
1251 1251
 		$args = new stdClass;
1252
-		if($member_srl)
1252
+		if ($member_srl)
1253 1253
 		{
1254 1254
 			$args->member_srl = $member_srl;
1255 1255
 		}
@@ -1262,7 +1262,7 @@  discard block
 block discarded – undo
1262 1262
 		$output = executeQuery('document.getDocumentDeclaredLogInfo', $args);
1263 1263
 
1264 1264
 		// Pass after registering a sesson if reported/declared documents are in the logs.
1265
-		if($output->data->count)
1265
+		if ($output->data->count)
1266 1266
 		{
1267 1267
 			$_SESSION['declared_document'][$document_srl] = true;
1268 1268
 			return new BaseObject(-1, 'failed_declared');
@@ -1273,23 +1273,23 @@  discard block
 block discarded – undo
1273 1273
 		$oDB->begin();
1274 1274
 
1275 1275
 		// Add the declared document
1276
-		if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args);
1276
+		if ($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args);
1277 1277
 		else $output = executeQuery('document.insertDeclaredDocument', $args);
1278
-		if(!$output->toBool()) return $output;
1278
+		if (!$output->toBool()) return $output;
1279 1279
 		// Leave logs
1280 1280
 		$output = executeQuery('document.insertDocumentDeclaredLog', $args);
1281
-		if(!$output->toBool())
1281
+		if (!$output->toBool())
1282 1282
 		{
1283 1283
 			$oDB->rollback();
1284 1284
 			return $output;
1285 1285
 		}
1286 1286
 
1287
-		$this->add('declared_count', $declared_count+1);
1287
+		$this->add('declared_count', $declared_count + 1);
1288 1288
 
1289 1289
 		// Call a trigger (after)
1290 1290
 		$trigger_obj->declared_count = $declared_count + 1;
1291 1291
 		$trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'after', $trigger_obj);
1292
-		if(!$trigger_output->toBool())
1292
+		if (!$trigger_output->toBool())
1293 1293
 		{
1294 1294
 			$oDB->rollback();
1295 1295
 			return $trigger_output;
@@ -1319,16 +1319,16 @@  discard block
 block discarded – undo
1319 1319
 		$args->document_srl = $document_srl;
1320 1320
 		$args->comment_count = $comment_count;
1321 1321
 
1322
-		if($comment_inserted)
1322
+		if ($comment_inserted)
1323 1323
 		{
1324
-			$args->update_order = -1*getNextSequence();
1324
+			$args->update_order = -1 * getNextSequence();
1325 1325
 			$args->last_updater = $last_updater;
1326 1326
 
1327 1327
 			$oCacheHandler = CacheHandler::getInstance('object');
1328
-			if($oCacheHandler->isSupport())
1328
+			if ($oCacheHandler->isSupport())
1329 1329
 			{
1330 1330
 				//remove document item from cache
1331
-				$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
1331
+				$cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl;
1332 1332
 				$oCacheHandler->delete($cache_key);
1333 1333
 			}
1334 1334
 		}
@@ -1349,10 +1349,10 @@  discard block
 block discarded – undo
1349 1349
 		$args->trackback_count = $trackback_count;
1350 1350
 
1351 1351
 		$oCacheHandler = CacheHandler::getInstance('object');
1352
-		if($oCacheHandler->isSupport())
1352
+		if ($oCacheHandler->isSupport())
1353 1353
 		{
1354 1354
 			//remove document item from cache
1355
-			$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
1355
+			$cache_key = 'document_item:'.getNumberingPath($document_srl).$document_srl;
1356 1356
 			$oCacheHandler->delete($cache_key);
1357 1357
 		}
1358 1358
 
@@ -1367,14 +1367,14 @@  discard block
 block discarded – undo
1367 1367
 	function insertCategory($obj)
1368 1368
 	{
1369 1369
 		// Sort the order to display if a child category is added
1370
-		if($obj->parent_srl)
1370
+		if ($obj->parent_srl)
1371 1371
 		{
1372 1372
 			// Get its parent category
1373 1373
 			$oDocumentModel = getModel('document');
1374 1374
 			$parent_category = $oDocumentModel->getCategory($obj->parent_srl);
1375 1375
 			$obj->list_order = $parent_category->list_order;
1376
-			$this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1);
1377
-			if(!$obj->category_srl) $obj->category_srl = getNextSequence();
1376
+			$this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order + 1);
1377
+			if (!$obj->category_srl) $obj->category_srl = getNextSequence();
1378 1378
 		}
1379 1379
 		else
1380 1380
 		{
@@ -1382,7 +1382,7 @@  discard block
 block discarded – undo
1382 1382
 		}
1383 1383
 
1384 1384
 		$output = executeQuery('document.insertCategory', $obj);
1385
-		if($output->toBool())
1385
+		if ($output->toBool())
1386 1386
 		{
1387 1387
 			$output->add('category_srl', $obj->category_srl);
1388 1388
 			$this->makeCategoryFile($obj->module_srl);
@@ -1416,13 +1416,13 @@  discard block
 block discarded – undo
1416 1416
 	{
1417 1417
 		// Create a document model object
1418 1418
 		$oDocumentModel = getModel('document');
1419
-		if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl);
1419
+		if (!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl, $category_srl);
1420 1420
 
1421 1421
 		$args = new stdClass;
1422 1422
 		$args->category_srl = $category_srl;
1423 1423
 		$args->document_count = $document_count;
1424 1424
 		$output = executeQuery('document.updateCategoryCount', $args);
1425
-		if($output->toBool()) $this->makeCategoryFile($module_srl);
1425
+		if ($output->toBool()) $this->makeCategoryFile($module_srl);
1426 1426
 
1427 1427
 		return $output;
1428 1428
 	}
@@ -1435,7 +1435,7 @@  discard block
 block discarded – undo
1435 1435
 	function updateCategory($obj)
1436 1436
 	{
1437 1437
 		$output = executeQuery('document.updateCategory', $obj);
1438
-		if($output->toBool()) $this->makeCategoryFile($obj->module_srl);
1438
+		if ($output->toBool()) $this->makeCategoryFile($obj->module_srl);
1439 1439
 		return $output;
1440 1440
 	}
1441 1441
 
@@ -1452,32 +1452,32 @@  discard block
 block discarded – undo
1452 1452
 		$category_info = $oDocumentModel->getCategory($category_srl);
1453 1453
 		// Display an error that the category cannot be deleted if it has a child
1454 1454
 		$output = executeQuery('document.getChildCategoryCount', $args);
1455
-		if(!$output->toBool()) return $output;
1456
-		if($output->data->count>0) return new BaseObject(-1, 'msg_cannot_delete_for_child');
1455
+		if (!$output->toBool()) return $output;
1456
+		if ($output->data->count > 0) return new BaseObject(-1, 'msg_cannot_delete_for_child');
1457 1457
 		// Delete a category information
1458 1458
 		$output = executeQuery('document.deleteCategory', $args);
1459
-		if(!$output->toBool()) return $output;
1459
+		if (!$output->toBool()) return $output;
1460 1460
 
1461 1461
 		$this->makeCategoryFile($category_info->module_srl);
1462 1462
 		// remvove cache
1463 1463
 		$oCacheHandler = CacheHandler::getInstance('object');
1464
-		if($oCacheHandler->isSupport())
1464
+		if ($oCacheHandler->isSupport())
1465 1465
 		{
1466 1466
 			$page = 0;
1467
-			while(true) {
1467
+			while (true) {
1468 1468
 				$args = new stdClass();
1469 1469
 				$args->category_srl = $category_srl;
1470 1470
 				$args->list_count = 100;
1471 1471
 				$args->page = ++$page;
1472 1472
 				$output = executeQuery('document.getDocumentList', $args, array('document_srl'));
1473 1473
 
1474
-				if($output->data == array())
1474
+				if ($output->data == array())
1475 1475
 					break;
1476 1476
 
1477
-				foreach($output->data as $val)
1477
+				foreach ($output->data as $val)
1478 1478
 				{
1479 1479
 					//remove document item from cache
1480
-					$cache_key = 'document_item:'. getNumberingPath($val->document_srl) . $val->document_srl;
1480
+					$cache_key = 'document_item:'.getNumberingPath($val->document_srl).$val->document_srl;
1481 1481
 					$oCacheHandler->delete($cache_key);
1482 1482
 				}
1483 1483
 			}
@@ -1524,18 +1524,18 @@  discard block
 block discarded – undo
1524 1524
 		// Seek a full list of categories
1525 1525
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
1526 1526
 		$category_srl_list = array_keys($category_list);
1527
-		if(count($category_srl_list)<2) return new BaseObject();
1527
+		if (count($category_srl_list) < 2) return new BaseObject();
1528 1528
 
1529 1529
 		$prev_category = NULL;
1530
-		foreach($category_list as $key => $val)
1530
+		foreach ($category_list as $key => $val)
1531 1531
 		{
1532
-			if($key==$category_srl) break;
1532
+			if ($key == $category_srl) break;
1533 1533
 			$prev_category = $val;
1534 1534
 		}
1535 1535
 		// Return if the previous category doesn't exist
1536
-		if(!$prev_category) return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1536
+		if (!$prev_category) return new BaseObject(-1, Context::getLang('msg_category_not_moved'));
1537 1537
 		// Return if the selected category is the top level
1538
-		if($category_srl_list[0]==$category_srl) return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1538
+		if ($category_srl_list[0] == $category_srl) return new BaseObject(-1, Context::getLang('msg_category_not_moved'));
1539 1539
 		// Information of the selected category
1540 1540
 		$cur_args = new stdClass;
1541 1541
 		$cur_args->category_srl = $category_srl;
@@ -1571,15 +1571,15 @@  discard block
 block discarded – undo
1571 1571
 		// Seek a full list of categories
1572 1572
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
1573 1573
 		$category_srl_list = array_keys($category_list);
1574
-		if(count($category_srl_list)<2) return new BaseObject();
1574
+		if (count($category_srl_list) < 2) return new BaseObject();
1575 1575
 
1576
-		for($i=0;$i<count($category_srl_list);$i++)
1576
+		for ($i = 0; $i < count($category_srl_list); $i++)
1577 1577
 		{
1578
-			if($category_srl_list[$i]==$category_srl) break;
1578
+			if ($category_srl_list[$i] == $category_srl) break;
1579 1579
 		}
1580 1580
 
1581
-		$next_category_srl = $category_srl_list[$i+1];
1582
-		if(!$category_list[$next_category_srl]) return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1581
+		$next_category_srl = $category_srl_list[$i + 1];
1582
+		if (!$category_list[$next_category_srl]) return new BaseObject(-1, Context::getLang('msg_category_not_moved'));
1583 1583
 		$next_category = $category_list[$next_category_srl];
1584 1584
 		// Information of the selected category
1585 1585
 		$cur_args = new stdClass;
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
 	{
1607 1607
 		$oDocumentModel = getModel('document');
1608 1608
 		$extra_keys = $oDocumentModel->getExtraKeys($module_srl);
1609
-		if(!count($extra_keys)) return;
1609
+		if (!count($extra_keys)) return;
1610 1610
 
1611 1611
 		$js_code = array();
1612 1612
 		$js_code[] = '<script>//<![CDATA[';
@@ -1616,16 +1616,16 @@  discard block
 block discarded – undo
1616 1616
 
1617 1617
 		$logged_info = Context::get('logged_info');
1618 1618
 
1619
-		foreach($extra_keys as $idx => $val)
1619
+		foreach ($extra_keys as $idx => $val)
1620 1620
 		{
1621 1621
 			$idx = $val->idx;
1622
-			if($val->type == 'kr_zip')
1622
+			if ($val->type == 'kr_zip')
1623 1623
 			{
1624 1624
 				$idx .= '[]';
1625 1625
 			}
1626 1626
 			$name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name);
1627 1627
 			$js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name);
1628
-			if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx);
1628
+			if ($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx);
1629 1629
 		}
1630 1630
 
1631 1631
 		$js_code[] = '})(jQuery);';
@@ -1643,12 +1643,12 @@  discard block
 block discarded – undo
1643 1643
 	function procDocumentInsertCategory($args = null)
1644 1644
 	{
1645 1645
 		// List variables
1646
-		if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid');
1646
+		if (!$args) $args = Context::gets('module_srl', 'category_srl', 'parent_srl', 'category_title', 'category_description', 'expand', 'group_srls', 'category_color', 'mid');
1647 1647
 		$args->title = $args->category_title;
1648 1648
 		$args->description = $args->category_description;
1649 1649
 		$args->color = $args->category_color;
1650 1650
 
1651
-		if(!$args->module_srl && $args->mid)
1651
+		if (!$args->module_srl && $args->mid)
1652 1652
 		{
1653 1653
 			$mid = $args->mid;
1654 1654
 			unset($args->mid);
@@ -1659,28 +1659,28 @@  discard block
 block discarded – undo
1659 1659
 		$columnList = array('module_srl', 'module');
1660 1660
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
1661 1661
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1662
-		if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted');
1662
+		if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted');
1663 1663
 
1664
-		if($args->expand !="Y") $args->expand = "N";
1665
-		if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls);
1664
+		if ($args->expand != "Y") $args->expand = "N";
1665
+		if (!is_array($args->group_srls)) $args->group_srls = str_replace('|@|', ',', $args->group_srls);
1666 1666
 		else $args->group_srls = implode(',', $args->group_srls);
1667
-		$args->parent_srl = (int)$args->parent_srl;
1667
+		$args->parent_srl = (int) $args->parent_srl;
1668 1668
 
1669 1669
 		$oDocumentModel = getModel('document');
1670 1670
 
1671 1671
 		$oDB = &DB::getInstance();
1672 1672
 		$oDB->begin();
1673 1673
 		// Check if already exists
1674
-		if($args->category_srl)
1674
+		if ($args->category_srl)
1675 1675
 		{
1676 1676
 			$category_info = $oDocumentModel->getCategory($args->category_srl);
1677
-			if($category_info->category_srl != $args->category_srl) $args->category_srl = null;
1677
+			if ($category_info->category_srl != $args->category_srl) $args->category_srl = null;
1678 1678
 		}
1679 1679
 		// Update if exists
1680
-		if($args->category_srl)
1680
+		if ($args->category_srl)
1681 1681
 		{
1682 1682
 			$output = $this->updateCategory($args);
1683
-			if(!$output->toBool())
1683
+			if (!$output->toBool())
1684 1684
 			{
1685 1685
 				$oDB->rollback();
1686 1686
 				return $output;
@@ -1690,7 +1690,7 @@  discard block
 block discarded – undo
1690 1690
 		else
1691 1691
 		{
1692 1692
 			$output = $this->insertCategory($args);
1693
-			if(!$output->toBool())
1693
+			if (!$output->toBool())
1694 1694
 			{
1695 1695
 				$oDB->rollback();
1696 1696
 				return $output;
@@ -1729,11 +1729,11 @@  discard block
 block discarded – undo
1729 1729
 		$columnList = array('module_srl', 'module');
1730 1730
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList);
1731 1731
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1732
-		if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted');
1732
+		if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted');
1733 1733
 
1734 1734
 		// First child of the parent_category_srl
1735 1735
 		$source_args = new stdClass;
1736
-		if($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0))
1736
+		if ($parent_category_srl > 0 || ($parent_category_srl == 0 && $target_category_srl == 0))
1737 1737
 		{
1738 1738
 			$parent_category = $oDocumentModel->getCategory($parent_category_srl);
1739 1739
 
@@ -1742,30 +1742,30 @@  discard block
 block discarded – undo
1742 1742
 			$args->parent_srl = $parent_category_srl;
1743 1743
 			$output = executeQuery('document.getChildCategoryMinListOrder', $args);
1744 1744
 
1745
-			if(!$output->toBool()) return $output;
1746
-			$args->list_order = (int)$output->data->list_order;
1747
-			if(!$args->list_order) $args->list_order = 0;
1745
+			if (!$output->toBool()) return $output;
1746
+			$args->list_order = (int) $output->data->list_order;
1747
+			if (!$args->list_order) $args->list_order = 0;
1748 1748
 			$args->list_order--;
1749 1749
 
1750 1750
 			$source_args->category_srl = $source_category_srl;
1751 1751
 			$source_args->parent_srl = $parent_category_srl;
1752 1752
 			$source_args->list_order = $args->list_order;
1753 1753
 			$output = $this->updateCategory($source_args);
1754
-			if(!$output->toBool()) return $output;
1754
+			if (!$output->toBool()) return $output;
1755 1755
 			// Sibling of the $target_category_srl
1756 1756
 		}
1757
-		else if($target_category_srl > 0)
1757
+		else if ($target_category_srl > 0)
1758 1758
 		{
1759 1759
 			$target_category = $oDocumentModel->getCategory($target_category_srl);
1760 1760
 			// Move all siblings of the $target_category down
1761
-			$output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1);
1762
-			if(!$output->toBool()) return $output;
1761
+			$output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order + 1);
1762
+			if (!$output->toBool()) return $output;
1763 1763
 
1764 1764
 			$source_args->category_srl = $source_category_srl;
1765 1765
 			$source_args->parent_srl = $target_category->parent_srl;
1766
-			$source_args->list_order = $target_category->list_order+1;
1766
+			$source_args->list_order = $target_category->list_order + 1;
1767 1767
 			$output = $this->updateCategory($source_args);
1768
-			if(!$output->toBool()) return $output;
1768
+			if (!$output->toBool()) return $output;
1769 1769
 		}
1770 1770
 		// Re-generate the xml file
1771 1771
 		$xml_file = $this->makeCategoryFile($source_category->module_srl);
@@ -1781,7 +1781,7 @@  discard block
 block discarded – undo
1781 1781
 	function procDocumentDeleteCategory()
1782 1782
 	{
1783 1783
 		// List variables
1784
-		$args = Context::gets('module_srl','category_srl');
1784
+		$args = Context::gets('module_srl', 'category_srl');
1785 1785
 
1786 1786
 		$oDB = &DB::getInstance();
1787 1787
 		$oDB->begin();
@@ -1790,17 +1790,17 @@  discard block
 block discarded – undo
1790 1790
 		$columnList = array('module_srl', 'module');
1791 1791
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
1792 1792
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1793
-		if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted');
1793
+		if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted');
1794 1794
 
1795 1795
 		$oDocumentModel = getModel('document');
1796 1796
 		// Get original information
1797 1797
 		$category_info = $oDocumentModel->getCategory($args->category_srl);
1798
-		if($category_info->parent_srl) $parent_srl = $category_info->parent_srl;
1798
+		if ($category_info->parent_srl) $parent_srl = $category_info->parent_srl;
1799 1799
 		// Display an error that the category cannot be deleted if it has a child node
1800
-		if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child');
1800
+		if ($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child');
1801 1801
 		// Remove from the DB
1802 1802
 		$output = $this->deleteCategory($args->category_srl);
1803
-		if(!$output->toBool())
1803
+		if (!$output->toBool())
1804 1804
 		{
1805 1805
 			$oDB->rollback();
1806 1806
 			return $output;
@@ -1831,11 +1831,11 @@  discard block
 block discarded – undo
1831 1831
 		$columnList = array('module_srl', 'module');
1832 1832
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
1833 1833
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1834
-		if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted');
1834
+		if (!$grant->manager) return new BaseObject(-1, 'msg_not_permitted');
1835 1835
 
1836 1836
 		$xml_file = $this->makeCategoryFile($module_srl);
1837 1837
 		// Set return value
1838
-		$this->add('xml_file',$xml_file);
1838
+		$this->add('xml_file', $xml_file);
1839 1839
 	}
1840 1840
 
1841 1841
 	/**
@@ -1846,9 +1846,9 @@  discard block
 block discarded – undo
1846 1846
 	function makeCategoryFile($module_srl)
1847 1847
 	{
1848 1848
 		// Return if there is no information you need for creating a cache file
1849
-		if(!$module_srl) return false;
1849
+		if (!$module_srl) return false;
1850 1850
 
1851
-		$module_srl = (int)$module_srl;
1851
+		$module_srl = (int) $module_srl;
1852 1852
 
1853 1853
 		// Get module information (to obtain mid)
1854 1854
 		$oModuleModel = getModel('module');
@@ -1856,7 +1856,7 @@  discard block
 block discarded – undo
1856 1856
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
1857 1857
 		$mid = $module_info->mid;
1858 1858
 
1859
-		if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category');
1859
+		if (!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category');
1860 1860
 		// Cache file's name
1861 1861
 		$xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl);
1862 1862
 		$php_file = sprintf("./files/cache/document_category/%s.php", $module_srl);
@@ -1868,17 +1868,17 @@  discard block
 block discarded – undo
1868 1868
 
1869 1869
 		$category_list = $output->data;
1870 1870
 
1871
-		if(!is_array($category_list)) $category_list = array($category_list);
1871
+		if (!is_array($category_list)) $category_list = array($category_list);
1872 1872
 
1873 1873
 		$category_count = count($category_list);
1874
-		for($i=0;$i<$category_count;$i++)
1874
+		for ($i = 0; $i < $category_count; $i++)
1875 1875
 		{
1876 1876
 			$category_srl = $category_list[$i]->category_srl;
1877
-			if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = '';
1877
+			if (!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = '';
1878 1878
 			$list[$category_srl] = $category_list[$i];
1879 1879
 		}
1880 1880
 		// Create the xml file without node data if no data is obtained
1881
-		if(!$list)
1881
+		if (!$list)
1882 1882
 		{
1883 1883
 			$xml_buff = "<root />";
1884 1884
 			FileHandler::writeFile($xml_file, $xml_buff);
@@ -1886,12 +1886,12 @@  discard block
 block discarded – undo
1886 1886
 			return $xml_file;
1887 1887
 		}
1888 1888
 		// Change to an array if only a single data is obtained
1889
-		if(!is_array($list)) $list = array($list);
1889
+		if (!is_array($list)) $list = array($list);
1890 1890
 		// Create a tree for loop
1891
-		foreach($list as $category_srl => $node)
1891
+		foreach ($list as $category_srl => $node)
1892 1892
 		{
1893 1893
 			$node->mid = $mid;
1894
-			$parent_srl = (int)$node->parent_srl;
1894
+			$parent_srl = (int) $node->parent_srl;
1895 1895
 			$tree[$parent_srl][$category_srl] = $node;
1896 1896
 		}
1897 1897
 		// A common header to set permissions and groups of the cache file
@@ -1965,13 +1965,13 @@  discard block
 block discarded – undo
1965 1965
 	 */
1966 1966
 	function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff)
1967 1967
 	{
1968
-		if(!$source_node) return;
1968
+		if (!$source_node) return;
1969 1969
 
1970
-		foreach($source_node as $category_srl => $node)
1970
+		foreach ($source_node as $category_srl => $node)
1971 1971
 		{
1972 1972
 			$child_buff = "";
1973 1973
 			// Get data of the child nodes
1974
-			if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff);
1974
+			if ($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff);
1975 1975
 			// List variables
1976 1976
 			$expand = ($node->expand) ? $node->expand : 'N';
1977 1977
 			$group_srls = ($node->group_srls) ? $node->group_srls : '';
@@ -1981,27 +1981,27 @@  discard block
 block discarded – undo
1981 1981
 			$color = ($node->color) ? $node->color : '';
1982 1982
 			$description = ($node->description) ? $node->description : '';
1983 1983
 			// If node->group_srls value exists
1984
-			if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls);
1984
+			if ($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $group_srls);
1985 1985
 			else $group_check_code = "true";
1986 1986
 
1987 1987
 			$title = $node->title;
1988 1988
 			$oModuleAdminModel = getAdminModel('module');
1989 1989
 
1990 1990
 			$langs = $oModuleAdminModel->getLangCode($site_srl, $title);
1991
-			if(count($langs))
1991
+			if (count($langs))
1992 1992
 			{
1993
-				foreach($langs as $key => $val)
1993
+				foreach ($langs as $key => $val)
1994 1994
 				{
1995
-					$xml_header_buff .= sprintf('$_titles[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true));
1995
+					$xml_header_buff .= sprintf('$_titles[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true));
1996 1996
 				}
1997 1997
 			}
1998 1998
 
1999 1999
 			$langx = $oModuleAdminModel->getLangCode($site_srl, $description);
2000
-			if(count($langx))
2000
+			if (count($langx))
2001 2001
 			{
2002
-				foreach($langx as $key => $val)
2002
+				foreach ($langx as $key => $val)
2003 2003
 				{
2004
-					$xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"','\\"',htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true));
2004
+					$xml_header_buff .= sprintf('$_descriptions[%d]["%s"] = %s; ', $category_srl, $key, var_export(str_replace('"', '\\"', htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)), true));
2005 2005
 				}
2006 2006
 			}
2007 2007
 
@@ -2014,7 +2014,7 @@  discard block
 block discarded – undo
2014 2014
 				$category_srl,
2015 2015
 				$group_check_code,
2016 2016
 				$category_srl,
2017
-				var_export(getUrl('','mid',$node->mid,'category',$category_srl), true),
2017
+				var_export(getUrl('', 'mid', $node->mid, 'category', $category_srl), true),
2018 2018
 				var_export($expand, true),
2019 2019
 				var_export($color, true),
2020 2020
 				$group_check_code,
@@ -2022,8 +2022,8 @@  discard block
 block discarded – undo
2022 2022
 				$node->document_count
2023 2023
 			);
2024 2024
 
2025
-			if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff);
2026
-			else $buff .=  sprintf('<node %s />', $attribute);
2025
+			if ($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff);
2026
+			else $buff .= sprintf('<node %s />', $attribute);
2027 2027
 		}
2028 2028
 		return $buff;
2029 2029
 	}
@@ -2042,13 +2042,13 @@  discard block
 block discarded – undo
2042 2042
 	function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff)
2043 2043
 	{
2044 2044
 		$output = array("buff"=>"", "category_srl_list"=>array());
2045
-		if(!$source_node) return $output;
2045
+		if (!$source_node) return $output;
2046 2046
 
2047 2047
 		// Set to an arraty for looping and then generate php script codes to be included
2048
-		foreach($source_node as $category_srl => $node)
2048
+		foreach ($source_node as $category_srl => $node)
2049 2049
 		{
2050 2050
 			// Get data from child nodes first if exist.
2051
-			if($category_srl && $tree[$category_srl]){
2051
+			if ($category_srl && $tree[$category_srl]) {
2052 2052
 				$child_output = $this->getPhpCacheCode($tree[$category_srl], $tree, $site_srl, $php_header_buff);
2053 2053
 			} else {
2054 2054
 				$child_output = array("buff"=>"", "category_srl_list"=>array());
@@ -2059,14 +2059,14 @@  discard block
 block discarded – undo
2059 2059
 			$output['category_srl_list'] = array_merge($output['category_srl_list'], $child_output['category_srl_list']);
2060 2060
 
2061 2061
 			// If node->group_srls value exists
2062
-			if($node->group_srls) {
2063
-				$group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$node->group_srls);
2062
+			if ($node->group_srls) {
2063
+				$group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))', $node->group_srls);
2064 2064
 			} else {
2065 2065
 				$group_check_code = "true";
2066 2066
 			}
2067 2067
 
2068 2068
 			// List variables
2069
-			$selected = '"' . implode('","', $child_output['category_srl_list']) . '"';
2069
+			$selected = '"'.implode('","', $child_output['category_srl_list']).'"';
2070 2070
 			$child_buff = $child_output['buff'];
2071 2071
 			$expand = $node->expand;
2072 2072
 
@@ -2075,32 +2075,32 @@  discard block
 block discarded – undo
2075 2075
 			$oModuleAdminModel = getAdminModel('module');
2076 2076
 			$langs = $oModuleAdminModel->getLangCode($site_srl, $title);
2077 2077
 
2078
-			if(count($langs))
2078
+			if (count($langs))
2079 2079
 			{
2080
-				foreach($langs as $key => $val)
2080
+				foreach ($langs as $key => $val)
2081 2081
 				{
2082 2082
 					$val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2083 2083
 					$php_header_buff .= sprintf(
2084 2084
 						'$_titles[%d]["%s"] = %s; ',
2085 2085
 						$category_srl,
2086 2086
 						$key,
2087
-						var_export(str_replace('"','\\"', $val), true)
2087
+						var_export(str_replace('"', '\\"', $val), true)
2088 2088
 					);
2089 2089
 				}
2090 2090
 			}
2091 2091
 
2092 2092
 			$langx = $oModuleAdminModel->getLangCode($site_srl, $description);
2093 2093
 
2094
-			if(count($langx))
2094
+			if (count($langx))
2095 2095
 			{
2096
-				foreach($langx as $key => $val)
2096
+				foreach ($langx as $key => $val)
2097 2097
 				{
2098 2098
 					$val = htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
2099 2099
 					$php_header_buff .= sprintf(
2100 2100
 						'$_descriptions[%d]["%s"] = %s; ',
2101 2101
 						$category_srl,
2102 2102
 						$key,
2103
-						var_export(str_replace('"','\\"', $val), true)
2103
+						var_export(str_replace('"', '\\"', $val), true)
2104 2104
 					);
2105 2105
 				}
2106 2106
 			}
@@ -2124,7 +2124,7 @@  discard block
 block discarded – undo
2124 2124
 			);
2125 2125
 
2126 2126
 			// Generate buff data
2127
-			$output['buff'] .=  sprintf('%s=>array(%s),', $node->category_srl, $attribute);
2127
+			$output['buff'] .= sprintf('%s=>array(%s),', $node->category_srl, $attribute);
2128 2128
 		}
2129 2129
 
2130 2130
 		return $output;
@@ -2141,7 +2141,7 @@  discard block
 block discarded – undo
2141 2141
 	function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self')
2142 2142
 	{
2143 2143
 		$document_popup_menu_list = Context::get('document_popup_menu_list');
2144
-		if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array();
2144
+		if (!is_array($document_popup_menu_list)) $document_popup_menu_list = array();
2145 2145
 
2146 2146
 		$obj = new stdClass();
2147 2147
 		$obj->url = $url;
@@ -2159,68 +2159,68 @@  discard block
 block discarded – undo
2159 2159
 	 */
2160 2160
 	function procDocumentAddCart()
2161 2161
 	{
2162
-		if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted');
2162
+		if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted');
2163 2163
 
2164 2164
 		// Get document_srl
2165
-		$srls = explode(',',Context::get('srls'));
2166
-		for($i = 0; $i < count($srls); $i++)
2165
+		$srls = explode(',', Context::get('srls'));
2166
+		for ($i = 0; $i < count($srls); $i++)
2167 2167
 		{
2168 2168
 			$srl = trim($srls[$i]);
2169 2169
 
2170
-			if(!$srl) continue;
2170
+			if (!$srl) continue;
2171 2171
 
2172 2172
 			$document_srls[] = $srl;
2173 2173
 		}
2174
-		if(!count($document_srls)) return;
2174
+		if (!count($document_srls)) return;
2175 2175
 
2176 2176
 		// Get module_srl of the documents
2177 2177
 		$args = new stdClass;
2178 2178
 		$args->list_count = count($document_srls);
2179
-		$args->document_srls = implode(',',$document_srls);
2179
+		$args->document_srls = implode(',', $document_srls);
2180 2180
 		$args->order_type = 'asc';
2181 2181
 		$output = executeQueryArray('document.getDocuments', $args);
2182
-		if(!$output->data) return new BaseObject();
2182
+		if (!$output->data) return new BaseObject();
2183 2183
 
2184 2184
 		unset($document_srls);
2185
-		foreach($output->data as $key => $val)
2185
+		foreach ($output->data as $key => $val)
2186 2186
 		{
2187 2187
 			$document_srls[$val->module_srl][] = $val->document_srl;
2188 2188
 		}
2189
-		if(!$document_srls || !count($document_srls)) return new BaseObject();
2189
+		if (!$document_srls || !count($document_srls)) return new BaseObject();
2190 2190
 
2191 2191
 		// Check if each of module administrators exists. Top-level administator will have a permission to modify every document of all modules.(Even to modify temporarily saved or trashed documents)
2192 2192
 		$oModuleModel = getModel('module');
2193 2193
 		$module_srls = array_keys($document_srls);
2194
-		for($i=0;$i<count($module_srls);$i++)
2194
+		for ($i = 0; $i < count($module_srls); $i++)
2195 2195
 		{
2196 2196
 			$module_srl = $module_srls[$i];
2197 2197
 			$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
2198 2198
 			$logged_info = Context::get('logged_info');
2199
-			if($logged_info->is_admin != 'Y')
2199
+			if ($logged_info->is_admin != 'Y')
2200 2200
 			{
2201
-				if(!$module_info)
2201
+				if (!$module_info)
2202 2202
 				{
2203 2203
 					unset($document_srls[$module_srl]);
2204 2204
 					continue;
2205 2205
 				}
2206 2206
 				$grant = $oModuleModel->getGrant($module_info, $logged_info);
2207
-				if(!$grant->manager)
2207
+				if (!$grant->manager)
2208 2208
 				{
2209 2209
 					unset($document_srls[$module_srl]);
2210 2210
 					continue;
2211 2211
 				}
2212 2212
 			}
2213 2213
 		}
2214
-		if(!count($document_srls)) return new BaseObject();
2214
+		if (!count($document_srls)) return new BaseObject();
2215 2215
 
2216
-		foreach($document_srls as $module_srl => $documents)
2216
+		foreach ($document_srls as $module_srl => $documents)
2217 2217
 		{
2218 2218
 			$cnt = count($documents);
2219
-			for($i=0;$i<$cnt;$i++)
2219
+			for ($i = 0; $i < $cnt; $i++)
2220 2220
 			{
2221
-				$document_srl = (int)trim($documents[$i]);
2222
-				if(!$document_srls) continue;
2223
-				if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]);
2221
+				$document_srl = (int) trim($documents[$i]);
2222
+				if (!$document_srls) continue;
2223
+				if ($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]);
2224 2224
 				else $_SESSION['document_management'][$document_srl] = true;
2225 2225
 			}
2226 2226
 		}
@@ -2233,9 +2233,9 @@  discard block
 block discarded – undo
2233 2233
 	function procDocumentManageCheckedDocument()
2234 2234
 	{
2235 2235
 		@set_time_limit(0);
2236
-		if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted');
2236
+		if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted');
2237 2237
 
2238
-		if(!checkCSRF())
2238
+		if (!checkCSRF())
2239 2239
 		{
2240 2240
 			return new BaseObject(-1, 'msg_invalid_request');
2241 2241
 		}
@@ -2243,45 +2243,45 @@  discard block
 block discarded – undo
2243 2243
 		$type = Context::get('type');
2244 2244
 		$target_module = Context::get('target_module_srl');
2245 2245
 		$module_srl = Context::get('module_srl');
2246
-		if($target_module && !$module_srl) $module_srl = $target_module;
2246
+		if ($target_module && !$module_srl) $module_srl = $target_module;
2247 2247
 		$category_srl = Context::get('target_category_srl');
2248 2248
 		$message_content = strip_tags(Context::get('message_content'));
2249
-		if($message_content) $message_content = nl2br($message_content);
2249
+		if ($message_content) $message_content = nl2br($message_content);
2250 2250
 
2251 2251
 		$cart = Context::get('cart');
2252 2252
 		$document_srl_list = (!is_array($cart)) ? explode('|@|', $cart) : $cart;
2253 2253
 
2254
-		array_map(function ($value) { return (int)$value; }, $document_srl_list);
2254
+		array_map(function($value) { return (int) $value; }, $document_srl_list);
2255 2255
 
2256 2256
 		$document_srl_count = count($document_srl_list);
2257 2257
 
2258 2258
 		$oDocumentModel = getModel('document');
2259 2259
 		$document_items = array();
2260
-		foreach($document_srl_list as $document_srl)
2260
+		foreach ($document_srl_list as $document_srl)
2261 2261
 		{
2262 2262
 			$oDocument = $oDocumentModel->getDocument($document_srl);
2263 2263
 			$document_items[] = $oDocument;
2264
-			if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted');
2264
+			if (!$oDocument->isGranted()) return $this->stop('msg_not_permitted');
2265 2265
 		}
2266 2266
 
2267 2267
 		// Send a message
2268
-		if($message_content)
2268
+		if ($message_content)
2269 2269
 		{
2270 2270
 
2271 2271
 			$oCommunicationController = getController('communication');
2272 2272
 
2273 2273
 			$logged_info = Context::get('logged_info');
2274 2274
 
2275
-			$title = cut_str($message_content,10,'...');
2275
+			$title = cut_str($message_content, 10, '...');
2276 2276
 			$sender_member_srl = $logged_info->member_srl;
2277 2277
 
2278
-			foreach($document_items as $oDocument)
2278
+			foreach ($document_items as $oDocument)
2279 2279
 			{
2280
-				if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue;
2280
+				if (!$oDocument->get('member_srl') || $oDocument->get('member_srl') == $sender_member_srl) continue;
2281 2281
 
2282
-				if($type=='move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl());
2282
+				if ($type == 'move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl());
2283 2283
 				else $purl = "";
2284
-				$content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s",$message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false));
2284
+				$content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s", $message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false));
2285 2285
 
2286 2286
 				$oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false);
2287 2287
 			}
@@ -2291,54 +2291,54 @@  discard block
 block discarded – undo
2291 2291
 		$oSpamController->setAvoidLog();
2292 2292
 
2293 2293
 		$oDocumentAdminController = getAdminController('document');
2294
-		if($type == 'move')
2294
+		if ($type == 'move')
2295 2295
 		{
2296
-			if(!$module_srl) return new BaseObject(-1, 'fail_to_move');
2296
+			if (!$module_srl) return new BaseObject(-1, 'fail_to_move');
2297 2297
 
2298 2298
 			$output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl);
2299
-			if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move');
2299
+			if (!$output->toBool()) return new BaseObject(-1, 'fail_to_move');
2300 2300
 
2301 2301
 			$msg_code = 'success_moved';
2302 2302
 
2303 2303
 		}
2304
-		else if($type == 'copy')
2304
+		else if ($type == 'copy')
2305 2305
 		{
2306
-			if(!$module_srl) return new BaseObject(-1, 'fail_to_move');
2306
+			if (!$module_srl) return new BaseObject(-1, 'fail_to_move');
2307 2307
 
2308 2308
 			$output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl);
2309
-			if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move');
2309
+			if (!$output->toBool()) return new BaseObject(-1, 'fail_to_move');
2310 2310
 
2311 2311
 			$msg_code = 'success_copied';
2312 2312
 		}
2313
-		else if($type =='delete')
2313
+		else if ($type == 'delete')
2314 2314
 		{
2315 2315
 			$oDB = &DB::getInstance();
2316 2316
 			$oDB->begin();
2317
-			for($i=0;$i<$document_srl_count;$i++)
2317
+			for ($i = 0; $i < $document_srl_count; $i++)
2318 2318
 			{
2319 2319
 				$document_srl = $document_srl_list[$i];
2320 2320
 				$output = $this->deleteDocument($document_srl, true);
2321
-				if(!$output->toBool()) return new BaseObject(-1, 'fail_to_delete');
2321
+				if (!$output->toBool()) return new BaseObject(-1, 'fail_to_delete');
2322 2322
 			}
2323 2323
 			$oDB->commit();
2324 2324
 			$msg_code = 'success_deleted';
2325 2325
 		}
2326
-		else if($type == 'trash')
2326
+		else if ($type == 'trash')
2327 2327
 		{
2328 2328
 			$args = new stdClass();
2329 2329
 			$args->description = $message_content;
2330 2330
 
2331 2331
 			$oDB = &DB::getInstance();
2332 2332
 			$oDB->begin();
2333
-			for($i=0;$i<$document_srl_count;$i++) {
2333
+			for ($i = 0; $i < $document_srl_count; $i++) {
2334 2334
 				$args->document_srl = $document_srl_list[$i];
2335 2335
 				$output = $this->moveDocumentToTrash($args);
2336
-				if(!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash');
2336
+				if (!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash');
2337 2337
 			}
2338 2338
 			$oDB->commit();
2339 2339
 			$msg_code = 'success_trashed';
2340 2340
 		}
2341
-		else if($type == 'cancelDeclare')
2341
+		else if ($type == 'cancelDeclare')
2342 2342
 		{
2343 2343
 			$args->document_srl = $document_srl_list;
2344 2344
 			$output = executeQuery('document.deleteDeclaredDocuments', $args);
@@ -2360,27 +2360,27 @@  discard block
 block discarded – undo
2360 2360
 	function procDocumentInsertModuleConfig()
2361 2361
 	{
2362 2362
 		$module_srl = Context::get('target_module_srl');
2363
-		if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
2363
+		if (preg_match('/^([0-9,]+)$/', $module_srl)) $module_srl = explode(',', $module_srl);
2364 2364
 		else $module_srl = array($module_srl);
2365 2365
 
2366 2366
 		$document_config = new stdClass();
2367 2367
 		$document_config->use_history = Context::get('use_history');
2368
-		if(!$document_config->use_history) $document_config->use_history = 'N';
2368
+		if (!$document_config->use_history) $document_config->use_history = 'N';
2369 2369
 
2370 2370
 		$document_config->use_vote_up = Context::get('use_vote_up');
2371
-		if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y';
2371
+		if (!$document_config->use_vote_up) $document_config->use_vote_up = 'Y';
2372 2372
 
2373 2373
 		$document_config->use_vote_down = Context::get('use_vote_down');
2374
-		if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y';
2374
+		if (!$document_config->use_vote_down) $document_config->use_vote_down = 'Y';
2375 2375
 
2376 2376
 		$document_config->use_status = Context::get('use_status');
2377 2377
 
2378 2378
 		$oModuleController = getController('module');
2379
-		for($i=0;$i<count($module_srl);$i++)
2379
+		for ($i = 0; $i < count($module_srl); $i++)
2380 2380
 		{
2381 2381
 			$srl = trim($module_srl[$i]);
2382
-			if(!$srl) continue;
2383
-			$output = $oModuleController->insertModulePartConfig('document',$srl,$document_config);
2382
+			if (!$srl) continue;
2383
+			$output = $oModuleController->insertModulePartConfig('document', $srl, $document_config);
2384 2384
 		}
2385 2385
 		$this->setError(-1);
2386 2386
 		$this->setMessage('success_updated', 'info');
@@ -2396,7 +2396,7 @@  discard block
 block discarded – undo
2396 2396
 	function procDocumentTempSave()
2397 2397
 	{
2398 2398
 		// Check login information
2399
-		if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged');
2399
+		if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged');
2400 2400
 		$module_info = Context::get('module_info');
2401 2401
 		$logged_info = Context::get('logged_info');
2402 2402
 
@@ -2408,7 +2408,7 @@  discard block
 block discarded – undo
2408 2408
 		unset($obj->is_notice);
2409 2409
 
2410 2410
 		// Extract from beginning part of contents in the guestbook
2411
-		if(!$obj->title)
2411
+		if (!$obj->title)
2412 2412
 		{
2413 2413
 			$obj->title = cut_str(strip_tags($obj->content), 20, '...');
2414 2414
 		}
@@ -2419,13 +2419,13 @@  discard block
 block discarded – undo
2419 2419
 		$oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager);
2420 2420
 
2421 2421
 		// Update if already exists
2422
-		if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
2422
+		if ($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl)
2423 2423
 		{
2424
-			if($oDocument->get('module_srl') != $obj->module_srl)
2424
+			if ($oDocument->get('module_srl') != $obj->module_srl)
2425 2425
 			{
2426 2426
 				return new BaseObject(-1, 'msg_invalid_request');
2427 2427
 			}
2428
-			if(!$oDocument->isGranted())
2428
+			if (!$oDocument->isGranted())
2429 2429
 			{
2430 2430
 				return new BaseObject(-1, 'msg_invalid_request');
2431 2431
 			}
@@ -2443,7 +2443,7 @@  discard block
 block discarded – undo
2443 2443
 			$oDocument = $oDocumentModel->getDocument($obj->document_srl, $this->grant->manager);
2444 2444
 		}
2445 2445
 		// Set the attachment to be invalid state
2446
-		if($oDocument->hasUploadedFiles())
2446
+		if ($oDocument->hasUploadedFiles())
2447 2447
 		{
2448 2448
 			$args = new stdClass;
2449 2449
 			$args->upload_target_srl = $oDocument->document_srl;
@@ -2461,11 +2461,11 @@  discard block
 block discarded – undo
2461 2461
 	 */
2462 2462
 	function procDocumentGetList()
2463 2463
 	{
2464
-		if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted');
2464
+		if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted');
2465 2465
 		$documentSrls = Context::get('document_srls');
2466
-		if($documentSrls) $documentSrlList = explode(',', $documentSrls);
2466
+		if ($documentSrls) $documentSrlList = explode(',', $documentSrls);
2467 2467
 
2468
-		if(count($documentSrlList) > 0)
2468
+		if (count($documentSrlList) > 0)
2469 2469
 		{
2470 2470
 			$oDocumentModel = getModel('document');
2471 2471
 			$columnList = array('document_srl', 'title', 'nick_name', 'status');
@@ -2489,10 +2489,10 @@  discard block
 block discarded – undo
2489 2489
 	 */
2490 2490
 	function _checkCommentStatusForOldVersion(&$obj)
2491 2491
 	{
2492
-		if(!isset($obj->allow_comment)) $obj->allow_comment = 'N';
2493
-		if(!isset($obj->lock_comment)) $obj->lock_comment = 'N';
2492
+		if (!isset($obj->allow_comment)) $obj->allow_comment = 'N';
2493
+		if (!isset($obj->lock_comment)) $obj->lock_comment = 'N';
2494 2494
 
2495
-		if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW';
2495
+		if ($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW';
2496 2496
 		else $obj->commentStatus = 'DENY';
2497 2497
 	}
2498 2498
 
@@ -2503,8 +2503,8 @@  discard block
 block discarded – undo
2503 2503
 	 */
2504 2504
 	function _checkDocumentStatusForOldVersion(&$obj)
2505 2505
 	{
2506
-		if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret');
2507
-		if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public');
2506
+		if (!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret');
2507
+		if (!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public');
2508 2508
 	}
2509 2509
 
2510 2510
 	public function updateUploaedCount($documentSrlList)
@@ -2512,10 +2512,10 @@  discard block
 block discarded – undo
2512 2512
 		$oDocumentModel = getModel('document');
2513 2513
 		$oFileModel = getModel('file');
2514 2514
 
2515
-		if(is_array($documentSrlList))
2515
+		if (is_array($documentSrlList))
2516 2516
 		{
2517 2517
 			$documentSrlList = array_unique($documentSrlList);
2518
-			foreach($documentSrlList AS $key => $documentSrl)
2518
+			foreach ($documentSrlList AS $key => $documentSrl)
2519 2519
 			{
2520 2520
 				$fileCount = $oFileModel->getFilesCount($documentSrl);
2521 2521
 				$args = new stdClass();
@@ -2536,14 +2536,14 @@  discard block
 block discarded – undo
2536 2536
 		$oDocumentModel = getModel('document');
2537 2537
 		$documentExtraKeys = $oDocumentModel->getExtraKeys($obj->originModuleSrl);
2538 2538
 
2539
-		if(is_array($documentExtraKeys) && is_array($obj->moduleSrlList))
2539
+		if (is_array($documentExtraKeys) && is_array($obj->moduleSrlList))
2540 2540
 		{
2541
-			$oDocumentController=getController('document');
2542
-			foreach($obj->moduleSrlList AS $key=>$value)
2541
+			$oDocumentController = getController('document');
2542
+			foreach ($obj->moduleSrlList AS $key=>$value)
2543 2543
 			{
2544
-				foreach($documentExtraKeys AS $extraItem)
2544
+				foreach ($documentExtraKeys AS $extraItem)
2545 2545
 				{
2546
-					$oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required , $extraItem->search , $extraItem->default , $extraItem->desc, $extraItem->eid) ;
2546
+					$oDocumentController->insertDocumentExtraKey($value, $extraItem->idx, $extraItem->name, $extraItem->type, $extraItem->is_required, $extraItem->search, $extraItem->default, $extraItem->desc, $extraItem->eid);
2547 2547
 				}
2548 2548
 			}
2549 2549
 		}
@@ -2555,9 +2555,9 @@  discard block
 block discarded – undo
2555 2555
 		$documentConfig = $oModuleModel->getModulePartConfig('document', $obj->originModuleSrl);
2556 2556
 
2557 2557
 		$oModuleController = getController('module');
2558
-		if(is_array($obj->moduleSrlList))
2558
+		if (is_array($obj->moduleSrlList))
2559 2559
 		{
2560
-			foreach($obj->moduleSrlList AS $key=>$moduleSrl)
2560
+			foreach ($obj->moduleSrlList AS $key=>$moduleSrl)
2561 2561
 			{
2562 2562
 				$oModuleController->insertModulePartConfig('document', $moduleSrl, $documentConfig);
2563 2563
 			}
Please login to merge, or discard this patch.
Braces   +530 added lines, -214 removed lines patch added patch discarded remove patch
@@ -24,19 +24,27 @@  discard block
 block discarded – undo
24 24
 	 */
25 25
 	function procDocumentVoteUp()
26 26
 	{
27
-		if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request');
27
+		if(!Context::get('is_logged')) {
28
+			return new BaseObject(-1, 'msg_invalid_request');
29
+		}
28 30
 
29 31
 		$document_srl = Context::get('target_srl');
30
-		if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request');
32
+		if(!$document_srl) {
33
+			return new BaseObject(-1, 'msg_invalid_request');
34
+		}
31 35
 
32 36
 		$oDocumentModel = getModel('document');
33 37
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
34 38
 		$module_srl = $oDocument->get('module_srl');
35
-		if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request');
39
+		if(!$module_srl) {
40
+			return new BaseObject(-1, 'msg_invalid_request');
41
+		}
36 42
 
37 43
 		$oModuleModel = getModel('module');
38 44
 		$document_config = $oModuleModel->getModulePartConfig('document',$module_srl);
39
-		if($document_config->use_vote_up=='N') return new BaseObject(-1, 'msg_invalid_request');
45
+		if($document_config->use_vote_up=='N') {
46
+			return new BaseObject(-1, 'msg_invalid_request');
47
+		}
40 48
 
41 49
 		$point = 1;
42 50
 		$output = $this->updateVotedCount($document_srl, $point);
@@ -69,19 +77,27 @@  discard block
 block discarded – undo
69 77
 	 */
70 78
 	function procDocumentVoteDown()
71 79
 	{
72
-		if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request');
80
+		if(!Context::get('is_logged')) {
81
+			return new BaseObject(-1, 'msg_invalid_request');
82
+		}
73 83
 
74 84
 		$document_srl = Context::get('target_srl');
75
-		if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request');
85
+		if(!$document_srl) {
86
+			return new BaseObject(-1, 'msg_invalid_request');
87
+		}
76 88
 
77 89
 		$oDocumentModel = getModel('document');
78 90
 		$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
79 91
 		$module_srl = $oDocument->get('module_srl');
80
-		if(!$module_srl) return new BaseObject(-1, 'msg_invalid_request');
92
+		if(!$module_srl) {
93
+			return new BaseObject(-1, 'msg_invalid_request');
94
+		}
81 95
 
82 96
 		$oModuleModel = getModel('module');
83 97
 		$document_config = $oModuleModel->getModulePartConfig('document',$module_srl);
84
-		if($document_config->use_vote_down=='N') return new BaseObject(-1, 'msg_invalid_request');
98
+		if($document_config->use_vote_down=='N') {
99
+			return new BaseObject(-1, 'msg_invalid_request');
100
+		}
85 101
 
86 102
 		$point = -1;
87 103
 		$output = $this->updateVotedCount($document_srl, $point);
@@ -95,10 +111,14 @@  discard block
 block discarded – undo
95 111
 	 */
96 112
 	function procDocumentDeclare()
97 113
 	{
98
-		if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_invalid_request');
114
+		if(!Context::get('is_logged')) {
115
+			return new BaseObject(-1, 'msg_invalid_request');
116
+		}
99 117
 
100 118
 		$document_srl = Context::get('target_srl');
101
-		if(!$document_srl) return new BaseObject(-1, 'msg_invalid_request');
119
+		if(!$document_srl) {
120
+			return new BaseObject(-1, 'msg_invalid_request');
121
+		}
102 122
 
103 123
 		return $this->declaredDocument($document_srl);
104 124
 	}
@@ -140,7 +160,9 @@  discard block
 block discarded – undo
140 160
 		$args->history_srl = $history_srl;
141 161
 		$args->module_srl = $module_srl;
142 162
 		$args->document_srl = $document_srl;
143
-		if(!$args->history_srl && !$args->module_srl && !$args->document_srl) return;
163
+		if(!$args->history_srl && !$args->module_srl && !$args->document_srl) {
164
+			return;
165
+		}
144 166
 		executeQuery("document.deleteHistory", $args);
145 167
 	}
146 168
 
@@ -152,15 +174,21 @@  discard block
 block discarded – undo
152 174
 	function triggerDeleteModuleDocuments(&$obj)
153 175
 	{
154 176
 		$module_srl = $obj->module_srl;
155
-		if(!$module_srl) return new BaseObject();
177
+		if(!$module_srl) {
178
+			return new BaseObject();
179
+		}
156 180
 		// Delete the document
157 181
 		$oDocumentAdminController = getAdminController('document');
158 182
 		$output = $oDocumentAdminController->deleteModuleDocument($module_srl);
159
-		if(!$output->toBool()) return $output;
183
+		if(!$output->toBool()) {
184
+			return $output;
185
+		}
160 186
 		// Delete the category
161 187
 		$oDocumentController = getController('document');
162 188
 		$output = $oDocumentController->deleteModuleCategory($module_srl);
163
-		if(!$output->toBool()) return $output;
189
+		if(!$output->toBool()) {
190
+			return $output;
191
+		}
164 192
 		// Delete extra key and variable, because module deleted
165 193
 		$this->deleteDocumentExtraKeys($module_srl);
166 194
 
@@ -202,10 +230,18 @@  discard block
 block discarded – undo
202 230
 		$oDB = &DB::getInstance();
203 231
 		$oDB->begin();
204 232
 		// List variables
205
-		if($obj->comment_status) $obj->commentStatus = $obj->comment_status;
206
-		if(!$obj->commentStatus) $obj->commentStatus = 'DENY';
207
-		if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj);
208
-		if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N';
233
+		if($obj->comment_status) {
234
+			$obj->commentStatus = $obj->comment_status;
235
+		}
236
+		if(!$obj->commentStatus) {
237
+			$obj->commentStatus = 'DENY';
238
+		}
239
+		if($obj->commentStatus == 'DENY') {
240
+			$this->_checkCommentStatusForOldVersion($obj);
241
+		}
242
+		if($obj->allow_trackback!='Y') {
243
+			$obj->allow_trackback = 'N';
244
+		}
209 245
 		if($obj->homepage) 
210 246
 		{
211 247
 			$obj->homepage = escape($obj->homepage);
@@ -215,9 +251,15 @@  discard block
 block discarded – undo
215 251
 			}
216 252
 		}
217 253
 		
218
-		if($obj->notify_message != 'Y') $obj->notify_message = 'N';
219
-		if(!$obj->email_address) $obj->email_address = '';
220
-		if(!$isRestore) $obj->ipaddress = $_SERVER['REMOTE_ADDR'];
254
+		if($obj->notify_message != 'Y') {
255
+			$obj->notify_message = 'N';
256
+		}
257
+		if(!$obj->email_address) {
258
+			$obj->email_address = '';
259
+		}
260
+		if(!$isRestore) {
261
+			$obj->ipaddress = $_SERVER['REMOTE_ADDR'];
262
+		}
221 263
 
222 264
                 // can modify regdate only manager
223 265
                 $grant = Context::get('grant');
@@ -227,7 +269,9 @@  discard block
 block discarded – undo
227 269
 		}
228 270
 		
229 271
 		// Serialize the $extra_vars, check the extra_vars type, because duplicate serialized avoid
230
-		if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars);
272
+		if(!is_string($obj->extra_vars)) {
273
+			$obj->extra_vars = serialize($obj->extra_vars);
274
+		}
231 275
 		// Remove the columns for automatic saving
232 276
 		unset($obj->_saved_doc_srl);
233 277
 		unset($obj->_saved_doc_title);
@@ -235,10 +279,15 @@  discard block
 block discarded – undo
235 279
 		unset($obj->_saved_doc_message);
236 280
 		// Call a trigger (before)
237 281
 		$output = ModuleHandler::triggerCall('document.insertDocument', 'before', $obj);
238
-		if(!$output->toBool()) return $output;
282
+		if(!$output->toBool()) {
283
+			return $output;
284
+		}
239 285
 		// Register it if no given document_srl exists
240
-		if(!$obj->document_srl) $obj->document_srl = getNextSequence();
241
-		elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) return new BaseObject(-1, 'msg_not_permitted');
286
+		if(!$obj->document_srl) {
287
+			$obj->document_srl = getNextSequence();
288
+		} elseif(!$manual_inserted && !$isRestore && !checkUserSequence($obj->document_srl)) {
289
+			return new BaseObject(-1, 'msg_not_permitted');
290
+		}
242 291
 
243 292
 		$oDocumentModel = getModel('document');
244 293
 		// Set to 0 if the category_srl doesn't exist
@@ -249,12 +298,19 @@  discard block
 block discarded – undo
249 298
 			{
250 299
 				return new BaseObject(-1, 'msg_not_permitted');
251 300
 			}
252
-			if(count($category_list) > 0 && !$category_list[$obj->category_srl]) $obj->category_srl = 0;
301
+			if(count($category_list) > 0 && !$category_list[$obj->category_srl]) {
302
+				$obj->category_srl = 0;
303
+			}
253 304
 		}
254 305
 		// Set the read counts and update order.
255
-		if(!$obj->readed_count) $obj->readed_count = 0;
256
-		if($isLatest) $obj->update_order = $obj->list_order = $obj->document_srl * -1;
257
-		else $obj->update_order = $obj->list_order;
306
+		if(!$obj->readed_count) {
307
+			$obj->readed_count = 0;
308
+		}
309
+		if($isLatest) {
310
+			$obj->update_order = $obj->list_order = $obj->document_srl * -1;
311
+		} else {
312
+			$obj->update_order = $obj->list_order;
313
+		}
258 314
 		// Check the status of password hash for manually inserting. Apply hashing for otherwise.
259 315
 		if($obj->password && !$obj->password_is_hashed)
260 316
 		{
@@ -276,9 +332,13 @@  discard block
 block discarded – undo
276 332
 		// If the tile is empty, extract string from the contents.
277 333
 		$obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
278 334
 		settype($obj->title, "string");
279
-		if($obj->title == '') $obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...');
335
+		if($obj->title == '') {
336
+			$obj->title = cut_str(trim(strip_tags(nl2br($obj->content))),20,'...');
337
+		}
280 338
 		// If no tile extracted from the contents, leave it untitled.
281
-		if($obj->title == '') $obj->title = 'Untitled';
339
+		if($obj->title == '') {
340
+			$obj->title = 'Untitled';
341
+		}
282 342
 		// Remove XE's own tags from the contents.
283 343
 		$obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content);
284 344
 		if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y')
@@ -290,13 +350,19 @@  discard block
 block discarded – undo
290 350
 			$obj->content = nl2br($obj->content);
291 351
 		}
292 352
 		// Remove iframe and script if not a top adminisrator in the session.
293
-		if($logged_info->is_admin != 'Y') $obj->content = removeHackTag($obj->content);
353
+		if($logged_info->is_admin != 'Y') {
354
+			$obj->content = removeHackTag($obj->content);
355
+		}
294 356
 		// An error appears if both log-in info and user name don't exist.
295
-		if(!$logged_info->member_srl && !$obj->nick_name) return new BaseObject(-1,'msg_invalid_request');
357
+		if(!$logged_info->member_srl && !$obj->nick_name) {
358
+			return new BaseObject(-1,'msg_invalid_request');
359
+		}
296 360
 
297 361
 		$obj->lang_code = Context::getLangType();
298 362
 		// Insert data into the DB
299
-		if(!$obj->status) $this->_checkDocumentStatusForOldVersion($obj);
363
+		if(!$obj->status) {
364
+			$this->_checkDocumentStatusForOldVersion($obj);
365
+		}
300 366
 		$output = executeQuery('document.insertDocument', $obj);
301 367
 		if(!$output->toBool())
302 368
 		{
@@ -313,19 +379,25 @@  discard block
 block discarded – undo
313 379
 				if(isset($obj->{'extra_vars'.$idx}))
314 380
 				{
315 381
 					$tmp = $obj->{'extra_vars'.$idx};
316
-					if(is_array($tmp))
317
-						$value = implode('|@|', $tmp);
318
-					else
319
-						$value = trim($tmp);
382
+					if(is_array($tmp)) {
383
+											$value = implode('|@|', $tmp);
384
+					} else {
385
+											$value = trim($tmp);
386
+					}
387
+				} else if(isset($obj->{$extra_item->name})) {
388
+					$value = trim($obj->{$extra_item->name});
389
+				}
390
+				if($value == NULL) {
391
+					continue;
320 392
 				}
321
-				else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name});
322
-				if($value == NULL) continue;
323 393
 
324 394
 				$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid);
325 395
 			}
326 396
 		}
327 397
 		// Update the category if the category_srl exists.
328
-		if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl);
398
+		if($obj->category_srl) {
399
+			$this->updateCategoryCount($obj->module_srl, $obj->category_srl);
400
+		}
329 401
 		// Call a trigger (after)
330 402
 		if($output->toBool())
331 403
 		{
@@ -367,27 +439,39 @@  discard block
 block discarded – undo
367 439
 			return new BaseObject(-1, 'msg_invalid_request');
368 440
 		}
369 441
 
370
-		if(!$source_obj->document_srl || !$obj->document_srl) return new BaseObject(-1,'msg_invalied_request');
371
-		if(!$obj->status && $obj->is_secret == 'Y') $obj->status = 'SECRET';
372
-		if(!$obj->status) $obj->status = 'PUBLIC';
442
+		if(!$source_obj->document_srl || !$obj->document_srl) {
443
+			return new BaseObject(-1,'msg_invalied_request');
444
+		}
445
+		if(!$obj->status && $obj->is_secret == 'Y') {
446
+			$obj->status = 'SECRET';
447
+		}
448
+		if(!$obj->status) {
449
+			$obj->status = 'PUBLIC';
450
+		}
373 451
 
374 452
 		// Call a trigger (before)
375 453
 		$output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj);
376
-		if(!$output->toBool()) return $output;
454
+		if(!$output->toBool()) {
455
+			return $output;
456
+		}
377 457
 
378 458
 		// begin transaction
379 459
 		$oDB = &DB::getInstance();
380 460
 		$oDB->begin();
381 461
 
382 462
 		$oModuleModel = getModel('module');
383
-		if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl');
463
+		if(!$obj->module_srl) {
464
+			$obj->module_srl = $source_obj->get('module_srl');
465
+		}
384 466
 		$module_srl = $obj->module_srl;
385 467
 		$document_config = $oModuleModel->getModulePartConfig('document', $module_srl);
386 468
 		if(!$document_config)
387 469
 		{
388 470
 			$document_config = new stdClass();
389 471
 		}
390
-		if(!isset($document_config->use_history)) $document_config->use_history = 'N';
472
+		if(!isset($document_config->use_history)) {
473
+			$document_config->use_history = 'N';
474
+		}
391 475
 		$bUseHistory = $document_config->use_history == 'Y' || $document_config->use_history == 'Trace';
392 476
 
393 477
 		if($bUseHistory)
@@ -396,22 +480,31 @@  discard block
 block discarded – undo
396 480
 			$args->history_srl = getNextSequence();
397 481
 			$args->document_srl = $obj->document_srl;
398 482
 			$args->module_srl = $module_srl;
399
-			if($document_config->use_history == 'Y') $args->content = $source_obj->get('content');
483
+			if($document_config->use_history == 'Y') {
484
+				$args->content = $source_obj->get('content');
485
+			}
400 486
 			$args->nick_name = $source_obj->get('nick_name');
401 487
 			$args->member_srl = $source_obj->get('member_srl');
402 488
 			$args->regdate = $source_obj->get('last_update');
403 489
 			$args->ipaddress = $_SERVER['REMOTE_ADDR'];
404 490
 			$output = executeQuery("document.insertHistory", $args);
405
-		}
406
-		else
491
+		} else
407 492
 		{
408 493
 			$obj->ipaddress = $source_obj->get('ipaddress');
409 494
 		}
410 495
 		// List variables
411
-		if($obj->comment_status) $obj->commentStatus = $obj->comment_status;
412
-		if(!$obj->commentStatus) $obj->commentStatus = 'DENY';
413
-		if($obj->commentStatus == 'DENY') $this->_checkCommentStatusForOldVersion($obj);
414
-		if($obj->allow_trackback!='Y') $obj->allow_trackback = 'N';
496
+		if($obj->comment_status) {
497
+			$obj->commentStatus = $obj->comment_status;
498
+		}
499
+		if(!$obj->commentStatus) {
500
+			$obj->commentStatus = 'DENY';
501
+		}
502
+		if($obj->commentStatus == 'DENY') {
503
+			$this->_checkCommentStatusForOldVersion($obj);
504
+		}
505
+		if($obj->allow_trackback!='Y') {
506
+			$obj->allow_trackback = 'N';
507
+		}
415 508
 		if($obj->homepage)
416 509
 		{
417 510
 			$obj->homepage = escape($obj->homepage);
@@ -421,7 +514,9 @@  discard block
 block discarded – undo
421 514
 			}
422 515
 		}
423 516
 		
424
-		if($obj->notify_message != 'Y') $obj->notify_message = 'N';
517
+		if($obj->notify_message != 'Y') {
518
+			$obj->notify_message = 'N';
519
+		}
425 520
 		
426 521
 		// can modify regdate only manager
427 522
                 $grant = Context::get('grant');
@@ -431,7 +526,9 @@  discard block
 block discarded – undo
431 526
 		}
432 527
 		
433 528
 		// Serialize the $extra_vars
434
-		if(!is_string($obj->extra_vars)) $obj->extra_vars = serialize($obj->extra_vars);
529
+		if(!is_string($obj->extra_vars)) {
530
+			$obj->extra_vars = serialize($obj->extra_vars);
531
+		}
435 532
 		// Remove the columns for automatic saving
436 533
 		unset($obj->_saved_doc_srl);
437 534
 		unset($obj->_saved_doc_title);
@@ -443,7 +540,9 @@  discard block
 block discarded – undo
443 540
 		if($source_obj->get('category_srl')!=$obj->category_srl)
444 541
 		{
445 542
 			$category_list = $oDocumentModel->getCategoryList($obj->module_srl);
446
-			if(!$category_list[$obj->category_srl]) $obj->category_srl = 0;
543
+			if(!$category_list[$obj->category_srl]) {
544
+				$obj->category_srl = 0;
545
+			}
447 546
 		}
448 547
 		// Change the update order
449 548
 		$obj->update_order = getNextSequence() * -1;
@@ -478,9 +577,13 @@  discard block
 block discarded – undo
478 577
 		// If the tile is empty, extract string from the contents.
479 578
 		$obj->title = htmlspecialchars($obj->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
480 579
 		settype($obj->title, "string");
481
-		if($obj->title == '') $obj->title = cut_str(strip_tags($obj->content),20,'...');
580
+		if($obj->title == '') {
581
+			$obj->title = cut_str(strip_tags($obj->content),20,'...');
582
+		}
482 583
 		// If no tile extracted from the contents, leave it untitled.
483
-		if($obj->title == '') $obj->title = 'Untitled';
584
+		if($obj->title == '') {
585
+			$obj->title = 'Untitled';
586
+		}
484 587
 		// Remove XE's own tags from the contents.
485 588
 		$obj->content = preg_replace('!<\!--(Before|After)(Document|Comment)\(([0-9]+),([0-9]+)\)-->!is', '', $obj->content);
486 589
 		if(Mobile::isFromMobilePhone() && $obj->use_editor != 'Y')
@@ -500,8 +603,7 @@  discard block
 block discarded – undo
500 603
 				$lang_code_args->document_srl = $source_obj->get('document_srl');
501 604
 				$lang_code_args->lang_code = Context::getLangType();
502 605
 				$output = executeQuery('document.updateDocumentsLangCode', $lang_code_args);
503
-			}
504
-			else
606
+			} else
505 607
 			{
506 608
 				$extra_content = new stdClass;
507 609
 				$extra_content->title = $obj->title;
@@ -520,7 +622,9 @@  discard block
 block discarded – undo
520 622
 			$obj->content = removeHackTag($obj->content);
521 623
 		}
522 624
 		// if temporary document, regdate is now setting
523
-		if($source_obj->get('status') == $this->getConfigStatus('temp')) $obj->regdate = date('YmdHis');
625
+		if($source_obj->get('status') == $this->getConfigStatus('temp')) {
626
+			$obj->regdate = date('YmdHis');
627
+		}
524 628
 
525 629
 		// Insert data into the DB
526 630
 		$output = executeQuery('document.updateDocument', $obj);
@@ -543,25 +647,37 @@  discard block
 block discarded – undo
543 647
 					if(isset($obj->{'extra_vars'.$idx}))
544 648
 					{
545 649
 						$tmp = $obj->{'extra_vars'.$idx};
546
-						if(is_array($tmp))
547
-							$value = implode('|@|', $tmp);
548
-						else
549
-							$value = trim($tmp);
650
+						if(is_array($tmp)) {
651
+													$value = implode('|@|', $tmp);
652
+						} else {
653
+													$value = trim($tmp);
654
+						}
655
+					} else if(isset($obj->{$extra_item->name})) {
656
+						$value = trim($obj->{$extra_item->name});
657
+					}
658
+					if($value == NULL) {
659
+						continue;
550 660
 					}
551
-					else if(isset($obj->{$extra_item->name})) $value = trim($obj->{$extra_item->name});
552
-					if($value == NULL) continue;
553 661
 					$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid);
554 662
 				}
555 663
 			}
556 664
 			// Inert extra vars for multi-language support of title and contents.
557
-			if($extra_content->title) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType());
558
-			if($extra_content->content) $this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType());
665
+			if($extra_content->title) {
666
+				$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -1, $extra_content->title, 'title_'.Context::getLangType());
667
+			}
668
+			if($extra_content->content) {
669
+				$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, -2, $extra_content->content, 'content_'.Context::getLangType());
670
+			}
559 671
 		}
560 672
 		// Update the category if the category_srl exists.
561 673
 		if($source_obj->get('category_srl') != $obj->category_srl || $source_obj->get('module_srl') == $logged_info->member_srl)
562 674
 		{
563
-			if($source_obj->get('category_srl') != $obj->category_srl) $this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl'));
564
-			if($obj->category_srl) $this->updateCategoryCount($obj->module_srl, $obj->category_srl);
675
+			if($source_obj->get('category_srl') != $obj->category_srl) {
676
+				$this->updateCategoryCount($obj->module_srl, $source_obj->get('category_srl'));
677
+			}
678
+			if($obj->category_srl) {
679
+				$this->updateCategoryCount($obj->module_srl, $obj->category_srl);
680
+			}
565 681
 		}
566 682
 		// Call a trigger (after)
567 683
 		if($output->toBool())
@@ -606,7 +722,9 @@  discard block
 block discarded – undo
606 722
 		$trigger_obj = new stdClass();
607 723
 		$trigger_obj->document_srl = $document_srl;
608 724
 		$output = ModuleHandler::triggerCall('document.deleteDocument', 'before', $trigger_obj);
609
-		if(!$output->toBool()) return $output;
725
+		if(!$output->toBool()) {
726
+			return $output;
727
+		}
610 728
 
611 729
 		// begin transaction
612 730
 		$oDB = &DB::getInstance();
@@ -618,12 +736,17 @@  discard block
 block discarded – undo
618 736
 			$oDocumentModel = getModel('document');
619 737
 			// Check if the documnet exists
620 738
 			$oDocument = $oDocumentModel->getDocument($document_srl, $is_admin);
739
+		} else if($isEmptyTrash && $oDocument == null) {
740
+			return new BaseObject(-1, 'document is not exists');
621 741
 		}
622
-		else if($isEmptyTrash && $oDocument == null) return new BaseObject(-1, 'document is not exists');
623 742
 
624
-		if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) return new BaseObject(-1, 'msg_invalid_document');
743
+		if(!$oDocument->isExists() || $oDocument->document_srl != $document_srl) {
744
+			return new BaseObject(-1, 'msg_invalid_document');
745
+		}
625 746
 		// Check if a permossion is granted
626
-		if(!$oDocument->isGranted()) return new BaseObject(-1, 'msg_not_permitted');
747
+		if(!$oDocument->isGranted()) {
748
+			return new BaseObject(-1, 'msg_not_permitted');
749
+		}
627 750
 
628 751
 		//if empty trash, document already deleted, therefore document not delete
629 752
 		$args = new stdClass();
@@ -643,7 +766,9 @@  discard block
 block discarded – undo
643 766
 
644 767
 		$this->deleteDocumentHistory(null, $document_srl, null);
645 768
 		// Update category information if the category_srl exists.
646
-		if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl'));
769
+		if($oDocument->get('category_srl')) {
770
+			$this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl'));
771
+		}
647 772
 		// Delete a declared list
648 773
 		executeQuery('document.deleteDeclared', $args);
649 774
 		// Delete extra variable
@@ -723,8 +848,11 @@  discard block
 block discarded – undo
723 848
 	{
724 849
 		$trash_args = new stdClass();
725 850
 		// Get trash_srl if a given trash_srl doesn't exist
726
-		if(!$obj->trash_srl) $trash_args->trash_srl = getNextSequence();
727
-		else $trash_args->trash_srl = $obj->trash_srl;
851
+		if(!$obj->trash_srl) {
852
+			$trash_args->trash_srl = getNextSequence();
853
+		} else {
854
+			$trash_args->trash_srl = $obj->trash_srl;
855
+		}
728 856
 		// Get its module_srl which the document belongs to
729 857
 		$oDocumentModel = getModel('document');
730 858
 		$oDocument = $oDocumentModel->getDocument($obj->document_srl);
@@ -732,7 +860,9 @@  discard block
 block discarded – undo
732 860
 		$trash_args->module_srl = $oDocument->get('module_srl');
733 861
 		$obj->module_srl = $oDocument->get('module_srl');
734 862
 		// Cannot throw data from the trash to the trash
735
-		if($trash_args->module_srl == 0) return false;
863
+		if($trash_args->module_srl == 0) {
864
+			return false;
865
+		}
736 866
 		// Data setting
737 867
 		$trash_args->document_srl = $obj->document_srl;
738 868
 		$trash_args->description = $obj->description;
@@ -793,7 +923,9 @@  discard block
 block discarded – undo
793 923
 		  }*/
794 924
 
795 925
 		// update category
796
-		if($oDocument->get('category_srl')) $this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl'));
926
+		if($oDocument->get('category_srl')) {
927
+			$this->updateCategoryCount($oDocument->get('module_srl'),$oDocument->get('category_srl'));
928
+		}
797 929
 
798 930
 		// remove thumbnails
799 931
 		FileHandler::removeDir(sprintf('files/thumbnails/%s',getNumberingPath($obj->document_srl, 3)));
@@ -838,7 +970,9 @@  discard block
 block discarded – undo
838 970
 	function updateReadedCount(&$oDocument)
839 971
 	{
840 972
 		// Pass if Crawler access
841
-		if(isCrawler()) return false;
973
+		if(isCrawler()) {
974
+			return false;
975
+		}
842 976
 		
843 977
 		$document_srl = $oDocument->document_srl;
844 978
 		$member_srl = $oDocument->get('member_srl');
@@ -846,10 +980,14 @@  discard block
 block discarded – undo
846 980
 
847 981
 		// Call a trigger when the read count is updated (before)
848 982
 		$trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'before', $oDocument);
849
-		if(!$trigger_output->toBool()) return $trigger_output;
983
+		if(!$trigger_output->toBool()) {
984
+			return $trigger_output;
985
+		}
850 986
 
851 987
 		// Pass if read count is increaded on the session information
852
-		if($_SESSION['readed_document'][$document_srl]) return false;
988
+		if($_SESSION['readed_document'][$document_srl]) {
989
+			return false;
990
+		}
853 991
 
854 992
 		// Pass if the author's IP address is as same as visitor's.
855 993
 		if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
@@ -914,7 +1052,9 @@  discard block
 block discarded – undo
914 1052
 	 */
915 1053
 	function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid)
916 1054
 	{
917
-		if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) return new BaseObject(-1,'msg_invalid_request');
1055
+		if(!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid) {
1056
+			return new BaseObject(-1,'msg_invalid_request');
1057
+		}
918 1058
 
919 1059
 		$obj = new stdClass();
920 1060
 		$obj->module_srl = $module_srl;
@@ -931,8 +1071,7 @@  discard block
 block discarded – undo
931 1071
 		if(!$output->data)
932 1072
 		{
933 1073
 			$output = executeQuery('document.insertDocumentExtraKey', $obj);
934
-		}
935
-		else
1074
+		} else
936 1075
 		{
937 1076
 			$output = executeQuery('document.updateDocumentExtraKey', $obj);
938 1077
 			// Update the extra var(eid)
@@ -958,10 +1097,14 @@  discard block
 block discarded – undo
958 1097
 	 */
959 1098
 	function deleteDocumentExtraKeys($module_srl, $var_idx = null)
960 1099
 	{
961
-		if(!$module_srl) return new BaseObject(-1,'msg_invalid_request');
1100
+		if(!$module_srl) {
1101
+			return new BaseObject(-1,'msg_invalid_request');
1102
+		}
962 1103
 		$obj = new stdClass();
963 1104
 		$obj->module_srl = $module_srl;
964
-		if(!is_null($var_idx)) $obj->var_idx = $var_idx;
1105
+		if(!is_null($var_idx)) {
1106
+			$obj->var_idx = $var_idx;
1107
+		}
965 1108
 
966 1109
 		$oDB = DB::getInstance();
967 1110
 		$oDB->begin();
@@ -1025,8 +1168,12 @@  discard block
 block discarded – undo
1025 1168
 	 */
1026 1169
 	function insertDocumentExtraVar($module_srl, $document_srl, $var_idx, $value, $eid = null, $lang_code = '')
1027 1170
 	{
1028
-		if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) return new BaseObject(-1,'msg_invalid_request');
1029
-		if(!$lang_code) $lang_code = Context::getLangType();
1171
+		if(!$module_srl || !$document_srl || !$var_idx || !isset($value)) {
1172
+			return new BaseObject(-1,'msg_invalid_request');
1173
+		}
1174
+		if(!$lang_code) {
1175
+			$lang_code = Context::getLangType();
1176
+		}
1030 1177
 
1031 1178
 		$obj = new stdClass;
1032 1179
 		$obj->module_srl = $module_srl;
@@ -1052,10 +1199,18 @@  discard block
 block discarded – undo
1052 1199
 	{
1053 1200
 		$obj = new stdClass();
1054 1201
 		$obj->module_srl = $module_srl;
1055
-		if(!is_null($document_srl)) $obj->document_srl = $document_srl;
1056
-		if(!is_null($var_idx)) $obj->var_idx = $var_idx;
1057
-		if(!is_null($lang_code)) $obj->lang_code = $lang_code;
1058
-		if(!is_null($eid)) $obj->eid = $eid;
1202
+		if(!is_null($document_srl)) {
1203
+			$obj->document_srl = $document_srl;
1204
+		}
1205
+		if(!is_null($var_idx)) {
1206
+			$obj->var_idx = $var_idx;
1207
+		}
1208
+		if(!is_null($lang_code)) {
1209
+			$obj->lang_code = $lang_code;
1210
+		}
1211
+		if(!is_null($eid)) {
1212
+			$obj->eid = $eid;
1213
+		}
1059 1214
 		$output = executeQuery('document.deleteDocumentExtraVars', $obj);
1060 1215
 		return $output;
1061 1216
 	}
@@ -1069,8 +1224,11 @@  discard block
 block discarded – undo
1069 1224
 	 */
1070 1225
 	function updateVotedCount($document_srl, $point = 1)
1071 1226
 	{
1072
-		if($point > 0) $failed_voted = 'failed_voted';
1073
-		else $failed_voted = 'failed_blamed';
1227
+		if($point > 0) {
1228
+			$failed_voted = 'failed_voted';
1229
+		} else {
1230
+			$failed_voted = 'failed_blamed';
1231
+		}
1074 1232
 		// Return fail if session already has information about votes
1075 1233
 		if($_SESSION['voted_document'][$document_srl])
1076 1234
 		{
@@ -1106,8 +1264,7 @@  discard block
 block discarded – undo
1106 1264
 		if($member_srl)
1107 1265
 		{
1108 1266
 			$args->member_srl = $member_srl;
1109
-		}
1110
-		else
1267
+		} else
1111 1268
 		{
1112 1269
 			$args->ipaddress = $_SERVER['REMOTE_ADDR'];
1113 1270
 		}
@@ -1144,18 +1301,21 @@  discard block
 block discarded – undo
1144 1301
 		{
1145 1302
 			$args->blamed_count = $trigger_obj->after_point;
1146 1303
 			$output = executeQuery('document.updateBlamedCount', $args);
1147
-		}
1148
-		else
1304
+		} else
1149 1305
 		{
1150 1306
 			$args->voted_count = $trigger_obj->after_point;
1151 1307
 			$output = executeQuery('document.updateVotedCount', $args);
1152 1308
 		}
1153
-		if(!$output->toBool()) return $output;
1309
+		if(!$output->toBool()) {
1310
+			return $output;
1311
+		}
1154 1312
 
1155 1313
 		// Leave logs
1156 1314
 		$args->point = $trigger_obj->point;
1157 1315
 		$output = executeQuery('document.insertDocumentVotedLog', $args);
1158
-		if(!$output->toBool()) return $output;
1316
+		if(!$output->toBool()) {
1317
+			return $output;
1318
+		}
1159 1319
 
1160 1320
 		// Call a trigger (after)
1161 1321
 		$trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'after', $trigger_obj);
@@ -1184,8 +1344,7 @@  discard block
 block discarded – undo
1184 1344
 		{
1185 1345
 			$output->setMessage('success_voted');
1186 1346
 			$output->add('voted_count', $trigger_obj->after_point);
1187
-		}
1188
-		else
1347
+		} else
1189 1348
 		{
1190 1349
 			$output->setMessage('success_blamed');
1191 1350
 			$output->add('blamed_count', $trigger_obj->after_point);
@@ -1202,13 +1361,17 @@  discard block
 block discarded – undo
1202 1361
 	function declaredDocument($document_srl)
1203 1362
 	{
1204 1363
 		// Fail if session information already has a reported document
1205
-		if($_SESSION['declared_document'][$document_srl]) return new BaseObject(-1, 'failed_declared');
1364
+		if($_SESSION['declared_document'][$document_srl]) {
1365
+			return new BaseObject(-1, 'failed_declared');
1366
+		}
1206 1367
 
1207 1368
 		// Check if previously reported
1208 1369
 		$args = new stdClass();
1209 1370
 		$args->document_srl = $document_srl;
1210 1371
 		$output = executeQuery('document.getDeclaredDocument', $args);
1211
-		if(!$output->toBool()) return $output;
1372
+		if(!$output->toBool()) {
1373
+			return $output;
1374
+		}
1212 1375
 
1213 1376
 		$declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0;
1214 1377
 
@@ -1252,8 +1415,7 @@  discard block
 block discarded – undo
1252 1415
 		if($member_srl)
1253 1416
 		{
1254 1417
 			$args->member_srl = $member_srl;
1255
-		}
1256
-		else
1418
+		} else
1257 1419
 		{
1258 1420
 			$args->ipaddress = $_SERVER['REMOTE_ADDR'];
1259 1421
 		}
@@ -1273,9 +1435,14 @@  discard block
 block discarded – undo
1273 1435
 		$oDB->begin();
1274 1436
 
1275 1437
 		// Add the declared document
1276
-		if($declared_count > 0) $output = executeQuery('document.updateDeclaredDocument', $args);
1277
-		else $output = executeQuery('document.insertDeclaredDocument', $args);
1278
-		if(!$output->toBool()) return $output;
1438
+		if($declared_count > 0) {
1439
+			$output = executeQuery('document.updateDeclaredDocument', $args);
1440
+		} else {
1441
+			$output = executeQuery('document.insertDeclaredDocument', $args);
1442
+		}
1443
+		if(!$output->toBool()) {
1444
+			return $output;
1445
+		}
1279 1446
 		// Leave logs
1280 1447
 		$output = executeQuery('document.insertDocumentDeclaredLog', $args);
1281 1448
 		if(!$output->toBool())
@@ -1374,9 +1541,10 @@  discard block
 block discarded – undo
1374 1541
 			$parent_category = $oDocumentModel->getCategory($obj->parent_srl);
1375 1542
 			$obj->list_order = $parent_category->list_order;
1376 1543
 			$this->updateCategoryListOrder($parent_category->module_srl, $parent_category->list_order+1);
1377
-			if(!$obj->category_srl) $obj->category_srl = getNextSequence();
1378
-		}
1379
-		else
1544
+			if(!$obj->category_srl) {
1545
+				$obj->category_srl = getNextSequence();
1546
+			}
1547
+		} else
1380 1548
 		{
1381 1549
 			$obj->list_order = $obj->category_srl = getNextSequence();
1382 1550
 		}
@@ -1416,13 +1584,17 @@  discard block
 block discarded – undo
1416 1584
 	{
1417 1585
 		// Create a document model object
1418 1586
 		$oDocumentModel = getModel('document');
1419
-		if(!$document_count) $document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl);
1587
+		if(!$document_count) {
1588
+			$document_count = $oDocumentModel->getCategoryDocumentCount($module_srl,$category_srl);
1589
+		}
1420 1590
 
1421 1591
 		$args = new stdClass;
1422 1592
 		$args->category_srl = $category_srl;
1423 1593
 		$args->document_count = $document_count;
1424 1594
 		$output = executeQuery('document.updateCategoryCount', $args);
1425
-		if($output->toBool()) $this->makeCategoryFile($module_srl);
1595
+		if($output->toBool()) {
1596
+			$this->makeCategoryFile($module_srl);
1597
+		}
1426 1598
 
1427 1599
 		return $output;
1428 1600
 	}
@@ -1435,7 +1607,9 @@  discard block
 block discarded – undo
1435 1607
 	function updateCategory($obj)
1436 1608
 	{
1437 1609
 		$output = executeQuery('document.updateCategory', $obj);
1438
-		if($output->toBool()) $this->makeCategoryFile($obj->module_srl);
1610
+		if($output->toBool()) {
1611
+			$this->makeCategoryFile($obj->module_srl);
1612
+		}
1439 1613
 		return $output;
1440 1614
 	}
1441 1615
 
@@ -1452,11 +1626,17 @@  discard block
 block discarded – undo
1452 1626
 		$category_info = $oDocumentModel->getCategory($category_srl);
1453 1627
 		// Display an error that the category cannot be deleted if it has a child
1454 1628
 		$output = executeQuery('document.getChildCategoryCount', $args);
1455
-		if(!$output->toBool()) return $output;
1456
-		if($output->data->count>0) return new BaseObject(-1, 'msg_cannot_delete_for_child');
1629
+		if(!$output->toBool()) {
1630
+			return $output;
1631
+		}
1632
+		if($output->data->count>0) {
1633
+			return new BaseObject(-1, 'msg_cannot_delete_for_child');
1634
+		}
1457 1635
 		// Delete a category information
1458 1636
 		$output = executeQuery('document.deleteCategory', $args);
1459
-		if(!$output->toBool()) return $output;
1637
+		if(!$output->toBool()) {
1638
+			return $output;
1639
+		}
1460 1640
 
1461 1641
 		$this->makeCategoryFile($category_info->module_srl);
1462 1642
 		// remvove cache
@@ -1471,8 +1651,9 @@  discard block
 block discarded – undo
1471 1651
 				$args->page = ++$page;
1472 1652
 				$output = executeQuery('document.getDocumentList', $args, array('document_srl'));
1473 1653
 
1474
-				if($output->data == array())
1475
-					break;
1654
+				if($output->data == array()) {
1655
+									break;
1656
+				}
1476 1657
 
1477 1658
 				foreach($output->data as $val)
1478 1659
 				{
@@ -1524,18 +1705,26 @@  discard block
 block discarded – undo
1524 1705
 		// Seek a full list of categories
1525 1706
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
1526 1707
 		$category_srl_list = array_keys($category_list);
1527
-		if(count($category_srl_list)<2) return new BaseObject();
1708
+		if(count($category_srl_list)<2) {
1709
+			return new BaseObject();
1710
+		}
1528 1711
 
1529 1712
 		$prev_category = NULL;
1530 1713
 		foreach($category_list as $key => $val)
1531 1714
 		{
1532
-			if($key==$category_srl) break;
1715
+			if($key==$category_srl) {
1716
+				break;
1717
+			}
1533 1718
 			$prev_category = $val;
1534 1719
 		}
1535 1720
 		// Return if the previous category doesn't exist
1536
-		if(!$prev_category) return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1721
+		if(!$prev_category) {
1722
+			return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1723
+		}
1537 1724
 		// Return if the selected category is the top level
1538
-		if($category_srl_list[0]==$category_srl) return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1725
+		if($category_srl_list[0]==$category_srl) {
1726
+			return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1727
+		}
1539 1728
 		// Information of the selected category
1540 1729
 		$cur_args = new stdClass;
1541 1730
 		$cur_args->category_srl = $category_srl;
@@ -1571,15 +1760,21 @@  discard block
 block discarded – undo
1571 1760
 		// Seek a full list of categories
1572 1761
 		$category_list = $oDocumentModel->getCategoryList($module_srl);
1573 1762
 		$category_srl_list = array_keys($category_list);
1574
-		if(count($category_srl_list)<2) return new BaseObject();
1763
+		if(count($category_srl_list)<2) {
1764
+			return new BaseObject();
1765
+		}
1575 1766
 
1576 1767
 		for($i=0;$i<count($category_srl_list);$i++)
1577 1768
 		{
1578
-			if($category_srl_list[$i]==$category_srl) break;
1769
+			if($category_srl_list[$i]==$category_srl) {
1770
+				break;
1771
+			}
1579 1772
 		}
1580 1773
 
1581 1774
 		$next_category_srl = $category_srl_list[$i+1];
1582
-		if(!$category_list[$next_category_srl]) return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1775
+		if(!$category_list[$next_category_srl]) {
1776
+			return new BaseObject(-1,Context::getLang('msg_category_not_moved'));
1777
+		}
1583 1778
 		$next_category = $category_list[$next_category_srl];
1584 1779
 		// Information of the selected category
1585 1780
 		$cur_args = new stdClass;
@@ -1606,7 +1801,9 @@  discard block
 block discarded – undo
1606 1801
 	{
1607 1802
 		$oDocumentModel = getModel('document');
1608 1803
 		$extra_keys = $oDocumentModel->getExtraKeys($module_srl);
1609
-		if(!count($extra_keys)) return;
1804
+		if(!count($extra_keys)) {
1805
+			return;
1806
+		}
1610 1807
 
1611 1808
 		$js_code = array();
1612 1809
 		$js_code[] = '<script>//<![CDATA[';
@@ -1625,7 +1822,9 @@  discard block
 block discarded – undo
1625 1822
 			}
1626 1823
 			$name = str_ireplace(array('<script', '</script'), array('<scr" + "ipt', '</scr" + "ipt'), $val->name);
1627 1824
 			$js_code[] = sprintf('validator.cast("ADD_MESSAGE", ["extra_vars%s","%s"]);', $idx, $name);
1628
-			if($val->is_required == 'Y') $js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx);
1825
+			if($val->is_required == 'Y') {
1826
+				$js_code[] = sprintf('validator.cast("ADD_EXTRA_FIELD", ["extra_vars%s", { required:true }]);', $idx);
1827
+			}
1629 1828
 		}
1630 1829
 
1631 1830
 		$js_code[] = '})(jQuery);';
@@ -1643,7 +1842,9 @@  discard block
 block discarded – undo
1643 1842
 	function procDocumentInsertCategory($args = null)
1644 1843
 	{
1645 1844
 		// List variables
1646
-		if(!$args) $args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid');
1845
+		if(!$args) {
1846
+			$args = Context::gets('module_srl','category_srl','parent_srl','category_title','category_description','expand','group_srls','category_color','mid');
1847
+		}
1647 1848
 		$args->title = $args->category_title;
1648 1849
 		$args->description = $args->category_description;
1649 1850
 		$args->color = $args->category_color;
@@ -1659,11 +1860,18 @@  discard block
 block discarded – undo
1659 1860
 		$columnList = array('module_srl', 'module');
1660 1861
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
1661 1862
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1662
-		if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted');
1863
+		if(!$grant->manager) {
1864
+			return new BaseObject(-1,'msg_not_permitted');
1865
+		}
1663 1866
 
1664
-		if($args->expand !="Y") $args->expand = "N";
1665
-		if(!is_array($args->group_srls)) $args->group_srls = str_replace('|@|',',',$args->group_srls);
1666
-		else $args->group_srls = implode(',', $args->group_srls);
1867
+		if($args->expand !="Y") {
1868
+			$args->expand = "N";
1869
+		}
1870
+		if(!is_array($args->group_srls)) {
1871
+			$args->group_srls = str_replace('|@|',',',$args->group_srls);
1872
+		} else {
1873
+			$args->group_srls = implode(',', $args->group_srls);
1874
+		}
1667 1875
 		$args->parent_srl = (int)$args->parent_srl;
1668 1876
 
1669 1877
 		$oDocumentModel = getModel('document');
@@ -1674,7 +1882,9 @@  discard block
 block discarded – undo
1674 1882
 		if($args->category_srl)
1675 1883
 		{
1676 1884
 			$category_info = $oDocumentModel->getCategory($args->category_srl);
1677
-			if($category_info->category_srl != $args->category_srl) $args->category_srl = null;
1885
+			if($category_info->category_srl != $args->category_srl) {
1886
+				$args->category_srl = null;
1887
+			}
1678 1888
 		}
1679 1889
 		// Update if exists
1680 1890
 		if($args->category_srl)
@@ -1686,8 +1896,7 @@  discard block
 block discarded – undo
1686 1896
 				return $output;
1687 1897
 			}
1688 1898
 			// Insert if not exist
1689
-		}
1690
-		else
1899
+		} else
1691 1900
 		{
1692 1901
 			$output = $this->insertCategory($args);
1693 1902
 			if(!$output->toBool())
@@ -1729,7 +1938,9 @@  discard block
 block discarded – undo
1729 1938
 		$columnList = array('module_srl', 'module');
1730 1939
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($source_category->module_srl, $columnList);
1731 1940
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1732
-		if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted');
1941
+		if(!$grant->manager) {
1942
+			return new BaseObject(-1,'msg_not_permitted');
1943
+		}
1733 1944
 
1734 1945
 		// First child of the parent_category_srl
1735 1946
 		$source_args = new stdClass;
@@ -1742,30 +1953,39 @@  discard block
 block discarded – undo
1742 1953
 			$args->parent_srl = $parent_category_srl;
1743 1954
 			$output = executeQuery('document.getChildCategoryMinListOrder', $args);
1744 1955
 
1745
-			if(!$output->toBool()) return $output;
1956
+			if(!$output->toBool()) {
1957
+				return $output;
1958
+			}
1746 1959
 			$args->list_order = (int)$output->data->list_order;
1747
-			if(!$args->list_order) $args->list_order = 0;
1960
+			if(!$args->list_order) {
1961
+				$args->list_order = 0;
1962
+			}
1748 1963
 			$args->list_order--;
1749 1964
 
1750 1965
 			$source_args->category_srl = $source_category_srl;
1751 1966
 			$source_args->parent_srl = $parent_category_srl;
1752 1967
 			$source_args->list_order = $args->list_order;
1753 1968
 			$output = $this->updateCategory($source_args);
1754
-			if(!$output->toBool()) return $output;
1969
+			if(!$output->toBool()) {
1970
+				return $output;
1971
+			}
1755 1972
 			// Sibling of the $target_category_srl
1756
-		}
1757
-		else if($target_category_srl > 0)
1973
+		} else if($target_category_srl > 0)
1758 1974
 		{
1759 1975
 			$target_category = $oDocumentModel->getCategory($target_category_srl);
1760 1976
 			// Move all siblings of the $target_category down
1761 1977
 			$output = $this->updateCategoryListOrder($target_category->module_srl, $target_category->list_order+1);
1762
-			if(!$output->toBool()) return $output;
1978
+			if(!$output->toBool()) {
1979
+				return $output;
1980
+			}
1763 1981
 
1764 1982
 			$source_args->category_srl = $source_category_srl;
1765 1983
 			$source_args->parent_srl = $target_category->parent_srl;
1766 1984
 			$source_args->list_order = $target_category->list_order+1;
1767 1985
 			$output = $this->updateCategory($source_args);
1768
-			if(!$output->toBool()) return $output;
1986
+			if(!$output->toBool()) {
1987
+				return $output;
1988
+			}
1769 1989
 		}
1770 1990
 		// Re-generate the xml file
1771 1991
 		$xml_file = $this->makeCategoryFile($source_category->module_srl);
@@ -1790,14 +2010,20 @@  discard block
 block discarded – undo
1790 2010
 		$columnList = array('module_srl', 'module');
1791 2011
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl, $columnList);
1792 2012
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1793
-		if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted');
2013
+		if(!$grant->manager) {
2014
+			return new BaseObject(-1,'msg_not_permitted');
2015
+		}
1794 2016
 
1795 2017
 		$oDocumentModel = getModel('document');
1796 2018
 		// Get original information
1797 2019
 		$category_info = $oDocumentModel->getCategory($args->category_srl);
1798
-		if($category_info->parent_srl) $parent_srl = $category_info->parent_srl;
2020
+		if($category_info->parent_srl) {
2021
+			$parent_srl = $category_info->parent_srl;
2022
+		}
1799 2023
 		// Display an error that the category cannot be deleted if it has a child node
1800
-		if($oDocumentModel->getCategoryChlidCount($args->category_srl)) return new BaseObject(-1, 'msg_cannot_delete_for_child');
2024
+		if($oDocumentModel->getCategoryChlidCount($args->category_srl)) {
2025
+			return new BaseObject(-1, 'msg_cannot_delete_for_child');
2026
+		}
1801 2027
 		// Remove from the DB
1802 2028
 		$output = $this->deleteCategory($args->category_srl);
1803 2029
 		if(!$output->toBool())
@@ -1831,7 +2057,9 @@  discard block
 block discarded – undo
1831 2057
 		$columnList = array('module_srl', 'module');
1832 2058
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
1833 2059
 		$grant = $oModuleModel->getGrant($module_info, Context::get('logged_info'));
1834
-		if(!$grant->manager) return new BaseObject(-1,'msg_not_permitted');
2060
+		if(!$grant->manager) {
2061
+			return new BaseObject(-1,'msg_not_permitted');
2062
+		}
1835 2063
 
1836 2064
 		$xml_file = $this->makeCategoryFile($module_srl);
1837 2065
 		// Set return value
@@ -1846,7 +2074,9 @@  discard block
 block discarded – undo
1846 2074
 	function makeCategoryFile($module_srl)
1847 2075
 	{
1848 2076
 		// Return if there is no information you need for creating a cache file
1849
-		if(!$module_srl) return false;
2077
+		if(!$module_srl) {
2078
+			return false;
2079
+		}
1850 2080
 
1851 2081
 		$module_srl = (int)$module_srl;
1852 2082
 
@@ -1856,7 +2086,9 @@  discard block
 block discarded – undo
1856 2086
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList);
1857 2087
 		$mid = $module_info->mid;
1858 2088
 
1859
-		if(!is_dir('./files/cache/document_category')) FileHandler::makeDir('./files/cache/document_category');
2089
+		if(!is_dir('./files/cache/document_category')) {
2090
+			FileHandler::makeDir('./files/cache/document_category');
2091
+		}
1860 2092
 		// Cache file's name
1861 2093
 		$xml_file = sprintf("./files/cache/document_category/%s.xml.php", $module_srl);
1862 2094
 		$php_file = sprintf("./files/cache/document_category/%s.php", $module_srl);
@@ -1868,13 +2100,17 @@  discard block
 block discarded – undo
1868 2100
 
1869 2101
 		$category_list = $output->data;
1870 2102
 
1871
-		if(!is_array($category_list)) $category_list = array($category_list);
2103
+		if(!is_array($category_list)) {
2104
+			$category_list = array($category_list);
2105
+		}
1872 2106
 
1873 2107
 		$category_count = count($category_list);
1874 2108
 		for($i=0;$i<$category_count;$i++)
1875 2109
 		{
1876 2110
 			$category_srl = $category_list[$i]->category_srl;
1877
-			if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) $category_list[$i]->group_srls = '';
2111
+			if(!preg_match('/^[0-9,]+$/', $category_list[$i]->group_srls)) {
2112
+				$category_list[$i]->group_srls = '';
2113
+			}
1878 2114
 			$list[$category_srl] = $category_list[$i];
1879 2115
 		}
1880 2116
 		// Create the xml file without node data if no data is obtained
@@ -1886,7 +2122,9 @@  discard block
 block discarded – undo
1886 2122
 			return $xml_file;
1887 2123
 		}
1888 2124
 		// Change to an array if only a single data is obtained
1889
-		if(!is_array($list)) $list = array($list);
2125
+		if(!is_array($list)) {
2126
+			$list = array($list);
2127
+		}
1890 2128
 		// Create a tree for loop
1891 2129
 		foreach($list as $category_srl => $node)
1892 2130
 		{
@@ -1965,13 +2203,17 @@  discard block
 block discarded – undo
1965 2203
 	 */
1966 2204
 	function getXmlTree($source_node, $tree, $site_srl, &$xml_header_buff)
1967 2205
 	{
1968
-		if(!$source_node) return;
2206
+		if(!$source_node) {
2207
+			return;
2208
+		}
1969 2209
 
1970 2210
 		foreach($source_node as $category_srl => $node)
1971 2211
 		{
1972 2212
 			$child_buff = "";
1973 2213
 			// Get data of the child nodes
1974
-			if($category_srl && $tree[$category_srl]) $child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff);
2214
+			if($category_srl && $tree[$category_srl]) {
2215
+				$child_buff = $this->getXmlTree($tree[$category_srl], $tree, $site_srl, $xml_header_buff);
2216
+			}
1975 2217
 			// List variables
1976 2218
 			$expand = ($node->expand) ? $node->expand : 'N';
1977 2219
 			$group_srls = ($node->group_srls) ? $node->group_srls : '';
@@ -1981,8 +2223,11 @@  discard block
 block discarded – undo
1981 2223
 			$color = ($node->color) ? $node->color : '';
1982 2224
 			$description = ($node->description) ? $node->description : '';
1983 2225
 			// If node->group_srls value exists
1984
-			if($group_srls) $group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls);
1985
-			else $group_check_code = "true";
2226
+			if($group_srls) {
2227
+				$group_check_code = sprintf('($is_admin==true||(is_array($group_srls)&&count(array_intersect($group_srls, array(%s)))))',$group_srls);
2228
+			} else {
2229
+				$group_check_code = "true";
2230
+			}
1986 2231
 
1987 2232
 			$title = $node->title;
1988 2233
 			$oModuleAdminModel = getAdminModel('module');
@@ -2022,8 +2267,11 @@  discard block
 block discarded – undo
2022 2267
 				$node->document_count
2023 2268
 			);
2024 2269
 
2025
-			if($child_buff) $buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff);
2026
-			else $buff .=  sprintf('<node %s />', $attribute);
2270
+			if($child_buff) {
2271
+				$buff .= sprintf('<node %s>%s</node>', $attribute, $child_buff);
2272
+			} else {
2273
+				$buff .=  sprintf('<node %s />', $attribute);
2274
+			}
2027 2275
 		}
2028 2276
 		return $buff;
2029 2277
 	}
@@ -2042,7 +2290,9 @@  discard block
 block discarded – undo
2042 2290
 	function getPhpCacheCode($source_node, $tree, $site_srl, &$php_header_buff)
2043 2291
 	{
2044 2292
 		$output = array("buff"=>"", "category_srl_list"=>array());
2045
-		if(!$source_node) return $output;
2293
+		if(!$source_node) {
2294
+			return $output;
2295
+		}
2046 2296
 
2047 2297
 		// Set to an arraty for looping and then generate php script codes to be included
2048 2298
 		foreach($source_node as $category_srl => $node)
@@ -2141,7 +2391,9 @@  discard block
 block discarded – undo
2141 2391
 	function addDocumentPopupMenu($url, $str, $icon = '', $target = 'self')
2142 2392
 	{
2143 2393
 		$document_popup_menu_list = Context::get('document_popup_menu_list');
2144
-		if(!is_array($document_popup_menu_list)) $document_popup_menu_list = array();
2394
+		if(!is_array($document_popup_menu_list)) {
2395
+			$document_popup_menu_list = array();
2396
+		}
2145 2397
 
2146 2398
 		$obj = new stdClass();
2147 2399
 		$obj->url = $url;
@@ -2159,7 +2411,9 @@  discard block
 block discarded – undo
2159 2411
 	 */
2160 2412
 	function procDocumentAddCart()
2161 2413
 	{
2162
-		if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted');
2414
+		if(!Context::get('is_logged')) {
2415
+			return new BaseObject(-1, 'msg_not_permitted');
2416
+		}
2163 2417
 
2164 2418
 		// Get document_srl
2165 2419
 		$srls = explode(',',Context::get('srls'));
@@ -2167,11 +2421,15 @@  discard block
 block discarded – undo
2167 2421
 		{
2168 2422
 			$srl = trim($srls[$i]);
2169 2423
 
2170
-			if(!$srl) continue;
2424
+			if(!$srl) {
2425
+				continue;
2426
+			}
2171 2427
 
2172 2428
 			$document_srls[] = $srl;
2173 2429
 		}
2174
-		if(!count($document_srls)) return;
2430
+		if(!count($document_srls)) {
2431
+			return;
2432
+		}
2175 2433
 
2176 2434
 		// Get module_srl of the documents
2177 2435
 		$args = new stdClass;
@@ -2179,14 +2437,18 @@  discard block
 block discarded – undo
2179 2437
 		$args->document_srls = implode(',',$document_srls);
2180 2438
 		$args->order_type = 'asc';
2181 2439
 		$output = executeQueryArray('document.getDocuments', $args);
2182
-		if(!$output->data) return new BaseObject();
2440
+		if(!$output->data) {
2441
+			return new BaseObject();
2442
+		}
2183 2443
 
2184 2444
 		unset($document_srls);
2185 2445
 		foreach($output->data as $key => $val)
2186 2446
 		{
2187 2447
 			$document_srls[$val->module_srl][] = $val->document_srl;
2188 2448
 		}
2189
-		if(!$document_srls || !count($document_srls)) return new BaseObject();
2449
+		if(!$document_srls || !count($document_srls)) {
2450
+			return new BaseObject();
2451
+		}
2190 2452
 
2191 2453
 		// Check if each of module administrators exists. Top-level administator will have a permission to modify every document of all modules.(Even to modify temporarily saved or trashed documents)
2192 2454
 		$oModuleModel = getModel('module');
@@ -2211,7 +2473,9 @@  discard block
 block discarded – undo
2211 2473
 				}
2212 2474
 			}
2213 2475
 		}
2214
-		if(!count($document_srls)) return new BaseObject();
2476
+		if(!count($document_srls)) {
2477
+			return new BaseObject();
2478
+		}
2215 2479
 
2216 2480
 		foreach($document_srls as $module_srl => $documents)
2217 2481
 		{
@@ -2219,9 +2483,14 @@  discard block
 block discarded – undo
2219 2483
 			for($i=0;$i<$cnt;$i++)
2220 2484
 			{
2221 2485
 				$document_srl = (int)trim($documents[$i]);
2222
-				if(!$document_srls) continue;
2223
-				if($_SESSION['document_management'][$document_srl]) unset($_SESSION['document_management'][$document_srl]);
2224
-				else $_SESSION['document_management'][$document_srl] = true;
2486
+				if(!$document_srls) {
2487
+					continue;
2488
+				}
2489
+				if($_SESSION['document_management'][$document_srl]) {
2490
+					unset($_SESSION['document_management'][$document_srl]);
2491
+				} else {
2492
+					$_SESSION['document_management'][$document_srl] = true;
2493
+				}
2225 2494
 			}
2226 2495
 		}
2227 2496
 	}
@@ -2233,7 +2502,9 @@  discard block
 block discarded – undo
2233 2502
 	function procDocumentManageCheckedDocument()
2234 2503
 	{
2235 2504
 		@set_time_limit(0);
2236
-		if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted');
2505
+		if(!Context::get('is_logged')) {
2506
+			return new BaseObject(-1,'msg_not_permitted');
2507
+		}
2237 2508
 
2238 2509
 		if(!checkCSRF())
2239 2510
 		{
@@ -2243,10 +2514,14 @@  discard block
 block discarded – undo
2243 2514
 		$type = Context::get('type');
2244 2515
 		$target_module = Context::get('target_module_srl');
2245 2516
 		$module_srl = Context::get('module_srl');
2246
-		if($target_module && !$module_srl) $module_srl = $target_module;
2517
+		if($target_module && !$module_srl) {
2518
+			$module_srl = $target_module;
2519
+		}
2247 2520
 		$category_srl = Context::get('target_category_srl');
2248 2521
 		$message_content = strip_tags(Context::get('message_content'));
2249
-		if($message_content) $message_content = nl2br($message_content);
2522
+		if($message_content) {
2523
+			$message_content = nl2br($message_content);
2524
+		}
2250 2525
 
2251 2526
 		$cart = Context::get('cart');
2252 2527
 		$document_srl_list = (!is_array($cart)) ? explode('|@|', $cart) : $cart;
@@ -2261,7 +2536,9 @@  discard block
 block discarded – undo
2261 2536
 		{
2262 2537
 			$oDocument = $oDocumentModel->getDocument($document_srl);
2263 2538
 			$document_items[] = $oDocument;
2264
-			if(!$oDocument->isGranted()) return $this->stop('msg_not_permitted');
2539
+			if(!$oDocument->isGranted()) {
2540
+				return $this->stop('msg_not_permitted');
2541
+			}
2265 2542
 		}
2266 2543
 
2267 2544
 		// Send a message
@@ -2277,10 +2554,15 @@  discard block
 block discarded – undo
2277 2554
 
2278 2555
 			foreach($document_items as $oDocument)
2279 2556
 			{
2280
-				if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) continue;
2557
+				if(!$oDocument->get('member_srl') || $oDocument->get('member_srl')==$sender_member_srl) {
2558
+					continue;
2559
+				}
2281 2560
 
2282
-				if($type=='move') $purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl());
2283
-				else $purl = "";
2561
+				if($type=='move') {
2562
+					$purl = sprintf("<a href=\"%s\" target=\"_blank\">%s</a>", $oDocument->getPermanentUrl(), $oDocument->getPermanentUrl());
2563
+				} else {
2564
+					$purl = "";
2565
+				}
2284 2566
 				$content = sprintf("<div>%s</div><hr />%s<div style=\"font-weight:bold\">%s</div>%s",$message_content, $purl, $oDocument->getTitleText(), $oDocument->getContent(false, false, false));
2285 2567
 
2286 2568
 				$oCommunicationController->sendMessage($sender_member_srl, $oDocument->get('member_srl'), $title, $content, false);
@@ -2293,24 +2575,30 @@  discard block
 block discarded – undo
2293 2575
 		$oDocumentAdminController = getAdminController('document');
2294 2576
 		if($type == 'move')
2295 2577
 		{
2296
-			if(!$module_srl) return new BaseObject(-1, 'fail_to_move');
2578
+			if(!$module_srl) {
2579
+				return new BaseObject(-1, 'fail_to_move');
2580
+			}
2297 2581
 
2298 2582
 			$output = $oDocumentAdminController->moveDocumentModule($document_srl_list, $module_srl, $category_srl);
2299
-			if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move');
2583
+			if(!$output->toBool()) {
2584
+				return new BaseObject(-1, 'fail_to_move');
2585
+			}
2300 2586
 
2301 2587
 			$msg_code = 'success_moved';
2302 2588
 
2303
-		}
2304
-		else if($type == 'copy')
2589
+		} else if($type == 'copy')
2305 2590
 		{
2306
-			if(!$module_srl) return new BaseObject(-1, 'fail_to_move');
2591
+			if(!$module_srl) {
2592
+				return new BaseObject(-1, 'fail_to_move');
2593
+			}
2307 2594
 
2308 2595
 			$output = $oDocumentAdminController->copyDocumentModule($document_srl_list, $module_srl, $category_srl);
2309
-			if(!$output->toBool()) return new BaseObject(-1, 'fail_to_move');
2596
+			if(!$output->toBool()) {
2597
+				return new BaseObject(-1, 'fail_to_move');
2598
+			}
2310 2599
 
2311 2600
 			$msg_code = 'success_copied';
2312
-		}
2313
-		else if($type =='delete')
2601
+		} else if($type =='delete')
2314 2602
 		{
2315 2603
 			$oDB = &DB::getInstance();
2316 2604
 			$oDB->begin();
@@ -2318,12 +2606,13 @@  discard block
 block discarded – undo
2318 2606
 			{
2319 2607
 				$document_srl = $document_srl_list[$i];
2320 2608
 				$output = $this->deleteDocument($document_srl, true);
2321
-				if(!$output->toBool()) return new BaseObject(-1, 'fail_to_delete');
2609
+				if(!$output->toBool()) {
2610
+					return new BaseObject(-1, 'fail_to_delete');
2611
+				}
2322 2612
 			}
2323 2613
 			$oDB->commit();
2324 2614
 			$msg_code = 'success_deleted';
2325
-		}
2326
-		else if($type == 'trash')
2615
+		} else if($type == 'trash')
2327 2616
 		{
2328 2617
 			$args = new stdClass();
2329 2618
 			$args->description = $message_content;
@@ -2333,12 +2622,13 @@  discard block
 block discarded – undo
2333 2622
 			for($i=0;$i<$document_srl_count;$i++) {
2334 2623
 				$args->document_srl = $document_srl_list[$i];
2335 2624
 				$output = $this->moveDocumentToTrash($args);
2336
-				if(!$output || !$output->toBool()) return new BaseObject(-1, 'fail_to_trash');
2625
+				if(!$output || !$output->toBool()) {
2626
+					return new BaseObject(-1, 'fail_to_trash');
2627
+				}
2337 2628
 			}
2338 2629
 			$oDB->commit();
2339 2630
 			$msg_code = 'success_trashed';
2340
-		}
2341
-		else if($type == 'cancelDeclare')
2631
+		} else if($type == 'cancelDeclare')
2342 2632
 		{
2343 2633
 			$args->document_srl = $document_srl_list;
2344 2634
 			$output = executeQuery('document.deleteDeclaredDocuments', $args);
@@ -2360,18 +2650,27 @@  discard block
 block discarded – undo
2360 2650
 	function procDocumentInsertModuleConfig()
2361 2651
 	{
2362 2652
 		$module_srl = Context::get('target_module_srl');
2363
-		if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl);
2364
-		else $module_srl = array($module_srl);
2653
+		if(preg_match('/^([0-9,]+)$/',$module_srl)) {
2654
+			$module_srl = explode(',',$module_srl);
2655
+		} else {
2656
+			$module_srl = array($module_srl);
2657
+		}
2365 2658
 
2366 2659
 		$document_config = new stdClass();
2367 2660
 		$document_config->use_history = Context::get('use_history');
2368
-		if(!$document_config->use_history) $document_config->use_history = 'N';
2661
+		if(!$document_config->use_history) {
2662
+			$document_config->use_history = 'N';
2663
+		}
2369 2664
 
2370 2665
 		$document_config->use_vote_up = Context::get('use_vote_up');
2371
-		if(!$document_config->use_vote_up) $document_config->use_vote_up = 'Y';
2666
+		if(!$document_config->use_vote_up) {
2667
+			$document_config->use_vote_up = 'Y';
2668
+		}
2372 2669
 
2373 2670
 		$document_config->use_vote_down = Context::get('use_vote_down');
2374
-		if(!$document_config->use_vote_down) $document_config->use_vote_down = 'Y';
2671
+		if(!$document_config->use_vote_down) {
2672
+			$document_config->use_vote_down = 'Y';
2673
+		}
2375 2674
 
2376 2675
 		$document_config->use_status = Context::get('use_status');
2377 2676
 
@@ -2379,7 +2678,9 @@  discard block
 block discarded – undo
2379 2678
 		for($i=0;$i<count($module_srl);$i++)
2380 2679
 		{
2381 2680
 			$srl = trim($module_srl[$i]);
2382
-			if(!$srl) continue;
2681
+			if(!$srl) {
2682
+				continue;
2683
+			}
2383 2684
 			$output = $oModuleController->insertModulePartConfig('document',$srl,$document_config);
2384 2685
 		}
2385 2686
 		$this->setError(-1);
@@ -2396,7 +2697,9 @@  discard block
 block discarded – undo
2396 2697
 	function procDocumentTempSave()
2397 2698
 	{
2398 2699
 		// Check login information
2399
-		if(!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_logged');
2700
+		if(!Context::get('is_logged')) {
2701
+			return new BaseObject(-1, 'msg_not_logged');
2702
+		}
2400 2703
 		$module_info = Context::get('module_info');
2401 2704
 		$logged_info = Context::get('logged_info');
2402 2705
 
@@ -2434,8 +2737,7 @@  discard block
 block discarded – undo
2434 2737
 			$output = $oDocumentController->updateDocument($oDocument, $obj);
2435 2738
 			$msg_code = 'success_updated';
2436 2739
 			// Otherwise, get a new
2437
-		}
2438
-		else
2740
+		} else
2439 2741
 		{
2440 2742
 			$output = $oDocumentController->insertDocument($obj);
2441 2743
 			$msg_code = 'success_registed';
@@ -2461,17 +2763,20 @@  discard block
 block discarded – undo
2461 2763
 	 */
2462 2764
 	function procDocumentGetList()
2463 2765
 	{
2464
-		if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted');
2766
+		if(!Context::get('is_logged')) {
2767
+			return new BaseObject(-1,'msg_not_permitted');
2768
+		}
2465 2769
 		$documentSrls = Context::get('document_srls');
2466
-		if($documentSrls) $documentSrlList = explode(',', $documentSrls);
2770
+		if($documentSrls) {
2771
+			$documentSrlList = explode(',', $documentSrls);
2772
+		}
2467 2773
 
2468 2774
 		if(count($documentSrlList) > 0)
2469 2775
 		{
2470 2776
 			$oDocumentModel = getModel('document');
2471 2777
 			$columnList = array('document_srl', 'title', 'nick_name', 'status');
2472 2778
 			$documentList = $oDocumentModel->getDocuments($documentSrlList, $this->grant->is_admin, false, $columnList);
2473
-		}
2474
-		else
2779
+		} else
2475 2780
 		{
2476 2781
 			global $lang;
2477 2782
 			$documentList = array();
@@ -2489,11 +2794,18 @@  discard block
 block discarded – undo
2489 2794
 	 */
2490 2795
 	function _checkCommentStatusForOldVersion(&$obj)
2491 2796
 	{
2492
-		if(!isset($obj->allow_comment)) $obj->allow_comment = 'N';
2493
-		if(!isset($obj->lock_comment)) $obj->lock_comment = 'N';
2797
+		if(!isset($obj->allow_comment)) {
2798
+			$obj->allow_comment = 'N';
2799
+		}
2800
+		if(!isset($obj->lock_comment)) {
2801
+			$obj->lock_comment = 'N';
2802
+		}
2494 2803
 
2495
-		if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') $obj->commentStatus = 'ALLOW';
2496
-		else $obj->commentStatus = 'DENY';
2804
+		if($obj->allow_comment == 'Y' && $obj->lock_comment == 'N') {
2805
+			$obj->commentStatus = 'ALLOW';
2806
+		} else {
2807
+			$obj->commentStatus = 'DENY';
2808
+		}
2497 2809
 	}
2498 2810
 
2499 2811
 	/**
@@ -2503,8 +2815,12 @@  discard block
 block discarded – undo
2503 2815
 	 */
2504 2816
 	function _checkDocumentStatusForOldVersion(&$obj)
2505 2817
 	{
2506
-		if(!$obj->status && $obj->is_secret == 'Y') $obj->status = $this->getConfigStatus('secret');
2507
-		if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public');
2818
+		if(!$obj->status && $obj->is_secret == 'Y') {
2819
+			$obj->status = $this->getConfigStatus('secret');
2820
+		}
2821
+		if(!$obj->status && $obj->is_secret != 'Y') {
2822
+			$obj->status = $this->getConfigStatus('public');
2823
+		}
2508 2824
 	}
2509 2825
 
2510 2826
 	public function updateUploaedCount($documentSrlList)
Please login to merge, or discard this patch.
modules/module/module.controller.php 1 patch
Spacing   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 		$output = executeQuery('module.insertActionForward', $args);
30 30
 
31 31
 		$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
32
-		if($oCacheHandler->isSupport())
32
+		if ($oCacheHandler->isSupport())
33 33
 		{
34 34
 			$cache_key = 'action_forward';
35 35
 			$oCacheHandler->delete($cache_key);
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		$output = executeQuery('module.deleteActionForward', $args);
52 52
 
53 53
 		$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
54
-		if($oCacheHandler->isSupport())
54
+		if ($oCacheHandler->isSupport())
55 55
 		{
56 56
 			$cache_key = 'action_forward';
57 57
 			$oCacheHandler->delete($cache_key);
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
 		$args->called_position = $called_position;
76 76
 
77 77
 		$output = executeQuery('module.insertTrigger', $args);
78
-		if($output->toBool())
78
+		if ($output->toBool())
79 79
 		{
80 80
 			//remove from cache
81 81
 			$GLOBALS['__triggers__'] = NULL;
82 82
 			$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
83
-			if($oCacheHandler->isSupport())
83
+			if ($oCacheHandler->isSupport())
84 84
 			{
85 85
 				$cache_key = 'triggers';
86 86
 				$oCacheHandler->delete($cache_key);
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 		$args->called_position = $called_position;
105 105
 
106 106
 		$output = executeQuery('module.deleteTrigger', $args);
107
-		if($output->toBool())
107
+		if ($output->toBool())
108 108
 		{
109 109
 			//remove from cache
110 110
 			$GLOBALS['__triggers__'] = NULL;
111 111
 			$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
112
-			if($oCacheHandler->isSupport())
112
+			if ($oCacheHandler->isSupport())
113 113
 			{
114 114
 				$cache_key = 'triggers';
115 115
 				$oCacheHandler->delete($cache_key);
@@ -129,12 +129,12 @@  discard block
 block discarded – undo
129 129
 		$args->module = $module;
130 130
 
131 131
 		$output = executeQuery('module.deleteModuleTriggers', $args);
132
-		if($output->toBool())
132
+		if ($output->toBool())
133 133
 		{
134 134
 			//remove from cache
135 135
 			$GLOBALS['__triggers__'] = NULL;
136 136
 			$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
137
-			if($oCacheHandler->isSupport())
137
+			if ($oCacheHandler->isSupport())
138 138
 			{
139 139
 				$cache_key = 'triggers';
140 140
 				$oCacheHandler->delete($cache_key);
@@ -148,11 +148,11 @@  discard block
 block discarded – undo
148 148
 	 * @brief Add module extend
149 149
 	 *
150 150
 	 */
151
-	function insertModuleExtend($parent_module, $extend_module, $type, $kind='')
151
+	function insertModuleExtend($parent_module, $extend_module, $type, $kind = '')
152 152
 	{
153
-		if($kind != 'admin') $kind = '';
154
-		if(!in_array($type,array('model','controller','view','api','mobile'))) return false;
155
-		if(in_array($parent_module, array('module','addon','widget','layout'))) return false;
153
+		if ($kind != 'admin') $kind = '';
154
+		if (!in_array($type, array('model', 'controller', 'view', 'api', 'mobile'))) return false;
155
+		if (in_array($parent_module, array('module', 'addon', 'widget', 'layout'))) return false;
156 156
 
157 157
 		$cache_file = './files/config/module_extend.php';
158 158
 		FileHandler::removeFile($cache_file);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 		$args->kind = $kind;
165 165
 
166 166
 		$output = executeQuery('module.getModuleExtendCount', $args);
167
-		if($output->data->count>0) return false;
167
+		if ($output->data->count > 0) return false;
168 168
 
169 169
 		$output = executeQuery('module.insertModuleExtend', $args);
170 170
 		return $output;
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * @brief Delete module extend
175 175
 	 *
176 176
 	 */
177
-	function deleteModuleExtend($parent_module, $extend_module, $type, $kind='')
177
+	function deleteModuleExtend($parent_module, $extend_module, $type, $kind = '')
178 178
 	{
179 179
 		$cache_file = './files/config/module_extend.php';
180 180
 		FileHandler::removeFile($cache_file);
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 		$oModuleModel = getModel('module');
200 200
 		$origin_config = $oModuleModel->getModuleConfig($module, $site_srl);
201 201
 
202
-		if(!$origin_config) $origin_config = new stdClass;
202
+		if (!$origin_config) $origin_config = new stdClass;
203 203
 
204
-		foreach($config as $key => $val)
204
+		foreach ($config as $key => $val)
205 205
 		{
206 206
 			$origin_config->{$key} = $val;
207 207
 		}
@@ -215,19 +215,19 @@  discard block
 block discarded – undo
215 215
 	 */
216 216
 	function insertModuleConfig($module, $config, $site_srl = 0)
217 217
 	{
218
-		$args =new stdClass();
218
+		$args = new stdClass();
219 219
 		$args->module = $module;
220 220
 		$args->config = serialize($config);
221 221
 		$args->site_srl = $site_srl;
222 222
 
223 223
 		$output = executeQuery('module.deleteModuleConfig', $args);
224
-		if(!$output->toBool()) return $output;
224
+		if (!$output->toBool()) return $output;
225 225
 
226 226
 		$output = executeQuery('module.insertModuleConfig', $args);
227 227
 
228 228
 		//remove from cache
229 229
 		$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
230
-		if($oCacheHandler->isSupport())
230
+		if ($oCacheHandler->isSupport())
231 231
 		{
232 232
 			$oCacheHandler->invalidateGroupKey('site_and_module');
233 233
 		}
@@ -246,13 +246,13 @@  discard block
 block discarded – undo
246 246
 		$args->config = serialize($config);
247 247
 
248 248
 		$output = executeQuery('module.deleteModulePartConfig', $args);
249
-		if(!$output->toBool()) return $output;
249
+		if (!$output->toBool()) return $output;
250 250
 
251 251
 		$output = executeQuery('module.insertModulePartConfig', $args);
252 252
 
253 253
 		//remove from cache
254 254
 		$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
255
-		if($oCacheHandler->isSupport())
255
+		if ($oCacheHandler->isSupport())
256 256
 		{
257 257
 			$oCacheHandler->invalidateGroupKey('site_and_module');
258 258
 		}
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 	 */
266 266
 	function insertSite($domain, $index_module_srl)
267 267
 	{
268
-		if(isSiteID($domain))
268
+		if (isSiteID($domain))
269 269
 		{
270 270
 			$oModuleModel = getModel('module');
271
-			if($oModuleModel->isIDExists($domain, 0)) return new BaseObject(-1,'msg_already_registed_vid');
271
+			if ($oModuleModel->isIDExists($domain, 0)) return new BaseObject(-1, 'msg_already_registed_vid');
272 272
 		}
273 273
 		else
274 274
 		{
@@ -284,10 +284,10 @@  discard block
 block discarded – undo
284 284
 		$columnList = array('modules.site_srl');
285 285
 		$oModuleModel = getModel('module');
286 286
 		$output = $oModuleModel->getSiteInfoByDomain($args->domain, $columnList);
287
-		if($output) return new BaseObject(-1,'msg_already_registed_vid');
287
+		if ($output) return new BaseObject(-1, 'msg_already_registed_vid');
288 288
 
289 289
 		$output = executeQuery('module.insertSite', $args);
290
-		if(!$output->toBool()) return $output;
290
+		if (!$output->toBool()) return $output;
291 291
 
292 292
 		$output->add('site_srl', $args->site_srl);
293 293
 		return $output;
@@ -302,32 +302,32 @@  discard block
 block discarded – undo
302 302
 		$columnList = array('sites.site_srl', 'sites.domain');
303 303
 		$site_info = $oModuleModel->getSiteInfo($args->site_srl, $columnList);
304 304
 
305
-		if(!$args->domain && $site_info->site_srl == $args->site_srl)
305
+		if (!$args->domain && $site_info->site_srl == $args->site_srl)
306 306
 		{
307 307
 			$args->domain = $site_info->domain;
308 308
 		}
309 309
 
310
-		if($site_info->domain != $args->domain)
310
+		if ($site_info->domain != $args->domain)
311 311
 		{
312 312
 			$info = $oModuleModel->getSiteInfoByDomain($args->domain, $columnList);
313
-			if($info->site_srl && $info->site_srl != $args->site_srl) return new BaseObject(-1,'msg_already_registed_domain');
314
-			if(isSiteID($args->domain) && $oModuleModel->isIDExists($args->domain)) return new BaseObject(-1,'msg_already_registed_vid');
313
+			if ($info->site_srl && $info->site_srl != $args->site_srl) return new BaseObject(-1, 'msg_already_registed_domain');
314
+			if (isSiteID($args->domain) && $oModuleModel->isIDExists($args->domain)) return new BaseObject(-1, 'msg_already_registed_vid');
315 315
 
316
-			if($args->domain && !isSiteID($args->domain))
316
+			if ($args->domain && !isSiteID($args->domain))
317 317
 			{
318 318
 				$args->domain = (strlen($args->domain) >= 1 && substr_compare($args->domain, '/', -1) === 0) ? substr($args->domain, 0, -1) : $args->domain;
319 319
 			}
320 320
 		}
321 321
 		$output = executeQuery('module.updateSite', $args);
322 322
 		//clear cache for default mid
323
-		if($args->site_srl == 0) $vid='';
324
-		else $vid=$args->domain;
323
+		if ($args->site_srl == 0) $vid = '';
324
+		else $vid = $args->domain;
325 325
 
326 326
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->index_module_srl);
327 327
 		$mid = $module_info->mid;
328 328
 
329 329
 		$oCacheHandler = CacheHandler::getInstance('object', null, true);
330
-		if($oCacheHandler->isSupport())
330
+		if ($oCacheHandler->isSupport())
331 331
 		{
332 332
 			$oCacheHandler->invalidateGroupKey('site_and_module');
333 333
 		}
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 		unset($args->act);
346 346
 		unset($args->page);
347 347
 		// Test mid value
348
-		if(!preg_match("/^[a-z][a-z0-9_]+$/i", $args->mid)) return new BaseObject(-1, 'msg_limit_mid');
348
+		if (!preg_match("/^[a-z][a-z0-9_]+$/i", $args->mid)) return new BaseObject(-1, 'msg_limit_mid');
349 349
 		// Test variables (separate basic vars and other vars in modules)
350 350
 		$extra_vars = clone($args);
351 351
 		unset($extra_vars->module_srl);
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 	 */
380 380
 	function insertModule($args)
381 381
 	{
382
-		if(isset($args->isMenuCreate))
382
+		if (isset($args->isMenuCreate))
383 383
 		{
384 384
 			$isMenuCreate = $args->isMenuCreate;
385 385
 		}
@@ -389,11 +389,11 @@  discard block
 block discarded – undo
389 389
 		}
390 390
 
391 391
 		$output = $this->arrangeModuleInfo($args, $extra_vars);
392
-		if(!$output->toBool()) return $output;
392
+		if (!$output->toBool()) return $output;
393 393
 		// Check whether the module name already exists
394
-		if(!$args->site_srl) $args->site_srl = 0;
394
+		if (!$args->site_srl) $args->site_srl = 0;
395 395
 		$oModuleModel = getModel('module');
396
-		if($oModuleModel->isIDExists($args->mid, $args->site_srl)) return new BaseObject(-1, 'msg_module_name_exists');
396
+		if ($oModuleModel->isIDExists($args->mid, $args->site_srl)) return new BaseObject(-1, 'msg_module_name_exists');
397 397
 
398 398
 		// begin transaction
399 399
 		$oDB = &DB::getInstance();
@@ -404,16 +404,16 @@  discard block
 block discarded – undo
404 404
 		$skin_vars = new stdClass();
405 405
 		$skin_vars->colorset = $skin_info->colorset[0]->name;
406 406
 		// Arrange variables and then execute a query
407
-		if(!$args->module_srl) $args->module_srl = getNextSequence();
407
+		if (!$args->module_srl) $args->module_srl = getNextSequence();
408 408
 
409 409
 		// default value
410
-		if($args->skin == '/USE_DEFAULT/')
410
+		if ($args->skin == '/USE_DEFAULT/')
411 411
 		{
412 412
 			$args->is_skin_fix = 'N';
413 413
 		}
414 414
 		else
415 415
 		{
416
-			if(isset($args->is_skin_fix))
416
+			if (isset($args->is_skin_fix))
417 417
 			{
418 418
 				$args->is_skin_fix = ($args->is_skin_fix != 'Y') ? 'N' : 'Y';
419 419
 			}
@@ -423,13 +423,13 @@  discard block
 block discarded – undo
423 423
 			}
424 424
 		}
425 425
 
426
-		if($args->mskin == '/USE_DEFAULT/')
426
+		if ($args->mskin == '/USE_DEFAULT/')
427 427
 		{
428 428
 			$args->is_mskin_fix = 'N';
429 429
 		}
430 430
 		else
431 431
 		{
432
-			if(isset($args->is_mskin_fix))
432
+			if (isset($args->is_mskin_fix))
433 433
 			{
434 434
 				$args->is_mskin_fix = ($args->is_mskin_fix != 'Y') ? 'N' : 'Y';
435 435
 			}
@@ -443,14 +443,14 @@  discard block
 block discarded – undo
443 443
 
444 444
 		$args->browser_title = strip_tags($args->browser_title);
445 445
 
446
-		if($isMenuCreate === TRUE)
446
+		if ($isMenuCreate === TRUE)
447 447
 		{
448 448
 			$menuArgs = new stdClass;
449 449
 			$menuArgs->menu_srl = $args->menu_srl;
450 450
 			$menuOutput = executeQuery('menu.getMenu', $menuArgs);
451 451
 
452 452
 			// if menu is not created, create menu also. and does not supported that in virtual site.
453
-			if(!$menuOutput->data && !$args->site_srl)
453
+			if (!$menuOutput->data && !$args->site_srl)
454 454
 			{
455 455
 				$oMenuAdminModel = getAdminModel('menu');
456 456
 
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
 				$menuArgs->listorder = $args->menu_item_srl * -1;
469 469
 
470 470
 				$menuItemOutput = executeQuery('menu.insertMenuItem', $menuArgs);
471
-				if(!$menuItemOutput->toBool())
471
+				if (!$menuItemOutput->toBool())
472 472
 				{
473 473
 					$oDB->rollback();
474 474
 					return $menuItemOutput;
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 		// Insert a module
482 482
 		$args->menu_srl = $menuArgs->menu_srl;
483 483
 		$output = executeQuery('module.insertModule', $args);
484
-		if(!$output->toBool())
484
+		if (!$output->toBool())
485 485
 		{
486 486
 			$oDB->rollback();
487 487
 			return $output;
@@ -493,12 +493,12 @@  discard block
 block discarded – undo
493 493
 		$oDB->commit();
494 494
 
495 495
 		$oCacheHandler = CacheHandler::getInstance('object', null, true);
496
-		if($oCacheHandler->isSupport())
496
+		if ($oCacheHandler->isSupport())
497 497
 		{
498 498
 			$oCacheHandler->invalidateGroupKey('site_and_module');
499 499
 		}
500 500
 
501
-		$output->add('module_srl',$args->module_srl);
501
+		$output->add('module_srl', $args->module_srl);
502 502
 		return $output;
503 503
 	}
504 504
 
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
 	 */
508 508
 	function updateModule($args)
509 509
 	{
510
-		if(isset($args->isMenuCreate))
510
+		if (isset($args->isMenuCreate))
511 511
 		{
512 512
 			$isMenuCreate = $args->isMenuCreate;
513 513
 		}
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 		}
518 518
 		
519 519
 		$output = $this->arrangeModuleInfo($args, $extra_vars);
520
-		if(!$output->toBool()) return $output;
520
+		if (!$output->toBool()) return $output;
521 521
 		// begin transaction
522 522
 		$oDB = &DB::getInstance();
523 523
 		$oDB->begin();
@@ -526,29 +526,29 @@  discard block
 block discarded – undo
526 526
 		$columnList = array('module_srl', 'site_srl', 'browser_title', 'mid');
527 527
 		$module_info = $oModuleModel->getModuleInfoByModuleSrl($args->module_srl);
528 528
 
529
-		if(!$args->site_srl || !$args->browser_title)
529
+		if (!$args->site_srl || !$args->browser_title)
530 530
 		{
531
-			if(!$args->site_srl) $args->site_srl = (int)$module_info->site_srl;
532
-			if(!$args->browser_title) $args->browser_title = $module_info->browser_title;
531
+			if (!$args->site_srl) $args->site_srl = (int) $module_info->site_srl;
532
+			if (!$args->browser_title) $args->browser_title = $module_info->browser_title;
533 533
 		}
534 534
 
535 535
 		$args->browser_title = strip_tags($args->browser_title);
536 536
 
537 537
 		$output = executeQuery('module.isExistsModuleName', $args);
538
-		if(!$output->toBool() || $output->data->count)
538
+		if (!$output->toBool() || $output->data->count)
539 539
 		{
540 540
 			$oDB->rollback();
541 541
 			return new BaseObject(-1, 'msg_module_name_exists');
542 542
 		}
543 543
 
544 544
 		// default value
545
-		if($args->skin == '/USE_DEFAULT/')
545
+		if ($args->skin == '/USE_DEFAULT/')
546 546
 		{
547 547
 			$args->is_skin_fix = 'N';
548 548
 		}
549 549
 		else
550 550
 		{
551
-			if(isset($args->is_skin_fix))
551
+			if (isset($args->is_skin_fix))
552 552
 			{
553 553
 				$args->is_skin_fix = ($args->is_skin_fix != 'Y') ? 'N' : 'Y';
554 554
 			}
@@ -558,13 +558,13 @@  discard block
 block discarded – undo
558 558
 			}
559 559
 		}
560 560
 
561
-		if($args->mskin == '/USE_DEFAULT/')
561
+		if ($args->mskin == '/USE_DEFAULT/')
562 562
 		{
563 563
 			$args->is_mskin_fix = 'N';
564 564
 		}
565 565
 		else
566 566
 		{
567
-			if(isset($args->is_mskin_fix))
567
+			if (isset($args->is_mskin_fix))
568 568
 			{
569 569
 				$args->is_mskin_fix = ($args->is_mskin_fix != 'Y') ? 'N' : 'Y';
570 570
 			}
@@ -574,27 +574,27 @@  discard block
 block discarded – undo
574 574
 			}
575 575
 		}
576 576
 		$output = executeQuery('module.updateModule', $args);
577
-		if(!$output->toBool())
577
+		if (!$output->toBool())
578 578
 		{
579 579
 			$oDB->rollback();
580 580
 			return $output;
581 581
 		}
582 582
 
583
-		if($isMenuCreate === TRUE)
583
+		if ($isMenuCreate === TRUE)
584 584
 		{
585 585
 			$menuArgs = new stdClass;
586 586
 			$menuArgs->url = $module_info->mid;
587 587
 			$menuArgs->site_srl = $module_info->site_srl;
588 588
 			$menuOutput = executeQueryArray('menu.getMenuItemByUrl', $menuArgs);
589
-			if($menuOutput->data && count($menuOutput->data))
589
+			if ($menuOutput->data && count($menuOutput->data))
590 590
 			{
591 591
 				$oMenuAdminController = getAdminController('menu');
592
-				foreach($menuOutput->data as $itemInfo)
592
+				foreach ($menuOutput->data as $itemInfo)
593 593
 				{
594 594
 					$itemInfo->url = $args->mid;
595 595
 	
596 596
 					$updateMenuItemOutput = $oMenuAdminController->updateMenuItem($itemInfo);
597
-					if(!$updateMenuItemOutput->toBool())
597
+					if (!$updateMenuItemOutput->toBool())
598 598
 					{
599 599
 						$oDB->rollback();
600 600
 						return $updateMenuItemOutput;
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 		}
605 605
 
606 606
 		// if mid changed, change mid of success_return_url to new mid
607
-		if($module_info->mid != $args->mid && Context::get('success_return_url'))
607
+		if ($module_info->mid != $args->mid && Context::get('success_return_url'))
608 608
 		{
609 609
 			changeValueInUrl('mid', $args->mid, $module_info->mid);
610 610
 		}
@@ -614,11 +614,11 @@  discard block
 block discarded – undo
614 614
 
615 615
 		$oDB->commit();
616 616
 
617
-		$output->add('module_srl',$args->module_srl);
617
+		$output->add('module_srl', $args->module_srl);
618 618
 
619 619
 		//remove from cache
620 620
 		$oCacheHandler = CacheHandler::getInstance('object', null, true);
621
-		if($oCacheHandler->isSupport())
621
+		if ($oCacheHandler->isSupport())
622 622
 		{
623 623
 			$oCacheHandler->invalidateGroupKey('site_and_module');
624 624
 		}
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 		$args->update_id = $update_id;
638 638
 		$output = executeQuery('module.insertModuleUpdateLog', $args);
639 639
 
640
-		if(!!$output->error) return false;
640
+		if (!!$output->error) return false;
641 641
 
642 642
 		return true;
643 643
 	}
@@ -652,11 +652,11 @@  discard block
 block discarded – undo
652 652
 		$args->site_srl = $site_srl;
653 653
 		$args->layout_srl = $layout_srl;
654 654
 		$output = executeQuery('module.updateModuleSite', $args);
655
-		if(!$output->toBool()) return $output;
655
+		if (!$output->toBool()) return $output;
656 656
 
657 657
 		//remove from cache
658 658
 		$oCacheHandler = CacheHandler::getInstance('object', null, true);
659
-		if($oCacheHandler->isSupport())
659
+		if ($oCacheHandler->isSupport())
660 660
 		{
661 661
 			$oCacheHandler->invalidateGroupKey('site_and_module');
662 662
 		}
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
 	 */
672 672
 	function deleteModule($module_srl, $site_srl = 0)
673 673
 	{
674
-		if(!$module_srl) return new BaseObject(-1,'msg_invalid_request');
674
+		if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request');
675 675
 
676 676
 		$site_module_info = Context::get('site_module_info');
677 677
 
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 		$args = new stdClass();
682 682
 		$args->url = $output->mid;
683 683
 		$args->is_shortcut = 'N';
684
-		if(!$site_srl) $args->site_srl = $site_module_info->site_srl;
684
+		if (!$site_srl) $args->site_srl = $site_module_info->site_srl;
685 685
 		else $args->site_srl = $site_srl;
686 686
 
687 687
 		unset($output);
@@ -690,9 +690,9 @@  discard block
 block discarded – undo
690 690
 		$menuOutput = $oMenuAdminModel->getMenuList($args);
691 691
 
692 692
 		// get menu_srl by site_srl
693
-		if(is_array($menuOutput->data))
693
+		if (is_array($menuOutput->data))
694 694
 		{
695
-			foreach($menuOutput->data AS $key=>$value)
695
+			foreach ($menuOutput->data AS $key=>$value)
696 696
 			{
697 697
 				$args->menu_srl = $value->menu_srl;
698 698
 				break;
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
 
702 702
 		$output = executeQuery('menu.getMenuItemByUrl', $args);
703 703
 		// menu delete
704
-		if($output->data)
704
+		if ($output->data)
705 705
 		{
706 706
 			unset($args);
707 707
 			$args = new stdClass;
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
 			$oMenuAdminController = getAdminController('menu');
713 713
 			$output = $oMenuAdminController->deleteItem($args);
714 714
 
715
-			if($output->isSuccess)
715
+			if ($output->isSuccess)
716 716
 			{
717 717
 				return new BaseObject(0, 'success_deleted');
718 718
 			}
@@ -734,19 +734,19 @@  discard block
 block discarded – undo
734 734
 	 */
735 735
 	public function onlyDeleteModule($module_srl)
736 736
 	{
737
-		if(!$module_srl) return new BaseObject(-1,'msg_invalid_request');
737
+		if (!$module_srl) return new BaseObject(-1, 'msg_invalid_request');
738 738
 
739 739
 		// check start module
740 740
 		$oModuleModel = getModel('module');
741 741
 		$columnList = array('sites.index_module_srl');
742 742
 		$start_module = $oModuleModel->getSiteInfo(0, $columnList);
743
-		if($module_srl == $start_module->index_module_srl) return new BaseObject(-1, 'msg_cannot_delete_startmodule');
743
+		if ($module_srl == $start_module->index_module_srl) return new BaseObject(-1, 'msg_cannot_delete_startmodule');
744 744
 
745 745
 		// Call a trigger (before)
746 746
 		$trigger_obj = new stdClass();
747 747
 		$trigger_obj->module_srl = $module_srl;
748 748
 		$output = ModuleHandler::triggerCall('module.deleteModule', 'before', $trigger_obj);
749
-		if(!$output->toBool()) return $output;
749
+		if (!$output->toBool()) return $output;
750 750
 
751 751
 		// begin transaction
752 752
 		$oDB = &DB::getInstance();
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 		$args->module_srl = $module_srl;
757 757
 		// Delete module information from the DB
758 758
 		$output = executeQuery('module.deleteModule', $args);
759
-		if(!$output->toBool())
759
+		if (!$output->toBool())
760 760
 		{
761 761
 			$oDB->rollback();
762 762
 			return $output;
@@ -770,10 +770,10 @@  discard block
 block discarded – undo
770 770
 		// Remove the module manager
771 771
 		$this->deleteAdminId($module_srl);
772 772
 		// Call a trigger (after)
773
-		if($output->toBool())
773
+		if ($output->toBool())
774 774
 		{
775 775
 			$trigger_output = ModuleHandler::triggerCall('module.deleteModule', 'after', $trigger_obj);
776
-			if(!$trigger_output->toBool())
776
+			if (!$trigger_output->toBool())
777 777
 			{
778 778
 				$oDB->rollback();
779 779
 				return $trigger_output;
@@ -785,7 +785,7 @@  discard block
 block discarded – undo
785 785
 
786 786
 		//remove from cache
787 787
 		$oCacheHandler = CacheHandler::getInstance('object', null, true);
788
-		if($oCacheHandler->isSupport())
788
+		if ($oCacheHandler->isSupport())
789 789
 		{
790 790
 			$oCacheHandler->invalidateGroupKey('site_and_module');
791 791
 		}
@@ -807,10 +807,10 @@  discard block
 block discarded – undo
807 807
 	function clearDefaultModule()
808 808
 	{
809 809
 		$output = executeQuery('module.clearDefaultModule');
810
-		if(!$output->toBool()) return $output;
810
+		if (!$output->toBool()) return $output;
811 811
 
812 812
 		$oCacheHandler = CacheHandler::getInstance('object', null, true);
813
-		if($oCacheHandler->isSupport())
813
+		if ($oCacheHandler->isSupport())
814 814
 		{
815 815
 			$oCacheHandler->invalidateGroupKey('site_and_module');
816 816
 		}
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 		$output = executeQuery('module.updateModuleMenu', $args);
827 827
 
828 828
 		$oCacheHandler = CacheHandler::getInstance('object', null, true);
829
-		if($oCacheHandler->isSupport())
829
+		if ($oCacheHandler->isSupport())
830 830
 		{
831 831
 			$oCacheHandler->invalidateGroupKey('site_and_module');
832 832
 		}
@@ -839,15 +839,15 @@  discard block
 block discarded – undo
839 839
 	 */
840 840
 	function updateModuleLayout($layout_srl, $menu_srl_list)
841 841
 	{
842
-		if(!count($menu_srl_list)) return;
842
+		if (!count($menu_srl_list)) return;
843 843
 
844 844
 		$args = new stdClass;
845 845
 		$args->layout_srl = $layout_srl;
846
-		$args->menu_srls = implode(',',$menu_srl_list);
846
+		$args->menu_srls = implode(',', $menu_srl_list);
847 847
 		$output = executeQuery('module.updateModuleLayout', $args);
848 848
 
849 849
 		$oCacheHandler = CacheHandler::getInstance('object', null, true);
850
-		if($oCacheHandler->isSupport())
850
+		if ($oCacheHandler->isSupport())
851 851
 		{
852 852
 			$oCacheHandler->invalidateGroupKey('site_and_module');
853 853
 		}
@@ -866,37 +866,37 @@  discard block
 block discarded – undo
866 866
 
867 867
 		$output = executeQuery('module.deleteSiteAdmin', $args);
868 868
 
869
-		if(!$output->toBool()) return $output;
869
+		if (!$output->toBool()) return $output;
870 870
 		// Get user id of an administrator
871
-		if(!is_array($arr_admins) || !count($arr_admins)) return new BaseObject();
872
-		foreach($arr_admins as $key => $user_id)
871
+		if (!is_array($arr_admins) || !count($arr_admins)) return new BaseObject();
872
+		foreach ($arr_admins as $key => $user_id)
873 873
 		{
874
-			if(!trim($user_id)) continue;
874
+			if (!trim($user_id)) continue;
875 875
 			$admins[] = trim($user_id);
876 876
 		}
877
-		if(!count($admins)) return new BaseObject();
877
+		if (!count($admins)) return new BaseObject();
878 878
 
879 879
 		$oMemberModel = getModel('member');
880 880
 		$member_config = $oMemberModel->getMemberConfig();
881
-		if($member_config->identifier == 'email_address')
881
+		if ($member_config->identifier == 'email_address')
882 882
 		{
883
-			$args->email_address = '\''.implode('\',\'',$admins).'\'';
883
+			$args->email_address = '\''.implode('\',\'', $admins).'\'';
884 884
 		}
885 885
 		else
886 886
 		{
887
-			$args->user_ids = '\''.implode('\',\'',$admins).'\'';
887
+			$args->user_ids = '\''.implode('\',\'', $admins).'\'';
888 888
 		}
889 889
 		$output = executeQueryArray('module.getAdminSrls', $args);
890
-		if(!$output->toBool()||!$output->data) return $output;
890
+		if (!$output->toBool() || !$output->data) return $output;
891 891
 
892
-		foreach($output->data as $key => $val)
892
+		foreach ($output->data as $key => $val)
893 893
 		{
894 894
 			unset($args);
895 895
 			$args = new stdClass;
896 896
 			$args->site_srl = $site_srl;
897 897
 			$args->member_srl = $val->member_srl;
898 898
 			$output = executeQueryArray('module.insertSiteAdmin', $args);
899
-			if(!$output->toBool()) return $output;
899
+			if (!$output->toBool()) return $output;
900 900
 		}
901 901
 		return new BaseObject();
902 902
 	}
@@ -909,12 +909,12 @@  discard block
 block discarded – undo
909 909
 		$oMemberModel = getModel('member');
910 910
 		$member_config = $oMemberModel->getMemberConfig();
911 911
 
912
-		if($member_config->identifier == 'email_address')
912
+		if ($member_config->identifier == 'email_address')
913 913
 			$member_info = $oMemberModel->getMemberInfoByEmailAddress($admin_id);
914 914
 		else
915 915
 			$member_info = $oMemberModel->getMemberInfoByUserID($admin_id);
916 916
 
917
-		if(!$member_info->member_srl) return;
917
+		if (!$member_info->member_srl) return;
918 918
 		$args = new stdClass();
919 919
 		$args->module_srl = $module_srl;
920 920
 		$args->member_srl = $member_info->member_srl;
@@ -929,11 +929,11 @@  discard block
 block discarded – undo
929 929
 		$args = new stdClass();
930 930
 		$args->module_srl = $module_srl;
931 931
 
932
-		if($admin_id)
932
+		if ($admin_id)
933 933
 		{
934 934
 			$oMemberModel = getModel('member');
935 935
 			$member_info = $oMemberModel->getMemberInfoByUserID($admin_id);
936
-			if($member_info->member_srl) $args->member_srl = $member_info->member_srl;
936
+			if ($member_info->member_srl) $args->member_srl = $member_info->member_srl;
937 937
 		}
938 938
 		return executeQuery('module.deleteAdminId', $args);
939 939
 	}
@@ -970,18 +970,18 @@  discard block
 block discarded – undo
970 970
 		$oDB->begin();
971 971
 
972 972
 		$output = $this->_deleteModuleSkinVars($module_srl, $mode);
973
-		if(!$output->toBool())
973
+		if (!$output->toBool())
974 974
 		{
975 975
 			$oDB->rollback();
976 976
 			return $output;
977 977
 		}
978 978
 
979 979
 		getDestroyXeVars($obj);
980
-		if(!$obj || !count($obj)) return new BaseObject();
980
+		if (!$obj || !count($obj)) return new BaseObject();
981 981
 
982 982
 		$args = new stdClass;
983 983
 		$args->module_srl = $module_srl;
984
-		foreach($obj as $key => $val)
984
+		foreach ($obj as $key => $val)
985 985
 		{
986 986
 			// #17927989 For an old board which used the old blog module
987 987
 			// it often saved menu item(stdClass) on the skin info column
@@ -992,9 +992,9 @@  discard block
 block discarded – undo
992 992
 
993 993
 			$args->name = trim($key);
994 994
 			$args->value = trim($val);
995
-			if(!$args->name || !$args->value) continue;
995
+			if (!$args->name || !$args->value) continue;
996 996
 
997
-			if($mode === 'P')
997
+			if ($mode === 'P')
998 998
 			{
999 999
 				$output = executeQuery('module.insertModuleSkinVars', $args);
1000 1000
 			}
@@ -1002,7 +1002,7 @@  discard block
 block discarded – undo
1002 1002
 			{
1003 1003
 				$output = executeQuery('module.insertModuleMobileSkinVars', $args);
1004 1004
 			}
1005
-			if(!$output->toBool())
1005
+			if (!$output->toBool())
1006 1006
 			{
1007 1007
 				return $output;
1008 1008
 				$oDB->rollback();
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 		$args->module_srl = $module_srl;
1042 1042
 		$mode = $mode === 'P' ? 'P' : 'M';
1043 1043
 
1044
-		if($mode === 'P')
1044
+		if ($mode === 'P')
1045 1045
 		{
1046 1046
 			$object_key = 'module_skin_vars:'.$module_srl;
1047 1047
 			$query = 'module.deleteModuleSkinVars';
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
 		//remove from cache
1056 1056
 		$oCacheHandler = CacheHandler::getInstance('object', null, true);
1057 1057
 		$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
1058
-		if($oCacheHandler->isSupport())
1058
+		if ($oCacheHandler->isSupport())
1059 1059
 		{
1060 1060
 			$oCacheHandler->delete($cache_key);
1061 1061
 		}
@@ -1070,22 +1070,22 @@  discard block
 block discarded – undo
1070 1070
 	{
1071 1071
 		$this->deleteModuleExtraVars($module_srl);
1072 1072
 		getDestroyXeVars($obj);
1073
-		if(!$obj || !count($obj)) return;
1073
+		if (!$obj || !count($obj)) return;
1074 1074
 
1075
-		foreach($obj as $key => $val)
1075
+		foreach ($obj as $key => $val)
1076 1076
 		{
1077
-			if(is_object($val) || is_array($val)) continue;
1077
+			if (is_object($val) || is_array($val)) continue;
1078 1078
 
1079 1079
 			$args = new stdClass();
1080 1080
 			$args->module_srl = $module_srl;
1081 1081
 			$args->name = trim($key);
1082 1082
 			$args->value = trim($val);
1083
-			if(!$args->name || !$args->value) continue;
1083
+			if (!$args->name || !$args->value) continue;
1084 1084
 			$output = executeQuery('module.insertModuleExtraVars', $args);
1085 1085
 		}
1086 1086
 
1087 1087
 		$oCacheHandler = CacheHandler::getInstance('object', null, true);
1088
-		if($oCacheHandler->isSupport())
1088
+		if ($oCacheHandler->isSupport())
1089 1089
 		{
1090 1090
 			$object_key = 'module_extra_vars:'.$module_srl;
1091 1091
 			$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 
1105 1105
 		//remove from cache
1106 1106
 		$oCacheHandler = CacheHandler::getInstance('object', null, true);
1107
-		if($oCacheHandler->isSupport())
1107
+		if ($oCacheHandler->isSupport())
1108 1108
 		{
1109 1109
 			$object_key = 'module_extra_vars:'.$module_srl;
1110 1110
 			$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
@@ -1120,19 +1120,19 @@  discard block
 block discarded – undo
1120 1120
 	function insertModuleGrants($module_srl, $obj)
1121 1121
 	{
1122 1122
 		$this->deleteModuleGrants($module_srl);
1123
-		if(!$obj || !count($obj)) return;
1123
+		if (!$obj || !count($obj)) return;
1124 1124
 
1125
-		foreach($obj as $name => $val)
1125
+		foreach ($obj as $name => $val)
1126 1126
 		{
1127
-			if(!$val || !count($val)) continue;
1127
+			if (!$val || !count($val)) continue;
1128 1128
 
1129
-			foreach($val as $group_srl)
1129
+			foreach ($val as $group_srl)
1130 1130
 			{
1131 1131
 				$args = new stdClass();
1132 1132
 				$args->module_srl = $module_srl;
1133 1133
 				$args->name = $name;
1134 1134
 				$args->group_srl = trim($group_srl);
1135
-				if(!$args->name || !$args->group_srl) continue;
1135
+				if (!$args->name || !$args->group_srl) continue;
1136 1136
 				executeQuery('module.insertModuleGrant', $args);
1137 1137
 			}
1138 1138
 		}
@@ -1153,9 +1153,9 @@  discard block
 block discarded – undo
1153 1153
 	 */
1154 1154
 	function replaceDefinedLangCode(&$output, $isReplaceLangCode = true)
1155 1155
 	{
1156
-		if($isReplaceLangCode)
1156
+		if ($isReplaceLangCode)
1157 1157
 		{
1158
-			$output = preg_replace_callback('!\$user_lang->([a-z0-9\_]+)!is', array($this,'_replaceLangCode'), $output);
1158
+			$output = preg_replace_callback('!\$user_lang->([a-z0-9\_]+)!is', array($this, '_replaceLangCode'), $output);
1159 1159
 		}
1160 1160
 	}
1161 1161
 
@@ -1164,29 +1164,29 @@  discard block
 block discarded – undo
1164 1164
 		static $lang = false;
1165 1165
 
1166 1166
 		$oCacheHandler = CacheHandler::getInstance('object', null, true);
1167
-		if($lang === false && $oCacheHandler->isSupport())
1167
+		if ($lang === false && $oCacheHandler->isSupport())
1168 1168
 		{
1169 1169
 			$site_module_info = Context::get('site_module_info');
1170
-			if(!$site_module_info)
1170
+			if (!$site_module_info)
1171 1171
 			{
1172 1172
 				$oModuleModel = getModel('module');
1173 1173
 				$site_module_info = $oModuleModel->getDefaultMid();
1174 1174
 				Context::set('site_module_info', $site_module_info);
1175 1175
 			}
1176 1176
 
1177
-			$object_key = 'user_defined_langs:' . $site_module_info->site_srl . ':' . Context::getLangType();
1177
+			$object_key = 'user_defined_langs:'.$site_module_info->site_srl.':'.Context::getLangType();
1178 1178
 			$cache_key = $oCacheHandler->getGroupKey('site_and_module', $object_key);
1179 1179
 			$lang = $oCacheHandler->get($cache_key);
1180 1180
 
1181
-			if($lang === false) {
1181
+			if ($lang === false) {
1182 1182
 				$oModuleAdminController = getAdminController('module');
1183 1183
 				$lang = $oModuleAdminController->makeCacheDefinedLangCode($site_module_info->site_srl);
1184 1184
 			}
1185 1185
 		}
1186 1186
 
1187
-		if(!Context::get($matches[1]) && $lang[$matches[1]]) return $lang[$matches[1]];
1187
+		if (!Context::get($matches[1]) && $lang[$matches[1]]) return $lang[$matches[1]];
1188 1188
 
1189
-		return str_replace('$user_lang->','',$matches[0]);
1189
+		return str_replace('$user_lang->', '', $matches[0]);
1190 1190
 	}
1191 1191
 
1192 1192
 
@@ -1199,17 +1199,17 @@  discard block
 block discarded – undo
1199 1199
 		if ($ajax) Context::setRequestMethod('JSON');
1200 1200
 
1201 1201
 		$logged_info = Context::get('logged_info');
1202
-		if($logged_info->is_admin !='Y' && !$logged_info->is_site_admin) return new BaseObject(-1, 'msg_not_permitted');
1202
+		if ($logged_info->is_admin != 'Y' && !$logged_info->is_site_admin) return new BaseObject(-1, 'msg_not_permitted');
1203 1203
 
1204
-		$vars = Context::gets('addfile','filter');
1204
+		$vars = Context::gets('addfile', 'filter');
1205 1205
 		$attributeNames = Context::get('attribute_name');
1206 1206
 		$attributeValues = Context::get('attribute_value');
1207
-		if(is_array($attributeNames) && is_array($attributeValues) && count($attributeNames) == count($attributeValues))
1207
+		if (is_array($attributeNames) && is_array($attributeValues) && count($attributeNames) == count($attributeValues))
1208 1208
 		{
1209 1209
 			$attributes = array();
1210
-			foreach($attributeNames as $no => $name)
1210
+			foreach ($attributeNames as $no => $name)
1211 1211
 			{
1212
-				if(empty($name))
1212
+				if (empty($name))
1213 1213
 				{
1214 1214
 					continue;
1215 1215
 				}
@@ -1221,16 +1221,16 @@  discard block
 block discarded – undo
1221 1221
 		$vars->comment = $attributes;
1222 1222
 		$module_filebox_srl = Context::get('module_filebox_srl');
1223 1223
 
1224
-		$ext = strtolower(substr(strrchr($vars->addfile['name'],'.'),1));
1224
+		$ext = strtolower(substr(strrchr($vars->addfile['name'], '.'), 1));
1225 1225
 		$vars->ext = $ext;
1226
-		if($vars->filter) $filter = explode(',',$vars->filter);
1227
-		else $filter = array('jpg','jpeg','gif','png');
1228
-		if(!in_array($ext,$filter)) return new BaseObject(-1, 'msg_error_occured');
1226
+		if ($vars->filter) $filter = explode(',', $vars->filter);
1227
+		else $filter = array('jpg', 'jpeg', 'gif', 'png');
1228
+		if (!in_array($ext, $filter)) return new BaseObject(-1, 'msg_error_occured');
1229 1229
 
1230 1230
 		$vars->member_srl = $logged_info->member_srl;
1231 1231
 
1232 1232
 		// update
1233
-		if($module_filebox_srl > 0)
1233
+		if ($module_filebox_srl > 0)
1234 1234
 		{
1235 1235
 			$vars->module_filebox_srl = $module_filebox_srl;
1236 1236
 			$output = $this->updateModuleFileBox($vars);
@@ -1238,10 +1238,10 @@  discard block
 block discarded – undo
1238 1238
 		// insert
1239 1239
 		else
1240 1240
 		{
1241
-			if(!Context::isUploaded()) return new BaseObject(-1, 'msg_error_occured');
1241
+			if (!Context::isUploaded()) return new BaseObject(-1, 'msg_error_occured');
1242 1242
 			$addfile = Context::get('addfile');
1243
-			if(!is_uploaded_file($addfile['tmp_name'])) return new BaseObject(-1, 'msg_error_occured');
1244
-			if($vars->addfile['error'] != 0) return new BaseObject(-1, 'msg_error_occured');
1243
+			if (!is_uploaded_file($addfile['tmp_name'])) return new BaseObject(-1, 'msg_error_occured');
1244
+			if ($vars->addfile['error'] != 0) return new BaseObject(-1, 'msg_error_occured');
1245 1245
 			$output = $this->insertModuleFileBox($vars);
1246 1246
 		}
1247 1247
 
@@ -1255,7 +1255,7 @@  discard block
 block discarded – undo
1255 1255
 		}
1256 1256
 		else
1257 1257
 		{
1258
-			if($output) $this->add('save_filename', $output->get('save_filename'));
1258
+			if ($output) $this->add('save_filename', $output->get('save_filename'));
1259 1259
 			else $this->add('save_filename', '');
1260 1260
 		}
1261 1261
 	}
@@ -1267,7 +1267,7 @@  discard block
 block discarded – undo
1267 1267
 	{
1268 1268
 		$args = new stdClass;
1269 1269
 		// have file
1270
-		if($vars->addfile['tmp_name'] && is_uploaded_file($vars->addfile['tmp_name']))
1270
+		if ($vars->addfile['tmp_name'] && is_uploaded_file($vars->addfile['tmp_name']))
1271 1271
 		{
1272 1272
 			$oModuleModel = getModel('module');
1273 1273
 			$output = $oModuleModel->getModuleFileBox($vars->module_filebox_srl);
@@ -1284,9 +1284,9 @@  discard block
 block discarded – undo
1284 1284
 			$tmp = $vars->addfile['tmp_name'];
1285 1285
 
1286 1286
 			// Check uploaded file
1287
-			if(!checkUploadedFile($tmp)) return false;
1287
+			if (!checkUploadedFile($tmp)) return false;
1288 1288
 
1289
-			if(!@move_uploaded_file($tmp, $save_filename))
1289
+			if (!@move_uploaded_file($tmp, $save_filename))
1290 1290
 			{
1291 1291
 				return false;
1292 1292
 			}
@@ -1321,14 +1321,14 @@  discard block
 block discarded – undo
1321 1321
 		$ext = explode($vars->addfile['name'], '.');
1322 1322
 		$ext = strtolower(array_pop($ext));
1323 1323
 
1324
-		$save_filename = sprintf('%s%s.%s',$path, $random->createSecureSalt(32, 'hex'), $vars->ext);
1324
+		$save_filename = sprintf('%s%s.%s', $path, $random->createSecureSalt(32, 'hex'), $vars->ext);
1325 1325
 		$tmp = $vars->addfile['tmp_name'];
1326 1326
 
1327 1327
 		// Check uploaded file
1328
-		if(!checkUploadedFile($tmp)) return false;
1328
+		if (!checkUploadedFile($tmp)) return false;
1329 1329
 
1330 1330
 		// upload
1331
-		if(!@move_uploaded_file($tmp, $save_filename))
1331
+		if (!@move_uploaded_file($tmp, $save_filename))
1332 1332
 		{
1333 1333
 			return false;
1334 1334
 		}
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
 		$args->member_srl = $vars->member_srl;
1340 1340
 		$args->comment = $vars->comment;
1341 1341
 		$args->filename = $save_filename;
1342
-		$args->fileextension = strtolower(substr(strrchr($vars->addfile['name'],'.'),1));
1342
+		$args->fileextension = strtolower(substr(strrchr($vars->addfile['name'], '.'), 1));
1343 1343
 		$args->filesize = $vars->addfile['size'];
1344 1344
 
1345 1345
 		$output = executeQuery('module.insertModuleFileBox', $args);
@@ -1354,14 +1354,14 @@  discard block
 block discarded – undo
1354 1354
 	function procModuleFileBoxDelete()
1355 1355
 	{
1356 1356
 		$logged_info = Context::get('logged_info');
1357
-		if($logged_info->is_admin !='Y' && !$logged_info->is_site_admin) return new BaseObject(-1, 'msg_not_permitted');
1357
+		if ($logged_info->is_admin != 'Y' && !$logged_info->is_site_admin) return new BaseObject(-1, 'msg_not_permitted');
1358 1358
 
1359 1359
 		$module_filebox_srl = Context::get('module_filebox_srl');
1360
-		if(!$module_filebox_srl) return new BaseObject(-1, 'msg_invalid_request');
1360
+		if (!$module_filebox_srl) return new BaseObject(-1, 'msg_invalid_request');
1361 1361
 		$vars = new stdClass();
1362 1362
 		$vars->module_filebox_srl = $module_filebox_srl;
1363 1363
 		$output = $this->deleteModuleFileBox($vars);
1364
-		if(!$output->toBool()) return $output;
1364
+		if (!$output->toBool()) return $output;
1365 1365
 	}
1366 1366
 
1367 1367
 	function deleteModuleFileBox($vars)
@@ -1384,11 +1384,11 @@  discard block
 block discarded – undo
1384 1384
 		$this->unlockTimeoutPassed();
1385 1385
 		$args = new stdClass;
1386 1386
 		$args->lock_name = $lock_name;
1387
-		if(!$timeout) $timeout = 60;
1387
+		if (!$timeout) $timeout = 60;
1388 1388
 		$args->deadline = date("YmdHis", $_SERVER['REQUEST_TIME'] + $timeout);
1389
-		if($member_srl) $args->member_srl = $member_srl;
1389
+		if ($member_srl) $args->member_srl = $member_srl;
1390 1390
 		$output = executeQuery('module.insertLock', $args);
1391
-		if($output->toBool())
1391
+		if ($output->toBool())
1392 1392
 		{
1393 1393
 			$output->add('lock_name', $lock_name);
1394 1394
 			$output->add('deadline', $args->deadline);
@@ -1417,7 +1417,7 @@  discard block
 block discarded – undo
1417 1417
 		$output = executeQuery('module.updateModuleInSites', $args);
1418 1418
 
1419 1419
 		$oCacheHandler = CacheHandler::getInstance('object', null, true);
1420
-		if($oCacheHandler->isSupport())
1420
+		if ($oCacheHandler->isSupport())
1421 1421
 		{
1422 1422
 			$oCacheHandler->invalidateGroupKey('site_and_module');
1423 1423
 		}
Please login to merge, or discard this patch.
modules/file/file.controller.php 2 patches
Spacing   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -29,40 +29,40 @@  discard block
 block discarded – undo
29 29
 		$file_info = Context::get('Filedata');
30 30
 
31 31
 		// An error appears if not a normally uploaded file
32
-		if(!is_uploaded_file($file_info['tmp_name'])) exit();
32
+		if (!is_uploaded_file($file_info['tmp_name'])) exit();
33 33
 
34 34
 		// Basic variables setting
35 35
 		$oFileModel = getModel('file');
36 36
 		$editor_sequence = Context::get('editor_sequence');
37 37
 		$upload_target_srl = intval(Context::get('uploadTargetSrl'));
38
-		if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
38
+		if (!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
39 39
 		$module_srl = $this->module_srl;
40 40
 		// Exit a session if there is neither upload permission nor information
41
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
41
+		if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
42 42
 		// Extract from session information if upload_target_srl is not specified
43
-		if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
43
+		if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
44 44
 		// Create if upload_target_srl is not defined in the session information
45
-		if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
45
+		if (!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
46 46
 
47 47
 		$output = $this->insertFile($file_info, $module_srl, $upload_target_srl);
48 48
 		Context::setResponseMethod('JSON');
49
-		$this->add('file_srl',$output->get('file_srl'));
50
-		$this->add('file_size',$output->get('file_size'));
51
-		$this->add('direct_download',$output->get('direct_download'));
52
-		$this->add('source_filename',$output->get('source_filename'));
53
-		$this->add('upload_target_srl',$output->get('upload_target_srl'));
54
-		$this->add('download_url',$output->get('uploaded_filename'));
55
-
56
-		if($output->get('direct_download') === 'Y')
49
+		$this->add('file_srl', $output->get('file_srl'));
50
+		$this->add('file_size', $output->get('file_size'));
51
+		$this->add('direct_download', $output->get('direct_download'));
52
+		$this->add('source_filename', $output->get('source_filename'));
53
+		$this->add('upload_target_srl', $output->get('upload_target_srl'));
54
+		$this->add('download_url', $output->get('uploaded_filename'));
55
+
56
+		if ($output->get('direct_download') === 'Y')
57 57
 		{
58
-			$this->add('download_url',$output->get('uploaded_filename'));
58
+			$this->add('download_url', $output->get('uploaded_filename'));
59 59
 		}
60 60
 		else
61 61
 		{
62
-			$this->add('download_url',$oFileModel->getDownloadUrl($output->get('file_srl'), $output->get('sid'), $module_srl));
62
+			$this->add('download_url', $oFileModel->getDownloadUrl($output->get('file_srl'), $output->get('sid'), $module_srl));
63 63
 		}
64 64
 
65
-		if($output->error != '0') {
65
+		if ($output->error != '0') {
66 66
 			$this->stop($output->message);
67 67
 		}
68 68
 	}
@@ -79,24 +79,24 @@  discard block
 block discarded – undo
79 79
 		$callback = Context::get('callback');
80 80
 		$module_srl = $this->module_srl;
81 81
 		$upload_target_srl = intval(Context::get('uploadTargetSrl'));
82
-		if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
82
+		if (!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
83 83
 
84 84
 		// Exit a session if there is neither upload permission nor information
85
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
85
+		if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
86 86
 		// Extract from session information if upload_target_srl is not specified
87
-		if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
87
+		if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
88 88
 		// Create if upload_target_srl is not defined in the session information
89
-		if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
89
+		if (!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
90 90
 
91 91
 		// Delete and then attempt to re-upload if file_srl is requested
92 92
 		$file_srl = Context::get('file_srl');
93
-		if($file_srl)
93
+		if ($file_srl)
94 94
 		{
95 95
 			$oFileModel = getModel('file');
96 96
 			$logged_info = Context::get('logged_info');
97 97
 			$file_info = $oFileModel->getFile($file_srl);
98 98
 			$file_grant = $oFileModel->getFileGrant($file_info, $logged_info);
99
-			if($file_info->file_srl == $file_srl && $file_grant->is_deletable)
99
+			if ($file_info->file_srl == $file_srl && $file_grant->is_deletable)
100 100
 			{
101 101
 				$this->deleteFile($file_srl);
102 102
 			}
@@ -104,12 +104,12 @@  discard block
 block discarded – undo
104 104
 
105 105
 		$file_info = Context::get('Filedata');
106 106
 		// An error appears if not a normally uploaded file
107
-		if(is_uploaded_file($file_info['tmp_name'])) {
107
+		if (is_uploaded_file($file_info['tmp_name'])) {
108 108
 			$output = $this->insertFile($file_info, $module_srl, $upload_target_srl);
109
-			Context::set('uploaded_fileinfo',$output);
109
+			Context::set('uploaded_fileinfo', $output);
110 110
 		}
111 111
 
112
-		Context::set('layout','none');
112
+		Context::set('layout', 'none');
113 113
 
114 114
 		$this->setTemplatePath($this->module_path.'tpl');
115 115
 		$this->setTemplateFile('iframe');
@@ -126,24 +126,24 @@  discard block
 block discarded – undo
126 126
 		$width = Context::get('width');
127 127
 		$height = Context::get('height');
128 128
 
129
-		if(!$file_srl || !$width)
129
+		if (!$file_srl || !$width)
130 130
 		{
131
-			return new BaseObject(-1,'msg_invalid_request');
131
+			return new BaseObject(-1, 'msg_invalid_request');
132 132
 		}
133 133
 
134 134
 		$oFileModel = getModel('file');
135 135
 		$fileInfo = $oFileModel->getFile($file_srl);
136
-		if(!$fileInfo || $fileInfo->direct_download != 'Y')
136
+		if (!$fileInfo || $fileInfo->direct_download != 'Y')
137 137
 		{
138
-			return new BaseObject(-1,'msg_invalid_request');
138
+			return new BaseObject(-1, 'msg_invalid_request');
139 139
 		}
140 140
 
141 141
 		$source_src = $fileInfo->uploaded_filename;
142
-		$output_src = $source_src . '.resized' . strrchr($source_src,'.');
142
+		$output_src = $source_src.'.resized'.strrchr($source_src, '.');
143 143
 
144
-		if(!$height) $height = $width-1;
144
+		if (!$height) $height = $width - 1;
145 145
 
146
-		if(FileHandler::createImageFile($source_src,$output_src,$width,$height,'','ratio'))
146
+		if (FileHandler::createImageFile($source_src, $output_src, $width, $height, '', 'ratio'))
147 147
 		{
148 148
 			$output = new stdClass();
149 149
 			$output->info = getimagesize($output_src);
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 		}
152 152
 		else
153 153
 		{
154
-			return new BaseObject(-1,'msg_invalid_request');
154
+			return new BaseObject(-1, 'msg_invalid_request');
155 155
 		}
156 156
 
157
-		$this->add('resized_info',$output);
157
+		$this->add('resized_info', $output);
158 158
 	}
159 159
 
160 160
 	/**
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 	{
193 193
 		$oFileModel = getModel('file');
194 194
 
195
-		if(isset($this->grant->access) && $this->grant->access !== true) return new BaseObject(-1, 'msg_not_permitted');
195
+		if (isset($this->grant->access) && $this->grant->access !== true) return new BaseObject(-1, 'msg_not_permitted');
196 196
 
197 197
 		$file_srl = Context::get('file_srl');
198 198
 		$sid = Context::get('sid');
@@ -201,26 +201,26 @@  discard block
 block discarded – undo
201 201
 		$columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type');
202 202
 		$file_obj = $oFileModel->getFile($file_srl, $columnList);
203 203
 		// If the requested file information is incorrect, an error that file cannot be found appears
204
-		if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) return $this->stop('msg_file_not_found');
204
+		if ($file_obj->file_srl != $file_srl || $file_obj->sid != $sid) return $this->stop('msg_file_not_found');
205 205
 		// Notify that file download is not allowed when standing-by(Only a top-administrator is permitted)
206
-		if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') return $this->stop('msg_not_permitted_download');
206
+		if ($logged_info->is_admin != 'Y' && $file_obj->isvalid != 'Y') return $this->stop('msg_not_permitted_download');
207 207
 		// File name
208 208
 		$filename = $file_obj->source_filename;
209 209
 		$file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl);
210 210
 		// Not allow the file outlink
211
-		if($file_module_config->allow_outlink == 'N')
211
+		if ($file_module_config->allow_outlink == 'N')
212 212
 		{
213 213
 			// Handles extension to allow outlink
214
-			if($file_module_config->allow_outlink_format)
214
+			if ($file_module_config->allow_outlink_format)
215 215
 			{
216 216
 				$allow_outlink_format_array = array();
217 217
 				$allow_outlink_format_array = explode(',', $file_module_config->allow_outlink_format);
218
-				if(!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format;
218
+				if (!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format;
219 219
 
220
-				foreach($allow_outlink_format_array as $val)
220
+				foreach ($allow_outlink_format_array as $val)
221 221
 				{
222 222
 					$val = trim($val);
223
-					if(preg_match("/\.{$val}$/i", $filename))
223
+					if (preg_match("/\.{$val}$/i", $filename))
224 224
 					{
225 225
 						$file_module_config->allow_outlink = 'Y';
226 226
 						break;
@@ -228,21 +228,21 @@  discard block
 block discarded – undo
228 228
 				}
229 229
 			}
230 230
 			// Sites that outlink is allowed
231
-			if($file_module_config->allow_outlink != 'Y')
231
+			if ($file_module_config->allow_outlink != 'Y')
232 232
 			{
233 233
 				$referer = parse_url($_SERVER["HTTP_REFERER"]);
234
-				if($referer['host'] != $_SERVER['HTTP_HOST'])
234
+				if ($referer['host'] != $_SERVER['HTTP_HOST'])
235 235
 				{
236
-					if($file_module_config->allow_outlink_site)
236
+					if ($file_module_config->allow_outlink_site)
237 237
 					{
238 238
 						$allow_outlink_site_array = array();
239 239
 						$allow_outlink_site_array = explode("\n", $file_module_config->allow_outlink_site);
240
-						if(!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site;
240
+						if (!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site;
241 241
 
242
-						foreach($allow_outlink_site_array as $val)
242
+						foreach ($allow_outlink_site_array as $val)
243 243
 						{
244 244
 							$site = parse_url(trim($val));
245
-							if($site['host'] == $referer['host'])
245
+							if ($site['host'] == $referer['host'])
246 246
 							{
247 247
 								$file_module_config->allow_outlink = 'Y';
248 248
 								break;
@@ -252,49 +252,49 @@  discard block
 block discarded – undo
252 252
 				}
253 253
 				else $file_module_config->allow_outlink = 'Y';
254 254
 			}
255
-			if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink');
255
+			if ($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink');
256 256
 		}
257 257
 
258 258
 		// Check if a permission for file download is granted
259 259
 		$downloadGrantCount = 0;
260
-		if(is_array($file_module_config->download_grant))
260
+		if (is_array($file_module_config->download_grant))
261 261
 		{
262
-			foreach($file_module_config->download_grant AS $value)
263
-				if($value) $downloadGrantCount++;
262
+			foreach ($file_module_config->download_grant AS $value)
263
+				if ($value) $downloadGrantCount++;
264 264
 		}
265 265
 
266
-		if(is_array($file_module_config->download_grant) && $downloadGrantCount>0)
266
+		if (is_array($file_module_config->download_grant) && $downloadGrantCount > 0)
267 267
 		{
268
-			if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download');
268
+			if (!Context::get('is_logged')) return $this->stop('msg_not_permitted_download');
269 269
 			$logged_info = Context::get('logged_info');
270
-			if($logged_info->is_admin != 'Y')
270
+			if ($logged_info->is_admin != 'Y')
271 271
 			{
272
-				$oModuleModel =& getModel('module');
272
+				$oModuleModel = & getModel('module');
273 273
 				$columnList = array('module_srl', 'site_srl');
274 274
 				$module_info = $oModuleModel->getModuleInfoByModuleSrl($file_obj->module_srl, $columnList);
275 275
 
276
-				if(!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl))
276
+				if (!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl))
277 277
 				{
278
-					$oMemberModel =& getModel('member');
278
+					$oMemberModel = & getModel('member');
279 279
 					$member_groups = $oMemberModel->getMemberGroups($logged_info->member_srl, $module_info->site_srl);
280 280
 
281 281
 					$is_permitted = false;
282
-					for($i=0;$i<count($file_module_config->download_grant);$i++)
282
+					for ($i = 0; $i < count($file_module_config->download_grant); $i++)
283 283
 					{
284 284
 						$group_srl = $file_module_config->download_grant[$i];
285
-						if($member_groups[$group_srl])
285
+						if ($member_groups[$group_srl])
286 286
 						{
287 287
 							$is_permitted = true;
288 288
 							break;
289 289
 						}
290 290
 					}
291
-					if(!$is_permitted) return $this->stop('msg_not_permitted_download');
291
+					if (!$is_permitted) return $this->stop('msg_not_permitted_download');
292 292
 				}
293 293
 			}
294 294
 		}
295 295
 		// Call a trigger (before)
296 296
 		$output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj);
297
-		if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download');
297
+		if (!$output->toBool()) return $this->stop(($output->message) ? $output->message : 'msg_not_permitted_download');
298 298
 
299 299
 
300 300
 		// 다운로드 후 (가상)
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 
308 308
 		$random = new Password();
309 309
 		$file_key = $_SESSION['__XE_FILE_KEY__'][$file_srl] = $random->createSecureSalt(32, 'hex');
310
-		header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput','file_srl',$file_srl,'file_key',$file_key));
310
+		header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput', 'file_srl', $file_srl, 'file_key', $file_key));
311 311
 		Context::close();
312 312
 		exit();
313 313
 
@@ -318,18 +318,18 @@  discard block
 block discarded – undo
318 318
 		$oFileModel = getModel('file');
319 319
 		$file_srl = Context::get('file_srl');
320 320
 		$file_key = Context::get('file_key');
321
-		if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true;
321
+		if (strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true;
322 322
 
323
-		if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__';
323
+		if ($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__';
324 324
 		else $session_key = '__XE_FILE_KEY__';
325 325
 		$columnList = array('source_filename', 'uploaded_filename', 'file_size');
326 326
 		$file_obj = $oFileModel->getFile($file_srl, $columnList);
327 327
 
328 328
 		$uploaded_filename = $file_obj->uploaded_filename;
329 329
 
330
-		if(!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found');
330
+		if (!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found');
331 331
 
332
-		if(!$file_key || $_SESSION[$session_key][$file_srl] != $file_key)
332
+		if (!$file_key || $_SESSION[$session_key][$file_srl] != $file_key)
333 333
 		{
334 334
 			unset($_SESSION[$session_key][$file_srl]);
335 335
 			return $this->stop('msg_invalid_request');
@@ -338,34 +338,34 @@  discard block
 block discarded – undo
338 338
 		$file_size = $file_obj->file_size;
339 339
 		$filename = $file_obj->source_filename;
340 340
 		
341
-		if(preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11)
341
+		if (preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11)
342 342
 		{
343
-			if($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT']))
343
+			if ($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT']))
344 344
 			{
345
-				$filename_param = 'filename="' . $filename . '"';
345
+				$filename_param = 'filename="'.$filename.'"';
346 346
 			}
347 347
 			else
348 348
 			{
349 349
 				$filename_param = sprintf('filename="%s"; filename*=UTF-8\'\'%s', $filename, rawurlencode($filename));
350 350
 			}
351 351
 		}
352
-		elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6)
352
+		elseif (preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6)
353 353
 		{
354 354
 			$filename_param = sprintf('filename="%s"; filename*=UTF-8\'\'%s', $filename, rawurlencode($filename));
355 355
 		}
356
-		elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
356
+		elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
357 357
 		{
358 358
 			$filename = rawurlencode($filename);
359
-			$filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"';
359
+			$filename_param = 'filename="'.preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1).'"';
360 360
 		}
361 361
 		else
362 362
 		{
363
-			$filename_param = 'filename="' . $filename . '"';
363
+			$filename_param = 'filename="'.$filename.'"';
364 364
 		}
365 365
 
366
-		if($is_android)
366
+		if ($is_android)
367 367
 		{
368
-			if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key;
368
+			if ($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key;
369 369
 		}
370 370
 
371 371
 		unset($_SESSION[$session_key][$file_srl]);
@@ -373,21 +373,21 @@  discard block
 block discarded – undo
373 373
 		Context::close();
374 374
 
375 375
 		$fp = fopen($uploaded_filename, 'rb');
376
-		if(!$fp) return $this->stop('msg_file_not_found');
376
+		if (!$fp) return $this->stop('msg_file_not_found');
377 377
 
378 378
 		header("Cache-Control: ");
379 379
 		header("Pragma: ");
380 380
 		header("Content-Type: application/octet-stream");
381
-		header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
381
+		header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
382 382
 
383
-		header("Content-Length: " .(string)($file_size));
384
-		header('Content-Disposition: attachment; ' . $filename_param);
383
+		header("Content-Length: ".(string) ($file_size));
384
+		header('Content-Disposition: attachment; '.$filename_param);
385 385
 		header("Content-Transfer-Encoding: binary\n");
386 386
 
387 387
 		// if file size is lager than 10MB, use fread function (#18675748)
388
-		if($file_size > 1024 * 1024)
388
+		if ($file_size > 1024 * 1024)
389 389
 		{
390
-			while(!feof($fp)) echo fread($fp, 1024);
390
+			while (!feof($fp)) echo fread($fp, 1024);
391 391
 			fclose($fp);
392 392
 		}
393 393
 		else
@@ -409,36 +409,36 @@  discard block
 block discarded – undo
409 409
 		$editor_sequence = Context::get('editor_sequence');
410 410
 		$file_srl = Context::get('file_srl');
411 411
 		$file_srls = Context::get('file_srls');
412
-		if($file_srls) $file_srl = $file_srls;
412
+		if ($file_srls) $file_srl = $file_srls;
413 413
 		// Exit a session if there is neither upload permission nor information
414
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
414
+		if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
415 415
 
416 416
 		$upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
417 417
 
418 418
 		$logged_info = Context::get('logged_info');
419 419
 		$oFileModel = getModel('file');
420 420
 
421
-		$srls = explode(',',$file_srl);
422
-		if(!count($srls)) return;
421
+		$srls = explode(',', $file_srl);
422
+		if (!count($srls)) return;
423 423
 
424
-		for($i=0;$i<count($srls);$i++)
424
+		for ($i = 0; $i < count($srls); $i++)
425 425
 		{
426
-			$srl = (int)$srls[$i];
427
-			if(!$srl) continue;
426
+			$srl = (int) $srls[$i];
427
+			if (!$srl) continue;
428 428
 
429 429
 			$args = new stdClass;
430 430
 			$args->file_srl = $srl;
431 431
 			$output = executeQuery('file.getFile', $args);
432
-			if(!$output->toBool()) continue;
432
+			if (!$output->toBool()) continue;
433 433
 
434 434
 			$file_info = $output->data;
435
-			if(!$file_info) continue;
435
+			if (!$file_info) continue;
436 436
 
437 437
 			$file_grant = $oFileModel->getFileGrant($file_info, $logged_info);
438 438
 
439
-			if(!$file_grant->is_deletable) continue;
439
+			if (!$file_grant->is_deletable) continue;
440 440
 
441
-			if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl);
441
+			if ($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl);
442 442
 		}
443 443
 	}
444 444
 
@@ -449,32 +449,32 @@  discard block
 block discarded – undo
449 449
 	 */
450 450
 	function procFileGetList()
451 451
 	{
452
-		if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted');
452
+		if (!Context::get('is_logged')) return new BaseObject(-1, 'msg_not_permitted');
453 453
 
454 454
 		$oModuleModel = getModel('module');
455 455
 
456 456
 		$logged_info = Context::get('logged_info');
457
-		if($logged_info->is_admin !== 'Y' && !$oModuleModel->isSiteAdmin($logged_info))
457
+		if ($logged_info->is_admin !== 'Y' && !$oModuleModel->isSiteAdmin($logged_info))
458 458
 		{
459 459
 			return new BaseObject(-1, 'msg_not_permitted');
460 460
 		}
461 461
 
462 462
 		$fileSrls = Context::get('file_srls');
463
-		if($fileSrls) $fileSrlList = explode(',', $fileSrls);
463
+		if ($fileSrls) $fileSrlList = explode(',', $fileSrls);
464 464
 
465 465
 		global $lang;
466
-		if(count($fileSrlList) > 0)
466
+		if (count($fileSrlList) > 0)
467 467
 		{
468 468
 			$oFileModel = getModel('file');
469 469
 			$fileList = $oFileModel->getFile($fileSrlList);
470
-			if(!is_array($fileList)) $fileList = array($fileList);
470
+			if (!is_array($fileList)) $fileList = array($fileList);
471 471
 
472
-			if(is_array($fileList))
472
+			if (is_array($fileList))
473 473
 			{
474
-				foreach($fileList AS $key=>$value)
474
+				foreach ($fileList AS $key=>$value)
475 475
 				{
476 476
 					$value->human_file_size = FileHandler::filesize($value->file_size);
477
-					if($value->isvalid=='Y') $value->validName = $lang->is_valid;
477
+					if ($value->isvalid == 'Y') $value->validName = $lang->is_valid;
478 478
 					else $value->validName = $lang->is_stand_by;
479 479
 				}
480 480
 			}
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 	function triggerCheckAttached(&$obj)
497 497
 	{
498 498
 		$document_srl = $obj->document_srl;
499
-		if(!$document_srl) return new BaseObject();
499
+		if (!$document_srl) return new BaseObject();
500 500
 		// Get numbers of attachments
501 501
 		$oFileModel = getModel('file');
502 502
 		$obj->uploaded_count = $oFileModel->getFilesCount($document_srl);
@@ -513,10 +513,10 @@  discard block
 block discarded – undo
513 513
 	function triggerAttachFiles(&$obj)
514 514
 	{
515 515
 		$document_srl = $obj->document_srl;
516
-		if(!$document_srl) return new BaseObject();
516
+		if (!$document_srl) return new BaseObject();
517 517
 
518 518
 		$output = $this->setFilesValid($document_srl);
519
-		if(!$output->toBool()) return $output;
519
+		if (!$output->toBool()) return $output;
520 520
 
521 521
 		return new BaseObject();
522 522
 	}
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 	function triggerDeleteAttached(&$obj)
531 531
 	{
532 532
 		$document_srl = $obj->document_srl;
533
-		if(!$document_srl) return new BaseObject();
533
+		if (!$document_srl) return new BaseObject();
534 534
 
535 535
 		$output = $this->deleteFiles($document_srl);
536 536
 		return $output;
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 	function triggerCommentCheckAttached(&$obj)
546 546
 	{
547 547
 		$comment_srl = $obj->comment_srl;
548
-		if(!$comment_srl) return new BaseObject();
548
+		if (!$comment_srl) return new BaseObject();
549 549
 		// Get numbers of attachments
550 550
 		$oFileModel = getModel('file');
551 551
 		$obj->uploaded_count = $oFileModel->getFilesCount($comment_srl);
@@ -563,10 +563,10 @@  discard block
 block discarded – undo
563 563
 	{
564 564
 		$comment_srl = $obj->comment_srl;
565 565
 		$uploaded_count = $obj->uploaded_count;
566
-		if(!$comment_srl || !$uploaded_count) return new BaseObject();
566
+		if (!$comment_srl || !$uploaded_count) return new BaseObject();
567 567
 
568 568
 		$output = $this->setFilesValid($comment_srl);
569
-		if(!$output->toBool()) return $output;
569
+		if (!$output->toBool()) return $output;
570 570
 
571 571
 		return new BaseObject();
572 572
 	}
@@ -580,9 +580,9 @@  discard block
 block discarded – undo
580 580
 	function triggerCommentDeleteAttached(&$obj)
581 581
 	{
582 582
 		$comment_srl = $obj->comment_srl;
583
-		if(!$comment_srl) return new BaseObject();
583
+		if (!$comment_srl) return new BaseObject();
584 584
 
585
-		if($obj->isMoveToTrash) return new BaseObject();
585
+		if ($obj->isMoveToTrash) return new BaseObject();
586 586
 
587 587
 		$output = $this->deleteFiles($comment_srl);
588 588
 		return $output;
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
 	function triggerDeleteModuleFiles(&$obj)
598 598
 	{
599 599
 		$module_srl = $obj->module_srl;
600
-		if(!$module_srl) return new BaseObject();
600
+		if (!$module_srl) return new BaseObject();
601 601
 
602 602
 		$oFileController = getAdminController('file');
603 603
 		return $oFileController->deleteModuleFiles($module_srl);
@@ -610,9 +610,9 @@  discard block
 block discarded – undo
610 610
 	 * @param int $upload_target_srl
611 611
 	 * @return void
612 612
 	 */
613
-	function setUploadInfo($editor_sequence, $upload_target_srl=0)
613
+	function setUploadInfo($editor_sequence, $upload_target_srl = 0)
614 614
 	{
615
-		if(!isset($_SESSION['upload_info'][$editor_sequence]))
615
+		if (!isset($_SESSION['upload_info'][$editor_sequence]))
616 616
 		{
617 617
 			$_SESSION['upload_info'][$editor_sequence] = new stdClass();
618 618
 		}
@@ -672,36 +672,36 @@  discard block
 block discarded – undo
672 672
 		$trigger_obj->module_srl = $module_srl;
673 673
 		$trigger_obj->upload_target_srl = $upload_target_srl;
674 674
 		$output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj);
675
-		if(!$output->toBool()) return $output;
675
+		if (!$output->toBool()) return $output;
676 676
 
677 677
 		// A workaround for Firefox upload bug
678
-		if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match))
678
+		if (preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match))
679 679
 		{
680 680
 			$file_info['name'] = base64_decode(strtr($match[1], ':', '/'));
681 681
 		}
682 682
 
683
-		if(!$manual_insert)
683
+		if (!$manual_insert)
684 684
 		{
685 685
 			// Get the file configurations
686 686
 			$logged_info = Context::get('logged_info');
687
-			if($logged_info->is_admin != 'Y')
687
+			if ($logged_info->is_admin != 'Y')
688 688
 			{
689 689
 				$oFileModel = getModel('file');
690 690
 				$config = $oFileModel->getFileConfig($module_srl);
691 691
 
692 692
 				// check file type
693
-				if(isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*')
693
+				if (isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*')
694 694
 				{
695 695
 					$filetypes = explode(';', $config->allowed_filetypes);
696 696
 					$ext = array();
697
-					foreach($filetypes as $item) {
697
+					foreach ($filetypes as $item) {
698 698
 						$item = explode('.', $item);
699 699
 						$ext[] = strtolower($item[1]);
700 700
 					}
701 701
 					$uploaded_ext = explode('.', $file_info['name']);
702 702
 					$uploaded_ext = strtolower(array_pop($uploaded_ext));
703 703
 
704
-					if(!in_array($uploaded_ext, $ext))
704
+					if (!in_array($uploaded_ext, $ext))
705 705
 					{
706 706
 						return $this->stop('msg_not_allowed_filetype');
707 707
 					}
@@ -710,64 +710,64 @@  discard block
 block discarded – undo
710 710
 				$allowed_filesize = $config->allowed_filesize * 1024 * 1024;
711 711
 				$allowed_attach_size = $config->allowed_attach_size * 1024 * 1024;
712 712
 				// An error appears if file size exceeds a limit
713
-				if($allowed_filesize < filesize($file_info['tmp_name'])) return new BaseObject(-1, 'msg_exceeds_limit_size');
713
+				if ($allowed_filesize < filesize($file_info['tmp_name'])) return new BaseObject(-1, 'msg_exceeds_limit_size');
714 714
 				// Get total file size of all attachements (from DB)
715 715
 				$size_args = new stdClass;
716 716
 				$size_args->upload_target_srl = $upload_target_srl;
717 717
 				$output = executeQuery('file.getAttachedFileSize', $size_args);
718
-				$attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']);
719
-				if($attached_size > $allowed_attach_size) return new BaseObject(-1, 'msg_exceeds_limit_size');
718
+				$attached_size = (int) $output->data->attached_size + filesize($file_info['tmp_name']);
719
+				if ($attached_size > $allowed_attach_size) return new BaseObject(-1, 'msg_exceeds_limit_size');
720 720
 			}
721 721
 		}
722 722
 
723 723
 		// https://github.com/xpressengine/xe-core/issues/1713
724
-		$file_info['name'] = preg_replace('/\.((ph(p|t|ar)?[0-9]?|p?html?|cgi|pl|exe|(?:a|j)sp|inc).*)$/i', '$0-x',$file_info['name']);
724
+		$file_info['name'] = preg_replace('/\.((ph(p|t|ar)?[0-9]?|p?html?|cgi|pl|exe|(?:a|j)sp|inc).*)$/i', '$0-x', $file_info['name']);
725 725
 		$file_info['name'] = removeHackTag($file_info['name']);
726
-		$file_info['name'] = str_replace(array('<','>'),array('%3C','%3E'),$file_info['name']);
726
+		$file_info['name'] = str_replace(array('<', '>'), array('%3C', '%3E'), $file_info['name']);
727 727
 		$file_info['name'] = str_replace('&amp;', '&', $file_info['name']);
728 728
 
729 729
 		// Get random number generator
730 730
 		$random = new Password();
731 731
 
732 732
 		// Set upload path by checking if the attachement is an image or other kinds of file
733
-		if(preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name']))
733
+		if (preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name']))
734 734
 		{
735
-			$path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3));
735
+			$path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
736 736
 
737 737
 			// special character to '_'
738 738
 			// change to random file name. because window php bug. window php is not recognize unicode character file name - by cherryfilter
739
-			$ext = substr(strrchr($file_info['name'],'.'),1);
739
+			$ext = substr(strrchr($file_info['name'], '.'), 1);
740 740
 			//$_filename = preg_replace('/[#$&*?+%"\']/', '_', $file_info['name']);
741 741
 			$_filename = $random->createSecureSalt(32, 'hex').'.'.$ext;
742 742
 			$filename  = $path.$_filename;
743 743
 			$idx = 1;
744
-			while(file_exists($filename))
744
+			while (file_exists($filename))
745 745
 			{
746
-				$filename = $path.preg_replace('/\.([a-z0-9]+)$/i','_'.$idx.'.$1',$_filename);
746
+				$filename = $path.preg_replace('/\.([a-z0-9]+)$/i', '_'.$idx.'.$1', $_filename);
747 747
 				$idx++;
748 748
 			}
749 749
 			$direct_download = 'Y';
750 750
 		}
751 751
 		else
752 752
 		{
753
-			$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3));
753
+			$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3));
754 754
 			$filename = $path.$random->createSecureSalt(32, 'hex');
755 755
 			$direct_download = 'N';
756 756
 		}
757 757
 		// Create a directory
758
-		if(!FileHandler::makeDir($path)) return new BaseObject(-1,'msg_not_permitted_create');
758
+		if (!FileHandler::makeDir($path)) return new BaseObject(-1, 'msg_not_permitted_create');
759 759
 
760 760
 		// Check uploaded file
761
-		if(!$manual_insert && !checkUploadedFile($file_info['tmp_name'], $file_info['name']))  return new BaseObject(-1,'msg_file_upload_error');
761
+		if (!$manual_insert && !checkUploadedFile($file_info['tmp_name'], $file_info['name']))  return new BaseObject(-1, 'msg_file_upload_error');
762 762
 
763 763
 		// Get random number generator
764 764
 		$random = new Password();
765 765
 		
766 766
 		// Move the file
767
-		if($manual_insert)
767
+		if ($manual_insert)
768 768
 		{
769 769
 			@copy($file_info['tmp_name'], $filename);
770
-			if(!file_exists($filename))
770
+			if (!file_exists($filename))
771 771
 			{
772 772
 				$filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext;
773 773
 				@copy($file_info['tmp_name'], $filename);
@@ -775,10 +775,10 @@  discard block
 block discarded – undo
775 775
 		}
776 776
 		else
777 777
 		{
778
-			if(!@move_uploaded_file($file_info['tmp_name'], $filename))
778
+			if (!@move_uploaded_file($file_info['tmp_name'], $filename))
779 779
 			{
780 780
 				$filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext;
781
-				if(!@move_uploaded_file($file_info['tmp_name'], $filename))  return new BaseObject(-1,'msg_file_upload_error');
781
+				if (!@move_uploaded_file($file_info['tmp_name'], $filename))  return new BaseObject(-1, 'msg_file_upload_error');
782 782
 			}
783 783
 		}
784 784
 		// Get member information
@@ -799,10 +799,10 @@  discard block
 block discarded – undo
799 799
 		$args->sid = $random->createSecureSalt(32, 'hex');
800 800
 
801 801
 		$output = executeQuery('file.insertFile', $args);
802
-		if(!$output->toBool()) return $output;
802
+		if (!$output->toBool()) return $output;
803 803
 		// Call a trigger (after)
804 804
 		$trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args);
805
-		if(!$trigger_output->toBool()) return $trigger_output;
805
+		if (!$trigger_output->toBool()) return $trigger_output;
806 806
 
807 807
 		$_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true;
808 808
 
@@ -845,18 +845,18 @@  discard block
 block discarded – undo
845 845
 	 */
846 846
 	function deleteFile($file_srl)
847 847
 	{
848
-		if(!$file_srl) return;
848
+		if (!$file_srl) return;
849 849
 
850 850
 		$srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl);
851
-		if(!count($srls)) return;
851
+		if (!count($srls)) return;
852 852
 
853 853
 		$oDocumentController = getController('document');
854 854
 		$documentSrlList = array();
855 855
 
856
-		foreach($srls as $srl)
856
+		foreach ($srls as $srl)
857 857
 		{
858
-			$srl = (int)$srl;
859
-			if(!$srl) 
858
+			$srl = (int) $srl;
859
+			if (!$srl) 
860 860
 			{
861 861
 				continue;
862 862
 			}
@@ -865,14 +865,14 @@  discard block
 block discarded – undo
865 865
 			$args->file_srl = $srl;
866 866
 			$output = executeQuery('file.getFile', $args);
867 867
 
868
-			if(!$output->toBool() || !$output->data) 
868
+			if (!$output->toBool() || !$output->data) 
869 869
 			{
870 870
 				continue;
871 871
 			}
872 872
 
873 873
 			$file_info = $output->data;
874 874
 
875
-			if($file_info->upload_target_srl)
875
+			if ($file_info->upload_target_srl)
876 876
 			{
877 877
 				$documentSrlList[] = $file_info->upload_target_srl;
878 878
 			}
@@ -883,15 +883,15 @@  discard block
 block discarded – undo
883 883
 			// Call a trigger (before)
884 884
 			$trigger_obj = $output->data;
885 885
 			$output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj);
886
-			if(!$output->toBool()) return $output;
886
+			if (!$output->toBool()) return $output;
887 887
 
888 888
 			// Remove from the DB
889 889
 			$output = executeQuery('file.deleteFile', $args);
890
-			if(!$output->toBool()) return $output;
890
+			if (!$output->toBool()) return $output;
891 891
 
892 892
 			// Call a trigger (after)
893 893
 			$trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj);
894
-			if(!$trigger_output->toBool()) return $trigger_output;
894
+			if (!$trigger_output->toBool()) return $trigger_output;
895 895
 
896 896
 			// If successfully deleted, remove the file
897 897
 			FileHandler::removeFile($uploaded_filename);
@@ -915,28 +915,28 @@  discard block
 block discarded – undo
915 915
 		$columnList = array('file_srl', 'uploaded_filename', 'module_srl');
916 916
 		$file_list = $oFileModel->getFiles($upload_target_srl, $columnList);
917 917
 		// Success returned if no attachement exists
918
-		if(!is_array($file_list)||!count($file_list)) return new BaseObject();
918
+		if (!is_array($file_list) || !count($file_list)) return new BaseObject();
919 919
 
920 920
 		// Delete the file
921 921
 		$path = array();
922 922
 		$file_count = count($file_list);
923
-		for($i=0;$i<$file_count;$i++)
923
+		for ($i = 0; $i < $file_count; $i++)
924 924
 		{
925 925
 			$this->deleteFile($file_list[$i]->file_srl);
926 926
 
927 927
 			$uploaded_filename = $file_list[$i]->uploaded_filename;
928 928
 			$path_info = pathinfo($uploaded_filename);
929
-			if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
929
+			if (!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
930 930
 		}
931 931
 
932 932
 		// Remove from the DB
933 933
 		$args = new stdClass();
934 934
 		$args->upload_target_srl = $upload_target_srl;
935 935
 		$output = executeQuery('file.deleteFiles', $args);
936
-		if(!$output->toBool()) return $output;
936
+		if (!$output->toBool()) return $output;
937 937
 		
938 938
 		// Remove a file directory of the document
939
-		for($i=0, $c=count($path); $i<$c; $i++)
939
+		for ($i = 0, $c = count($path); $i < $c; $i++)
940 940
 		{
941 941
 			FileHandler::removeBlankDir($path[$i]);
942 942
 		}
@@ -954,23 +954,23 @@  discard block
 block discarded – undo
954 954
 	 */
955 955
 	function moveFile($source_srl, $target_module_srl, $target_srl)
956 956
 	{
957
-		if($source_srl == $target_srl) return;
957
+		if ($source_srl == $target_srl) return;
958 958
 
959 959
 		$oFileModel = getModel('file');
960 960
 		$file_list = $oFileModel->getFiles($source_srl);
961
-		if(!$file_list) return;
961
+		if (!$file_list) return;
962 962
 
963 963
 		$file_count = count($file_list);
964 964
  
965
-		for($i=0;$i<$file_count;$i++)
965
+		for ($i = 0; $i < $file_count; $i++)
966 966
 		{
967 967
 			unset($file_info);
968 968
 			$file_info = $file_list[$i];
969 969
 			$old_file = $file_info->uploaded_filename;
970 970
 			// Determine the file path by checking if the file is an image or other kinds
971
-			if(preg_match("/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_info->source_filename))
971
+			if (preg_match("/\.(asf|asf|asx|avi|flv|gif|jpeg|jpg|m4a|m4v|mid|midi|moov|mov|mp1|mp2|mp3|mp4|mpeg|mpg|ogg|png|qt|ra|ram|rm|rmm|wav|webm|webp|wma|wmv)$/i", $file_info->source_filename))
972 972
 			{
973
-				$path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl);
973
+				$path = sprintf("./files/attach/images/%s/%s/", $target_module_srl, $target_srl);
974 974
 				$new_file = $path.$file_info->source_filename;
975 975
 			}
976 976
 			else
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
 				$new_file = $path.$random->createSecureSalt(32, 'hex');
981 981
 			}
982 982
 			// Pass if a target document to move is same
983
-			if($old_file == $new_file) continue;
983
+			if ($old_file == $new_file) continue;
984 984
 			// Create a directory
985 985
 			FileHandler::makeDir($path);
986 986
 			// Move the file
@@ -1000,18 +1000,18 @@  discard block
 block discarded – undo
1000 1000
 		$vars = Context::getRequestVars();
1001 1001
 		$logged_info = Context::get('logged_info');
1002 1002
 
1003
-		if(!$vars->editor_sequence) return new BaseObject(-1, 'msg_invalid_request');
1003
+		if (!$vars->editor_sequence) return new BaseObject(-1, 'msg_invalid_request');
1004 1004
 
1005 1005
 		$upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl;
1006 1006
 
1007 1007
 		$oFileModel = getModel('file');
1008 1008
 		$file_info = $oFileModel->getFile($vars->file_srl);
1009 1009
 
1010
-		if(!$file_info) return new BaseObject(-1, 'msg_not_founded');
1010
+		if (!$file_info) return new BaseObject(-1, 'msg_not_founded');
1011 1011
 
1012
-		if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new BaseObject(-1, 'msg_not_permitted');
1012
+		if (!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new BaseObject(-1, 'msg_not_permitted');
1013 1013
 
1014
-		$args =  new stdClass();
1014
+		$args = new stdClass();
1015 1015
 		$args->file_srl = $vars->file_srl;
1016 1016
 		$args->upload_target_srl = $upload_target_srl;
1017 1017
 
@@ -1020,18 +1020,18 @@  discard block
 block discarded – undo
1020 1020
 		
1021 1021
 		$args->cover_image = 'N';
1022 1022
 		$output = executeQuery('file.updateClearCoverImage', $args);
1023
-		if(!$output->toBool())
1023
+		if (!$output->toBool())
1024 1024
 		{
1025 1025
 				$oDB->rollback();
1026 1026
 				return $output;
1027 1027
 		}
1028 1028
 
1029
-		if($file_info->cover_image != 'Y')
1029
+		if ($file_info->cover_image != 'Y')
1030 1030
 		{
1031 1031
 
1032 1032
 			$args->cover_image = 'Y';
1033 1033
 			$output = executeQuery('file.updateCoverImage', $args);
1034
-			if(!$output->toBool())
1034
+			if (!$output->toBool())
1035 1035
 			{
1036 1036
 				$oDB->rollback();
1037 1037
 				return $output;
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
 
1042 1042
 		$oDB->commit();
1043 1043
 
1044
-		$this->add('is_cover',$args->cover_image);
1044
+		$this->add('is_cover', $args->cover_image);
1045 1045
 
1046 1046
 		// 썸네일 삭제
1047 1047
 		$thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($upload_target_srl, 3));
@@ -1067,9 +1067,9 @@  discard block
 block discarded – undo
1067 1067
 		$fileConfig = $oModuleModel->getModulePartConfig('file', $obj->originModuleSrl);
1068 1068
 
1069 1069
 		$oModuleController = getController('module');
1070
-		if(is_array($obj->moduleSrlList))
1070
+		if (is_array($obj->moduleSrlList))
1071 1071
 		{
1072
-			foreach($obj->moduleSrlList AS $key=>$moduleSrl)
1072
+			foreach ($obj->moduleSrlList AS $key=>$moduleSrl)
1073 1073
 			{
1074 1074
 				$oModuleController->insertModulePartConfig('file', $moduleSrl, $fileConfig);
1075 1075
 			}
Please login to merge, or discard this patch.
Braces   +227 added lines, -96 removed lines patch added patch discarded remove patch
@@ -29,20 +29,30 @@  discard block
 block discarded – undo
29 29
 		$file_info = Context::get('Filedata');
30 30
 
31 31
 		// An error appears if not a normally uploaded file
32
-		if(!is_uploaded_file($file_info['tmp_name'])) exit();
32
+		if(!is_uploaded_file($file_info['tmp_name'])) {
33
+			exit();
34
+		}
33 35
 
34 36
 		// Basic variables setting
35 37
 		$oFileModel = getModel('file');
36 38
 		$editor_sequence = Context::get('editor_sequence');
37 39
 		$upload_target_srl = intval(Context::get('uploadTargetSrl'));
38
-		if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
40
+		if(!$upload_target_srl) {
41
+			$upload_target_srl = intval(Context::get('upload_target_srl'));
42
+		}
39 43
 		$module_srl = $this->module_srl;
40 44
 		// Exit a session if there is neither upload permission nor information
41
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
45
+		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) {
46
+			exit();
47
+		}
42 48
 		// Extract from session information if upload_target_srl is not specified
43
-		if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
49
+		if(!$upload_target_srl) {
50
+			$upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
51
+		}
44 52
 		// Create if upload_target_srl is not defined in the session information
45
-		if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
53
+		if(!$upload_target_srl) {
54
+			$_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
55
+		}
46 56
 
47 57
 		$output = $this->insertFile($file_info, $module_srl, $upload_target_srl);
48 58
 		Context::setResponseMethod('JSON');
@@ -56,8 +66,7 @@  discard block
 block discarded – undo
56 66
 		if($output->get('direct_download') === 'Y')
57 67
 		{
58 68
 			$this->add('download_url',$output->get('uploaded_filename'));
59
-		}
60
-		else
69
+		} else
61 70
 		{
62 71
 			$this->add('download_url',$oFileModel->getDownloadUrl($output->get('file_srl'), $output->get('sid'), $module_srl));
63 72
 		}
@@ -79,14 +88,22 @@  discard block
 block discarded – undo
79 88
 		$callback = Context::get('callback');
80 89
 		$module_srl = $this->module_srl;
81 90
 		$upload_target_srl = intval(Context::get('uploadTargetSrl'));
82
-		if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl'));
91
+		if(!$upload_target_srl) {
92
+			$upload_target_srl = intval(Context::get('upload_target_srl'));
93
+		}
83 94
 
84 95
 		// Exit a session if there is neither upload permission nor information
85
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
96
+		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) {
97
+			exit();
98
+		}
86 99
 		// Extract from session information if upload_target_srl is not specified
87
-		if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
100
+		if(!$upload_target_srl) {
101
+			$upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
102
+		}
88 103
 		// Create if upload_target_srl is not defined in the session information
89
-		if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
104
+		if(!$upload_target_srl) {
105
+			$_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence();
106
+		}
90 107
 
91 108
 		// Delete and then attempt to re-upload if file_srl is requested
92 109
 		$file_srl = Context::get('file_srl');
@@ -141,15 +158,16 @@  discard block
 block discarded – undo
141 158
 		$source_src = $fileInfo->uploaded_filename;
142 159
 		$output_src = $source_src . '.resized' . strrchr($source_src,'.');
143 160
 
144
-		if(!$height) $height = $width-1;
161
+		if(!$height) {
162
+			$height = $width-1;
163
+		}
145 164
 
146 165
 		if(FileHandler::createImageFile($source_src,$output_src,$width,$height,'','ratio'))
147 166
 		{
148 167
 			$output = new stdClass();
149 168
 			$output->info = getimagesize($output_src);
150 169
 			$output->src = $output_src;
151
-		}
152
-		else
170
+		} else
153 171
 		{
154 172
 			return new BaseObject(-1,'msg_invalid_request');
155 173
 		}
@@ -192,7 +210,9 @@  discard block
 block discarded – undo
192 210
 	{
193 211
 		$oFileModel = getModel('file');
194 212
 
195
-		if(isset($this->grant->access) && $this->grant->access !== true) return new BaseObject(-1, 'msg_not_permitted');
213
+		if(isset($this->grant->access) && $this->grant->access !== true) {
214
+			return new BaseObject(-1, 'msg_not_permitted');
215
+		}
196 216
 
197 217
 		$file_srl = Context::get('file_srl');
198 218
 		$sid = Context::get('sid');
@@ -201,9 +221,13 @@  discard block
 block discarded – undo
201 221
 		$columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type');
202 222
 		$file_obj = $oFileModel->getFile($file_srl, $columnList);
203 223
 		// If the requested file information is incorrect, an error that file cannot be found appears
204
-		if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) return $this->stop('msg_file_not_found');
224
+		if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) {
225
+			return $this->stop('msg_file_not_found');
226
+		}
205 227
 		// Notify that file download is not allowed when standing-by(Only a top-administrator is permitted)
206
-		if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') return $this->stop('msg_not_permitted_download');
228
+		if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') {
229
+			return $this->stop('msg_not_permitted_download');
230
+		}
207 231
 		// File name
208 232
 		$filename = $file_obj->source_filename;
209 233
 		$file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl);
@@ -215,7 +239,9 @@  discard block
 block discarded – undo
215 239
 			{
216 240
 				$allow_outlink_format_array = array();
217 241
 				$allow_outlink_format_array = explode(',', $file_module_config->allow_outlink_format);
218
-				if(!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format;
242
+				if(!is_array($allow_outlink_format_array)) {
243
+					$allow_outlink_format_array[0] = $file_module_config->allow_outlink_format;
244
+				}
219 245
 
220 246
 				foreach($allow_outlink_format_array as $val)
221 247
 				{
@@ -237,7 +263,9 @@  discard block
 block discarded – undo
237 263
 					{
238 264
 						$allow_outlink_site_array = array();
239 265
 						$allow_outlink_site_array = explode("\n", $file_module_config->allow_outlink_site);
240
-						if(!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site;
266
+						if(!is_array($allow_outlink_site_array)) {
267
+							$allow_outlink_site_array[0] = $file_module_config->allow_outlink_site;
268
+						}
241 269
 
242 270
 						foreach($allow_outlink_site_array as $val)
243 271
 						{
@@ -249,23 +277,29 @@  discard block
 block discarded – undo
249 277
 							}
250 278
 						}
251 279
 					}
280
+				} else {
281
+					$file_module_config->allow_outlink = 'Y';
252 282
 				}
253
-				else $file_module_config->allow_outlink = 'Y';
254 283
 			}
255
-			if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink');
284
+			if($file_module_config->allow_outlink != 'Y') {
285
+				return $this->stop('msg_not_allowed_outlink');
286
+			}
256 287
 		}
257 288
 
258 289
 		// Check if a permission for file download is granted
259 290
 		$downloadGrantCount = 0;
260 291
 		if(is_array($file_module_config->download_grant))
261 292
 		{
262
-			foreach($file_module_config->download_grant AS $value)
263
-				if($value) $downloadGrantCount++;
293
+			foreach($file_module_config->download_grant AS $value) {
294
+							if($value) $downloadGrantCount++;
295
+			}
264 296
 		}
265 297
 
266 298
 		if(is_array($file_module_config->download_grant) && $downloadGrantCount>0)
267 299
 		{
268
-			if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download');
300
+			if(!Context::get('is_logged')) {
301
+				return $this->stop('msg_not_permitted_download');
302
+			}
269 303
 			$logged_info = Context::get('logged_info');
270 304
 			if($logged_info->is_admin != 'Y')
271 305
 			{
@@ -288,13 +322,17 @@  discard block
 block discarded – undo
288 322
 							break;
289 323
 						}
290 324
 					}
291
-					if(!$is_permitted) return $this->stop('msg_not_permitted_download');
325
+					if(!$is_permitted) {
326
+						return $this->stop('msg_not_permitted_download');
327
+					}
292 328
 				}
293 329
 			}
294 330
 		}
295 331
 		// Call a trigger (before)
296 332
 		$output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj);
297
-		if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download');
333
+		if(!$output->toBool()) {
334
+			return $this->stop(($output->message)?$output->message:'msg_not_permitted_download');
335
+		}
298 336
 
299 337
 
300 338
 		// 다운로드 후 (가상)
@@ -318,16 +356,23 @@  discard block
 block discarded – undo
318 356
 		$oFileModel = getModel('file');
319 357
 		$file_srl = Context::get('file_srl');
320 358
 		$file_key = Context::get('file_key');
321
-		if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true;
359
+		if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) {
360
+			$is_android = true;
361
+		}
322 362
 
323
-		if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__';
324
-		else $session_key = '__XE_FILE_KEY__';
363
+		if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) {
364
+			$session_key = '__XE_FILE_KEY_AND__';
365
+		} else {
366
+			$session_key = '__XE_FILE_KEY__';
367
+		}
325 368
 		$columnList = array('source_filename', 'uploaded_filename', 'file_size');
326 369
 		$file_obj = $oFileModel->getFile($file_srl, $columnList);
327 370
 
328 371
 		$uploaded_filename = $file_obj->uploaded_filename;
329 372
 
330
-		if(!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found');
373
+		if(!file_exists($uploaded_filename)) {
374
+			return $this->stop('msg_file_not_found');
375
+		}
331 376
 
332 377
 		if(!$file_key || $_SESSION[$session_key][$file_srl] != $file_key)
333 378
 		{
@@ -343,29 +388,27 @@  discard block
 block discarded – undo
343 388
 			if($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT']))
344 389
 			{
345 390
 				$filename_param = 'filename="' . $filename . '"';
346
-			}
347
-			else
391
+			} else
348 392
 			{
349 393
 				$filename_param = sprintf('filename="%s"; filename*=UTF-8\'\'%s', $filename, rawurlencode($filename));
350 394
 			}
351
-		}
352
-		elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6)
395
+		} elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6)
353 396
 		{
354 397
 			$filename_param = sprintf('filename="%s"; filename*=UTF-8\'\'%s', $filename, rawurlencode($filename));
355
-		}
356
-		elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
398
+		} elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE)
357 399
 		{
358 400
 			$filename = rawurlencode($filename);
359 401
 			$filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"';
360
-		}
361
-		else
402
+		} else
362 403
 		{
363 404
 			$filename_param = 'filename="' . $filename . '"';
364 405
 		}
365 406
 
366 407
 		if($is_android)
367 408
 		{
368
-			if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key;
409
+			if($_SESSION['__XE_FILE_KEY__'][$file_srl]) {
410
+				$_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key;
411
+			}
369 412
 		}
370 413
 
371 414
 		unset($_SESSION[$session_key][$file_srl]);
@@ -373,7 +416,9 @@  discard block
 block discarded – undo
373 416
 		Context::close();
374 417
 
375 418
 		$fp = fopen($uploaded_filename, 'rb');
376
-		if(!$fp) return $this->stop('msg_file_not_found');
419
+		if(!$fp) {
420
+			return $this->stop('msg_file_not_found');
421
+		}
377 422
 
378 423
 		header("Cache-Control: ");
379 424
 		header("Pragma: ");
@@ -387,10 +432,11 @@  discard block
 block discarded – undo
387 432
 		// if file size is lager than 10MB, use fread function (#18675748)
388 433
 		if($file_size > 1024 * 1024)
389 434
 		{
390
-			while(!feof($fp)) echo fread($fp, 1024);
435
+			while(!feof($fp)) {
436
+				echo fread($fp, 1024);
437
+			}
391 438
 			fclose($fp);
392
-		}
393
-		else
439
+		} else
394 440
 		{
395 441
 			fpassthru($fp);
396 442
 		}
@@ -409,9 +455,13 @@  discard block
 block discarded – undo
409 455
 		$editor_sequence = Context::get('editor_sequence');
410 456
 		$file_srl = Context::get('file_srl');
411 457
 		$file_srls = Context::get('file_srls');
412
-		if($file_srls) $file_srl = $file_srls;
458
+		if($file_srls) {
459
+			$file_srl = $file_srls;
460
+		}
413 461
 		// Exit a session if there is neither upload permission nor information
414
-		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit();
462
+		if(!$_SESSION['upload_info'][$editor_sequence]->enabled) {
463
+			exit();
464
+		}
415 465
 
416 466
 		$upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl;
417 467
 
@@ -419,26 +469,38 @@  discard block
 block discarded – undo
419 469
 		$oFileModel = getModel('file');
420 470
 
421 471
 		$srls = explode(',',$file_srl);
422
-		if(!count($srls)) return;
472
+		if(!count($srls)) {
473
+			return;
474
+		}
423 475
 
424 476
 		for($i=0;$i<count($srls);$i++)
425 477
 		{
426 478
 			$srl = (int)$srls[$i];
427
-			if(!$srl) continue;
479
+			if(!$srl) {
480
+				continue;
481
+			}
428 482
 
429 483
 			$args = new stdClass;
430 484
 			$args->file_srl = $srl;
431 485
 			$output = executeQuery('file.getFile', $args);
432
-			if(!$output->toBool()) continue;
486
+			if(!$output->toBool()) {
487
+				continue;
488
+			}
433 489
 
434 490
 			$file_info = $output->data;
435
-			if(!$file_info) continue;
491
+			if(!$file_info) {
492
+				continue;
493
+			}
436 494
 
437 495
 			$file_grant = $oFileModel->getFileGrant($file_info, $logged_info);
438 496
 
439
-			if(!$file_grant->is_deletable) continue;
497
+			if(!$file_grant->is_deletable) {
498
+				continue;
499
+			}
440 500
 
441
-			if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl);
501
+			if($upload_target_srl && $file_srl) {
502
+				$output = $this->deleteFile($file_srl);
503
+			}
442 504
 		}
443 505
 	}
444 506
 
@@ -449,7 +511,9 @@  discard block
 block discarded – undo
449 511
 	 */
450 512
 	function procFileGetList()
451 513
 	{
452
-		if(!Context::get('is_logged')) return new BaseObject(-1,'msg_not_permitted');
514
+		if(!Context::get('is_logged')) {
515
+			return new BaseObject(-1,'msg_not_permitted');
516
+		}
453 517
 
454 518
 		$oModuleModel = getModel('module');
455 519
 
@@ -460,26 +524,32 @@  discard block
 block discarded – undo
460 524
 		}
461 525
 
462 526
 		$fileSrls = Context::get('file_srls');
463
-		if($fileSrls) $fileSrlList = explode(',', $fileSrls);
527
+		if($fileSrls) {
528
+			$fileSrlList = explode(',', $fileSrls);
529
+		}
464 530
 
465 531
 		global $lang;
466 532
 		if(count($fileSrlList) > 0)
467 533
 		{
468 534
 			$oFileModel = getModel('file');
469 535
 			$fileList = $oFileModel->getFile($fileSrlList);
470
-			if(!is_array($fileList)) $fileList = array($fileList);
536
+			if(!is_array($fileList)) {
537
+				$fileList = array($fileList);
538
+			}
471 539
 
472 540
 			if(is_array($fileList))
473 541
 			{
474 542
 				foreach($fileList AS $key=>$value)
475 543
 				{
476 544
 					$value->human_file_size = FileHandler::filesize($value->file_size);
477
-					if($value->isvalid=='Y') $value->validName = $lang->is_valid;
478
-					else $value->validName = $lang->is_stand_by;
545
+					if($value->isvalid=='Y') {
546
+						$value->validName = $lang->is_valid;
547
+					} else {
548
+						$value->validName = $lang->is_stand_by;
549
+					}
479 550
 				}
480 551
 			}
481
-		}
482
-		else
552
+		} else
483 553
 		{
484 554
 			$fileList = array();
485 555
 			$this->setMessage($lang->no_files);
@@ -496,7 +566,9 @@  discard block
 block discarded – undo
496 566
 	function triggerCheckAttached(&$obj)
497 567
 	{
498 568
 		$document_srl = $obj->document_srl;
499
-		if(!$document_srl) return new BaseObject();
569
+		if(!$document_srl) {
570
+			return new BaseObject();
571
+		}
500 572
 		// Get numbers of attachments
501 573
 		$oFileModel = getModel('file');
502 574
 		$obj->uploaded_count = $oFileModel->getFilesCount($document_srl);
@@ -513,10 +585,14 @@  discard block
 block discarded – undo
513 585
 	function triggerAttachFiles(&$obj)
514 586
 	{
515 587
 		$document_srl = $obj->document_srl;
516
-		if(!$document_srl) return new BaseObject();
588
+		if(!$document_srl) {
589
+			return new BaseObject();
590
+		}
517 591
 
518 592
 		$output = $this->setFilesValid($document_srl);
519
-		if(!$output->toBool()) return $output;
593
+		if(!$output->toBool()) {
594
+			return $output;
595
+		}
520 596
 
521 597
 		return new BaseObject();
522 598
 	}
@@ -530,7 +606,9 @@  discard block
 block discarded – undo
530 606
 	function triggerDeleteAttached(&$obj)
531 607
 	{
532 608
 		$document_srl = $obj->document_srl;
533
-		if(!$document_srl) return new BaseObject();
609
+		if(!$document_srl) {
610
+			return new BaseObject();
611
+		}
534 612
 
535 613
 		$output = $this->deleteFiles($document_srl);
536 614
 		return $output;
@@ -545,7 +623,9 @@  discard block
 block discarded – undo
545 623
 	function triggerCommentCheckAttached(&$obj)
546 624
 	{
547 625
 		$comment_srl = $obj->comment_srl;
548
-		if(!$comment_srl) return new BaseObject();
626
+		if(!$comment_srl) {
627
+			return new BaseObject();
628
+		}
549 629
 		// Get numbers of attachments
550 630
 		$oFileModel = getModel('file');
551 631
 		$obj->uploaded_count = $oFileModel->getFilesCount($comment_srl);
@@ -563,10 +643,14 @@  discard block
 block discarded – undo
563 643
 	{
564 644
 		$comment_srl = $obj->comment_srl;
565 645
 		$uploaded_count = $obj->uploaded_count;
566
-		if(!$comment_srl || !$uploaded_count) return new BaseObject();
646
+		if(!$comment_srl || !$uploaded_count) {
647
+			return new BaseObject();
648
+		}
567 649
 
568 650
 		$output = $this->setFilesValid($comment_srl);
569
-		if(!$output->toBool()) return $output;
651
+		if(!$output->toBool()) {
652
+			return $output;
653
+		}
570 654
 
571 655
 		return new BaseObject();
572 656
 	}
@@ -580,9 +664,13 @@  discard block
 block discarded – undo
580 664
 	function triggerCommentDeleteAttached(&$obj)
581 665
 	{
582 666
 		$comment_srl = $obj->comment_srl;
583
-		if(!$comment_srl) return new BaseObject();
667
+		if(!$comment_srl) {
668
+			return new BaseObject();
669
+		}
584 670
 
585
-		if($obj->isMoveToTrash) return new BaseObject();
671
+		if($obj->isMoveToTrash) {
672
+			return new BaseObject();
673
+		}
586 674
 
587 675
 		$output = $this->deleteFiles($comment_srl);
588 676
 		return $output;
@@ -597,7 +685,9 @@  discard block
 block discarded – undo
597 685
 	function triggerDeleteModuleFiles(&$obj)
598 686
 	{
599 687
 		$module_srl = $obj->module_srl;
600
-		if(!$module_srl) return new BaseObject();
688
+		if(!$module_srl) {
689
+			return new BaseObject();
690
+		}
601 691
 
602 692
 		$oFileController = getAdminController('file');
603 693
 		return $oFileController->deleteModuleFiles($module_srl);
@@ -672,7 +762,9 @@  discard block
 block discarded – undo
672 762
 		$trigger_obj->module_srl = $module_srl;
673 763
 		$trigger_obj->upload_target_srl = $upload_target_srl;
674 764
 		$output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj);
675
-		if(!$output->toBool()) return $output;
765
+		if(!$output->toBool()) {
766
+			return $output;
767
+		}
676 768
 
677 769
 		// A workaround for Firefox upload bug
678 770
 		if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match))
@@ -710,13 +802,17 @@  discard block
 block discarded – undo
710 802
 				$allowed_filesize = $config->allowed_filesize * 1024 * 1024;
711 803
 				$allowed_attach_size = $config->allowed_attach_size * 1024 * 1024;
712 804
 				// An error appears if file size exceeds a limit
713
-				if($allowed_filesize < filesize($file_info['tmp_name'])) return new BaseObject(-1, 'msg_exceeds_limit_size');
805
+				if($allowed_filesize < filesize($file_info['tmp_name'])) {
806
+					return new BaseObject(-1, 'msg_exceeds_limit_size');
807
+				}
714 808
 				// Get total file size of all attachements (from DB)
715 809
 				$size_args = new stdClass;
716 810
 				$size_args->upload_target_srl = $upload_target_srl;
717 811
 				$output = executeQuery('file.getAttachedFileSize', $size_args);
718 812
 				$attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']);
719
-				if($attached_size > $allowed_attach_size) return new BaseObject(-1, 'msg_exceeds_limit_size');
813
+				if($attached_size > $allowed_attach_size) {
814
+					return new BaseObject(-1, 'msg_exceeds_limit_size');
815
+				}
720 816
 			}
721 817
 		}
722 818
 
@@ -747,18 +843,21 @@  discard block
 block discarded – undo
747 843
 				$idx++;
748 844
 			}
749 845
 			$direct_download = 'Y';
750
-		}
751
-		else
846
+		} else
752 847
 		{
753 848
 			$path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3));
754 849
 			$filename = $path.$random->createSecureSalt(32, 'hex');
755 850
 			$direct_download = 'N';
756 851
 		}
757 852
 		// Create a directory
758
-		if(!FileHandler::makeDir($path)) return new BaseObject(-1,'msg_not_permitted_create');
853
+		if(!FileHandler::makeDir($path)) {
854
+			return new BaseObject(-1,'msg_not_permitted_create');
855
+		}
759 856
 
760 857
 		// Check uploaded file
761
-		if(!$manual_insert && !checkUploadedFile($file_info['tmp_name'], $file_info['name']))  return new BaseObject(-1,'msg_file_upload_error');
858
+		if(!$manual_insert && !checkUploadedFile($file_info['tmp_name'], $file_info['name'])) {
859
+			return new BaseObject(-1,'msg_file_upload_error');
860
+		}
762 861
 
763 862
 		// Get random number generator
764 863
 		$random = new Password();
@@ -772,13 +871,14 @@  discard block
 block discarded – undo
772 871
 				$filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext;
773 872
 				@copy($file_info['tmp_name'], $filename);
774 873
 			}
775
-		}
776
-		else
874
+		} else
777 875
 		{
778 876
 			if(!@move_uploaded_file($file_info['tmp_name'], $filename))
779 877
 			{
780 878
 				$filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext;
781
-				if(!@move_uploaded_file($file_info['tmp_name'], $filename))  return new BaseObject(-1,'msg_file_upload_error');
879
+				if(!@move_uploaded_file($file_info['tmp_name'], $filename)) {
880
+					return new BaseObject(-1,'msg_file_upload_error');
881
+				}
782 882
 			}
783 883
 		}
784 884
 		// Get member information
@@ -799,10 +899,14 @@  discard block
 block discarded – undo
799 899
 		$args->sid = $random->createSecureSalt(32, 'hex');
800 900
 
801 901
 		$output = executeQuery('file.insertFile', $args);
802
-		if(!$output->toBool()) return $output;
902
+		if(!$output->toBool()) {
903
+			return $output;
904
+		}
803 905
 		// Call a trigger (after)
804 906
 		$trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args);
805
-		if(!$trigger_output->toBool()) return $trigger_output;
907
+		if(!$trigger_output->toBool()) {
908
+			return $trigger_output;
909
+		}
806 910
 
807 911
 		$_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true;
808 912
 
@@ -845,10 +949,14 @@  discard block
 block discarded – undo
845 949
 	 */
846 950
 	function deleteFile($file_srl)
847 951
 	{
848
-		if(!$file_srl) return;
952
+		if(!$file_srl) {
953
+			return;
954
+		}
849 955
 
850 956
 		$srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl);
851
-		if(!count($srls)) return;
957
+		if(!count($srls)) {
958
+			return;
959
+		}
852 960
 
853 961
 		$oDocumentController = getController('document');
854 962
 		$documentSrlList = array();
@@ -883,15 +991,21 @@  discard block
 block discarded – undo
883 991
 			// Call a trigger (before)
884 992
 			$trigger_obj = $output->data;
885 993
 			$output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj);
886
-			if(!$output->toBool()) return $output;
994
+			if(!$output->toBool()) {
995
+				return $output;
996
+			}
887 997
 
888 998
 			// Remove from the DB
889 999
 			$output = executeQuery('file.deleteFile', $args);
890
-			if(!$output->toBool()) return $output;
1000
+			if(!$output->toBool()) {
1001
+				return $output;
1002
+			}
891 1003
 
892 1004
 			// Call a trigger (after)
893 1005
 			$trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj);
894
-			if(!$trigger_output->toBool()) return $trigger_output;
1006
+			if(!$trigger_output->toBool()) {
1007
+				return $trigger_output;
1008
+			}
895 1009
 
896 1010
 			// If successfully deleted, remove the file
897 1011
 			FileHandler::removeFile($uploaded_filename);
@@ -915,7 +1029,9 @@  discard block
 block discarded – undo
915 1029
 		$columnList = array('file_srl', 'uploaded_filename', 'module_srl');
916 1030
 		$file_list = $oFileModel->getFiles($upload_target_srl, $columnList);
917 1031
 		// Success returned if no attachement exists
918
-		if(!is_array($file_list)||!count($file_list)) return new BaseObject();
1032
+		if(!is_array($file_list)||!count($file_list)) {
1033
+			return new BaseObject();
1034
+		}
919 1035
 
920 1036
 		// Delete the file
921 1037
 		$path = array();
@@ -926,14 +1042,18 @@  discard block
 block discarded – undo
926 1042
 
927 1043
 			$uploaded_filename = $file_list[$i]->uploaded_filename;
928 1044
 			$path_info = pathinfo($uploaded_filename);
929
-			if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
1045
+			if(!in_array($path_info['dirname'], $path)) {
1046
+				$path[] = $path_info['dirname'];
1047
+			}
930 1048
 		}
931 1049
 
932 1050
 		// Remove from the DB
933 1051
 		$args = new stdClass();
934 1052
 		$args->upload_target_srl = $upload_target_srl;
935 1053
 		$output = executeQuery('file.deleteFiles', $args);
936
-		if(!$output->toBool()) return $output;
1054
+		if(!$output->toBool()) {
1055
+			return $output;
1056
+		}
937 1057
 		
938 1058
 		// Remove a file directory of the document
939 1059
 		for($i=0, $c=count($path); $i<$c; $i++)
@@ -954,11 +1074,15 @@  discard block
 block discarded – undo
954 1074
 	 */
955 1075
 	function moveFile($source_srl, $target_module_srl, $target_srl)
956 1076
 	{
957
-		if($source_srl == $target_srl) return;
1077
+		if($source_srl == $target_srl) {
1078
+			return;
1079
+		}
958 1080
 
959 1081
 		$oFileModel = getModel('file');
960 1082
 		$file_list = $oFileModel->getFiles($source_srl);
961
-		if(!$file_list) return;
1083
+		if(!$file_list) {
1084
+			return;
1085
+		}
962 1086
 
963 1087
 		$file_count = count($file_list);
964 1088
  
@@ -972,15 +1096,16 @@  discard block
 block discarded – undo
972 1096
 			{
973 1097
 				$path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl);
974 1098
 				$new_file = $path.$file_info->source_filename;
975
-			}
976
-			else
1099
+			} else
977 1100
 			{
978 1101
 				$path = sprintf("./files/attach/binaries/%s/%s/", $target_module_srl, $target_srl);
979 1102
 				$random = new Password();
980 1103
 				$new_file = $path.$random->createSecureSalt(32, 'hex');
981 1104
 			}
982 1105
 			// Pass if a target document to move is same
983
-			if($old_file == $new_file) continue;
1106
+			if($old_file == $new_file) {
1107
+				continue;
1108
+			}
984 1109
 			// Create a directory
985 1110
 			FileHandler::makeDir($path);
986 1111
 			// Move the file
@@ -1000,16 +1125,22 @@  discard block
 block discarded – undo
1000 1125
 		$vars = Context::getRequestVars();
1001 1126
 		$logged_info = Context::get('logged_info');
1002 1127
 
1003
-		if(!$vars->editor_sequence) return new BaseObject(-1, 'msg_invalid_request');
1128
+		if(!$vars->editor_sequence) {
1129
+			return new BaseObject(-1, 'msg_invalid_request');
1130
+		}
1004 1131
 
1005 1132
 		$upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl;
1006 1133
 
1007 1134
 		$oFileModel = getModel('file');
1008 1135
 		$file_info = $oFileModel->getFile($vars->file_srl);
1009 1136
 
1010
-		if(!$file_info) return new BaseObject(-1, 'msg_not_founded');
1137
+		if(!$file_info) {
1138
+			return new BaseObject(-1, 'msg_not_founded');
1139
+		}
1011 1140
 
1012
-		if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new BaseObject(-1, 'msg_not_permitted');
1141
+		if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) {
1142
+			return new BaseObject(-1, 'msg_not_permitted');
1143
+		}
1013 1144
 
1014 1145
 		$args =  new stdClass();
1015 1146
 		$args->file_srl = $vars->file_srl;
Please login to merge, or discard this patch.
modules/comment/comment.item.php 1 patch
Spacing   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	function _loadFromDB()
51 51
 	{
52
-		if(!$this->comment_srl)
52
+		if (!$this->comment_srl)
53 53
 		{
54 54
 			return;
55 55
 		}
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	function setAttribute($attribute)
69 69
 	{
70
-		if(!$attribute->comment_srl)
70
+		if (!$attribute->comment_srl)
71 71
 		{
72 72
 			$this->comment_srl = NULL;
73 73
 			return;
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
 		$this->adds($attribute);
78 78
 
79 79
 		// define vars on the object for backward compatibility of skins
80
-		if(count($attribute))
80
+		if (count($attribute))
81 81
 		{
82
-			foreach($attribute as $key => $val)
82
+			foreach ($attribute as $key => $val)
83 83
 			{
84 84
 				$this->{$key} = $val;
85 85
 			}
@@ -93,29 +93,29 @@  discard block
 block discarded – undo
93 93
 
94 94
 	function isGranted()
95 95
 	{
96
-		if($_SESSION['own_comment'][$this->comment_srl])
96
+		if ($_SESSION['own_comment'][$this->comment_srl])
97 97
 		{
98 98
 			return TRUE;
99 99
 		}
100 100
 
101
-		if(!Context::get('is_logged'))
101
+		if (!Context::get('is_logged'))
102 102
 		{
103 103
 			return FALSE;
104 104
 		}
105 105
 
106 106
 		$logged_info = Context::get('logged_info');
107
-		if($logged_info->is_admin == 'Y')
107
+		if ($logged_info->is_admin == 'Y')
108 108
 		{
109 109
 			return TRUE;
110 110
 		}
111 111
 
112 112
 		$grant = Context::get('grant');
113
-		if($grant->manager)
113
+		if ($grant->manager)
114 114
 		{
115 115
 			return TRUE;
116 116
 		}
117 117
 
118
-		if($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl') * -1 == $logged_info->member_srl))
118
+		if ($this->get('member_srl') && ($this->get('member_srl') == $logged_info->member_srl || $this->get('member_srl') * -1 == $logged_info->member_srl))
119 119
 		{
120 120
 			return TRUE;
121 121
 		}
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 
137 137
 	function isEditable()
138 138
 	{
139
-		if($this->isGranted() || !$this->get('member_srl'))
139
+		if ($this->isGranted() || !$this->get('member_srl'))
140 140
 		{
141 141
 			return TRUE;
142 142
 		}
@@ -150,12 +150,12 @@  discard block
 block discarded – undo
150 150
 
151 151
 	function isAccessible()
152 152
 	{
153
-		if($_SESSION['accessibled_comment'][$this->comment_srl])
153
+		if ($_SESSION['accessibled_comment'][$this->comment_srl])
154 154
 		{
155 155
 			return TRUE;
156 156
 		}
157 157
 
158
-		if($this->isGranted() || !$this->isSecret())
158
+		if ($this->isGranted() || !$this->isSecret())
159 159
 		{
160 160
 			$this->setAccessible();
161 161
 			return TRUE;
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 
164 164
 		$oDocumentModel = getModel('document');
165 165
 		$oDocument = $oDocumentModel->getDocument($this->get('document_srl'));
166
-		if($oDocument->isGranted())
166
+		if ($oDocument->isGranted())
167 167
 		{
168 168
 			$this->setAccessible();
169 169
 			return TRUE;
@@ -184,20 +184,20 @@  discard block
 block discarded – undo
184 184
 	function notify($type, $content)
185 185
 	{
186 186
 		// return if not useNotify
187
-		if(!$this->useNotify())
187
+		if (!$this->useNotify())
188 188
 		{
189 189
 			return;
190 190
 		}
191 191
 
192 192
 		// pass if the author is not logged-in user 
193
-		if(!$this->get('member_srl'))
193
+		if (!$this->get('member_srl'))
194 194
 		{
195 195
 			return;
196 196
 		}
197 197
 
198 198
 		// return if the currently logged-in user is an author of the comment.
199 199
 		$logged_info = Context::get('logged_info');
200
-		if($logged_info->member_srl == $this->get('member_srl'))
200
+		if ($logged_info->member_srl == $this->get('member_srl'))
201 201
 		{
202 202
 			return;
203 203
 		}
@@ -207,9 +207,9 @@  discard block
 block discarded – undo
207 207
 		$oDocument = $oDocumentModel->getDocument($this->get('document_srl'));
208 208
 
209 209
 		// Variables
210
-		if($type)
210
+		if ($type)
211 211
 		{
212
-			$title = "[" . $type . "] ";
212
+			$title = "[".$type."] ";
213 213
 		}
214 214
 
215 215
 		$title .= cut_str(strip_tags($content), 30, '...');
@@ -224,17 +224,17 @@  discard block
 block discarded – undo
224 224
 
225 225
 	function getIpAddress()
226 226
 	{
227
-		if($this->isGranted())
227
+		if ($this->isGranted())
228 228
 		{
229 229
 			return $this->get('ipaddress');
230 230
 		}
231 231
 
232
-		return '*' . strstr($this->get('ipaddress'), '.');
232
+		return '*'.strstr($this->get('ipaddress'), '.');
233 233
 	}
234 234
 
235 235
 	function isExistsHomepage()
236 236
 	{
237
-		if(trim($this->get('homepage')))
237
+		if (trim($this->get('homepage')))
238 238
 		{
239 239
 			return TRUE;
240 240
 		}
@@ -245,14 +245,14 @@  discard block
 block discarded – undo
245 245
 	function getHomepageUrl()
246 246
 	{
247 247
 		$url = trim($this->get('homepage'));
248
-		if(!$url)
248
+		if (!$url)
249 249
 		{
250 250
 			return;
251 251
 		}
252 252
 
253
-		if(strncasecmp('http://', $url, 7) !== 0)
253
+		if (strncasecmp('http://', $url, 7) !== 0)
254 254
 		{
255
-			$url = "http://" . $url;
255
+			$url = "http://".$url;
256 256
 		}
257 257
 
258 258
 		return escape($url, false);
@@ -284,14 +284,14 @@  discard block
 block discarded – undo
284 284
 	 */
285 285
 	function getContentText($strlen = 0)
286 286
 	{
287
-		if($this->isSecret() && !$this->isAccessible())
287
+		if ($this->isSecret() && !$this->isAccessible())
288 288
 		{
289 289
 			return Context::getLang('msg_is_secret');
290 290
 		}
291 291
 
292 292
 		$content = $this->get('content');
293 293
 
294
-		if($strlen)
294
+		if ($strlen)
295 295
 		{
296 296
 			return cut_str(strip_tags($content), $strlen, '...');
297 297
 		}
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	 */
306 306
 	function getContent($add_popup_menu = TRUE, $add_content_info = TRUE, $add_xe_content_class = TRUE)
307 307
 	{
308
-		if($this->isSecret() && !$this->isAccessible())
308
+		if ($this->isSecret() && !$this->isAccessible())
309 309
 		{
310 310
 			return Context::getLang('msg_is_secret');
311 311
 		}
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 		stripEmbedTagForAdmin($content, $this->get('member_srl'));
315 315
 
316 316
 		// when displaying the comment on the pop-up menu
317
-		if($add_popup_menu && Context::get('is_logged'))
317
+		if ($add_popup_menu && Context::get('is_logged'))
318 318
 		{
319 319
 			$content = sprintf(
320 320
 					'%s<div class="comment_popup_menu"><a href="#popup_menu_area" class="comment_%d" onclick="return false">%s</a></div>', $content, $this->comment_srl, Context::getLang('cmd_comment_do')
@@ -322,10 +322,10 @@  discard block
 block discarded – undo
322 322
 		}
323 323
 
324 324
 		// if additional information which can access contents is set
325
-		if($add_content_info)
325
+		if ($add_content_info)
326 326
 		{
327 327
 			$memberSrl = $this->get('member_srl');
328
-			if($memberSrl < 0)
328
+			if ($memberSrl < 0)
329 329
 			{
330 330
 				$memberSrl = 0;
331 331
 			}
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 		}
337 337
 		else
338 338
 		{
339
-			if($add_xe_content_class)
339
+			if ($add_xe_content_class)
340 340
 			{
341 341
 				$content = sprintf('<div class="xe_content">%s</div>', $content);
342 342
 			}
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 
397 397
 	function getRegdateGM()
398 398
 	{
399
-		return $this->getRegdate('D, d M Y H:i:s') . ' ' . $GLOBALS['_time_zone'];
399
+		return $this->getRegdate('D, d M Y H:i:s').' '.$GLOBALS['_time_zone'];
400 400
 	}
401 401
 
402 402
 	function getUpdate($format = 'Y.m.d H:i:s')
@@ -406,7 +406,7 @@  discard block
 block discarded – undo
406 406
 
407 407
 	function getPermanentUrl()
408 408
 	{
409
-		return getFullUrl('', 'mid', $this->getCommentMid(), 'document_srl', $this->get('document_srl')) . '#comment_' . $this->get('comment_srl');
409
+		return getFullUrl('', 'mid', $this->getCommentMid(), 'document_srl', $this->get('document_srl')).'#comment_'.$this->get('comment_srl');
410 410
 	}
411 411
 
412 412
 	function getUpdateTime()
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 
428 428
 	function hasUploadedFiles()
429 429
 	{
430
-		if(($this->isSecret() && !$this->isAccessible()) && !$this->isGranted())
430
+		if (($this->isSecret() && !$this->isAccessible()) && !$this->isGranted())
431 431
 		{
432 432
 			return FALSE;
433 433
 		}
@@ -436,12 +436,12 @@  discard block
 block discarded – undo
436 436
 
437 437
 	function getUploadedFiles()
438 438
 	{
439
-		if(($this->isSecret() && !$this->isAccessible()) && !$this->isGranted())
439
+		if (($this->isSecret() && !$this->isAccessible()) && !$this->isGranted())
440 440
 		{
441 441
 			return;
442 442
 		}
443 443
 
444
-		if(!$this->get('uploaded_count'))
444
+		if (!$this->get('uploaded_count'))
445 445
 		{
446 446
 			return;
447 447
 		}
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 	function getEditor()
459 459
 	{
460 460
 		$module_srl = $this->get('module_srl');
461
-		if(!$module_srl)
461
+		if (!$module_srl)
462 462
 		{
463 463
 			$module_srl = Context::get('module_srl');
464 464
 		}
@@ -472,13 +472,13 @@  discard block
 block discarded – undo
472 472
 	 */
473 473
 	function getProfileImage()
474 474
 	{
475
-		if(!$this->isExists() || !$this->get('member_srl'))
475
+		if (!$this->isExists() || !$this->get('member_srl'))
476 476
 		{
477 477
 			return;
478 478
 		}
479 479
 		$oMemberModel = getModel('member');
480 480
 		$profile_info = $oMemberModel->getProfileImage($this->get('member_srl'));
481
-		if(!$profile_info)
481
+		if (!$profile_info)
482 482
 		{
483 483
 			return;
484 484
 		}
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 	function getSignature()
494 494
 	{
495 495
 		// pass if the posting not exists.
496
-		if(!$this->isExists() || !$this->get('member_srl'))
496
+		if (!$this->isExists() || !$this->get('member_srl'))
497 497
 		{
498 498
 			return;
499 499
 		}
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
 		$signature = $oMemberModel->getSignature($this->get('member_srl'));
504 504
 
505 505
 		// check if max height of the signiture is specified on the member module
506
-		if(!isset($GLOBALS['__member_signature_max_height']))
506
+		if (!isset($GLOBALS['__member_signature_max_height']))
507 507
 		{
508 508
 			$oModuleModel = getModel('module');
509 509
 			$member_config = $oModuleModel->getModuleConfig('member');
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
 
513 513
 		$max_signature_height = $GLOBALS['__member_signature_max_height'];
514 514
 
515
-		if($max_signature_height)
515
+		if ($max_signature_height)
516 516
 		{
517 517
 			$signature = sprintf('<div style="max-height:%dpx;overflow:auto;overflow-x:hidden;height:expression(this.scrollHeight > %d ? \'%dpx\': \'auto\')">%s</div>', $max_signature_height, $max_signature_height, $max_signature_height, $signature);
518 518
 		}
@@ -522,12 +522,12 @@  discard block
 block discarded – undo
522 522
 
523 523
 	function thumbnailExists($width = 80, $height = 0, $type = '')
524 524
 	{
525
-		if(!$this->comment_srl)
525
+		if (!$this->comment_srl)
526 526
 		{
527 527
 			return FALSE;
528 528
 		}
529 529
 
530
-		if(!$this->getThumbnail($width, $height, $type))
530
+		if (!$this->getThumbnail($width, $height, $type))
531 531
 		{
532 532
 			return FALSE;
533 533
 		}
@@ -538,42 +538,42 @@  discard block
 block discarded – undo
538 538
 	function getThumbnail($width = 80, $height = 0, $thumbnail_type = '')
539 539
 	{
540 540
 		// return false if no doc exists
541
-		if(!$this->comment_srl)
541
+		if (!$this->comment_srl)
542 542
 		{
543 543
 			return;
544 544
 		}
545 545
 
546
-		if($this->isSecret() && !$this->isGranted())
546
+		if ($this->isSecret() && !$this->isGranted())
547 547
 		{
548 548
 			return;
549 549
 		}
550 550
 
551 551
 		// If signiture height setting is omitted, create a square
552
-		if(!$height)
552
+		if (!$height)
553 553
 		{
554 554
 			$height = $width;
555 555
 		}
556 556
 
557 557
 		$content = $this->get('content');
558
-		if(!$this->hasUploadedFiles())
558
+		if (!$this->hasUploadedFiles())
559 559
 		{
560
-			if(!$content)
560
+			if (!$content)
561 561
 			{
562 562
 				$args = new stdClass();
563 563
 				$args->comment_srl = $this->comment_srl;
564 564
 				$output = executeQuery('document.getComment', $args, array('content'));
565
-				if($output->toBool() && $output->data)
565
+				if ($output->toBool() && $output->data)
566 566
 				{
567 567
 					$content = $output->data->content;
568 568
 					$this->add('content', $content);
569 569
 				}
570 570
 			}
571 571
 
572
-			if(!preg_match("!<img!is", $content)) return;
572
+			if (!preg_match("!<img!is", $content)) return;
573 573
 		}
574 574
 
575 575
 		// get thumbail generation info on the doc module configuration.
576
-		if(!in_array($thumbnail_type, array('crop', 'ratio')))
576
+		if (!in_array($thumbnail_type, array('crop', 'ratio')))
577 577
 		{
578 578
 			$thumbnail_type = 'crop';
579 579
 		}
@@ -582,18 +582,18 @@  discard block
 block discarded – undo
582 582
 		$thumbnail_path = sprintf('files/thumbnails/%s', getNumberingPath($this->comment_srl, 3));
583 583
 		$thumbnail_file = sprintf('%s%dx%d.%s.jpg', $thumbnail_path, $width, $height, $thumbnail_type);
584 584
 		$thumbnail_lockfile = sprintf('%s%dx%d.%s.lock', $thumbnail_path, $width, $height, $thumbnail_type);
585
-		$thumbnail_url = Context::getRequestUri() . $thumbnail_file;
585
+		$thumbnail_url = Context::getRequestUri().$thumbnail_file;
586 586
 
587 587
 		// return false if a size of existing thumbnail file is 0. otherwise return the file path
588
-		if(file_exists($thumbnail_file) || file_exists($thumbnail_lockfile))
588
+		if (file_exists($thumbnail_file) || file_exists($thumbnail_lockfile))
589 589
 		{
590
-			if(filesize($thumbnail_file) < 1)
590
+			if (filesize($thumbnail_file) < 1)
591 591
 			{
592 592
 				return FALSE;
593 593
 			}
594 594
 			else
595 595
 			{
596
-				return $thumbnail_url . '?' . date('YmdHis', filemtime($thumbnail_file));
596
+				return $thumbnail_url.'?'.date('YmdHis', filemtime($thumbnail_file));
597 597
 			}
598 598
 		}
599 599
 
@@ -605,33 +605,33 @@  discard block
 block discarded – undo
605 605
 		$is_tmp_file = FALSE;
606 606
 
607 607
 		// find an image file among attached files
608
-		if($this->hasUploadedFiles())
608
+		if ($this->hasUploadedFiles())
609 609
 		{
610 610
 			$file_list = $this->getUploadedFiles();
611 611
 
612 612
 			$first_image = null;
613
-			foreach($file_list as $file)
613
+			foreach ($file_list as $file)
614 614
 			{
615
-				if($file->direct_download !== 'Y') continue;
615
+				if ($file->direct_download !== 'Y') continue;
616 616
 
617
-				if($file->cover_image === 'Y' && file_exists($file->uploaded_filename))
617
+				if ($file->cover_image === 'Y' && file_exists($file->uploaded_filename))
618 618
 				{
619 619
 					$source_file = $file->uploaded_filename;
620 620
 					break;
621 621
 				}
622 622
 
623
-				if($first_image) continue;
623
+				if ($first_image) continue;
624 624
 
625
-				if(preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename))
625
+				if (preg_match("/\.(jpe?g|png|gif|bmp)$/i", $file->source_filename))
626 626
 				{
627
-					if(file_exists($file->uploaded_filename))
627
+					if (file_exists($file->uploaded_filename))
628 628
 					{
629 629
 						$first_image = $file->uploaded_filename;
630 630
 					}
631 631
 				}
632 632
 			}
633 633
 
634
-			if(!$source_file && $first_image)
634
+			if (!$source_file && $first_image)
635 635
 			{
636 636
 				$source_file = $first_image;
637 637
 			}
@@ -639,31 +639,31 @@  discard block
 block discarded – undo
639 639
 
640 640
 		// get an image file from the doc content if no file attached. 
641 641
 		$is_tmp_file = false;
642
-		if(!$source_file)
642
+		if (!$source_file)
643 643
 		{
644 644
 			$random = new Password();
645 645
 
646 646
 			preg_match_all("!<img[^>]*src=(?:\"|\')([^\"\']*?)(?:\"|\')!is", $content, $matches, PREG_SET_ORDER);
647 647
 
648
-			foreach($matches as $target_image)
648
+			foreach ($matches as $target_image)
649 649
 			{
650 650
 				$target_src = trim($target_image[1]);
651
-				if(preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue;
651
+				if (preg_match('/\/(common|modules|widgets|addons|layouts|m\.layouts)\//i', $target_src)) continue;
652 652
 
653
-				if(!preg_match('/^(http|https):\/\//i',$target_src))
653
+				if (!preg_match('/^(http|https):\/\//i', $target_src))
654 654
 				{
655 655
 					$target_src = Context::getRequestUri().$target_src;
656 656
 				}
657 657
 
658 658
 				$target_src = htmlspecialchars_decode($target_src);
659 659
 
660
-				$tmp_file = _XE_PATH_ . 'files/cache/tmp/' . $random->createSecureSalt(32, 'hex');
660
+				$tmp_file = _XE_PATH_.'files/cache/tmp/'.$random->createSecureSalt(32, 'hex');
661 661
 				FileHandler::getRemoteFile($target_src, $tmp_file);
662
-				if(!file_exists($tmp_file)) continue;
662
+				if (!file_exists($tmp_file)) continue;
663 663
 
664 664
 				$imageinfo = getimagesize($tmp_file);
665 665
 				list($_w, $_h) = $imageinfo;
666
-				if($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) {
666
+				if ($imageinfo === false || ($_w < ($width * 0.3) && $_h < ($height * 0.3))) {
667 667
 					FileHandler::removeFile($tmp_file);
668 668
 					continue;
669 669
 				}
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 		$output = FileHandler::createImageFile($source_file, $thumbnail_file, $width, $height, 'jpg', $thumbnail_type);
678 678
 
679 679
 		// Remove source file if it was temporary
680
-		if($is_tmp_file)
680
+		if ($is_tmp_file)
681 681
 		{
682 682
 			FileHandler::removeFile($source_file);
683 683
 		}
@@ -686,12 +686,12 @@  discard block
 block discarded – undo
686 686
 		FileHandler::removeFile($thumbnail_lockfile);
687 687
 
688 688
 		// Create an empty file if thumbnail generation failed
689
-		if(!$output)
689
+		if (!$output)
690 690
 		{
691
-			FileHandler::writeFile($thumbnail_file, '','w');
691
+			FileHandler::writeFile($thumbnail_file, '', 'w');
692 692
 		}
693 693
 
694
-		return $thumbnail_url . '?' . date('YmdHis', filemtime($thumbnail_file));
694
+		return $thumbnail_url.'?'.date('YmdHis', filemtime($thumbnail_file));
695 695
 	}
696 696
 
697 697
 	function isCarted()
Please login to merge, or discard this patch.