@@ -6,13 +6,13 @@ discard block |
||
| 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 |
||
| 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,7 +250,7 @@ discard block |
||
| 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 | 255 | $arr_seq = $_SESSION['seq']; |
| 256 | 256 | } |
@@ -266,11 +266,11 @@ discard block |
||
| 266 | 266 | */ |
| 267 | 267 | function checkUserSequence($seq) |
| 268 | 268 | { |
| 269 | - if(!isset($_SESSION['seq'])) |
|
| 269 | + if (!isset($_SESSION['seq'])) |
|
| 270 | 270 | { |
| 271 | 271 | return false; |
| 272 | 272 | } |
| 273 | - if(!in_array($seq, $_SESSION['seq'])) |
|
| 273 | + if (!in_array($seq, $_SESSION['seq'])) |
|
| 274 | 274 | { |
| 275 | 275 | return false; |
| 276 | 276 | } |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | $num_args = func_num_args(); |
| 297 | 297 | $args_list = func_get_args(); |
| 298 | 298 | |
| 299 | - if($num_args) |
|
| 299 | + if ($num_args) |
|
| 300 | 300 | $url = Context::getUrl($num_args, $args_list); |
| 301 | 301 | else |
| 302 | 302 | $url = Context::getRequestUri(); |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | $num_args = func_num_args(); |
| 316 | 316 | $args_list = func_get_args(); |
| 317 | 317 | |
| 318 | - if($num_args) |
|
| 318 | + if ($num_args) |
|
| 319 | 319 | { |
| 320 | 320 | $url = Context::getUrl($num_args, $args_list, NULL, FALSE); |
| 321 | 321 | } |
@@ -338,7 +338,7 @@ discard block |
||
| 338 | 338 | $num_args = func_num_args(); |
| 339 | 339 | $args_list = func_get_args(); |
| 340 | 340 | |
| 341 | - if($num_args) |
|
| 341 | + if ($num_args) |
|
| 342 | 342 | { |
| 343 | 343 | $url = Context::getUrl($num_args, $args_list, NULL, TRUE, TRUE); |
| 344 | 344 | } |
@@ -360,16 +360,16 @@ discard block |
||
| 360 | 360 | $num_args = func_num_args(); |
| 361 | 361 | $args_list = func_get_args(); |
| 362 | 362 | $request_uri = Context::getRequestUri(); |
| 363 | - if(!$num_args) |
|
| 363 | + if (!$num_args) |
|
| 364 | 364 | { |
| 365 | 365 | return $request_uri; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | 368 | $url = Context::getUrl($num_args, $args_list); |
| 369 | - if(strncasecmp('http', $url, 4) !== 0) |
|
| 369 | + if (strncasecmp('http', $url, 4) !== 0) |
|
| 370 | 370 | { |
| 371 | 371 | preg_match('/^(http|https):\/\/([^\/]+)\//', $request_uri, $match); |
| 372 | - return substr($match[0], 0, -1) . $url; |
|
| 372 | + return substr($match[0], 0, -1).$url; |
|
| 373 | 373 | } |
| 374 | 374 | return $url; |
| 375 | 375 | } |
@@ -384,17 +384,17 @@ discard block |
||
| 384 | 384 | $num_args = func_num_args(); |
| 385 | 385 | $args_list = func_get_args(); |
| 386 | 386 | $request_uri = Context::getRequestUri(); |
| 387 | - if(!$num_args) |
|
| 387 | + if (!$num_args) |
|
| 388 | 388 | { |
| 389 | 389 | return $request_uri; |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | $url = Context::getUrl($num_args, $args_list, NULL, FALSE); |
| 393 | - if(strncasecmp('http', $url, 4) !== 0) |
|
| 393 | + if (strncasecmp('http', $url, 4) !== 0) |
|
| 394 | 394 | { |
| 395 | 395 | preg_match('/^(http|https):\/\/([^\/]+)\//', $request_uri, $match); |
| 396 | 396 | $url = Context::getUrl($num_args, $args_list, NULL, FALSE); |
| 397 | - return substr($match[0], 0, -1) . $url; |
|
| 397 | + return substr($match[0], 0, -1).$url; |
|
| 398 | 398 | } |
| 399 | 399 | return $url; |
| 400 | 400 | } |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | $num_args = func_num_args(); |
| 411 | 411 | $args_list = func_get_args(); |
| 412 | 412 | |
| 413 | - if(!$num_args) |
|
| 413 | + if (!$num_args) |
|
| 414 | 414 | { |
| 415 | 415 | return Context::getRequestUri(); |
| 416 | 416 | } |
@@ -432,7 +432,7 @@ discard block |
||
| 432 | 432 | $num_args = func_num_args(); |
| 433 | 433 | $args_list = func_get_args(); |
| 434 | 434 | |
| 435 | - if(!$num_args) |
|
| 435 | + if (!$num_args) |
|
| 436 | 436 | { |
| 437 | 437 | return Context::getRequestUri(); |
| 438 | 438 | } |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | $args_list = func_get_args(); |
| 455 | 455 | |
| 456 | 456 | $request_uri = Context::getRequestUri(); |
| 457 | - if(!$num_args) |
|
| 457 | + if (!$num_args) |
|
| 458 | 458 | { |
| 459 | 459 | return $request_uri; |
| 460 | 460 | } |
@@ -463,10 +463,10 @@ discard block |
||
| 463 | 463 | $num_args = count($args_list); |
| 464 | 464 | |
| 465 | 465 | $url = Context::getUrl($num_args, $args_list, $domain); |
| 466 | - if(strncasecmp('http', $url, 4) !== 0) |
|
| 466 | + if (strncasecmp('http', $url, 4) !== 0) |
|
| 467 | 467 | { |
| 468 | 468 | preg_match('/^(http|https):\/\/([^\/]+)\//', $request_uri, $match); |
| 469 | - return substr($match[0], 0, -1) . $url; |
|
| 469 | + return substr($match[0], 0, -1).$url; |
|
| 470 | 470 | } |
| 471 | 471 | return $url; |
| 472 | 472 | } |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | function getCurrentPageUrl() |
| 480 | 480 | { |
| 481 | 481 | $protocol = $_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://'; |
| 482 | - $url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
| 482 | + $url = $protocol.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; |
|
| 483 | 483 | return htmlspecialchars($url, ENT_COMPAT, 'UTF-8', FALSE); |
| 484 | 484 | } |
| 485 | 485 | |
@@ -504,12 +504,12 @@ discard block |
||
| 504 | 504 | */ |
| 505 | 505 | function cut_str($string, $cut_size = 0, $tail = '...') |
| 506 | 506 | { |
| 507 | - if($cut_size < 1 || !$string) |
|
| 507 | + if ($cut_size < 1 || !$string) |
|
| 508 | 508 | { |
| 509 | 509 | return $string; |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | - if($GLOBALS['use_mb_strimwidth'] || function_exists('mb_strimwidth')) |
|
| 512 | + if ($GLOBALS['use_mb_strimwidth'] || function_exists('mb_strimwidth')) |
|
| 513 | 513 | { |
| 514 | 514 | $GLOBALS['use_mb_strimwidth'] = TRUE; |
| 515 | 515 | return mb_strimwidth($string, 0, $cut_size + 4, $tail, 'utf-8'); |
@@ -523,16 +523,16 @@ discard block |
||
| 523 | 523 | $char_count = 0; |
| 524 | 524 | |
| 525 | 525 | $idx = 0; |
| 526 | - while($idx < $string_length && $char_count < $cut_size && $char_width <= $max_width) |
|
| 526 | + while ($idx < $string_length && $char_count < $cut_size && $char_width <= $max_width) |
|
| 527 | 527 | { |
| 528 | 528 | $c = ord(substr($string, $idx, 1)); |
| 529 | 529 | $char_count++; |
| 530 | - if($c < 128) |
|
| 530 | + if ($c < 128) |
|
| 531 | 531 | { |
| 532 | 532 | $char_width += (int) $chars[$c - 32]; |
| 533 | 533 | $idx++; |
| 534 | 534 | } |
| 535 | - else if(191 < $c && $c < 224) |
|
| 535 | + else if (191 < $c && $c < 224) |
|
| 536 | 536 | { |
| 537 | 537 | $char_width += $chars[4]; |
| 538 | 538 | $idx += 2; |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | $output = substr($string, 0, $idx); |
| 548 | - if(strlen($output) < $string_length) |
|
| 548 | + if (strlen($output) < $string_length) |
|
| 549 | 549 | { |
| 550 | 550 | $output .= $tail; |
| 551 | 551 | } |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | function zgap() |
| 562 | 562 | { |
| 563 | 563 | $time_zone = $GLOBALS['_time_zone']; |
| 564 | - if($time_zone < 0) |
|
| 564 | + if ($time_zone < 0) |
|
| 565 | 565 | { |
| 566 | 566 | $to = -1; |
| 567 | 567 | } |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | $t_min = substr($time_zone, 3, 2) * $to; |
| 575 | 575 | |
| 576 | 576 | $server_time_zone = date("O"); |
| 577 | - if($server_time_zone < 0) |
|
| 577 | + if ($server_time_zone < 0) |
|
| 578 | 578 | { |
| 579 | 579 | $so = -1; |
| 580 | 580 | } |
@@ -601,7 +601,7 @@ discard block |
||
| 601 | 601 | */ |
| 602 | 602 | function ztime($str) |
| 603 | 603 | { |
| 604 | - if(!$str) |
|
| 604 | + if (!$str) |
|
| 605 | 605 | { |
| 606 | 606 | return; |
| 607 | 607 | } |
@@ -612,7 +612,7 @@ discard block |
||
| 612 | 612 | $year = (int) substr($str, 0, 4); |
| 613 | 613 | $month = (int) substr($str, 4, 2); |
| 614 | 614 | $day = (int) substr($str, 6, 2); |
| 615 | - if(strlen($str) <= 8) |
|
| 615 | + if (strlen($str) <= 8) |
|
| 616 | 616 | { |
| 617 | 617 | $gap = 0; |
| 618 | 618 | } |
@@ -636,19 +636,19 @@ discard block |
||
| 636 | 636 | $gap = $_SERVER['REQUEST_TIME'] + zgap() - ztime($date); |
| 637 | 637 | |
| 638 | 638 | $lang_time_gap = Context::getLang('time_gap'); |
| 639 | - if($gap < 60) |
|
| 639 | + if ($gap < 60) |
|
| 640 | 640 | { |
| 641 | 641 | $buff = sprintf($lang_time_gap['min'], (int) ($gap / 60) + 1); |
| 642 | 642 | } |
| 643 | - elseif($gap < 60 * 60) |
|
| 643 | + elseif ($gap < 60 * 60) |
|
| 644 | 644 | { |
| 645 | 645 | $buff = sprintf($lang_time_gap['mins'], (int) ($gap / 60) + 1); |
| 646 | 646 | } |
| 647 | - elseif($gap < 60 * 60 * 2) |
|
| 647 | + elseif ($gap < 60 * 60 * 2) |
|
| 648 | 648 | { |
| 649 | 649 | $buff = sprintf($lang_time_gap['hour'], (int) ($gap / 60 / 60) + 1); |
| 650 | 650 | } |
| 651 | - elseif($gap < 60 * 60 * 24) |
|
| 651 | + elseif ($gap < 60 * 60 * 24) |
|
| 652 | 652 | { |
| 653 | 653 | $buff = sprintf($lang_time_gap['hours'], (int) ($gap / 60 / 60) + 1); |
| 654 | 654 | } |
@@ -685,40 +685,40 @@ discard block |
||
| 685 | 685 | function zdate($str, $format = 'Y-m-d H:i:s', $conversion = TRUE) |
| 686 | 686 | { |
| 687 | 687 | // return null if no target time is specified |
| 688 | - if(!$str) |
|
| 688 | + if (!$str) |
|
| 689 | 689 | { |
| 690 | 690 | return; |
| 691 | 691 | } |
| 692 | 692 | // convert the date format according to the language |
| 693 | - if($conversion == TRUE) |
|
| 693 | + if ($conversion == TRUE) |
|
| 694 | 694 | { |
| 695 | - switch(Context::getLangType()) |
|
| 695 | + switch (Context::getLangType()) |
|
| 696 | 696 | { |
| 697 | 697 | case 'en' : |
| 698 | 698 | case 'es' : |
| 699 | - if($format == 'Y-m-d') |
|
| 699 | + if ($format == 'Y-m-d') |
|
| 700 | 700 | { |
| 701 | 701 | $format = 'M d, Y'; |
| 702 | 702 | } |
| 703 | - elseif($format == 'Y-m-d H:i:s') |
|
| 703 | + elseif ($format == 'Y-m-d H:i:s') |
|
| 704 | 704 | { |
| 705 | 705 | $format = 'M d, Y H:i:s'; |
| 706 | 706 | } |
| 707 | - elseif($format == 'Y-m-d H:i') |
|
| 707 | + elseif ($format == 'Y-m-d H:i') |
|
| 708 | 708 | { |
| 709 | 709 | $format = 'M d, Y H:i'; |
| 710 | 710 | } |
| 711 | 711 | break; |
| 712 | 712 | case 'vi' : |
| 713 | - if($format == 'Y-m-d') |
|
| 713 | + if ($format == 'Y-m-d') |
|
| 714 | 714 | { |
| 715 | 715 | $format = 'd-m-Y'; |
| 716 | 716 | } |
| 717 | - elseif($format == 'Y-m-d H:i:s') |
|
| 717 | + elseif ($format == 'Y-m-d H:i:s') |
|
| 718 | 718 | { |
| 719 | 719 | $format = 'H:i:s d-m-Y'; |
| 720 | 720 | } |
| 721 | - elseif($format == 'Y-m-d H:i') |
|
| 721 | + elseif ($format == 'Y-m-d H:i') |
|
| 722 | 722 | { |
| 723 | 723 | $format = 'H:i d-m-Y'; |
| 724 | 724 | } |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | // If year value is less than 1970, handle it separately. |
| 730 | - if((int) substr($str, 0, 4) < 1970) |
|
| 730 | + if ((int) substr($str, 0, 4) < 1970) |
|
| 731 | 731 | { |
| 732 | 732 | $hour = (int) substr($str, 8, 2); |
| 733 | 733 | $min = (int) substr($str, 10, 2); |
@@ -777,9 +777,9 @@ discard block |
||
| 777 | 777 | function getEncodeEmailAddress($email) |
| 778 | 778 | { |
| 779 | 779 | $return = ''; |
| 780 | - for($i = 0, $c = strlen($email); $i < $c; $i++) |
|
| 780 | + for ($i = 0, $c = strlen($email); $i < $c; $i++) |
|
| 781 | 781 | { |
| 782 | - $return .= '&#' . (rand(0, 1) == 0 ? ord($email[$i]) : 'X' . dechex(ord($email[$i]))) . ';'; |
|
| 782 | + $return .= '&#'.(rand(0, 1) == 0 ? ord($email[$i]) : 'X'.dechex(ord($email[$i]))).';'; |
|
| 783 | 783 | } |
| 784 | 784 | return $return; |
| 785 | 785 | } |
@@ -800,25 +800,25 @@ discard block |
||
| 800 | 800 | static $debug_file; |
| 801 | 801 | static $debug_file_exist; |
| 802 | 802 | |
| 803 | - if(!(__DEBUG__ & 1)) |
|
| 803 | + if (!(__DEBUG__ & 1)) |
|
| 804 | 804 | { |
| 805 | 805 | return; |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | static $firephp; |
| 809 | 809 | $bt = debug_backtrace(); |
| 810 | - if(is_array($bt)) |
|
| 810 | + if (is_array($bt)) |
|
| 811 | 811 | { |
| 812 | 812 | $bt_debug_print = array_shift($bt); |
| 813 | 813 | $bt_called_function = array_shift($bt); |
| 814 | 814 | } |
| 815 | 815 | $file_name = str_replace(_XE_PATH_, '', $bt_debug_print['file']); |
| 816 | 816 | $line_num = $bt_debug_print['line']; |
| 817 | - $function = $bt_called_function['class'] . $bt_called_function['type'] . $bt_called_function['function']; |
|
| 817 | + $function = $bt_called_function['class'].$bt_called_function['type'].$bt_called_function['function']; |
|
| 818 | 818 | |
| 819 | - if(__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1) |
|
| 819 | + if (__DEBUG_OUTPUT__ == 2 && version_compare(PHP_VERSION, '6.0.0') === -1) |
|
| 820 | 820 | { |
| 821 | - if(!isset($firephp)) |
|
| 821 | + if (!isset($firephp)) |
|
| 822 | 822 | { |
| 823 | 823 | $firephp = FirePHP::getInstance(TRUE); |
| 824 | 824 | } |
@@ -827,16 +827,16 @@ discard block |
||
| 827 | 827 | $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())); |
| 828 | 828 | |
| 829 | 829 | // Check a FirePHP option |
| 830 | - if($display_option === 'TABLE') |
|
| 830 | + if ($display_option === 'TABLE') |
|
| 831 | 831 | { |
| 832 | 832 | $label = $display_option; |
| 833 | 833 | } |
| 834 | - if($display_option === 'ERROR') |
|
| 834 | + if ($display_option === 'ERROR') |
|
| 835 | 835 | { |
| 836 | 836 | $type = $display_option; |
| 837 | 837 | } |
| 838 | 838 | // Check if the IP specified by __DEBUG_PROTECT__ option is same as the access IP. |
| 839 | - if(__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
|
| 839 | + if (__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
|
| 840 | 840 | { |
| 841 | 841 | $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'; |
| 842 | 842 | $label = NULL; |
@@ -846,18 +846,18 @@ discard block |
||
| 846 | 846 | } |
| 847 | 847 | else |
| 848 | 848 | { |
| 849 | - if(__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
|
| 849 | + if (__DEBUG_PROTECT__ === 1 && __DEBUG_PROTECT_IP__ != $_SERVER['REMOTE_ADDR']) |
|
| 850 | 850 | { |
| 851 | 851 | return; |
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | $print = array(); |
| 855 | - if($debug_file_exist === NULL) $print[] = '<?php exit() ?>'; |
|
| 855 | + if ($debug_file_exist === NULL) $print[] = '<?php exit() ?>'; |
|
| 856 | 856 | |
| 857 | - if(!$debug_file) $debug_file = _XE_PATH_ . 'files/' . $file; |
|
| 858 | - if(!$debug_file_exist) $debug_file_exist = file_exists($debug_file); |
|
| 857 | + if (!$debug_file) $debug_file = _XE_PATH_.'files/'.$file; |
|
| 858 | + if (!$debug_file_exist) $debug_file_exist = file_exists($debug_file); |
|
| 859 | 859 | |
| 860 | - if($display_option === TRUE || $display_option === 'ERROR') |
|
| 860 | + if ($display_option === TRUE || $display_option === 'ERROR') |
|
| 861 | 861 | { |
| 862 | 862 | $print[] = str_repeat('=', 80); |
| 863 | 863 | } |
@@ -865,10 +865,10 @@ discard block |
||
| 865 | 865 | $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())); |
| 866 | 866 | |
| 867 | 867 | $type = gettype($debug_output); |
| 868 | - if(!in_array($type, array('array', 'object', 'resource'))) |
|
| 868 | + if (!in_array($type, array('array', 'object', 'resource'))) |
|
| 869 | 869 | { |
| 870 | - if($display_option === 'ERROR') $print[] = 'ERROR : ' . var_export($debug_output, TRUE); |
|
| 871 | - else $print[] = $type . '(' . var_export($debug_output, TRUE) . ')'; |
|
| 870 | + if ($display_option === 'ERROR') $print[] = 'ERROR : '.var_export($debug_output, TRUE); |
|
| 871 | + else $print[] = $type.'('.var_export($debug_output, TRUE).')'; |
|
| 872 | 872 | $print[] = PHP_EOL.PHP_EOL; |
| 873 | 873 | } |
| 874 | 874 | else |
@@ -877,7 +877,7 @@ discard block |
||
| 877 | 877 | $print[] = PHP_EOL; |
| 878 | 878 | } |
| 879 | 879 | |
| 880 | - @file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND|LOCK_EX); |
|
| 880 | + @file_put_contents($debug_file, implode(PHP_EOL, $print), FILE_APPEND | LOCK_EX); |
|
| 881 | 881 | } |
| 882 | 882 | } |
| 883 | 883 | |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | */ |
| 889 | 889 | function writeSlowlog($type, $elapsed_time, $obj) |
| 890 | 890 | { |
| 891 | - if(!__LOG_SLOW_TRIGGER__ && !__LOG_SLOW_ADDON__ && !__LOG_SLOW_WIDGET__ && !__LOG_SLOW_QUERY__) return; |
|
| 891 | + if (!__LOG_SLOW_TRIGGER__ && !__LOG_SLOW_ADDON__ && !__LOG_SLOW_WIDGET__ && !__LOG_SLOW_QUERY__) return; |
|
| 892 | 892 | |
| 893 | 893 | static $log_filename = array( |
| 894 | 894 | 'query' => 'files/_slowlog_query.php', |
@@ -898,47 +898,47 @@ discard block |
||
| 898 | 898 | ); |
| 899 | 899 | $write_file = true; |
| 900 | 900 | |
| 901 | - $log_file = _XE_PATH_ . $log_filename[$type]; |
|
| 901 | + $log_file = _XE_PATH_.$log_filename[$type]; |
|
| 902 | 902 | |
| 903 | 903 | $buff = array(); |
| 904 | 904 | $buff[] = '<?php exit(); ?>'; |
| 905 | 905 | $buff[] = date('c'); |
| 906 | 906 | |
| 907 | - if($type == 'trigger' && __LOG_SLOW_TRIGGER__ > 0 && $elapsed_time > __LOG_SLOW_TRIGGER__) |
|
| 907 | + if ($type == 'trigger' && __LOG_SLOW_TRIGGER__ > 0 && $elapsed_time > __LOG_SLOW_TRIGGER__) |
|
| 908 | 908 | { |
| 909 | - $buff[] = "\tCaller : " . $obj->caller; |
|
| 910 | - $buff[] = "\tCalled : " . $obj->called; |
|
| 909 | + $buff[] = "\tCaller : ".$obj->caller; |
|
| 910 | + $buff[] = "\tCalled : ".$obj->called; |
|
| 911 | 911 | } |
| 912 | - else if($type == 'addon' && __LOG_SLOW_ADDON__ > 0 && $elapsed_time > __LOG_SLOW_ADDON__) |
|
| 912 | + else if ($type == 'addon' && __LOG_SLOW_ADDON__ > 0 && $elapsed_time > __LOG_SLOW_ADDON__) |
|
| 913 | 913 | { |
| 914 | - $buff[] = "\tAddon : " . $obj->called; |
|
| 915 | - $buff[] = "\tCalled position : " . $obj->caller; |
|
| 914 | + $buff[] = "\tAddon : ".$obj->called; |
|
| 915 | + $buff[] = "\tCalled position : ".$obj->caller; |
|
| 916 | 916 | } |
| 917 | - else if($type == 'widget' && __LOG_SLOW_WIDGET__ > 0 && $elapsed_time > __LOG_SLOW_WIDGET__) |
|
| 917 | + else if ($type == 'widget' && __LOG_SLOW_WIDGET__ > 0 && $elapsed_time > __LOG_SLOW_WIDGET__) |
|
| 918 | 918 | { |
| 919 | - $buff[] = "\tWidget : " . $obj->called; |
|
| 919 | + $buff[] = "\tWidget : ".$obj->called; |
|
| 920 | 920 | } |
| 921 | - else if($type == 'query' && __LOG_SLOW_QUERY__ > 0 && $elapsed_time > __LOG_SLOW_QUERY__) |
|
| 921 | + else if ($type == 'query' && __LOG_SLOW_QUERY__ > 0 && $elapsed_time > __LOG_SLOW_QUERY__) |
|
| 922 | 922 | { |
| 923 | 923 | |
| 924 | 924 | $buff[] = $obj->query; |
| 925 | - $buff[] = "\tQuery ID : " . $obj->query_id; |
|
| 926 | - $buff[] = "\tCaller : " . $obj->caller; |
|
| 927 | - $buff[] = "\tConnection : " . $obj->connection; |
|
| 925 | + $buff[] = "\tQuery ID : ".$obj->query_id; |
|
| 926 | + $buff[] = "\tCaller : ".$obj->caller; |
|
| 927 | + $buff[] = "\tConnection : ".$obj->connection; |
|
| 928 | 928 | } |
| 929 | 929 | else |
| 930 | 930 | { |
| 931 | 931 | $write_file = false; |
| 932 | 932 | } |
| 933 | 933 | |
| 934 | - if($write_file) |
|
| 934 | + if ($write_file) |
|
| 935 | 935 | { |
| 936 | 936 | $buff[] = sprintf("\t%0.6f sec", $elapsed_time); |
| 937 | - $buff[] = PHP_EOL . PHP_EOL; |
|
| 937 | + $buff[] = PHP_EOL.PHP_EOL; |
|
| 938 | 938 | file_put_contents($log_file, implode(PHP_EOL, $buff), FILE_APPEND); |
| 939 | 939 | } |
| 940 | 940 | |
| 941 | - if($type != 'query') |
|
| 941 | + if ($type != 'query') |
|
| 942 | 942 | { |
| 943 | 943 | $trigger_args = $obj; |
| 944 | 944 | $trigger_args->_log_type = $type; |
@@ -978,11 +978,11 @@ discard block |
||
| 978 | 978 | */ |
| 979 | 979 | function delObjectVars($target_obj, $del_obj) |
| 980 | 980 | { |
| 981 | - if(!is_object($target_obj)) |
|
| 981 | + if (!is_object($target_obj)) |
|
| 982 | 982 | { |
| 983 | 983 | return; |
| 984 | 984 | } |
| 985 | - if(!is_object($del_obj)) |
|
| 985 | + if (!is_object($del_obj)) |
|
| 986 | 986 | { |
| 987 | 987 | return; |
| 988 | 988 | } |
@@ -992,7 +992,7 @@ discard block |
||
| 992 | 992 | |
| 993 | 993 | $target = array_keys($target_vars); |
| 994 | 994 | $del = array_keys($del_vars); |
| 995 | - if(!count($target) || !count($del)) |
|
| 995 | + if (!count($target) || !count($del)) |
|
| 996 | 996 | { |
| 997 | 997 | return $target_obj; |
| 998 | 998 | } |
@@ -1000,10 +1000,10 @@ discard block |
||
| 1000 | 1000 | $return_obj = new stdClass(); |
| 1001 | 1001 | |
| 1002 | 1002 | $target_count = count($target); |
| 1003 | - for($i = 0; $i < $target_count; $i++) |
|
| 1003 | + for ($i = 0; $i < $target_count; $i++) |
|
| 1004 | 1004 | { |
| 1005 | 1005 | $target_key = $target[$i]; |
| 1006 | - if(!in_array($target_key, $del)) |
|
| 1006 | + if (!in_array($target_key, $del)) |
|
| 1007 | 1007 | { |
| 1008 | 1008 | $return_obj->{$target_key} = $target_obj->{$target_key}; |
| 1009 | 1009 | } |
@@ -1016,10 +1016,10 @@ discard block |
||
| 1016 | 1016 | { |
| 1017 | 1017 | $del_vars = array('error_return_url', 'success_return_url', 'ruleset', 'xe_validator_id'); |
| 1018 | 1018 | |
| 1019 | - foreach($del_vars as $var) |
|
| 1019 | + foreach ($del_vars as $var) |
|
| 1020 | 1020 | { |
| 1021 | - if(is_array($vars)) unset($vars[$var]); |
|
| 1022 | - else if(is_object($vars)) unset($vars->$var); |
|
| 1021 | + if (is_array($vars)) unset($vars[$var]); |
|
| 1022 | + else if (is_object($vars)) unset($vars->$var); |
|
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | 1025 | return $vars; |
@@ -1036,12 +1036,12 @@ discard block |
||
| 1036 | 1036 | */ |
| 1037 | 1037 | function handleError($errno, $errstr, $file, $line) |
| 1038 | 1038 | { |
| 1039 | - if(!__DEBUG__) |
|
| 1039 | + if (!__DEBUG__) |
|
| 1040 | 1040 | { |
| 1041 | 1041 | return; |
| 1042 | 1042 | } |
| 1043 | 1043 | $errors = array(E_USER_ERROR, E_ERROR, E_PARSE); |
| 1044 | - if(!in_array($errno, $errors)) |
|
| 1044 | + if (!in_array($errno, $errors)) |
|
| 1045 | 1045 | { |
| 1046 | 1046 | return; |
| 1047 | 1047 | } |
@@ -1061,8 +1061,8 @@ discard block |
||
| 1061 | 1061 | function getNumberingPath($no, $size = 3) |
| 1062 | 1062 | { |
| 1063 | 1063 | $mod = pow(10, $size); |
| 1064 | - $output = sprintf('%0' . $size . 'd/', $no % $mod); |
|
| 1065 | - if($no >= $mod) |
|
| 1064 | + $output = sprintf('%0'.$size.'d/', $no % $mod); |
|
| 1065 | + if ($no >= $mod) |
|
| 1066 | 1066 | { |
| 1067 | 1067 | $output .= getNumberingPath((int) $no / $mod, $size); |
| 1068 | 1068 | } |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | |
| 1083 | 1083 | function purifierHtml(&$content) |
| 1084 | 1084 | { |
| 1085 | - require_once(_XE_PATH_ . 'classes/security/Purifier.class.php'); |
|
| 1085 | + require_once(_XE_PATH_.'classes/security/Purifier.class.php'); |
|
| 1086 | 1086 | $oPurifier = Purifier::getInstance(); |
| 1087 | 1087 | $oPurifier->purify($content); |
| 1088 | 1088 | } |
@@ -1095,7 +1095,7 @@ discard block |
||
| 1095 | 1095 | */ |
| 1096 | 1096 | function removeHackTag($content) |
| 1097 | 1097 | { |
| 1098 | - require_once(_XE_PATH_ . 'classes/security/EmbedFilter.class.php'); |
|
| 1098 | + require_once(_XE_PATH_.'classes/security/EmbedFilter.class.php'); |
|
| 1099 | 1099 | $oEmbedFilter = EmbedFilter::getInstance(); |
| 1100 | 1100 | $oEmbedFilter->check($content); |
| 1101 | 1101 | |
@@ -1137,7 +1137,7 @@ discard block |
||
| 1137 | 1137 | */ |
| 1138 | 1138 | function checkUploadedFile($file) |
| 1139 | 1139 | { |
| 1140 | - require_once(_XE_PATH_ . 'classes/security/UploadFileFilter.class.php'); |
|
| 1140 | + require_once(_XE_PATH_.'classes/security/UploadFileFilter.class.php'); |
|
| 1141 | 1141 | return UploadFileFilter::check($file); |
| 1142 | 1142 | } |
| 1143 | 1143 | |
@@ -1151,13 +1151,13 @@ discard block |
||
| 1151 | 1151 | { |
| 1152 | 1152 | $content = preg_replace('@<(/?)xmp.*?>@i', '<\1xmp>', $content); |
| 1153 | 1153 | |
| 1154 | - if(($start_xmp = strrpos($content, '<xmp>')) !== FALSE) |
|
| 1154 | + if (($start_xmp = strrpos($content, '<xmp>')) !== FALSE) |
|
| 1155 | 1155 | { |
| 1156 | - if(($close_xmp = strrpos($content, '</xmp>')) === FALSE) |
|
| 1156 | + if (($close_xmp = strrpos($content, '</xmp>')) === FALSE) |
|
| 1157 | 1157 | { |
| 1158 | 1158 | $content .= '</xmp>'; |
| 1159 | 1159 | } |
| 1160 | - else if($close_xmp < $start_xmp) |
|
| 1160 | + else if ($close_xmp < $start_xmp) |
|
| 1161 | 1161 | { |
| 1162 | 1162 | $content .= '</xmp>'; |
| 1163 | 1163 | } |
@@ -1177,33 +1177,33 @@ discard block |
||
| 1177 | 1177 | $tag = strtolower($match[2]); |
| 1178 | 1178 | |
| 1179 | 1179 | // xmp tag ?뺣━ |
| 1180 | - if($tag == 'xmp') |
|
| 1180 | + if ($tag == 'xmp') |
|
| 1181 | 1181 | { |
| 1182 | 1182 | return "<{$match[1]}xmp>"; |
| 1183 | 1183 | } |
| 1184 | - if($match[1]) |
|
| 1184 | + if ($match[1]) |
|
| 1185 | 1185 | { |
| 1186 | 1186 | return $match[0]; |
| 1187 | 1187 | } |
| 1188 | - if($match[4]) |
|
| 1188 | + if ($match[4]) |
|
| 1189 | 1189 | { |
| 1190 | - $match[4] = ' ' . $match[4]; |
|
| 1190 | + $match[4] = ' '.$match[4]; |
|
| 1191 | 1191 | } |
| 1192 | 1192 | |
| 1193 | 1193 | $attrs = array(); |
| 1194 | - if(preg_match_all('/([\w:-]+)\s*=(?:\s*(["\']))?(?(2)(.*?)\2|([^ ]+))/s', $match[3], $m)) |
|
| 1194 | + if (preg_match_all('/([\w:-]+)\s*=(?:\s*(["\']))?(?(2)(.*?)\2|([^ ]+))/s', $match[3], $m)) |
|
| 1195 | 1195 | { |
| 1196 | - foreach($m[1] as $idx => $name) |
|
| 1196 | + foreach ($m[1] as $idx => $name) |
|
| 1197 | 1197 | { |
| 1198 | - if(strlen($name) >= 2 && substr_compare($name, 'on', 0, 2) === 0) |
|
| 1198 | + if (strlen($name) >= 2 && substr_compare($name, 'on', 0, 2) === 0) |
|
| 1199 | 1199 | { |
| 1200 | 1200 | continue; |
| 1201 | 1201 | } |
| 1202 | 1202 | |
| 1203 | - $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]); |
|
| 1203 | + $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]); |
|
| 1204 | 1204 | $val = preg_replace('/^\s+|[\t\n\r]+/', '', $val); |
| 1205 | 1205 | |
| 1206 | - if(preg_match('/^[a-z]+script:/i', $val)) |
|
| 1206 | + if (preg_match('/^[a-z]+script:/i', $val)) |
|
| 1207 | 1207 | { |
| 1208 | 1208 | continue; |
| 1209 | 1209 | } |
@@ -1214,60 +1214,60 @@ discard block |
||
| 1214 | 1214 | |
| 1215 | 1215 | $filter_arrts = array('style', 'src', 'href'); |
| 1216 | 1216 | |
| 1217 | - if($tag === 'object') array_push($filter_arrts, 'data'); |
|
| 1218 | - if($tag === 'param') array_push($filter_arrts, 'value'); |
|
| 1217 | + if ($tag === 'object') array_push($filter_arrts, 'data'); |
|
| 1218 | + if ($tag === 'param') array_push($filter_arrts, 'value'); |
|
| 1219 | 1219 | |
| 1220 | - foreach($filter_arrts as $attr) |
|
| 1220 | + foreach ($filter_arrts as $attr) |
|
| 1221 | 1221 | { |
| 1222 | - if(!isset($attrs[$attr])) continue; |
|
| 1222 | + if (!isset($attrs[$attr])) continue; |
|
| 1223 | 1223 | |
| 1224 | 1224 | $attr_value = rawurldecode($attrs[$attr]); |
| 1225 | 1225 | $attr_value = htmlspecialchars_decode($attr_value, ENT_COMPAT); |
| 1226 | 1226 | $attr_value = preg_replace('/\s+|[\t\n\r]+/', '', $attr_value); |
| 1227 | - if(preg_match('@(\?|&|;)(act=(\w+))@i', $attr_value, $m) && $m[3] !== 'procFileDownload') |
|
| 1227 | + if (preg_match('@(\?|&|;)(act=(\w+))@i', $attr_value, $m) && $m[3] !== 'procFileDownload') |
|
| 1228 | 1228 | { |
| 1229 | 1229 | unset($attrs[$attr]); |
| 1230 | 1230 | } |
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | - if(isset($attrs['style']) && preg_match('@(?:/\*|\*/|\n|:\s*expression\s*\()@i', $attrs['style'])) |
|
| 1233 | + if (isset($attrs['style']) && preg_match('@(?:/\*|\*/|\n|:\s*expression\s*\()@i', $attrs['style'])) |
|
| 1234 | 1234 | { |
| 1235 | 1235 | unset($attrs['style']); |
| 1236 | 1236 | } |
| 1237 | 1237 | |
| 1238 | 1238 | $attr = array(); |
| 1239 | - foreach($attrs as $name => $val) |
|
| 1239 | + foreach ($attrs as $name => $val) |
|
| 1240 | 1240 | { |
| 1241 | - if($tag == 'object' || $tag == 'embed' || $tag == 'a') |
|
| 1241 | + if ($tag == 'object' || $tag == 'embed' || $tag == 'a') |
|
| 1242 | 1242 | { |
| 1243 | 1243 | $attribute = strtolower(trim($name)); |
| 1244 | - if($attribute == 'data' || $attribute == 'src' || $attribute == 'href') |
|
| 1244 | + if ($attribute == 'data' || $attribute == 'src' || $attribute == 'href') |
|
| 1245 | 1245 | { |
| 1246 | - if(stripos($val, 'data:') === 0) |
|
| 1246 | + if (stripos($val, 'data:') === 0) |
|
| 1247 | 1247 | { |
| 1248 | 1248 | continue; |
| 1249 | 1249 | } |
| 1250 | 1250 | } |
| 1251 | 1251 | } |
| 1252 | 1252 | |
| 1253 | - if($tag == 'img') |
|
| 1253 | + if ($tag == 'img') |
|
| 1254 | 1254 | { |
| 1255 | 1255 | $attribute = strtolower(trim($name)); |
| 1256 | - if(stripos($val, 'data:') === 0) |
|
| 1256 | + if (stripos($val, 'data:') === 0) |
|
| 1257 | 1257 | { |
| 1258 | 1258 | continue; |
| 1259 | 1259 | } |
| 1260 | 1260 | } |
| 1261 | 1261 | $val = str_replace('"', '"', $val); |
| 1262 | - $attr[] = $name . "=\"{$val}\""; |
|
| 1262 | + $attr[] = $name."=\"{$val}\""; |
|
| 1263 | 1263 | } |
| 1264 | - $attr = count($attr) ? ' ' . implode(' ', $attr) : ''; |
|
| 1264 | + $attr = count($attr) ? ' '.implode(' ', $attr) : ''; |
|
| 1265 | 1265 | |
| 1266 | 1266 | return "<{$match[1]}{$tag}{$attr}{$match[4]}>"; |
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | 1269 | // convert hexa value to RGB |
| 1270 | -if(!function_exists('hexrgb')) |
|
| 1270 | +if (!function_exists('hexrgb')) |
|
| 1271 | 1271 | { |
| 1272 | 1272 | |
| 1273 | 1273 | /** |
@@ -1303,9 +1303,9 @@ discard block |
||
| 1303 | 1303 | |
| 1304 | 1304 | settype($password, "string"); |
| 1305 | 1305 | |
| 1306 | - for($i = 0; $i < strlen($password); $i++) |
|
| 1306 | + for ($i = 0; $i < strlen($password); $i++) |
|
| 1307 | 1307 | { |
| 1308 | - if($password[$i] == ' ' || $password[$i] == '\t') |
|
| 1308 | + if ($password[$i] == ' ' || $password[$i] == '\t') |
|
| 1309 | 1309 | { |
| 1310 | 1310 | continue; |
| 1311 | 1311 | } |
@@ -1317,11 +1317,11 @@ discard block |
||
| 1317 | 1317 | $result1 = sprintf("%08lx", $nr & ((1 << 31) - 1)); |
| 1318 | 1318 | $result2 = sprintf("%08lx", $nr2 & ((1 << 31) - 1)); |
| 1319 | 1319 | |
| 1320 | - if($result1 == '80000000') |
|
| 1320 | + if ($result1 == '80000000') |
|
| 1321 | 1321 | { |
| 1322 | 1322 | $nr += 0x80000000; |
| 1323 | 1323 | } |
| 1324 | - if($result2 == '80000000') |
|
| 1324 | + if ($result2 == '80000000') |
|
| 1325 | 1325 | { |
| 1326 | 1326 | $nr2 += 0x80000000; |
| 1327 | 1327 | } |
@@ -1337,7 +1337,7 @@ discard block |
||
| 1337 | 1337 | function getScriptPath() |
| 1338 | 1338 | { |
| 1339 | 1339 | static $url = NULL; |
| 1340 | - if($url == NULL) |
|
| 1340 | + if ($url == NULL) |
|
| 1341 | 1341 | { |
| 1342 | 1342 | $url = str_ireplace('/tools/', '/', preg_replace('/index.php$/i', '', str_replace('\\', '/', $_SERVER['SCRIPT_NAME']))); |
| 1343 | 1343 | } |
@@ -1367,14 +1367,14 @@ discard block |
||
| 1367 | 1367 | $decodedStr = ''; |
| 1368 | 1368 | $pos = 0; |
| 1369 | 1369 | $len = strlen($source); |
| 1370 | - while($pos < $len) |
|
| 1370 | + while ($pos < $len) |
|
| 1371 | 1371 | { |
| 1372 | 1372 | $charAt = substr($source, $pos, 1); |
| 1373 | - if($charAt == '%') |
|
| 1373 | + if ($charAt == '%') |
|
| 1374 | 1374 | { |
| 1375 | 1375 | $pos++; |
| 1376 | 1376 | $charAt = substr($source, $pos, 1); |
| 1377 | - if($charAt == 'u') |
|
| 1377 | + if ($charAt == 'u') |
|
| 1378 | 1378 | { |
| 1379 | 1379 | // we got a unicode character |
| 1380 | 1380 | $pos++; |
@@ -1408,21 +1408,21 @@ discard block |
||
| 1408 | 1408 | */ |
| 1409 | 1409 | function _code2utf($num) |
| 1410 | 1410 | { |
| 1411 | - if($num < 128) |
|
| 1411 | + if ($num < 128) |
|
| 1412 | 1412 | { |
| 1413 | 1413 | return chr($num); |
| 1414 | 1414 | } |
| 1415 | - if($num < 2048) |
|
| 1415 | + if ($num < 2048) |
|
| 1416 | 1416 | { |
| 1417 | - return chr(($num >> 6) + 192) . chr(($num & 63) + 128); |
|
| 1417 | + return chr(($num >> 6) + 192).chr(($num & 63) + 128); |
|
| 1418 | 1418 | } |
| 1419 | - if($num < 65536) |
|
| 1419 | + if ($num < 65536) |
|
| 1420 | 1420 | { |
| 1421 | - return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 1421 | + return chr(($num >> 12) + 224).chr((($num >> 6) & 63) + 128).chr(($num & 63) + 128); |
|
| 1422 | 1422 | } |
| 1423 | - if($num < 2097152) |
|
| 1423 | + if ($num < 2097152) |
|
| 1424 | 1424 | { |
| 1425 | - return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); |
|
| 1425 | + return chr(($num >> 18) + 240).chr((($num >> 12) & 63) + 128).chr((($num >> 6) & 63) + 128).chr(($num & 63) + 128); |
|
| 1426 | 1426 | } |
| 1427 | 1427 | return ''; |
| 1428 | 1428 | } |
@@ -1437,7 +1437,7 @@ discard block |
||
| 1437 | 1437 | */ |
| 1438 | 1438 | function detectUTF8($string, $return_convert = FALSE, $urldecode = TRUE) |
| 1439 | 1439 | { |
| 1440 | - if($urldecode) |
|
| 1440 | + if ($urldecode) |
|
| 1441 | 1441 | { |
| 1442 | 1442 | $string = urldecode($string); |
| 1443 | 1443 | } |
@@ -1445,12 +1445,12 @@ discard block |
||
| 1445 | 1445 | $sample = iconv('utf-8', 'utf-8', $string); |
| 1446 | 1446 | $is_utf8 = (md5($sample) === md5($string)); |
| 1447 | 1447 | |
| 1448 | - if(!$urldecode) |
|
| 1448 | + if (!$urldecode) |
|
| 1449 | 1449 | { |
| 1450 | 1450 | $string = urldecode($string); |
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | - if($return_convert) |
|
| 1453 | + if ($return_convert) |
|
| 1454 | 1454 | { |
| 1455 | 1455 | return ($is_utf8) ? $string : iconv('euc-kr', 'utf-8', $string); |
| 1456 | 1456 | } |
@@ -1466,7 +1466,7 @@ discard block |
||
| 1466 | 1466 | */ |
| 1467 | 1467 | function json_encode2($data) |
| 1468 | 1468 | { |
| 1469 | - switch(gettype($data)) |
|
| 1469 | + switch (gettype($data)) |
|
| 1470 | 1470 | { |
| 1471 | 1471 | case 'boolean': |
| 1472 | 1472 | return $data ? 'true' : 'false'; |
@@ -1474,15 +1474,15 @@ discard block |
||
| 1474 | 1474 | case 'double': |
| 1475 | 1475 | return $data; |
| 1476 | 1476 | case 'string': |
| 1477 | - return '"' . strtr($data, array('\\' => '\\\\', '"' => '\\"')) . '"'; |
|
| 1477 | + return '"'.strtr($data, array('\\' => '\\\\', '"' => '\\"')).'"'; |
|
| 1478 | 1478 | case 'object': |
| 1479 | 1479 | $data = get_object_vars($data); |
| 1480 | 1480 | case 'array': |
| 1481 | 1481 | $rel = FALSE; // relative array? |
| 1482 | 1482 | $key = array_keys($data); |
| 1483 | - foreach($key as $v) |
|
| 1483 | + foreach ($key as $v) |
|
| 1484 | 1484 | { |
| 1485 | - if(!is_int($v)) |
|
| 1485 | + if (!is_int($v)) |
|
| 1486 | 1486 | { |
| 1487 | 1487 | $rel = TRUE; |
| 1488 | 1488 | break; |
@@ -1490,12 +1490,12 @@ discard block |
||
| 1490 | 1490 | } |
| 1491 | 1491 | |
| 1492 | 1492 | $arr = array(); |
| 1493 | - foreach($data as $k => $v) |
|
| 1493 | + foreach ($data as $k => $v) |
|
| 1494 | 1494 | { |
| 1495 | - $arr[] = ($rel ? '"' . strtr($k, array('\\' => '\\\\', '"' => '\\"')) . '":' : '') . json_encode2($v); |
|
| 1495 | + $arr[] = ($rel ? '"'.strtr($k, array('\\' => '\\\\', '"' => '\\"')).'":' : '').json_encode2($v); |
|
| 1496 | 1496 | } |
| 1497 | 1497 | |
| 1498 | - return $rel ? '{' . join(',', $arr) . '}' : '[' . join(',', $arr) . ']'; |
|
| 1498 | + return $rel ? '{'.join(',', $arr).'}' : '['.join(',', $arr).']'; |
|
| 1499 | 1499 | default: |
| 1500 | 1500 | return '""'; |
| 1501 | 1501 | } |
@@ -1509,7 +1509,7 @@ discard block |
||
| 1509 | 1509 | */ |
| 1510 | 1510 | function isCrawler($agent = NULL) |
| 1511 | 1511 | { |
| 1512 | - if(!$agent) |
|
| 1512 | + if (!$agent) |
|
| 1513 | 1513 | { |
| 1514 | 1514 | $agent = $_SERVER['HTTP_USER_AGENT']; |
| 1515 | 1515 | } |
@@ -1519,9 +1519,9 @@ discard block |
||
| 1519 | 1519 | /*'211.245.21.110-211.245.21.119' mixsh is closed */ |
| 1520 | 1520 | ); |
| 1521 | 1521 | |
| 1522 | - foreach($check_agent as $str) |
|
| 1522 | + foreach ($check_agent as $str) |
|
| 1523 | 1523 | { |
| 1524 | - if(stristr($agent, $str) != FALSE) |
|
| 1524 | + if (stristr($agent, $str) != FALSE) |
|
| 1525 | 1525 | { |
| 1526 | 1526 | return TRUE; |
| 1527 | 1527 | } |
@@ -1539,7 +1539,7 @@ discard block |
||
| 1539 | 1539 | */ |
| 1540 | 1540 | function stripEmbedTagForAdmin(&$content, $writer_member_srl) |
| 1541 | 1541 | { |
| 1542 | - if(!Context::get('is_logged')) |
|
| 1542 | + if (!Context::get('is_logged')) |
|
| 1543 | 1543 | { |
| 1544 | 1544 | return; |
| 1545 | 1545 | } |
@@ -1547,18 +1547,18 @@ discard block |
||
| 1547 | 1547 | $oModuleModel = getModel('module'); |
| 1548 | 1548 | $logged_info = Context::get('logged_info'); |
| 1549 | 1549 | |
| 1550 | - if($writer_member_srl != $logged_info->member_srl && ($logged_info->is_admin == "Y" || $oModuleModel->isSiteAdmin($logged_info))) |
|
| 1550 | + if ($writer_member_srl != $logged_info->member_srl && ($logged_info->is_admin == "Y" || $oModuleModel->isSiteAdmin($logged_info))) |
|
| 1551 | 1551 | { |
| 1552 | - if($writer_member_srl) |
|
| 1552 | + if ($writer_member_srl) |
|
| 1553 | 1553 | { |
| 1554 | 1554 | $oMemberModel = getModel('member'); |
| 1555 | 1555 | $member_info = $oMemberModel->getMemberInfoByMemberSrl($writer_member_srl); |
| 1556 | - if($member_info->is_admin == "Y") |
|
| 1556 | + if ($member_info->is_admin == "Y") |
|
| 1557 | 1557 | { |
| 1558 | 1558 | return; |
| 1559 | 1559 | } |
| 1560 | 1560 | } |
| 1561 | - $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>"; |
|
| 1561 | + $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>"; |
|
| 1562 | 1562 | $content = preg_replace('/<object[^>]+>(.*?<\/object>)?/is', $security_msg, $content); |
| 1563 | 1563 | $content = preg_replace('/<embed[^>]+>(\s*<\/embed>)?/is', $security_msg, $content); |
| 1564 | 1564 | $content = preg_replace('/<img[^>]+editor_component="multimedia_link"[^>]*>(\s*<\/img>)?/is', $security_msg, $content); |
@@ -1575,18 +1575,18 @@ discard block |
||
| 1575 | 1575 | function requirePear() |
| 1576 | 1576 | { |
| 1577 | 1577 | static $required = false; |
| 1578 | - if($required) |
|
| 1578 | + if ($required) |
|
| 1579 | 1579 | { |
| 1580 | 1580 | return; |
| 1581 | 1581 | } |
| 1582 | 1582 | |
| 1583 | - if(version_compare(PHP_VERSION, "5.3.0") < 0) |
|
| 1583 | + if (version_compare(PHP_VERSION, "5.3.0") < 0) |
|
| 1584 | 1584 | { |
| 1585 | - set_include_path(_XE_PATH_ . "libs/PEAR" . PATH_SEPARATOR . get_include_path()); |
|
| 1585 | + set_include_path(_XE_PATH_."libs/PEAR".PATH_SEPARATOR.get_include_path()); |
|
| 1586 | 1586 | } |
| 1587 | 1587 | else |
| 1588 | 1588 | { |
| 1589 | - set_include_path(_XE_PATH_ . "libs/PEAR.1.9.5" . PATH_SEPARATOR . get_include_path()); |
|
| 1589 | + set_include_path(_XE_PATH_."libs/PEAR.1.9.5".PATH_SEPARATOR.get_include_path()); |
|
| 1590 | 1590 | } |
| 1591 | 1591 | |
| 1592 | 1592 | $required = true; |
@@ -1594,7 +1594,7 @@ discard block |
||
| 1594 | 1594 | |
| 1595 | 1595 | function checkCSRF() |
| 1596 | 1596 | { |
| 1597 | - if($_SERVER['REQUEST_METHOD'] != 'POST') |
|
| 1597 | + if ($_SERVER['REQUEST_METHOD'] != 'POST') |
|
| 1598 | 1598 | { |
| 1599 | 1599 | return FALSE; |
| 1600 | 1600 | } |
@@ -1602,9 +1602,9 @@ discard block |
||
| 1602 | 1602 | $default_url = Context::getDefaultUrl(); |
| 1603 | 1603 | $referer = $_SERVER["HTTP_REFERER"]; |
| 1604 | 1604 | |
| 1605 | - if(strpos($default_url, 'xn--') !== FALSE && strpos($referer, 'xn--') === FALSE) |
|
| 1605 | + if (strpos($default_url, 'xn--') !== FALSE && strpos($referer, 'xn--') === FALSE) |
|
| 1606 | 1606 | { |
| 1607 | - require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php'); |
|
| 1607 | + require_once(_XE_PATH_.'libs/idna_convert/idna_convert.class.php'); |
|
| 1608 | 1608 | $IDN = new idna_convert(array('idn_version' => 2008)); |
| 1609 | 1609 | $referer = $IDN->encode($referer); |
| 1610 | 1610 | } |
@@ -1615,9 +1615,9 @@ discard block |
||
| 1615 | 1615 | $oModuleModel = getModel('module'); |
| 1616 | 1616 | $siteModuleInfo = $oModuleModel->getDefaultMid(); |
| 1617 | 1617 | |
| 1618 | - if($siteModuleInfo->site_srl == 0) |
|
| 1618 | + if ($siteModuleInfo->site_srl == 0) |
|
| 1619 | 1619 | { |
| 1620 | - if($default_url['host'] !== $referer['host']) |
|
| 1620 | + if ($default_url['host'] !== $referer['host']) |
|
| 1621 | 1621 | { |
| 1622 | 1622 | return FALSE; |
| 1623 | 1623 | } |
@@ -1625,7 +1625,7 @@ discard block |
||
| 1625 | 1625 | else |
| 1626 | 1626 | { |
| 1627 | 1627 | $virtualSiteInfo = $oModuleModel->getSiteInfo($siteModuleInfo->site_srl); |
| 1628 | - if(strtolower($virtualSiteInfo->domain) != strtolower(Context::get('vid')) && !strstr(strtolower($virtualSiteInfo->domain), strtolower($referer['host']))) |
|
| 1628 | + if (strtolower($virtualSiteInfo->domain) != strtolower(Context::get('vid')) && !strstr(strtolower($virtualSiteInfo->domain), strtolower($referer['host']))) |
|
| 1629 | 1629 | { |
| 1630 | 1630 | return FALSE; |
| 1631 | 1631 | } |
@@ -1641,15 +1641,15 @@ discard block |
||
| 1641 | 1641 | */ |
| 1642 | 1642 | function recurciveExposureCheck(&$menu) |
| 1643 | 1643 | { |
| 1644 | - if(is_array($menu)) |
|
| 1644 | + if (is_array($menu)) |
|
| 1645 | 1645 | { |
| 1646 | - foreach($menu AS $key=>$value) |
|
| 1646 | + foreach ($menu AS $key=>$value) |
|
| 1647 | 1647 | { |
| 1648 | - if(!$value['isShow']) |
|
| 1648 | + if (!$value['isShow']) |
|
| 1649 | 1649 | { |
| 1650 | 1650 | unset($menu[$key]); |
| 1651 | 1651 | } |
| 1652 | - if(is_array($value['list']) && count($value['list']) > 0) |
|
| 1652 | + if (is_array($value['list']) && count($value['list']) > 0) |
|
| 1653 | 1653 | { |
| 1654 | 1654 | recurciveExposureCheck($menu[$key]['list']); |
| 1655 | 1655 | } |
@@ -1659,14 +1659,14 @@ discard block |
||
| 1659 | 1659 | |
| 1660 | 1660 | function changeValueInUrl($key, $requestKey, $dbKey, $urlName = 'success_return_url') |
| 1661 | 1661 | { |
| 1662 | - if($requestKey != $dbKey) |
|
| 1662 | + if ($requestKey != $dbKey) |
|
| 1663 | 1663 | { |
| 1664 | 1664 | $arrayUrl = parse_url(Context::get('success_return_url')); |
| 1665 | - if($arrayUrl['query']) |
|
| 1665 | + if ($arrayUrl['query']) |
|
| 1666 | 1666 | { |
| 1667 | 1667 | parse_str($arrayUrl['query'], $parsedStr); |
| 1668 | 1668 | |
| 1669 | - if(isset($parsedStr[$key])) |
|
| 1669 | + if (isset($parsedStr[$key])) |
|
| 1670 | 1670 | { |
| 1671 | 1671 | $parsedStr[$key] = $requestKey; |
| 1672 | 1672 | $successReturnUrl .= $arrayUrl['path'].'?'.http_build_query($parsedStr); |
@@ -1709,14 +1709,14 @@ discard block |
||
| 1709 | 1709 | */ |
| 1710 | 1710 | function alertScript($msg) |
| 1711 | 1711 | { |
| 1712 | - if(!$msg) |
|
| 1712 | + if (!$msg) |
|
| 1713 | 1713 | { |
| 1714 | 1714 | return; |
| 1715 | 1715 | } |
| 1716 | 1716 | |
| 1717 | 1717 | echo '<script type="text/javascript"> |
| 1718 | 1718 | //<![CDATA[ |
| 1719 | -alert("' . $msg . '"); |
|
| 1719 | +alert("' . $msg.'"); |
|
| 1720 | 1720 | //]]> |
| 1721 | 1721 | </script>'; |
| 1722 | 1722 | } |
@@ -1747,7 +1747,7 @@ discard block |
||
| 1747 | 1747 | |
| 1748 | 1748 | echo '<script type="text/javascript"> |
| 1749 | 1749 | //<![CDATA[ |
| 1750 | -' . $reloadScript . ' |
|
| 1750 | +' . $reloadScript.' |
|
| 1751 | 1751 | //]]> |
| 1752 | 1752 | </script>'; |
| 1753 | 1753 | } |
@@ -19,11 +19,11 @@ |
||
| 19 | 19 | { |
| 20 | 20 | $event = $subject->getLastEvent(); |
| 21 | 21 | |
| 22 | - switch($event['name']) |
|
| 22 | + switch ($event['name']) |
|
| 23 | 23 | { |
| 24 | 24 | case 'receivedHeaders': |
| 25 | 25 | $this->fp = @fopen($this->filename, 'wb'); |
| 26 | - if(!$this->fp) |
|
| 26 | + if (!$this->fp) |
|
| 27 | 27 | { |
| 28 | 28 | throw new Exception("Cannot open target file '{$filename}'"); |
| 29 | 29 | } |
@@ -29,24 +29,24 @@ discard block |
||
| 29 | 29 | $file_info = $_FILES['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 | - if($output->error != '0') $this->stop($output->message); |
|
| 49 | + if ($output->error != '0') $this->stop($output->message); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -61,26 +61,26 @@ discard block |
||
| 61 | 61 | $callback = Context::get('callback'); |
| 62 | 62 | $module_srl = $this->module_srl; |
| 63 | 63 | $upload_target_srl = intval(Context::get('uploadTargetSrl')); |
| 64 | - if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
| 64 | + if (!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
| 65 | 65 | |
| 66 | 66 | // Exit a session if there is neither upload permission nor information |
| 67 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
| 67 | + if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
| 68 | 68 | // Extract from session information if upload_target_srl is not specified |
| 69 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
| 69 | + if (!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
| 70 | 70 | // Create if upload_target_srl is not defined in the session information |
| 71 | - if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
| 71 | + if (!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
| 72 | 72 | // Delete and then attempt to re-upload if file_srl is requested |
| 73 | 73 | $file_srl = Context::get('file_srl'); |
| 74 | - if($file_srl) $this->deleteFile($file_srl); |
|
| 74 | + if ($file_srl) $this->deleteFile($file_srl); |
|
| 75 | 75 | |
| 76 | 76 | $file_info = Context::get('Filedata'); |
| 77 | 77 | // An error appears if not a normally uploaded file |
| 78 | - if(is_uploaded_file($file_info['tmp_name'])) { |
|
| 78 | + if (is_uploaded_file($file_info['tmp_name'])) { |
|
| 79 | 79 | $output = $this->insertFile($file_info, $module_srl, $upload_target_srl); |
| 80 | - Context::set('uploaded_fileinfo',$output); |
|
| 80 | + Context::set('uploaded_fileinfo', $output); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - Context::set('layout','none'); |
|
| 83 | + Context::set('layout', 'none'); |
|
| 84 | 84 | |
| 85 | 85 | $this->setTemplatePath($this->module_path.'tpl'); |
| 86 | 86 | $this->setTemplateFile('iframe'); |
@@ -97,24 +97,24 @@ discard block |
||
| 97 | 97 | $width = Context::get('width'); |
| 98 | 98 | $height = Context::get('height'); |
| 99 | 99 | |
| 100 | - if(!$file_srl || !$width) |
|
| 100 | + if (!$file_srl || !$width) |
|
| 101 | 101 | { |
| 102 | - return new Object(-1,'msg_invalid_request'); |
|
| 102 | + return new Object(-1, 'msg_invalid_request'); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $oFileModel = getModel('file'); |
| 106 | 106 | $fileInfo = $oFileModel->getFile($file_srl); |
| 107 | - if(!$fileInfo || $fileInfo->direct_download != 'Y') |
|
| 107 | + if (!$fileInfo || $fileInfo->direct_download != 'Y') |
|
| 108 | 108 | { |
| 109 | - return new Object(-1,'msg_invalid_request'); |
|
| 109 | + return new Object(-1, 'msg_invalid_request'); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | $source_src = $fileInfo->uploaded_filename; |
| 113 | - $output_src = $source_src . '.resized' . strrchr($source_src,'.'); |
|
| 113 | + $output_src = $source_src.'.resized'.strrchr($source_src, '.'); |
|
| 114 | 114 | |
| 115 | - if(!$height) $height = $width-1; |
|
| 115 | + if (!$height) $height = $width - 1; |
|
| 116 | 116 | |
| 117 | - if(FileHandler::createImageFile($source_src,$output_src,$width,$height,'','ratio')) |
|
| 117 | + if (FileHandler::createImageFile($source_src, $output_src, $width, $height, '', 'ratio')) |
|
| 118 | 118 | { |
| 119 | 119 | $output = new stdClass(); |
| 120 | 120 | $output->info = getimagesize($output_src); |
@@ -122,10 +122,10 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | else |
| 124 | 124 | { |
| 125 | - return new Object(-1,'msg_invalid_request'); |
|
| 125 | + return new Object(-1, 'msg_invalid_request'); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $this->add('resized_info',$output); |
|
| 128 | + $this->add('resized_info', $output); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | { |
| 164 | 164 | $oFileModel = getModel('file'); |
| 165 | 165 | |
| 166 | - if(isset($this->grant->access) && $this->grant->access !== true) return new Object(-1, 'msg_not_permitted'); |
|
| 166 | + if (isset($this->grant->access) && $this->grant->access !== true) return new Object(-1, 'msg_not_permitted'); |
|
| 167 | 167 | |
| 168 | 168 | $file_srl = Context::get('file_srl'); |
| 169 | 169 | $sid = Context::get('sid'); |
@@ -172,26 +172,26 @@ discard block |
||
| 172 | 172 | $columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type'); |
| 173 | 173 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
| 174 | 174 | // If the requested file information is incorrect, an error that file cannot be found appears |
| 175 | - if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) return $this->stop('msg_file_not_found'); |
|
| 175 | + if ($file_obj->file_srl != $file_srl || $file_obj->sid != $sid) return $this->stop('msg_file_not_found'); |
|
| 176 | 176 | // Notify that file download is not allowed when standing-by(Only a top-administrator is permitted) |
| 177 | - if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') return $this->stop('msg_not_permitted_download'); |
|
| 177 | + if ($logged_info->is_admin != 'Y' && $file_obj->isvalid != 'Y') return $this->stop('msg_not_permitted_download'); |
|
| 178 | 178 | // File name |
| 179 | 179 | $filename = $file_obj->source_filename; |
| 180 | 180 | $file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl); |
| 181 | 181 | // Not allow the file outlink |
| 182 | - if($file_module_config->allow_outlink == 'N') |
|
| 182 | + if ($file_module_config->allow_outlink == 'N') |
|
| 183 | 183 | { |
| 184 | 184 | // Handles extension to allow outlink |
| 185 | - if($file_module_config->allow_outlink_format) |
|
| 185 | + if ($file_module_config->allow_outlink_format) |
|
| 186 | 186 | { |
| 187 | 187 | $allow_outlink_format_array = array(); |
| 188 | 188 | $allow_outlink_format_array = explode(',', $file_module_config->allow_outlink_format); |
| 189 | - if(!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format; |
|
| 189 | + if (!is_array($allow_outlink_format_array)) $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format; |
|
| 190 | 190 | |
| 191 | - foreach($allow_outlink_format_array as $val) |
|
| 191 | + foreach ($allow_outlink_format_array as $val) |
|
| 192 | 192 | { |
| 193 | 193 | $val = trim($val); |
| 194 | - if(preg_match("/\.{$val}$/i", $filename)) |
|
| 194 | + if (preg_match("/\.{$val}$/i", $filename)) |
|
| 195 | 195 | { |
| 196 | 196 | $file_module_config->allow_outlink = 'Y'; |
| 197 | 197 | break; |
@@ -199,21 +199,21 @@ discard block |
||
| 199 | 199 | } |
| 200 | 200 | } |
| 201 | 201 | // Sites that outlink is allowed |
| 202 | - if($file_module_config->allow_outlink != 'Y') |
|
| 202 | + if ($file_module_config->allow_outlink != 'Y') |
|
| 203 | 203 | { |
| 204 | 204 | $referer = parse_url($_SERVER["HTTP_REFERER"]); |
| 205 | - if($referer['host'] != $_SERVER['HTTP_HOST']) |
|
| 205 | + if ($referer['host'] != $_SERVER['HTTP_HOST']) |
|
| 206 | 206 | { |
| 207 | - if($file_module_config->allow_outlink_site) |
|
| 207 | + if ($file_module_config->allow_outlink_site) |
|
| 208 | 208 | { |
| 209 | 209 | $allow_outlink_site_array = array(); |
| 210 | 210 | $allow_outlink_site_array = explode("\n", $file_module_config->allow_outlink_site); |
| 211 | - if(!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
| 211 | + if (!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
| 212 | 212 | |
| 213 | - foreach($allow_outlink_site_array as $val) |
|
| 213 | + foreach ($allow_outlink_site_array as $val) |
|
| 214 | 214 | { |
| 215 | 215 | $site = parse_url(trim($val)); |
| 216 | - if($site['host'] == $referer['host']) |
|
| 216 | + if ($site['host'] == $referer['host']) |
|
| 217 | 217 | { |
| 218 | 218 | $file_module_config->allow_outlink = 'Y'; |
| 219 | 219 | break; |
@@ -223,49 +223,49 @@ discard block |
||
| 223 | 223 | } |
| 224 | 224 | else $file_module_config->allow_outlink = 'Y'; |
| 225 | 225 | } |
| 226 | - if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink'); |
|
| 226 | + if ($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink'); |
|
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | // Check if a permission for file download is granted |
| 230 | 230 | $downloadGrantCount = 0; |
| 231 | - if(is_array($file_module_config->download_grant)) |
|
| 231 | + if (is_array($file_module_config->download_grant)) |
|
| 232 | 232 | { |
| 233 | - foreach($file_module_config->download_grant AS $value) |
|
| 234 | - if($value) $downloadGrantCount++; |
|
| 233 | + foreach ($file_module_config->download_grant AS $value) |
|
| 234 | + if ($value) $downloadGrantCount++; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | - if(is_array($file_module_config->download_grant) && $downloadGrantCount>0) |
|
| 237 | + if (is_array($file_module_config->download_grant) && $downloadGrantCount > 0) |
|
| 238 | 238 | { |
| 239 | - if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); |
|
| 239 | + if (!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); |
|
| 240 | 240 | $logged_info = Context::get('logged_info'); |
| 241 | - if($logged_info->is_admin != 'Y') |
|
| 241 | + if ($logged_info->is_admin != 'Y') |
|
| 242 | 242 | { |
| 243 | - $oModuleModel =& getModel('module'); |
|
| 243 | + $oModuleModel = & getModel('module'); |
|
| 244 | 244 | $columnList = array('module_srl', 'site_srl'); |
| 245 | 245 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($file_obj->module_srl, $columnList); |
| 246 | 246 | |
| 247 | - if(!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl)) |
|
| 247 | + if (!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl)) |
|
| 248 | 248 | { |
| 249 | - $oMemberModel =& getModel('member'); |
|
| 249 | + $oMemberModel = & getModel('member'); |
|
| 250 | 250 | $member_groups = $oMemberModel->getMemberGroups($logged_info->member_srl, $module_info->site_srl); |
| 251 | 251 | |
| 252 | 252 | $is_permitted = false; |
| 253 | - for($i=0;$i<count($file_module_config->download_grant);$i++) |
|
| 253 | + for ($i = 0; $i < count($file_module_config->download_grant); $i++) |
|
| 254 | 254 | { |
| 255 | 255 | $group_srl = $file_module_config->download_grant[$i]; |
| 256 | - if($member_groups[$group_srl]) |
|
| 256 | + if ($member_groups[$group_srl]) |
|
| 257 | 257 | { |
| 258 | 258 | $is_permitted = true; |
| 259 | 259 | break; |
| 260 | 260 | } |
| 261 | 261 | } |
| 262 | - if(!$is_permitted) return $this->stop('msg_not_permitted_download'); |
|
| 262 | + if (!$is_permitted) return $this->stop('msg_not_permitted_download'); |
|
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | } |
| 266 | 266 | // Call a trigger (before) |
| 267 | 267 | $output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj); |
| 268 | - if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download'); |
|
| 268 | + if (!$output->toBool()) return $this->stop(($output->message) ? $output->message : 'msg_not_permitted_download'); |
|
| 269 | 269 | |
| 270 | 270 | |
| 271 | 271 | // 다운로드 후 (가상) |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | |
| 279 | 279 | $random = new Password(); |
| 280 | 280 | $file_key = $_SESSION['__XE_FILE_KEY__'][$file_srl] = $random->createSecureSalt(32, 'hex'); |
| 281 | - header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput','file_srl',$file_srl,'file_key',$file_key)); |
|
| 281 | + header('Location: '.getNotEncodedUrl('', 'act', 'procFileOutput', 'file_srl', $file_srl, 'file_key', $file_key)); |
|
| 282 | 282 | Context::close(); |
| 283 | 283 | exit(); |
| 284 | 284 | |
@@ -289,18 +289,18 @@ discard block |
||
| 289 | 289 | $oFileModel = getModel('file'); |
| 290 | 290 | $file_srl = Context::get('file_srl'); |
| 291 | 291 | $file_key = Context::get('file_key'); |
| 292 | - if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true; |
|
| 292 | + if (strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true; |
|
| 293 | 293 | |
| 294 | - if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__'; |
|
| 294 | + if ($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__'; |
|
| 295 | 295 | else $session_key = '__XE_FILE_KEY__'; |
| 296 | 296 | $columnList = array('source_filename', 'uploaded_filename', 'file_size'); |
| 297 | 297 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
| 298 | 298 | |
| 299 | 299 | $uploaded_filename = $file_obj->uploaded_filename; |
| 300 | 300 | |
| 301 | - if(!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found'); |
|
| 301 | + if (!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found'); |
|
| 302 | 302 | |
| 303 | - if(!$file_key || $_SESSION[$session_key][$file_srl] != $file_key) |
|
| 303 | + if (!$file_key || $_SESSION[$session_key][$file_srl] != $file_key) |
|
| 304 | 304 | { |
| 305 | 305 | unset($_SESSION[$session_key][$file_srl]); |
| 306 | 306 | return $this->stop('msg_invalid_request'); |
@@ -309,34 +309,34 @@ discard block |
||
| 309 | 309 | $file_size = $file_obj->file_size; |
| 310 | 310 | $filename = $file_obj->source_filename; |
| 311 | 311 | |
| 312 | - if(preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11) |
|
| 312 | + if (preg_match('#(?:Chrome|Edge)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 11) |
|
| 313 | 313 | { |
| 314 | - if($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT'])) |
|
| 314 | + if ($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT'])) |
|
| 315 | 315 | { |
| 316 | - $filename_param = 'filename="' . $filename . '"'; |
|
| 316 | + $filename_param = 'filename="'.$filename.'"'; |
|
| 317 | 317 | } |
| 318 | 318 | else |
| 319 | 319 | { |
| 320 | - $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
|
| 320 | + $filename_param = "filename*=UTF-8''".rawurlencode($filename).'; filename="'.rawurlencode($filename).'"'; |
|
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | - elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
| 323 | + elseif (preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
| 324 | 324 | { |
| 325 | - $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
|
| 325 | + $filename_param = "filename*=UTF-8''".rawurlencode($filename).'; filename="'.rawurlencode($filename).'"'; |
|
| 326 | 326 | } |
| 327 | - elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
| 327 | + elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
| 328 | 328 | { |
| 329 | 329 | $filename = rawurlencode($filename); |
| 330 | - $filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"'; |
|
| 330 | + $filename_param = 'filename="'.preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1).'"'; |
|
| 331 | 331 | } |
| 332 | 332 | else |
| 333 | 333 | { |
| 334 | - $filename_param = 'filename="' . $filename . '"'; |
|
| 334 | + $filename_param = 'filename="'.$filename.'"'; |
|
| 335 | 335 | } |
| 336 | 336 | |
| 337 | - if($is_android) |
|
| 337 | + if ($is_android) |
|
| 338 | 338 | { |
| 339 | - if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
| 339 | + if ($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | unset($_SESSION[$session_key][$file_srl]); |
@@ -344,21 +344,21 @@ discard block |
||
| 344 | 344 | Context::close(); |
| 345 | 345 | |
| 346 | 346 | $fp = fopen($uploaded_filename, 'rb'); |
| 347 | - if(!$fp) return $this->stop('msg_file_not_found'); |
|
| 347 | + if (!$fp) return $this->stop('msg_file_not_found'); |
|
| 348 | 348 | |
| 349 | 349 | header("Cache-Control: "); |
| 350 | 350 | header("Pragma: "); |
| 351 | 351 | header("Content-Type: application/octet-stream"); |
| 352 | - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); |
|
| 352 | + header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT"); |
|
| 353 | 353 | |
| 354 | - header("Content-Length: " .(string)($file_size)); |
|
| 355 | - header('Content-Disposition: attachment; ' . $filename_param); |
|
| 354 | + header("Content-Length: ".(string) ($file_size)); |
|
| 355 | + header('Content-Disposition: attachment; '.$filename_param); |
|
| 356 | 356 | header("Content-Transfer-Encoding: binary\n"); |
| 357 | 357 | |
| 358 | 358 | // if file size is lager than 10MB, use fread function (#18675748) |
| 359 | - if(filesize($uploaded_filename) > 1024 * 1024) |
|
| 359 | + if (filesize($uploaded_filename) > 1024 * 1024) |
|
| 360 | 360 | { |
| 361 | - while(!feof($fp)) echo fread($fp, 1024); |
|
| 361 | + while (!feof($fp)) echo fread($fp, 1024); |
|
| 362 | 362 | fclose($fp); |
| 363 | 363 | } |
| 364 | 364 | else |
@@ -380,36 +380,36 @@ discard block |
||
| 380 | 380 | $editor_sequence = Context::get('editor_sequence'); |
| 381 | 381 | $file_srl = Context::get('file_srl'); |
| 382 | 382 | $file_srls = Context::get('file_srls'); |
| 383 | - if($file_srls) $file_srl = $file_srls; |
|
| 383 | + if ($file_srls) $file_srl = $file_srls; |
|
| 384 | 384 | // Exit a session if there is neither upload permission nor information |
| 385 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
| 385 | + if (!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
| 386 | 386 | |
| 387 | 387 | $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
| 388 | 388 | |
| 389 | 389 | $logged_info = Context::get('logged_info'); |
| 390 | 390 | $oFileModel = getModel('file'); |
| 391 | 391 | |
| 392 | - $srls = explode(',',$file_srl); |
|
| 393 | - if(!count($srls)) return; |
|
| 392 | + $srls = explode(',', $file_srl); |
|
| 393 | + if (!count($srls)) return; |
|
| 394 | 394 | |
| 395 | - for($i=0;$i<count($srls);$i++) |
|
| 395 | + for ($i = 0; $i < count($srls); $i++) |
|
| 396 | 396 | { |
| 397 | - $srl = (int)$srls[$i]; |
|
| 398 | - if(!$srl) continue; |
|
| 397 | + $srl = (int) $srls[$i]; |
|
| 398 | + if (!$srl) continue; |
|
| 399 | 399 | |
| 400 | 400 | $args = new stdClass; |
| 401 | 401 | $args->file_srl = $srl; |
| 402 | 402 | $output = executeQuery('file.getFile', $args); |
| 403 | - if(!$output->toBool()) continue; |
|
| 403 | + if (!$output->toBool()) continue; |
|
| 404 | 404 | |
| 405 | 405 | $file_info = $output->data; |
| 406 | - if(!$file_info) continue; |
|
| 406 | + if (!$file_info) continue; |
|
| 407 | 407 | |
| 408 | 408 | $file_grant = $oFileModel->getFileGrant($file_info, $logged_info); |
| 409 | 409 | |
| 410 | - if(!$file_grant->is_deletable) continue; |
|
| 410 | + if (!$file_grant->is_deletable) continue; |
|
| 411 | 411 | |
| 412 | - if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
| 412 | + if ($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
| 413 | 413 | } |
| 414 | 414 | } |
| 415 | 415 | |
@@ -420,23 +420,23 @@ discard block |
||
| 420 | 420 | */ |
| 421 | 421 | function procFileGetList() |
| 422 | 422 | { |
| 423 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
| 423 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
| 424 | 424 | $fileSrls = Context::get('file_srls'); |
| 425 | - if($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
| 425 | + if ($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
| 426 | 426 | |
| 427 | 427 | global $lang; |
| 428 | - if(count($fileSrlList) > 0) |
|
| 428 | + if (count($fileSrlList) > 0) |
|
| 429 | 429 | { |
| 430 | 430 | $oFileModel = getModel('file'); |
| 431 | 431 | $fileList = $oFileModel->getFile($fileSrlList); |
| 432 | - if(!is_array($fileList)) $fileList = array($fileList); |
|
| 432 | + if (!is_array($fileList)) $fileList = array($fileList); |
|
| 433 | 433 | |
| 434 | - if(is_array($fileList)) |
|
| 434 | + if (is_array($fileList)) |
|
| 435 | 435 | { |
| 436 | - foreach($fileList AS $key=>$value) |
|
| 436 | + foreach ($fileList AS $key=>$value) |
|
| 437 | 437 | { |
| 438 | 438 | $value->human_file_size = FileHandler::filesize($value->file_size); |
| 439 | - if($value->isvalid=='Y') $value->validName = $lang->is_valid; |
|
| 439 | + if ($value->isvalid == 'Y') $value->validName = $lang->is_valid; |
|
| 440 | 440 | else $value->validName = $lang->is_stand_by; |
| 441 | 441 | } |
| 442 | 442 | } |
@@ -458,7 +458,7 @@ discard block |
||
| 458 | 458 | function triggerCheckAttached(&$obj) |
| 459 | 459 | { |
| 460 | 460 | $document_srl = $obj->document_srl; |
| 461 | - if(!$document_srl) return new Object(); |
|
| 461 | + if (!$document_srl) return new Object(); |
|
| 462 | 462 | // Get numbers of attachments |
| 463 | 463 | $oFileModel = getModel('file'); |
| 464 | 464 | $obj->uploaded_count = $oFileModel->getFilesCount($document_srl); |
@@ -475,10 +475,10 @@ discard block |
||
| 475 | 475 | function triggerAttachFiles(&$obj) |
| 476 | 476 | { |
| 477 | 477 | $document_srl = $obj->document_srl; |
| 478 | - if(!$document_srl) return new Object(); |
|
| 478 | + if (!$document_srl) return new Object(); |
|
| 479 | 479 | |
| 480 | 480 | $output = $this->setFilesValid($document_srl); |
| 481 | - if(!$output->toBool()) return $output; |
|
| 481 | + if (!$output->toBool()) return $output; |
|
| 482 | 482 | |
| 483 | 483 | return new Object(); |
| 484 | 484 | } |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | function triggerDeleteAttached(&$obj) |
| 493 | 493 | { |
| 494 | 494 | $document_srl = $obj->document_srl; |
| 495 | - if(!$document_srl) return new Object(); |
|
| 495 | + if (!$document_srl) return new Object(); |
|
| 496 | 496 | |
| 497 | 497 | $output = $this->deleteFiles($document_srl); |
| 498 | 498 | return $output; |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | function triggerCommentCheckAttached(&$obj) |
| 508 | 508 | { |
| 509 | 509 | $comment_srl = $obj->comment_srl; |
| 510 | - if(!$comment_srl) return new Object(); |
|
| 510 | + if (!$comment_srl) return new Object(); |
|
| 511 | 511 | // Get numbers of attachments |
| 512 | 512 | $oFileModel = getModel('file'); |
| 513 | 513 | $obj->uploaded_count = $oFileModel->getFilesCount($comment_srl); |
@@ -525,10 +525,10 @@ discard block |
||
| 525 | 525 | { |
| 526 | 526 | $comment_srl = $obj->comment_srl; |
| 527 | 527 | $uploaded_count = $obj->uploaded_count; |
| 528 | - if(!$comment_srl || !$uploaded_count) return new Object(); |
|
| 528 | + if (!$comment_srl || !$uploaded_count) return new Object(); |
|
| 529 | 529 | |
| 530 | 530 | $output = $this->setFilesValid($comment_srl); |
| 531 | - if(!$output->toBool()) return $output; |
|
| 531 | + if (!$output->toBool()) return $output; |
|
| 532 | 532 | |
| 533 | 533 | return new Object(); |
| 534 | 534 | } |
@@ -542,9 +542,9 @@ discard block |
||
| 542 | 542 | function triggerCommentDeleteAttached(&$obj) |
| 543 | 543 | { |
| 544 | 544 | $comment_srl = $obj->comment_srl; |
| 545 | - if(!$comment_srl) return new Object(); |
|
| 545 | + if (!$comment_srl) return new Object(); |
|
| 546 | 546 | |
| 547 | - if($obj->isMoveToTrash) return new Object(); |
|
| 547 | + if ($obj->isMoveToTrash) return new Object(); |
|
| 548 | 548 | |
| 549 | 549 | $output = $this->deleteFiles($comment_srl); |
| 550 | 550 | return $output; |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | function triggerDeleteModuleFiles(&$obj) |
| 560 | 560 | { |
| 561 | 561 | $module_srl = $obj->module_srl; |
| 562 | - if(!$module_srl) return new Object(); |
|
| 562 | + if (!$module_srl) return new Object(); |
|
| 563 | 563 | |
| 564 | 564 | $oFileController = getAdminController('file'); |
| 565 | 565 | return $oFileController->deleteModuleFiles($module_srl); |
@@ -572,9 +572,9 @@ discard block |
||
| 572 | 572 | * @param int $upload_target_srl |
| 573 | 573 | * @return void |
| 574 | 574 | */ |
| 575 | - function setUploadInfo($editor_sequence, $upload_target_srl=0) |
|
| 575 | + function setUploadInfo($editor_sequence, $upload_target_srl = 0) |
|
| 576 | 576 | { |
| 577 | - if(!isset($_SESSION['upload_info'][$editor_sequence])) |
|
| 577 | + if (!isset($_SESSION['upload_info'][$editor_sequence])) |
|
| 578 | 578 | { |
| 579 | 579 | $_SESSION['upload_info'][$editor_sequence] = new stdClass(); |
| 580 | 580 | } |
@@ -634,36 +634,36 @@ discard block |
||
| 634 | 634 | $trigger_obj->module_srl = $module_srl; |
| 635 | 635 | $trigger_obj->upload_target_srl = $upload_target_srl; |
| 636 | 636 | $output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj); |
| 637 | - if(!$output->toBool()) return $output; |
|
| 637 | + if (!$output->toBool()) return $output; |
|
| 638 | 638 | |
| 639 | 639 | // A workaround for Firefox upload bug |
| 640 | - if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
|
| 640 | + if (preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
|
| 641 | 641 | { |
| 642 | 642 | $file_info['name'] = base64_decode(strtr($match[1], ':', '/')); |
| 643 | 643 | } |
| 644 | 644 | |
| 645 | - if(!$manual_insert) |
|
| 645 | + if (!$manual_insert) |
|
| 646 | 646 | { |
| 647 | 647 | // Get the file configurations |
| 648 | 648 | $logged_info = Context::get('logged_info'); |
| 649 | - if($logged_info->is_admin != 'Y') |
|
| 649 | + if ($logged_info->is_admin != 'Y') |
|
| 650 | 650 | { |
| 651 | 651 | $oFileModel = getModel('file'); |
| 652 | 652 | $config = $oFileModel->getFileConfig($module_srl); |
| 653 | 653 | |
| 654 | 654 | // check file type |
| 655 | - if(isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*') |
|
| 655 | + if (isset($config->allowed_filetypes) && $config->allowed_filetypes !== '*.*') |
|
| 656 | 656 | { |
| 657 | 657 | $filetypes = explode(';', $config->allowed_filetypes); |
| 658 | 658 | $ext = array(); |
| 659 | - foreach($filetypes as $item) { |
|
| 659 | + foreach ($filetypes as $item) { |
|
| 660 | 660 | $item = explode('.', $item); |
| 661 | 661 | $ext[] = strtolower($item[1]); |
| 662 | 662 | } |
| 663 | 663 | $uploaded_ext = explode('.', $file_info['name']); |
| 664 | 664 | $uploaded_ext = strtolower(array_pop($uploaded_ext)); |
| 665 | 665 | |
| 666 | - if(!in_array($uploaded_ext, $ext)) |
|
| 666 | + if (!in_array($uploaded_ext, $ext)) |
|
| 667 | 667 | { |
| 668 | 668 | return $this->stop('msg_not_allowed_filetype'); |
| 669 | 669 | } |
@@ -672,63 +672,63 @@ discard block |
||
| 672 | 672 | $allowed_filesize = $config->allowed_filesize * 1024 * 1024; |
| 673 | 673 | $allowed_attach_size = $config->allowed_attach_size * 1024 * 1024; |
| 674 | 674 | // An error appears if file size exceeds a limit |
| 675 | - if($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size'); |
|
| 675 | + if ($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size'); |
|
| 676 | 676 | // Get total file size of all attachements (from DB) |
| 677 | 677 | $size_args = new stdClass; |
| 678 | 678 | $size_args->upload_target_srl = $upload_target_srl; |
| 679 | 679 | $output = executeQuery('file.getAttachedFileSize', $size_args); |
| 680 | - $attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']); |
|
| 681 | - if($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size'); |
|
| 680 | + $attached_size = (int) $output->data->attached_size + filesize($file_info['tmp_name']); |
|
| 681 | + if ($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size'); |
|
| 682 | 682 | } |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | // https://github.com/xpressengine/xe-core/issues/1713 |
| 686 | - $file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x',$file_info['name']); |
|
| 686 | + $file_info['name'] = preg_replace('/\.(php|phtm|phar|html?|cgi|pl|exe|jsp|asp|inc)/i', '$0-x', $file_info['name']); |
|
| 687 | 687 | $file_info['name'] = removeHackTag($file_info['name']); |
| 688 | - $file_info['name'] = str_replace(array('<','>'),array('%3C','%3E'),$file_info['name']); |
|
| 688 | + $file_info['name'] = str_replace(array('<', '>'), array('%3C', '%3E'), $file_info['name']); |
|
| 689 | 689 | |
| 690 | 690 | // Get random number generator |
| 691 | 691 | $random = new Password(); |
| 692 | 692 | |
| 693 | 693 | // Set upload path by checking if the attachement is an image or other kinds of file |
| 694 | - if(preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|swf|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name'])) |
|
| 694 | + if (preg_match("/\.(jpe?g|gif|png|wm[va]|mpe?g|avi|swf|flv|mp[1-4]|as[fx]|wav|midi?|moo?v|qt|r[am]{1,2}|m4v)$/i", $file_info['name'])) |
|
| 695 | 695 | { |
| 696 | - $path = sprintf("./files/attach/images/%s/%s", $module_srl,getNumberingPath($upload_target_srl,3)); |
|
| 696 | + $path = sprintf("./files/attach/images/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
| 697 | 697 | |
| 698 | 698 | // special character to '_' |
| 699 | 699 | // change to random file name. because window php bug. window php is not recognize unicode character file name - by cherryfilter |
| 700 | - $ext = substr(strrchr($file_info['name'],'.'),1); |
|
| 700 | + $ext = substr(strrchr($file_info['name'], '.'), 1); |
|
| 701 | 701 | //$_filename = preg_replace('/[#$&*?+%"\']/', '_', $file_info['name']); |
| 702 | 702 | $_filename = $random->createSecureSalt(32, 'hex').'.'.$ext; |
| 703 | 703 | $filename = $path.$_filename; |
| 704 | 704 | $idx = 1; |
| 705 | - while(file_exists($filename)) |
|
| 705 | + while (file_exists($filename)) |
|
| 706 | 706 | { |
| 707 | - $filename = $path.preg_replace('/\.([a-z0-9]+)$/i','_'.$idx.'.$1',$_filename); |
|
| 707 | + $filename = $path.preg_replace('/\.([a-z0-9]+)$/i', '_'.$idx.'.$1', $_filename); |
|
| 708 | 708 | $idx++; |
| 709 | 709 | } |
| 710 | 710 | $direct_download = 'Y'; |
| 711 | 711 | } |
| 712 | 712 | else |
| 713 | 713 | { |
| 714 | - $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
|
| 714 | + $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl, 3)); |
|
| 715 | 715 | $filename = $path.$random->createSecureSalt(32, 'hex'); |
| 716 | 716 | $direct_download = 'N'; |
| 717 | 717 | } |
| 718 | 718 | // Create a directory |
| 719 | - if(!FileHandler::makeDir($path)) return new Object(-1,'msg_not_permitted_create'); |
|
| 719 | + if (!FileHandler::makeDir($path)) return new Object(-1, 'msg_not_permitted_create'); |
|
| 720 | 720 | |
| 721 | 721 | // Check uploaded file |
| 722 | - if(!checkUploadedFile($file_info['tmp_name'])) return new Object(-1,'msg_file_upload_error'); |
|
| 722 | + if (!checkUploadedFile($file_info['tmp_name'])) return new Object(-1, 'msg_file_upload_error'); |
|
| 723 | 723 | |
| 724 | 724 | // Get random number generator |
| 725 | 725 | $random = new Password(); |
| 726 | 726 | |
| 727 | 727 | // Move the file |
| 728 | - if($manual_insert) |
|
| 728 | + if ($manual_insert) |
|
| 729 | 729 | { |
| 730 | 730 | @copy($file_info['tmp_name'], $filename); |
| 731 | - if(!file_exists($filename)) |
|
| 731 | + if (!file_exists($filename)) |
|
| 732 | 732 | { |
| 733 | 733 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
| 734 | 734 | @copy($file_info['tmp_name'], $filename); |
@@ -736,10 +736,10 @@ discard block |
||
| 736 | 736 | } |
| 737 | 737 | else |
| 738 | 738 | { |
| 739 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) |
|
| 739 | + if (!@move_uploaded_file($file_info['tmp_name'], $filename)) |
|
| 740 | 740 | { |
| 741 | 741 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
| 742 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1,'msg_file_upload_error'); |
|
| 742 | + if (!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1, 'msg_file_upload_error'); |
|
| 743 | 743 | } |
| 744 | 744 | } |
| 745 | 745 | // Get member information |
@@ -760,10 +760,10 @@ discard block |
||
| 760 | 760 | $args->sid = $random->createSecureSalt(32, 'hex'); |
| 761 | 761 | |
| 762 | 762 | $output = executeQuery('file.insertFile', $args); |
| 763 | - if(!$output->toBool()) return $output; |
|
| 763 | + if (!$output->toBool()) return $output; |
|
| 764 | 764 | // Call a trigger (after) |
| 765 | 765 | $trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args); |
| 766 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
| 766 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
| 767 | 767 | |
| 768 | 768 | $_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true; |
| 769 | 769 | |
@@ -806,18 +806,18 @@ discard block |
||
| 806 | 806 | */ |
| 807 | 807 | function deleteFile($file_srl) |
| 808 | 808 | { |
| 809 | - if(!$file_srl) return; |
|
| 809 | + if (!$file_srl) return; |
|
| 810 | 810 | |
| 811 | 811 | $srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl); |
| 812 | - if(!count($srls)) return; |
|
| 812 | + if (!count($srls)) return; |
|
| 813 | 813 | |
| 814 | 814 | $oDocumentController = getController('document'); |
| 815 | 815 | $documentSrlList = array(); |
| 816 | 816 | |
| 817 | - foreach($srls as $srl) |
|
| 817 | + foreach ($srls as $srl) |
|
| 818 | 818 | { |
| 819 | - $srl = (int)$srl; |
|
| 820 | - if(!$srl) |
|
| 819 | + $srl = (int) $srl; |
|
| 820 | + if (!$srl) |
|
| 821 | 821 | { |
| 822 | 822 | continue; |
| 823 | 823 | } |
@@ -826,14 +826,14 @@ discard block |
||
| 826 | 826 | $args->file_srl = $srl; |
| 827 | 827 | $output = executeQuery('file.getFile', $args); |
| 828 | 828 | |
| 829 | - if(!$output->toBool() || !$output->data) |
|
| 829 | + if (!$output->toBool() || !$output->data) |
|
| 830 | 830 | { |
| 831 | 831 | continue; |
| 832 | 832 | } |
| 833 | 833 | |
| 834 | 834 | $file_info = $output->data; |
| 835 | 835 | |
| 836 | - if($file_info->upload_target_srl) |
|
| 836 | + if ($file_info->upload_target_srl) |
|
| 837 | 837 | { |
| 838 | 838 | $documentSrlList[] = $file_info->upload_target_srl; |
| 839 | 839 | } |
@@ -844,15 +844,15 @@ discard block |
||
| 844 | 844 | // Call a trigger (before) |
| 845 | 845 | $trigger_obj = $output->data; |
| 846 | 846 | $output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj); |
| 847 | - if(!$output->toBool()) return $output; |
|
| 847 | + if (!$output->toBool()) return $output; |
|
| 848 | 848 | |
| 849 | 849 | // Remove from the DB |
| 850 | 850 | $output = executeQuery('file.deleteFile', $args); |
| 851 | - if(!$output->toBool()) return $output; |
|
| 851 | + if (!$output->toBool()) return $output; |
|
| 852 | 852 | |
| 853 | 853 | // Call a trigger (after) |
| 854 | 854 | $trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj); |
| 855 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
| 855 | + if (!$trigger_output->toBool()) return $trigger_output; |
|
| 856 | 856 | |
| 857 | 857 | // If successfully deleted, remove the file |
| 858 | 858 | FileHandler::removeFile($uploaded_filename); |
@@ -876,28 +876,28 @@ discard block |
||
| 876 | 876 | $columnList = array('file_srl', 'uploaded_filename', 'module_srl'); |
| 877 | 877 | $file_list = $oFileModel->getFiles($upload_target_srl, $columnList); |
| 878 | 878 | // Success returned if no attachement exists |
| 879 | - if(!is_array($file_list)||!count($file_list)) return new Object(); |
|
| 879 | + if (!is_array($file_list) || !count($file_list)) return new Object(); |
|
| 880 | 880 | |
| 881 | 881 | // Delete the file |
| 882 | 882 | $path = array(); |
| 883 | 883 | $file_count = count($file_list); |
| 884 | - for($i=0;$i<$file_count;$i++) |
|
| 884 | + for ($i = 0; $i < $file_count; $i++) |
|
| 885 | 885 | { |
| 886 | 886 | $this->deleteFile($file_list[$i]->file_srl); |
| 887 | 887 | |
| 888 | 888 | $uploaded_filename = $file_list[$i]->uploaded_filename; |
| 889 | 889 | $path_info = pathinfo($uploaded_filename); |
| 890 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
| 890 | + if (!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | // Remove from the DB |
| 894 | 894 | $args = new stdClass(); |
| 895 | 895 | $args->upload_target_srl = $upload_target_srl; |
| 896 | 896 | $output = executeQuery('file.deleteFiles', $args); |
| 897 | - if(!$output->toBool()) return $output; |
|
| 897 | + if (!$output->toBool()) return $output; |
|
| 898 | 898 | |
| 899 | 899 | // Remove a file directory of the document |
| 900 | - for($i=0, $c=count($path); $i<$c; $i++) |
|
| 900 | + for ($i = 0, $c = count($path); $i < $c; $i++) |
|
| 901 | 901 | { |
| 902 | 902 | FileHandler::removeBlankDir($path[$i]); |
| 903 | 903 | } |
@@ -915,23 +915,23 @@ discard block |
||
| 915 | 915 | */ |
| 916 | 916 | function moveFile($source_srl, $target_module_srl, $target_srl) |
| 917 | 917 | { |
| 918 | - if($source_srl == $target_srl) return; |
|
| 918 | + if ($source_srl == $target_srl) return; |
|
| 919 | 919 | |
| 920 | 920 | $oFileModel = getModel('file'); |
| 921 | 921 | $file_list = $oFileModel->getFiles($source_srl); |
| 922 | - if(!$file_list) return; |
|
| 922 | + if (!$file_list) return; |
|
| 923 | 923 | |
| 924 | 924 | $file_count = count($file_list); |
| 925 | 925 | |
| 926 | - for($i=0;$i<$file_count;$i++) |
|
| 926 | + for ($i = 0; $i < $file_count; $i++) |
|
| 927 | 927 | { |
| 928 | 928 | unset($file_info); |
| 929 | 929 | $file_info = $file_list[$i]; |
| 930 | 930 | $old_file = $file_info->uploaded_filename; |
| 931 | 931 | // Determine the file path by checking if the file is an image or other kinds |
| 932 | - if(preg_match("/\.(jpg|jpeg|gif|png|wmv|wma|mpg|mpeg|avi|swf|flv|mp1|mp2|mp3|mp4|asf|wav|asx|mid|midi|asf|mov|moov|qt|rm|ram|ra|rmm|m4v)$/i", $file_info->source_filename)) |
|
| 932 | + if (preg_match("/\.(jpg|jpeg|gif|png|wmv|wma|mpg|mpeg|avi|swf|flv|mp1|mp2|mp3|mp4|asf|wav|asx|mid|midi|asf|mov|moov|qt|rm|ram|ra|rmm|m4v)$/i", $file_info->source_filename)) |
|
| 933 | 933 | { |
| 934 | - $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl); |
|
| 934 | + $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl, $target_srl); |
|
| 935 | 935 | $new_file = $path.$file_info->source_filename; |
| 936 | 936 | } |
| 937 | 937 | else |
@@ -941,7 +941,7 @@ discard block |
||
| 941 | 941 | $new_file = $path.$random->createSecureSalt(32, 'hex'); |
| 942 | 942 | } |
| 943 | 943 | // Pass if a target document to move is same |
| 944 | - if($old_file == $new_file) continue; |
|
| 944 | + if ($old_file == $new_file) continue; |
|
| 945 | 945 | // Create a directory |
| 946 | 946 | FileHandler::makeDir($path); |
| 947 | 947 | // Move the file |
@@ -961,18 +961,18 @@ discard block |
||
| 961 | 961 | $vars = Context::getRequestVars(); |
| 962 | 962 | $logged_info = Context::get('logged_info'); |
| 963 | 963 | |
| 964 | - if(!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request'); |
|
| 964 | + if (!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request'); |
|
| 965 | 965 | |
| 966 | 966 | $upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl; |
| 967 | 967 | |
| 968 | 968 | $oFileModel = getModel('file'); |
| 969 | 969 | $file_info = $oFileModel->getFile($vars->file_srl); |
| 970 | 970 | |
| 971 | - if(!$file_info) return new Object(-1, 'msg_not_founded'); |
|
| 971 | + if (!$file_info) return new Object(-1, 'msg_not_founded'); |
|
| 972 | 972 | |
| 973 | - if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
| 973 | + if (!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
| 974 | 974 | |
| 975 | - $args = new stdClass(); |
|
| 975 | + $args = new stdClass(); |
|
| 976 | 976 | $args->file_srl = $vars->file_srl; |
| 977 | 977 | $args->upload_target_srl = $upload_target_srl; |
| 978 | 978 | |
@@ -981,7 +981,7 @@ discard block |
||
| 981 | 981 | |
| 982 | 982 | $args->cover_image = 'N'; |
| 983 | 983 | $output = executeQuery('file.updateClearCoverImage', $args); |
| 984 | - if(!$output->toBool()) |
|
| 984 | + if (!$output->toBool()) |
|
| 985 | 985 | { |
| 986 | 986 | $oDB->rollback(); |
| 987 | 987 | return $output; |
@@ -989,7 +989,7 @@ discard block |
||
| 989 | 989 | |
| 990 | 990 | $args->cover_image = 'Y'; |
| 991 | 991 | $output = executeQuery('file.updateCoverImage', $args); |
| 992 | - if(!$output->toBool()) |
|
| 992 | + if (!$output->toBool()) |
|
| 993 | 993 | { |
| 994 | 994 | $oDB->rollback(); |
| 995 | 995 | return $output; |
@@ -1021,9 +1021,9 @@ discard block |
||
| 1021 | 1021 | $fileConfig = $oModuleModel->getModulePartConfig('file', $obj->originModuleSrl); |
| 1022 | 1022 | |
| 1023 | 1023 | $oModuleController = getController('module'); |
| 1024 | - if(is_array($obj->moduleSrlList)) |
|
| 1024 | + if (is_array($obj->moduleSrlList)) |
|
| 1025 | 1025 | { |
| 1026 | - foreach($obj->moduleSrlList AS $key=>$moduleSrl) |
|
| 1026 | + foreach ($obj->moduleSrlList AS $key=>$moduleSrl) |
|
| 1027 | 1027 | { |
| 1028 | 1028 | $oModuleController->insertModulePartConfig('file', $moduleSrl, $fileConfig); |
| 1029 | 1029 | } |
@@ -29,24 +29,36 @@ discard block |
||
| 29 | 29 | $file_info = $_FILES['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'); |
| 49 | - if($output->error != '0') $this->stop($output->message); |
|
| 59 | + if($output->error != '0') { |
|
| 60 | + $this->stop($output->message); |
|
| 61 | + } |
|
| 50 | 62 | } |
| 51 | 63 | |
| 52 | 64 | /** |
@@ -61,17 +73,27 @@ discard block |
||
| 61 | 73 | $callback = Context::get('callback'); |
| 62 | 74 | $module_srl = $this->module_srl; |
| 63 | 75 | $upload_target_srl = intval(Context::get('uploadTargetSrl')); |
| 64 | - if(!$upload_target_srl) $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
| 76 | + if(!$upload_target_srl) { |
|
| 77 | + $upload_target_srl = intval(Context::get('upload_target_srl')); |
|
| 78 | + } |
|
| 65 | 79 | |
| 66 | 80 | // Exit a session if there is neither upload permission nor information |
| 67 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
| 81 | + if(!$_SESSION['upload_info'][$editor_sequence]->enabled) { |
|
| 82 | + exit(); |
|
| 83 | + } |
|
| 68 | 84 | // Extract from session information if upload_target_srl is not specified |
| 69 | - if(!$upload_target_srl) $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
| 85 | + if(!$upload_target_srl) { |
|
| 86 | + $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
|
| 87 | + } |
|
| 70 | 88 | // Create if upload_target_srl is not defined in the session information |
| 71 | - if(!$upload_target_srl) $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
| 89 | + if(!$upload_target_srl) { |
|
| 90 | + $_SESSION['upload_info'][$editor_sequence]->upload_target_srl = $upload_target_srl = getNextSequence(); |
|
| 91 | + } |
|
| 72 | 92 | // Delete and then attempt to re-upload if file_srl is requested |
| 73 | 93 | $file_srl = Context::get('file_srl'); |
| 74 | - if($file_srl) $this->deleteFile($file_srl); |
|
| 94 | + if($file_srl) { |
|
| 95 | + $this->deleteFile($file_srl); |
|
| 96 | + } |
|
| 75 | 97 | |
| 76 | 98 | $file_info = Context::get('Filedata'); |
| 77 | 99 | // An error appears if not a normally uploaded file |
@@ -112,15 +134,16 @@ discard block |
||
| 112 | 134 | $source_src = $fileInfo->uploaded_filename; |
| 113 | 135 | $output_src = $source_src . '.resized' . strrchr($source_src,'.'); |
| 114 | 136 | |
| 115 | - if(!$height) $height = $width-1; |
|
| 137 | + if(!$height) { |
|
| 138 | + $height = $width-1; |
|
| 139 | + } |
|
| 116 | 140 | |
| 117 | 141 | if(FileHandler::createImageFile($source_src,$output_src,$width,$height,'','ratio')) |
| 118 | 142 | { |
| 119 | 143 | $output = new stdClass(); |
| 120 | 144 | $output->info = getimagesize($output_src); |
| 121 | 145 | $output->src = $output_src; |
| 122 | - } |
|
| 123 | - else |
|
| 146 | + } else |
|
| 124 | 147 | { |
| 125 | 148 | return new Object(-1,'msg_invalid_request'); |
| 126 | 149 | } |
@@ -163,7 +186,9 @@ discard block |
||
| 163 | 186 | { |
| 164 | 187 | $oFileModel = getModel('file'); |
| 165 | 188 | |
| 166 | - if(isset($this->grant->access) && $this->grant->access !== true) return new Object(-1, 'msg_not_permitted'); |
|
| 189 | + if(isset($this->grant->access) && $this->grant->access !== true) { |
|
| 190 | + return new Object(-1, 'msg_not_permitted'); |
|
| 191 | + } |
|
| 167 | 192 | |
| 168 | 193 | $file_srl = Context::get('file_srl'); |
| 169 | 194 | $sid = Context::get('sid'); |
@@ -172,9 +197,13 @@ discard block |
||
| 172 | 197 | $columnList = array('file_srl', 'sid', 'isvalid', 'source_filename', 'module_srl', 'uploaded_filename', 'file_size', 'member_srl', 'upload_target_srl', 'upload_target_type'); |
| 173 | 198 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
| 174 | 199 | // If the requested file information is incorrect, an error that file cannot be found appears |
| 175 | - if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) return $this->stop('msg_file_not_found'); |
|
| 200 | + if($file_obj->file_srl!=$file_srl || $file_obj->sid!=$sid) { |
|
| 201 | + return $this->stop('msg_file_not_found'); |
|
| 202 | + } |
|
| 176 | 203 | // Notify that file download is not allowed when standing-by(Only a top-administrator is permitted) |
| 177 | - if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') return $this->stop('msg_not_permitted_download'); |
|
| 204 | + if($logged_info->is_admin != 'Y' && $file_obj->isvalid!='Y') { |
|
| 205 | + return $this->stop('msg_not_permitted_download'); |
|
| 206 | + } |
|
| 178 | 207 | // File name |
| 179 | 208 | $filename = $file_obj->source_filename; |
| 180 | 209 | $file_module_config = $oFileModel->getFileModuleConfig($file_obj->module_srl); |
@@ -186,7 +215,9 @@ discard block |
||
| 186 | 215 | { |
| 187 | 216 | $allow_outlink_format_array = array(); |
| 188 | 217 | $allow_outlink_format_array = explode(',', $file_module_config->allow_outlink_format); |
| 189 | - 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)) { |
|
| 219 | + $allow_outlink_format_array[0] = $file_module_config->allow_outlink_format; |
|
| 220 | + } |
|
| 190 | 221 | |
| 191 | 222 | foreach($allow_outlink_format_array as $val) |
| 192 | 223 | { |
@@ -208,7 +239,9 @@ discard block |
||
| 208 | 239 | { |
| 209 | 240 | $allow_outlink_site_array = array(); |
| 210 | 241 | $allow_outlink_site_array = explode("\n", $file_module_config->allow_outlink_site); |
| 211 | - if(!is_array($allow_outlink_site_array)) $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
| 242 | + if(!is_array($allow_outlink_site_array)) { |
|
| 243 | + $allow_outlink_site_array[0] = $file_module_config->allow_outlink_site; |
|
| 244 | + } |
|
| 212 | 245 | |
| 213 | 246 | foreach($allow_outlink_site_array as $val) |
| 214 | 247 | { |
@@ -220,23 +253,29 @@ discard block |
||
| 220 | 253 | } |
| 221 | 254 | } |
| 222 | 255 | } |
| 256 | + } else { |
|
| 257 | + $file_module_config->allow_outlink = 'Y'; |
|
| 223 | 258 | } |
| 224 | - else $file_module_config->allow_outlink = 'Y'; |
|
| 225 | 259 | } |
| 226 | - if($file_module_config->allow_outlink != 'Y') return $this->stop('msg_not_allowed_outlink'); |
|
| 260 | + if($file_module_config->allow_outlink != 'Y') { |
|
| 261 | + return $this->stop('msg_not_allowed_outlink'); |
|
| 262 | + } |
|
| 227 | 263 | } |
| 228 | 264 | |
| 229 | 265 | // Check if a permission for file download is granted |
| 230 | 266 | $downloadGrantCount = 0; |
| 231 | 267 | if(is_array($file_module_config->download_grant)) |
| 232 | 268 | { |
| 233 | - foreach($file_module_config->download_grant AS $value) |
|
| 234 | - if($value) $downloadGrantCount++; |
|
| 269 | + foreach($file_module_config->download_grant AS $value) { |
|
| 270 | + if($value) $downloadGrantCount++; |
|
| 271 | + } |
|
| 235 | 272 | } |
| 236 | 273 | |
| 237 | 274 | if(is_array($file_module_config->download_grant) && $downloadGrantCount>0) |
| 238 | 275 | { |
| 239 | - if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); |
|
| 276 | + if(!Context::get('is_logged')) { |
|
| 277 | + return $this->stop('msg_not_permitted_download'); |
|
| 278 | + } |
|
| 240 | 279 | $logged_info = Context::get('logged_info'); |
| 241 | 280 | if($logged_info->is_admin != 'Y') |
| 242 | 281 | { |
@@ -259,13 +298,17 @@ discard block |
||
| 259 | 298 | break; |
| 260 | 299 | } |
| 261 | 300 | } |
| 262 | - if(!$is_permitted) return $this->stop('msg_not_permitted_download'); |
|
| 301 | + if(!$is_permitted) { |
|
| 302 | + return $this->stop('msg_not_permitted_download'); |
|
| 303 | + } |
|
| 263 | 304 | } |
| 264 | 305 | } |
| 265 | 306 | } |
| 266 | 307 | // Call a trigger (before) |
| 267 | 308 | $output = ModuleHandler::triggerCall('file.downloadFile', 'before', $file_obj); |
| 268 | - if(!$output->toBool()) return $this->stop(($output->message)?$output->message:'msg_not_permitted_download'); |
|
| 309 | + if(!$output->toBool()) { |
|
| 310 | + return $this->stop(($output->message)?$output->message:'msg_not_permitted_download'); |
|
| 311 | + } |
|
| 269 | 312 | |
| 270 | 313 | |
| 271 | 314 | // 다운로드 후 (가상) |
@@ -289,16 +332,23 @@ discard block |
||
| 289 | 332 | $oFileModel = getModel('file'); |
| 290 | 333 | $file_srl = Context::get('file_srl'); |
| 291 | 334 | $file_key = Context::get('file_key'); |
| 292 | - if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) $is_android = true; |
|
| 335 | + if(strstr($_SERVER['HTTP_USER_AGENT'], "Android")) { |
|
| 336 | + $is_android = true; |
|
| 337 | + } |
|
| 293 | 338 | |
| 294 | - if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) $session_key = '__XE_FILE_KEY_AND__'; |
|
| 295 | - else $session_key = '__XE_FILE_KEY__'; |
|
| 339 | + if($is_android && $_SESSION['__XE_FILE_KEY_AND__'][$file_srl]) { |
|
| 340 | + $session_key = '__XE_FILE_KEY_AND__'; |
|
| 341 | + } else { |
|
| 342 | + $session_key = '__XE_FILE_KEY__'; |
|
| 343 | + } |
|
| 296 | 344 | $columnList = array('source_filename', 'uploaded_filename', 'file_size'); |
| 297 | 345 | $file_obj = $oFileModel->getFile($file_srl, $columnList); |
| 298 | 346 | |
| 299 | 347 | $uploaded_filename = $file_obj->uploaded_filename; |
| 300 | 348 | |
| 301 | - if(!file_exists($uploaded_filename)) return $this->stop('msg_file_not_found'); |
|
| 349 | + if(!file_exists($uploaded_filename)) { |
|
| 350 | + return $this->stop('msg_file_not_found'); |
|
| 351 | + } |
|
| 302 | 352 | |
| 303 | 353 | if(!$file_key || $_SESSION[$session_key][$file_srl] != $file_key) |
| 304 | 354 | { |
@@ -314,29 +364,27 @@ discard block |
||
| 314 | 364 | if($is_android && preg_match('#\bwv\b|(?:Version|Browser)/\d+#', $_SERVER['HTTP_USER_AGENT'])) |
| 315 | 365 | { |
| 316 | 366 | $filename_param = 'filename="' . $filename . '"'; |
| 317 | - } |
|
| 318 | - else |
|
| 367 | + } else |
|
| 319 | 368 | { |
| 320 | 369 | $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
| 321 | 370 | } |
| 322 | - } |
|
| 323 | - elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
| 371 | + } elseif(preg_match('#(?:Firefox|Safari|Trident)/(\d+)\.#', $_SERVER['HTTP_USER_AGENT'], $matches) && $matches[1] >= 6) |
|
| 324 | 372 | { |
| 325 | 373 | $filename_param = "filename*=UTF-8''" . rawurlencode($filename) . '; filename="' . rawurlencode($filename) . '"'; |
| 326 | - } |
|
| 327 | - elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
| 374 | + } elseif(strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE) |
|
| 328 | 375 | { |
| 329 | 376 | $filename = rawurlencode($filename); |
| 330 | 377 | $filename_param = 'filename="' . preg_replace('/\./', '%2e', $filename, substr_count($filename, '.') - 1) . '"'; |
| 331 | - } |
|
| 332 | - else |
|
| 378 | + } else |
|
| 333 | 379 | { |
| 334 | 380 | $filename_param = 'filename="' . $filename . '"'; |
| 335 | 381 | } |
| 336 | 382 | |
| 337 | 383 | if($is_android) |
| 338 | 384 | { |
| 339 | - if($_SESSION['__XE_FILE_KEY__'][$file_srl]) $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
| 385 | + if($_SESSION['__XE_FILE_KEY__'][$file_srl]) { |
|
| 386 | + $_SESSION['__XE_FILE_KEY_AND__'][$file_srl] = $file_key; |
|
| 387 | + } |
|
| 340 | 388 | } |
| 341 | 389 | |
| 342 | 390 | unset($_SESSION[$session_key][$file_srl]); |
@@ -344,7 +392,9 @@ discard block |
||
| 344 | 392 | Context::close(); |
| 345 | 393 | |
| 346 | 394 | $fp = fopen($uploaded_filename, 'rb'); |
| 347 | - if(!$fp) return $this->stop('msg_file_not_found'); |
|
| 395 | + if(!$fp) { |
|
| 396 | + return $this->stop('msg_file_not_found'); |
|
| 397 | + } |
|
| 348 | 398 | |
| 349 | 399 | header("Cache-Control: "); |
| 350 | 400 | header("Pragma: "); |
@@ -358,10 +408,11 @@ discard block |
||
| 358 | 408 | // if file size is lager than 10MB, use fread function (#18675748) |
| 359 | 409 | if(filesize($uploaded_filename) > 1024 * 1024) |
| 360 | 410 | { |
| 361 | - while(!feof($fp)) echo fread($fp, 1024); |
|
| 411 | + while(!feof($fp)) { |
|
| 412 | + echo fread($fp, 1024); |
|
| 413 | + } |
|
| 362 | 414 | fclose($fp); |
| 363 | - } |
|
| 364 | - else |
|
| 415 | + } else |
|
| 365 | 416 | { |
| 366 | 417 | fpassthru($fp); |
| 367 | 418 | } |
@@ -380,9 +431,13 @@ discard block |
||
| 380 | 431 | $editor_sequence = Context::get('editor_sequence'); |
| 381 | 432 | $file_srl = Context::get('file_srl'); |
| 382 | 433 | $file_srls = Context::get('file_srls'); |
| 383 | - if($file_srls) $file_srl = $file_srls; |
|
| 434 | + if($file_srls) { |
|
| 435 | + $file_srl = $file_srls; |
|
| 436 | + } |
|
| 384 | 437 | // Exit a session if there is neither upload permission nor information |
| 385 | - if(!$_SESSION['upload_info'][$editor_sequence]->enabled) exit(); |
|
| 438 | + if(!$_SESSION['upload_info'][$editor_sequence]->enabled) { |
|
| 439 | + exit(); |
|
| 440 | + } |
|
| 386 | 441 | |
| 387 | 442 | $upload_target_srl = $_SESSION['upload_info'][$editor_sequence]->upload_target_srl; |
| 388 | 443 | |
@@ -390,26 +445,38 @@ discard block |
||
| 390 | 445 | $oFileModel = getModel('file'); |
| 391 | 446 | |
| 392 | 447 | $srls = explode(',',$file_srl); |
| 393 | - if(!count($srls)) return; |
|
| 448 | + if(!count($srls)) { |
|
| 449 | + return; |
|
| 450 | + } |
|
| 394 | 451 | |
| 395 | 452 | for($i=0;$i<count($srls);$i++) |
| 396 | 453 | { |
| 397 | 454 | $srl = (int)$srls[$i]; |
| 398 | - if(!$srl) continue; |
|
| 455 | + if(!$srl) { |
|
| 456 | + continue; |
|
| 457 | + } |
|
| 399 | 458 | |
| 400 | 459 | $args = new stdClass; |
| 401 | 460 | $args->file_srl = $srl; |
| 402 | 461 | $output = executeQuery('file.getFile', $args); |
| 403 | - if(!$output->toBool()) continue; |
|
| 462 | + if(!$output->toBool()) { |
|
| 463 | + continue; |
|
| 464 | + } |
|
| 404 | 465 | |
| 405 | 466 | $file_info = $output->data; |
| 406 | - if(!$file_info) continue; |
|
| 467 | + if(!$file_info) { |
|
| 468 | + continue; |
|
| 469 | + } |
|
| 407 | 470 | |
| 408 | 471 | $file_grant = $oFileModel->getFileGrant($file_info, $logged_info); |
| 409 | 472 | |
| 410 | - if(!$file_grant->is_deletable) continue; |
|
| 473 | + if(!$file_grant->is_deletable) { |
|
| 474 | + continue; |
|
| 475 | + } |
|
| 411 | 476 | |
| 412 | - if($upload_target_srl && $file_srl) $output = $this->deleteFile($file_srl); |
|
| 477 | + if($upload_target_srl && $file_srl) { |
|
| 478 | + $output = $this->deleteFile($file_srl); |
|
| 479 | + } |
|
| 413 | 480 | } |
| 414 | 481 | } |
| 415 | 482 | |
@@ -420,28 +487,36 @@ discard block |
||
| 420 | 487 | */ |
| 421 | 488 | function procFileGetList() |
| 422 | 489 | { |
| 423 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
| 490 | + if(!Context::get('is_logged')) { |
|
| 491 | + return new Object(-1,'msg_not_permitted'); |
|
| 492 | + } |
|
| 424 | 493 | $fileSrls = Context::get('file_srls'); |
| 425 | - if($fileSrls) $fileSrlList = explode(',', $fileSrls); |
|
| 494 | + if($fileSrls) { |
|
| 495 | + $fileSrlList = explode(',', $fileSrls); |
|
| 496 | + } |
|
| 426 | 497 | |
| 427 | 498 | global $lang; |
| 428 | 499 | if(count($fileSrlList) > 0) |
| 429 | 500 | { |
| 430 | 501 | $oFileModel = getModel('file'); |
| 431 | 502 | $fileList = $oFileModel->getFile($fileSrlList); |
| 432 | - if(!is_array($fileList)) $fileList = array($fileList); |
|
| 503 | + if(!is_array($fileList)) { |
|
| 504 | + $fileList = array($fileList); |
|
| 505 | + } |
|
| 433 | 506 | |
| 434 | 507 | if(is_array($fileList)) |
| 435 | 508 | { |
| 436 | 509 | foreach($fileList AS $key=>$value) |
| 437 | 510 | { |
| 438 | 511 | $value->human_file_size = FileHandler::filesize($value->file_size); |
| 439 | - if($value->isvalid=='Y') $value->validName = $lang->is_valid; |
|
| 440 | - else $value->validName = $lang->is_stand_by; |
|
| 512 | + if($value->isvalid=='Y') { |
|
| 513 | + $value->validName = $lang->is_valid; |
|
| 514 | + } else { |
|
| 515 | + $value->validName = $lang->is_stand_by; |
|
| 516 | + } |
|
| 441 | 517 | } |
| 442 | 518 | } |
| 443 | - } |
|
| 444 | - else |
|
| 519 | + } else |
|
| 445 | 520 | { |
| 446 | 521 | $fileList = array(); |
| 447 | 522 | $this->setMessage($lang->no_files); |
@@ -458,7 +533,9 @@ discard block |
||
| 458 | 533 | function triggerCheckAttached(&$obj) |
| 459 | 534 | { |
| 460 | 535 | $document_srl = $obj->document_srl; |
| 461 | - if(!$document_srl) return new Object(); |
|
| 536 | + if(!$document_srl) { |
|
| 537 | + return new Object(); |
|
| 538 | + } |
|
| 462 | 539 | // Get numbers of attachments |
| 463 | 540 | $oFileModel = getModel('file'); |
| 464 | 541 | $obj->uploaded_count = $oFileModel->getFilesCount($document_srl); |
@@ -475,10 +552,14 @@ discard block |
||
| 475 | 552 | function triggerAttachFiles(&$obj) |
| 476 | 553 | { |
| 477 | 554 | $document_srl = $obj->document_srl; |
| 478 | - if(!$document_srl) return new Object(); |
|
| 555 | + if(!$document_srl) { |
|
| 556 | + return new Object(); |
|
| 557 | + } |
|
| 479 | 558 | |
| 480 | 559 | $output = $this->setFilesValid($document_srl); |
| 481 | - if(!$output->toBool()) return $output; |
|
| 560 | + if(!$output->toBool()) { |
|
| 561 | + return $output; |
|
| 562 | + } |
|
| 482 | 563 | |
| 483 | 564 | return new Object(); |
| 484 | 565 | } |
@@ -492,7 +573,9 @@ discard block |
||
| 492 | 573 | function triggerDeleteAttached(&$obj) |
| 493 | 574 | { |
| 494 | 575 | $document_srl = $obj->document_srl; |
| 495 | - if(!$document_srl) return new Object(); |
|
| 576 | + if(!$document_srl) { |
|
| 577 | + return new Object(); |
|
| 578 | + } |
|
| 496 | 579 | |
| 497 | 580 | $output = $this->deleteFiles($document_srl); |
| 498 | 581 | return $output; |
@@ -507,7 +590,9 @@ discard block |
||
| 507 | 590 | function triggerCommentCheckAttached(&$obj) |
| 508 | 591 | { |
| 509 | 592 | $comment_srl = $obj->comment_srl; |
| 510 | - if(!$comment_srl) return new Object(); |
|
| 593 | + if(!$comment_srl) { |
|
| 594 | + return new Object(); |
|
| 595 | + } |
|
| 511 | 596 | // Get numbers of attachments |
| 512 | 597 | $oFileModel = getModel('file'); |
| 513 | 598 | $obj->uploaded_count = $oFileModel->getFilesCount($comment_srl); |
@@ -525,10 +610,14 @@ discard block |
||
| 525 | 610 | { |
| 526 | 611 | $comment_srl = $obj->comment_srl; |
| 527 | 612 | $uploaded_count = $obj->uploaded_count; |
| 528 | - if(!$comment_srl || !$uploaded_count) return new Object(); |
|
| 613 | + if(!$comment_srl || !$uploaded_count) { |
|
| 614 | + return new Object(); |
|
| 615 | + } |
|
| 529 | 616 | |
| 530 | 617 | $output = $this->setFilesValid($comment_srl); |
| 531 | - if(!$output->toBool()) return $output; |
|
| 618 | + if(!$output->toBool()) { |
|
| 619 | + return $output; |
|
| 620 | + } |
|
| 532 | 621 | |
| 533 | 622 | return new Object(); |
| 534 | 623 | } |
@@ -542,9 +631,13 @@ discard block |
||
| 542 | 631 | function triggerCommentDeleteAttached(&$obj) |
| 543 | 632 | { |
| 544 | 633 | $comment_srl = $obj->comment_srl; |
| 545 | - if(!$comment_srl) return new Object(); |
|
| 634 | + if(!$comment_srl) { |
|
| 635 | + return new Object(); |
|
| 636 | + } |
|
| 546 | 637 | |
| 547 | - if($obj->isMoveToTrash) return new Object(); |
|
| 638 | + if($obj->isMoveToTrash) { |
|
| 639 | + return new Object(); |
|
| 640 | + } |
|
| 548 | 641 | |
| 549 | 642 | $output = $this->deleteFiles($comment_srl); |
| 550 | 643 | return $output; |
@@ -559,7 +652,9 @@ discard block |
||
| 559 | 652 | function triggerDeleteModuleFiles(&$obj) |
| 560 | 653 | { |
| 561 | 654 | $module_srl = $obj->module_srl; |
| 562 | - if(!$module_srl) return new Object(); |
|
| 655 | + if(!$module_srl) { |
|
| 656 | + return new Object(); |
|
| 657 | + } |
|
| 563 | 658 | |
| 564 | 659 | $oFileController = getAdminController('file'); |
| 565 | 660 | return $oFileController->deleteModuleFiles($module_srl); |
@@ -634,7 +729,9 @@ discard block |
||
| 634 | 729 | $trigger_obj->module_srl = $module_srl; |
| 635 | 730 | $trigger_obj->upload_target_srl = $upload_target_srl; |
| 636 | 731 | $output = ModuleHandler::triggerCall('file.insertFile', 'before', $trigger_obj); |
| 637 | - if(!$output->toBool()) return $output; |
|
| 732 | + if(!$output->toBool()) { |
|
| 733 | + return $output; |
|
| 734 | + } |
|
| 638 | 735 | |
| 639 | 736 | // A workaround for Firefox upload bug |
| 640 | 737 | if(preg_match('/^=\?UTF-8\?B\?(.+)\?=$/i', $file_info['name'], $match)) |
@@ -672,13 +769,17 @@ discard block |
||
| 672 | 769 | $allowed_filesize = $config->allowed_filesize * 1024 * 1024; |
| 673 | 770 | $allowed_attach_size = $config->allowed_attach_size * 1024 * 1024; |
| 674 | 771 | // An error appears if file size exceeds a limit |
| 675 | - if($allowed_filesize < filesize($file_info['tmp_name'])) return new Object(-1, 'msg_exceeds_limit_size'); |
|
| 772 | + if($allowed_filesize < filesize($file_info['tmp_name'])) { |
|
| 773 | + return new Object(-1, 'msg_exceeds_limit_size'); |
|
| 774 | + } |
|
| 676 | 775 | // Get total file size of all attachements (from DB) |
| 677 | 776 | $size_args = new stdClass; |
| 678 | 777 | $size_args->upload_target_srl = $upload_target_srl; |
| 679 | 778 | $output = executeQuery('file.getAttachedFileSize', $size_args); |
| 680 | 779 | $attached_size = (int)$output->data->attached_size + filesize($file_info['tmp_name']); |
| 681 | - if($attached_size > $allowed_attach_size) return new Object(-1, 'msg_exceeds_limit_size'); |
|
| 780 | + if($attached_size > $allowed_attach_size) { |
|
| 781 | + return new Object(-1, 'msg_exceeds_limit_size'); |
|
| 782 | + } |
|
| 682 | 783 | } |
| 683 | 784 | } |
| 684 | 785 | |
@@ -708,18 +809,21 @@ discard block |
||
| 708 | 809 | $idx++; |
| 709 | 810 | } |
| 710 | 811 | $direct_download = 'Y'; |
| 711 | - } |
|
| 712 | - else |
|
| 812 | + } else |
|
| 713 | 813 | { |
| 714 | 814 | $path = sprintf("./files/attach/binaries/%s/%s", $module_srl, getNumberingPath($upload_target_srl,3)); |
| 715 | 815 | $filename = $path.$random->createSecureSalt(32, 'hex'); |
| 716 | 816 | $direct_download = 'N'; |
| 717 | 817 | } |
| 718 | 818 | // Create a directory |
| 719 | - if(!FileHandler::makeDir($path)) return new Object(-1,'msg_not_permitted_create'); |
|
| 819 | + if(!FileHandler::makeDir($path)) { |
|
| 820 | + return new Object(-1,'msg_not_permitted_create'); |
|
| 821 | + } |
|
| 720 | 822 | |
| 721 | 823 | // Check uploaded file |
| 722 | - if(!checkUploadedFile($file_info['tmp_name'])) return new Object(-1,'msg_file_upload_error'); |
|
| 824 | + if(!checkUploadedFile($file_info['tmp_name'])) { |
|
| 825 | + return new Object(-1,'msg_file_upload_error'); |
|
| 826 | + } |
|
| 723 | 827 | |
| 724 | 828 | // Get random number generator |
| 725 | 829 | $random = new Password(); |
@@ -733,13 +837,14 @@ discard block |
||
| 733 | 837 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
| 734 | 838 | @copy($file_info['tmp_name'], $filename); |
| 735 | 839 | } |
| 736 | - } |
|
| 737 | - else |
|
| 840 | + } else |
|
| 738 | 841 | { |
| 739 | 842 | if(!@move_uploaded_file($file_info['tmp_name'], $filename)) |
| 740 | 843 | { |
| 741 | 844 | $filename = $path.$random->createSecureSalt(32, 'hex').'.'.$ext; |
| 742 | - if(!@move_uploaded_file($file_info['tmp_name'], $filename)) return new Object(-1,'msg_file_upload_error'); |
|
| 845 | + if(!@move_uploaded_file($file_info['tmp_name'], $filename)) { |
|
| 846 | + return new Object(-1,'msg_file_upload_error'); |
|
| 847 | + } |
|
| 743 | 848 | } |
| 744 | 849 | } |
| 745 | 850 | // Get member information |
@@ -760,10 +865,14 @@ discard block |
||
| 760 | 865 | $args->sid = $random->createSecureSalt(32, 'hex'); |
| 761 | 866 | |
| 762 | 867 | $output = executeQuery('file.insertFile', $args); |
| 763 | - if(!$output->toBool()) return $output; |
|
| 868 | + if(!$output->toBool()) { |
|
| 869 | + return $output; |
|
| 870 | + } |
|
| 764 | 871 | // Call a trigger (after) |
| 765 | 872 | $trigger_output = ModuleHandler::triggerCall('file.insertFile', 'after', $args); |
| 766 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
| 873 | + if(!$trigger_output->toBool()) { |
|
| 874 | + return $trigger_output; |
|
| 875 | + } |
|
| 767 | 876 | |
| 768 | 877 | $_SESSION['__XE_UPLOADING_FILES_INFO__'][$args->file_srl] = true; |
| 769 | 878 | |
@@ -806,10 +915,14 @@ discard block |
||
| 806 | 915 | */ |
| 807 | 916 | function deleteFile($file_srl) |
| 808 | 917 | { |
| 809 | - if(!$file_srl) return; |
|
| 918 | + if(!$file_srl) { |
|
| 919 | + return; |
|
| 920 | + } |
|
| 810 | 921 | |
| 811 | 922 | $srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl); |
| 812 | - if(!count($srls)) return; |
|
| 923 | + if(!count($srls)) { |
|
| 924 | + return; |
|
| 925 | + } |
|
| 813 | 926 | |
| 814 | 927 | $oDocumentController = getController('document'); |
| 815 | 928 | $documentSrlList = array(); |
@@ -844,15 +957,21 @@ discard block |
||
| 844 | 957 | // Call a trigger (before) |
| 845 | 958 | $trigger_obj = $output->data; |
| 846 | 959 | $output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj); |
| 847 | - if(!$output->toBool()) return $output; |
|
| 960 | + if(!$output->toBool()) { |
|
| 961 | + return $output; |
|
| 962 | + } |
|
| 848 | 963 | |
| 849 | 964 | // Remove from the DB |
| 850 | 965 | $output = executeQuery('file.deleteFile', $args); |
| 851 | - if(!$output->toBool()) return $output; |
|
| 966 | + if(!$output->toBool()) { |
|
| 967 | + return $output; |
|
| 968 | + } |
|
| 852 | 969 | |
| 853 | 970 | // Call a trigger (after) |
| 854 | 971 | $trigger_output = ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj); |
| 855 | - if(!$trigger_output->toBool()) return $trigger_output; |
|
| 972 | + if(!$trigger_output->toBool()) { |
|
| 973 | + return $trigger_output; |
|
| 974 | + } |
|
| 856 | 975 | |
| 857 | 976 | // If successfully deleted, remove the file |
| 858 | 977 | FileHandler::removeFile($uploaded_filename); |
@@ -876,7 +995,9 @@ discard block |
||
| 876 | 995 | $columnList = array('file_srl', 'uploaded_filename', 'module_srl'); |
| 877 | 996 | $file_list = $oFileModel->getFiles($upload_target_srl, $columnList); |
| 878 | 997 | // Success returned if no attachement exists |
| 879 | - if(!is_array($file_list)||!count($file_list)) return new Object(); |
|
| 998 | + if(!is_array($file_list)||!count($file_list)) { |
|
| 999 | + return new Object(); |
|
| 1000 | + } |
|
| 880 | 1001 | |
| 881 | 1002 | // Delete the file |
| 882 | 1003 | $path = array(); |
@@ -887,14 +1008,18 @@ discard block |
||
| 887 | 1008 | |
| 888 | 1009 | $uploaded_filename = $file_list[$i]->uploaded_filename; |
| 889 | 1010 | $path_info = pathinfo($uploaded_filename); |
| 890 | - if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; |
|
| 1011 | + if(!in_array($path_info['dirname'], $path)) { |
|
| 1012 | + $path[] = $path_info['dirname']; |
|
| 1013 | + } |
|
| 891 | 1014 | } |
| 892 | 1015 | |
| 893 | 1016 | // Remove from the DB |
| 894 | 1017 | $args = new stdClass(); |
| 895 | 1018 | $args->upload_target_srl = $upload_target_srl; |
| 896 | 1019 | $output = executeQuery('file.deleteFiles', $args); |
| 897 | - if(!$output->toBool()) return $output; |
|
| 1020 | + if(!$output->toBool()) { |
|
| 1021 | + return $output; |
|
| 1022 | + } |
|
| 898 | 1023 | |
| 899 | 1024 | // Remove a file directory of the document |
| 900 | 1025 | for($i=0, $c=count($path); $i<$c; $i++) |
@@ -915,11 +1040,15 @@ discard block |
||
| 915 | 1040 | */ |
| 916 | 1041 | function moveFile($source_srl, $target_module_srl, $target_srl) |
| 917 | 1042 | { |
| 918 | - if($source_srl == $target_srl) return; |
|
| 1043 | + if($source_srl == $target_srl) { |
|
| 1044 | + return; |
|
| 1045 | + } |
|
| 919 | 1046 | |
| 920 | 1047 | $oFileModel = getModel('file'); |
| 921 | 1048 | $file_list = $oFileModel->getFiles($source_srl); |
| 922 | - if(!$file_list) return; |
|
| 1049 | + if(!$file_list) { |
|
| 1050 | + return; |
|
| 1051 | + } |
|
| 923 | 1052 | |
| 924 | 1053 | $file_count = count($file_list); |
| 925 | 1054 | |
@@ -933,15 +1062,16 @@ discard block |
||
| 933 | 1062 | { |
| 934 | 1063 | $path = sprintf("./files/attach/images/%s/%s/", $target_module_srl,$target_srl); |
| 935 | 1064 | $new_file = $path.$file_info->source_filename; |
| 936 | - } |
|
| 937 | - else |
|
| 1065 | + } else |
|
| 938 | 1066 | { |
| 939 | 1067 | $path = sprintf("./files/attach/binaries/%s/%s/", $target_module_srl, $target_srl); |
| 940 | 1068 | $random = new Password(); |
| 941 | 1069 | $new_file = $path.$random->createSecureSalt(32, 'hex'); |
| 942 | 1070 | } |
| 943 | 1071 | // Pass if a target document to move is same |
| 944 | - if($old_file == $new_file) continue; |
|
| 1072 | + if($old_file == $new_file) { |
|
| 1073 | + continue; |
|
| 1074 | + } |
|
| 945 | 1075 | // Create a directory |
| 946 | 1076 | FileHandler::makeDir($path); |
| 947 | 1077 | // Move the file |
@@ -961,16 +1091,22 @@ discard block |
||
| 961 | 1091 | $vars = Context::getRequestVars(); |
| 962 | 1092 | $logged_info = Context::get('logged_info'); |
| 963 | 1093 | |
| 964 | - if(!$vars->editor_sequence) return new Object(-1, 'msg_invalid_request'); |
|
| 1094 | + if(!$vars->editor_sequence) { |
|
| 1095 | + return new Object(-1, 'msg_invalid_request'); |
|
| 1096 | + } |
|
| 965 | 1097 | |
| 966 | 1098 | $upload_target_srl = $_SESSION['upload_info'][$vars->editor_sequence]->upload_target_srl; |
| 967 | 1099 | |
| 968 | 1100 | $oFileModel = getModel('file'); |
| 969 | 1101 | $file_info = $oFileModel->getFile($vars->file_srl); |
| 970 | 1102 | |
| 971 | - if(!$file_info) return new Object(-1, 'msg_not_founded'); |
|
| 1103 | + if(!$file_info) { |
|
| 1104 | + return new Object(-1, 'msg_not_founded'); |
|
| 1105 | + } |
|
| 972 | 1106 | |
| 973 | - if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) return new Object(-1, 'msg_not_permitted'); |
|
| 1107 | + if(!$this->manager && !$file_info->member_srl === $logged_info->member_srl) { |
|
| 1108 | + return new Object(-1, 'msg_not_permitted'); |
|
| 1109 | + } |
|
| 974 | 1110 | |
| 975 | 1111 | $args = new stdClass(); |
| 976 | 1112 | $args->file_srl = $vars->file_srl; |
@@ -74,14 +74,12 @@ discard block |
||
| 74 | 74 | if(is_dir($source_dir . $file)) |
| 75 | 75 | { |
| 76 | 76 | self::copyDir($source_dir . $file, $target_dir . $file, $type); |
| 77 | - } |
|
| 78 | - else |
|
| 77 | + } else |
|
| 79 | 78 | { |
| 80 | 79 | if($type == 'force') |
| 81 | 80 | { |
| 82 | 81 | @unlink($target_dir . $file); |
| 83 | - } |
|
| 84 | - else |
|
| 82 | + } else |
|
| 85 | 83 | { |
| 86 | 84 | if(!file_exists($target_dir . $file)) |
| 87 | 85 | { |
@@ -379,15 +377,13 @@ discard block |
||
| 379 | 377 | if(is_dir($target)) |
| 380 | 378 | { |
| 381 | 379 | self::removeDir($target); |
| 382 | - } |
|
| 383 | - else |
|
| 380 | + } else |
|
| 384 | 381 | { |
| 385 | 382 | unlink($target); |
| 386 | 383 | } |
| 387 | 384 | } |
| 388 | 385 | rmdir($path); |
| 389 | - } |
|
| 390 | - else |
|
| 386 | + } else |
|
| 391 | 387 | { |
| 392 | 388 | unlink($path); |
| 393 | 389 | } |
@@ -454,16 +450,16 @@ discard block |
||
| 454 | 450 | if(is_dir($target)) |
| 455 | 451 | { |
| 456 | 452 | self::removeFilesInDir($target); |
| 457 | - } |
|
| 458 | - else |
|
| 453 | + } else |
|
| 459 | 454 | { |
| 460 | 455 | unlink($target); |
| 461 | 456 | } |
| 462 | 457 | } |
| 463 | - } |
|
| 464 | - else |
|
| 458 | + } else |
|
| 465 | 459 | { |
| 466 | - if(self::exists($path)) unlink($path); |
|
| 460 | + if(self::exists($path)) { |
|
| 461 | + unlink($path); |
|
| 462 | + } |
|
| 467 | 463 | } |
| 468 | 464 | |
| 469 | 465 | } |
@@ -532,8 +528,7 @@ discard block |
||
| 532 | 528 | $oRequest = new HTTP_Request(__PROXY_SERVER__); |
| 533 | 529 | $oRequest->setMethod('POST'); |
| 534 | 530 | $oRequest->addPostData('arg', serialize(array('Destination' => $url, 'method' => $method, 'body' => $body, 'content_type' => $content_type, "headers" => $headers, "post_data" => $post_data))); |
| 535 | - } |
|
| 536 | - else |
|
| 531 | + } else |
|
| 537 | 532 | { |
| 538 | 533 | $oRequest = new HTTP_Request($url); |
| 539 | 534 | |
@@ -547,8 +542,7 @@ discard block |
||
| 547 | 542 | { |
| 548 | 543 | $oRequest->attach($observer); |
| 549 | 544 | } |
| 550 | - } |
|
| 551 | - else |
|
| 545 | + } else |
|
| 552 | 546 | { |
| 553 | 547 | $oRequest->setConfig($key, $val); |
| 554 | 548 | } |
@@ -559,8 +553,7 @@ discard block |
||
| 559 | 553 | if(extension_loaded('curl')) |
| 560 | 554 | { |
| 561 | 555 | $oRequest->setConfig('adapter', 'curl'); |
| 562 | - } |
|
| 563 | - elseif(version_compare(PHP_VERSION, '5.6', '<')) |
|
| 556 | + } elseif(version_compare(PHP_VERSION, '5.6', '<')) |
|
| 564 | 557 | { |
| 565 | 558 | $oRequest->setConfig('ssl_verify_host', false); |
| 566 | 559 | } |
@@ -591,20 +584,21 @@ discard block |
||
| 591 | 584 | $oRequest->addPostData($key, $val); |
| 592 | 585 | } |
| 593 | 586 | } |
| 594 | - if(!$content_type) |
|
| 595 | - $oRequest->addHeader('Content-Type', 'text/html'); |
|
| 596 | - else |
|
| 597 | - $oRequest->addHeader('Content-Type', $content_type); |
|
| 587 | + if(!$content_type) { |
|
| 588 | + $oRequest->addHeader('Content-Type', 'text/html'); |
|
| 589 | + } else { |
|
| 590 | + $oRequest->addHeader('Content-Type', $content_type); |
|
| 591 | + } |
|
| 598 | 592 | $oRequest->setMethod($method); |
| 599 | - if($body) |
|
| 600 | - $oRequest->setBody($body); |
|
| 593 | + if($body) { |
|
| 594 | + $oRequest->setBody($body); |
|
| 595 | + } |
|
| 601 | 596 | } |
| 602 | 597 | |
| 603 | 598 | if(method_exists($oRequest, 'setConfig')) |
| 604 | 599 | { |
| 605 | 600 | $oRequest->setConfig('timeout', $timeout); |
| 606 | - } |
|
| 607 | - elseif(property_exists($oRequest, '_timeout')) |
|
| 601 | + } elseif(property_exists($oRequest, '_timeout')) |
|
| 608 | 602 | { |
| 609 | 603 | $oRequest->_timeout = $timeout; |
| 610 | 604 | } |
@@ -635,13 +629,11 @@ discard block |
||
| 635 | 629 | if(isset($request_config['store_body']) && !$request_config['store_body']) |
| 636 | 630 | { |
| 637 | 631 | return TRUE; |
| 638 | - } |
|
| 639 | - else |
|
| 632 | + } else |
|
| 640 | 633 | { |
| 641 | 634 | return $response; |
| 642 | 635 | } |
| 643 | - } |
|
| 644 | - catch(Exception $e) |
|
| 636 | + } catch(Exception $e) |
|
| 645 | 637 | { |
| 646 | 638 | return NULL; |
| 647 | 639 | } |
@@ -672,8 +664,7 @@ discard block |
||
| 672 | 664 | try |
| 673 | 665 | { |
| 674 | 666 | $result = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers, $cookies, $post_data, $request_config); |
| 675 | - } |
|
| 676 | - catch(Exception $e) |
|
| 667 | + } catch(Exception $e) |
|
| 677 | 668 | { |
| 678 | 669 | return FALSE; |
| 679 | 670 | } |
@@ -803,8 +794,7 @@ discard block |
||
| 803 | 794 | $per = ($width_per > $height_per) ? $height_per : $width_per; |
| 804 | 795 | $resize_width = $width * $per; |
| 805 | 796 | $resize_height = $height * $per; |
| 806 | - } |
|
| 807 | - else |
|
| 797 | + } else |
|
| 808 | 798 | { |
| 809 | 799 | $per = ($width_per < $height_per) ? $height_per : $width_per; |
| 810 | 800 | } |
@@ -814,8 +804,7 @@ discard block |
||
| 814 | 804 | if(function_exists('imagecreateTRUEcolor')) |
| 815 | 805 | { |
| 816 | 806 | $thumb = imagecreateTRUEcolor($resize_width, $resize_height); |
| 817 | - } |
|
| 818 | - else if(function_exists('imagecreate')) |
|
| 807 | + } else if(function_exists('imagecreate')) |
|
| 819 | 808 | { |
| 820 | 809 | $thumb = imagecreate($resize_width, $resize_height); |
| 821 | 810 | } |
@@ -880,8 +869,7 @@ discard block |
||
| 880 | 869 | if(function_exists('imagecopyresampled')) |
| 881 | 870 | { |
| 882 | 871 | imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height); |
| 883 | - } |
|
| 884 | - else |
|
| 872 | + } else |
|
| 885 | 873 | { |
| 886 | 874 | imagecopyresized($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height); |
| 887 | 875 | } |
@@ -950,8 +938,7 @@ discard block |
||
| 950 | 938 | if(is_array($arr) && count($arr) > 0) |
| 951 | 939 | { |
| 952 | 940 | return $arr; |
| 953 | - } |
|
| 954 | - else |
|
| 941 | + } else |
|
| 955 | 942 | { |
| 956 | 943 | return array(); |
| 957 | 944 | } |
@@ -1001,12 +988,10 @@ discard block |
||
| 1001 | 988 | $return[] = sprintf("%s=\"%s\"", $k, $v); |
| 1002 | 989 | } |
| 1003 | 990 | // value |
| 1004 | - } |
|
| 1005 | - else if(is_object($val)) |
|
| 991 | + } else if(is_object($val)) |
|
| 1006 | 992 | { |
| 1007 | 993 | continue; |
| 1008 | - } |
|
| 1009 | - else |
|
| 994 | + } else |
|
| 1010 | 995 | { |
| 1011 | 996 | $return[] = sprintf("%s=\"%s\"", $key, $val); |
| 1012 | 997 | } |
@@ -17,9 +17,9 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | function getRealPath($source) |
| 19 | 19 | { |
| 20 | - if(strlen($source) >= 2 && substr_compare($source, './', 0, 2) === 0) |
|
| 20 | + if (strlen($source) >= 2 && substr_compare($source, './', 0, 2) === 0) |
|
| 21 | 21 | { |
| 22 | - return _XE_PATH_ . substr($source, 2); |
|
| 22 | + return _XE_PATH_.substr($source, 2); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | return $source; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | { |
| 41 | 41 | $source_dir = self::getRealPath($source_dir); |
| 42 | 42 | $target_dir = self::getRealPath($target_dir); |
| 43 | - if(!is_dir($source_dir)) |
|
| 43 | + if (!is_dir($source_dir)) |
|
| 44 | 44 | { |
| 45 | 45 | return FALSE; |
| 46 | 46 | } |
@@ -48,44 +48,44 @@ discard block |
||
| 48 | 48 | // generate when no target exists |
| 49 | 49 | self::makeDir($target_dir); |
| 50 | 50 | |
| 51 | - if(substr($source_dir, -1) != DIRECTORY_SEPARATOR) |
|
| 51 | + if (substr($source_dir, -1) != DIRECTORY_SEPARATOR) |
|
| 52 | 52 | { |
| 53 | 53 | $source_dir .= DIRECTORY_SEPARATOR; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if(substr($target_dir, -1) != DIRECTORY_SEPARATOR) |
|
| 56 | + if (substr($target_dir, -1) != DIRECTORY_SEPARATOR) |
|
| 57 | 57 | { |
| 58 | 58 | $target_dir .= DIRECTORY_SEPARATOR; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | $oDir = dir($source_dir); |
| 62 | - while($file = $oDir->read()) |
|
| 62 | + while ($file = $oDir->read()) |
|
| 63 | 63 | { |
| 64 | - if($file{0} == '.') |
|
| 64 | + if ($file{0} == '.') |
|
| 65 | 65 | { |
| 66 | 66 | continue; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - if($filter && preg_match($filter, $file)) |
|
| 69 | + if ($filter && preg_match($filter, $file)) |
|
| 70 | 70 | { |
| 71 | 71 | continue; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if(is_dir($source_dir . $file)) |
|
| 74 | + if (is_dir($source_dir.$file)) |
|
| 75 | 75 | { |
| 76 | - self::copyDir($source_dir . $file, $target_dir . $file, $type); |
|
| 76 | + self::copyDir($source_dir.$file, $target_dir.$file, $type); |
|
| 77 | 77 | } |
| 78 | 78 | else |
| 79 | 79 | { |
| 80 | - if($type == 'force') |
|
| 80 | + if ($type == 'force') |
|
| 81 | 81 | { |
| 82 | - @unlink($target_dir . $file); |
|
| 82 | + @unlink($target_dir.$file); |
|
| 83 | 83 | } |
| 84 | 84 | else |
| 85 | 85 | { |
| 86 | - if(!file_exists($target_dir . $file)) |
|
| 86 | + if (!file_exists($target_dir.$file)) |
|
| 87 | 87 | { |
| 88 | - @copy($source_dir . $file, $target_dir . $file); |
|
| 88 | + @copy($source_dir.$file, $target_dir.$file); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | } |
@@ -110,12 +110,12 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | self::makeDir($target_dir); |
| 112 | 112 | |
| 113 | - if($force == 'Y') |
|
| 113 | + if ($force == 'Y') |
|
| 114 | 114 | { |
| 115 | - @unlink($target_dir . DIRECTORY_SEPARATOR . $target); |
|
| 115 | + @unlink($target_dir.DIRECTORY_SEPARATOR.$target); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - @copy($source, $target_dir . DIRECTORY_SEPARATOR . $target); |
|
| 118 | + @copy($source, $target_dir.DIRECTORY_SEPARATOR.$target); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | function readFile($filename) |
| 128 | 128 | { |
| 129 | - if(($filename = self::exists($filename)) === FALSE || filesize($filename) < 1) |
|
| 129 | + if (($filename = self::exists($filename)) === FALSE || filesize($filename) < 1) |
|
| 130 | 130 | { |
| 131 | 131 | return; |
| 132 | 132 | } |
@@ -149,12 +149,12 @@ discard block |
||
| 149 | 149 | self::makeDir($pathinfo['dirname']); |
| 150 | 150 | |
| 151 | 151 | $flags = 0; |
| 152 | - if(strtolower($mode) == 'a') |
|
| 152 | + if (strtolower($mode) == 'a') |
|
| 153 | 153 | { |
| 154 | 154 | $flags = FILE_APPEND; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - @file_put_contents($filename, $buff, $flags|LOCK_EX); |
|
| 157 | + @file_put_contents($filename, $buff, $flags | LOCK_EX); |
|
| 158 | 158 | @chmod($filename, 0644); |
| 159 | 159 | } |
| 160 | 160 | |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | */ |
| 193 | 193 | function moveFile($source, $target) |
| 194 | 194 | { |
| 195 | - if(($source = self::exists($source)) !== FALSE) |
|
| 195 | + if (($source = self::exists($source)) !== FALSE) |
|
| 196 | 196 | { |
| 197 | 197 | self::removeFile($target); |
| 198 | 198 | return self::rename($source, $target); |
@@ -230,35 +230,35 @@ discard block |
||
| 230 | 230 | $path = self::getRealPath($path); |
| 231 | 231 | $output = array(); |
| 232 | 232 | |
| 233 | - if(substr($path, -1) != '/') |
|
| 233 | + if (substr($path, -1) != '/') |
|
| 234 | 234 | { |
| 235 | 235 | $path .= '/'; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - if(!is_dir($path)) |
|
| 238 | + if (!is_dir($path)) |
|
| 239 | 239 | { |
| 240 | 240 | return $output; |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | $files = scandir($path); |
| 244 | - foreach($files as $file) |
|
| 244 | + foreach ($files as $file) |
|
| 245 | 245 | { |
| 246 | - if($file{0} == '.' || ($filter && !preg_match($filter, $file))) |
|
| 246 | + if ($file{0} == '.' || ($filter && !preg_match($filter, $file))) |
|
| 247 | 247 | { |
| 248 | 248 | continue; |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - if($to_lower) |
|
| 251 | + if ($to_lower) |
|
| 252 | 252 | { |
| 253 | 253 | $file = strtolower($file); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - if($filter) |
|
| 256 | + if ($filter) |
|
| 257 | 257 | { |
| 258 | 258 | $file = preg_replace($filter, '$1', $file); |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - if($concat_prefix) |
|
| 261 | + if ($concat_prefix) |
|
| 262 | 262 | { |
| 263 | 263 | $file = sprintf('%s%s', str_replace(_XE_PATH_, '', $path), $file); |
| 264 | 264 | } |
@@ -279,12 +279,12 @@ discard block |
||
| 279 | 279 | */ |
| 280 | 280 | function makeDir($path_string) |
| 281 | 281 | { |
| 282 | - if(self::exists($path_string) !== FALSE) |
|
| 282 | + if (self::exists($path_string) !== FALSE) |
|
| 283 | 283 | { |
| 284 | 284 | return TRUE; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | - if(!ini_get('safe_mode')) |
|
| 287 | + if (!ini_get('safe_mode')) |
|
| 288 | 288 | { |
| 289 | 289 | @mkdir($path_string, 0755, TRUE); |
| 290 | 290 | @chmod($path_string, 0755); |
@@ -295,35 +295,35 @@ discard block |
||
| 295 | 295 | static $oFtp = NULL; |
| 296 | 296 | |
| 297 | 297 | $ftp_info = Context::getFTPInfo(); |
| 298 | - if($oFtp == NULL) |
|
| 298 | + if ($oFtp == NULL) |
|
| 299 | 299 | { |
| 300 | - if(!Context::isFTPRegisted()) |
|
| 300 | + if (!Context::isFTPRegisted()) |
|
| 301 | 301 | { |
| 302 | 302 | return; |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | - require_once(_XE_PATH_ . 'libs/ftp.class.php'); |
|
| 305 | + require_once(_XE_PATH_.'libs/ftp.class.php'); |
|
| 306 | 306 | $oFtp = new ftp(); |
| 307 | - if(!$ftp_info->ftp_host) |
|
| 307 | + if (!$ftp_info->ftp_host) |
|
| 308 | 308 | { |
| 309 | 309 | $ftp_info->ftp_host = "127.0.0.1"; |
| 310 | 310 | } |
| 311 | - if(!$ftp_info->ftp_port) |
|
| 311 | + if (!$ftp_info->ftp_port) |
|
| 312 | 312 | { |
| 313 | 313 | $ftp_info->ftp_port = 21; |
| 314 | 314 | } |
| 315 | - if(!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) |
|
| 315 | + if (!$oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) |
|
| 316 | 316 | { |
| 317 | 317 | return; |
| 318 | 318 | } |
| 319 | - if(!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 319 | + if (!$oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) |
|
| 320 | 320 | { |
| 321 | 321 | $oFtp->ftp_quit(); |
| 322 | 322 | return; |
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - if(!($ftp_path = $ftp_info->ftp_root_path)) |
|
| 326 | + if (!($ftp_path = $ftp_info->ftp_root_path)) |
|
| 327 | 327 | { |
| 328 | 328 | $ftp_path = DIRECTORY_SEPARATOR; |
| 329 | 329 | } |
@@ -332,19 +332,19 @@ discard block |
||
| 332 | 332 | $path_list = explode(DIRECTORY_SEPARATOR, $path_string); |
| 333 | 333 | |
| 334 | 334 | $path = _XE_PATH_; |
| 335 | - for($i = 0, $c = count($path_list); $i < $c; $i++) |
|
| 335 | + for ($i = 0, $c = count($path_list); $i < $c; $i++) |
|
| 336 | 336 | { |
| 337 | - if(!$path_list[$i]) |
|
| 337 | + if (!$path_list[$i]) |
|
| 338 | 338 | { |
| 339 | 339 | continue; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $path .= $path_list[$i] . DIRECTORY_SEPARATOR; |
|
| 343 | - $ftp_path .= $path_list[$i] . DIRECTORY_SEPARATOR; |
|
| 344 | - if(!is_dir($path)) |
|
| 342 | + $path .= $path_list[$i].DIRECTORY_SEPARATOR; |
|
| 343 | + $ftp_path .= $path_list[$i].DIRECTORY_SEPARATOR; |
|
| 344 | + if (!is_dir($path)) |
|
| 345 | 345 | { |
| 346 | 346 | $oFtp->ftp_mkdir($ftp_path); |
| 347 | - $oFtp->ftp_site("CHMOD 777 " . $ftp_path); |
|
| 347 | + $oFtp->ftp_site("CHMOD 777 ".$ftp_path); |
|
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 | } |
@@ -360,23 +360,23 @@ discard block |
||
| 360 | 360 | */ |
| 361 | 361 | function removeDir($path) |
| 362 | 362 | { |
| 363 | - if(($path = self::isDir($path)) === FALSE) |
|
| 363 | + if (($path = self::isDir($path)) === FALSE) |
|
| 364 | 364 | { |
| 365 | 365 | return; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - if(self::isDir($path)) |
|
| 368 | + if (self::isDir($path)) |
|
| 369 | 369 | { |
| 370 | 370 | $files = array_diff(scandir($path), array('..', '.')); |
| 371 | 371 | |
| 372 | - foreach($files as $file) |
|
| 372 | + foreach ($files as $file) |
|
| 373 | 373 | { |
| 374 | - if(($target = self::getRealPath($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
| 374 | + if (($target = self::getRealPath($path.DIRECTORY_SEPARATOR.$file)) === FALSE) |
|
| 375 | 375 | { |
| 376 | 376 | continue; |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - if(is_dir($target)) |
|
| 379 | + if (is_dir($target)) |
|
| 380 | 380 | { |
| 381 | 381 | self::removeDir($target); |
| 382 | 382 | } |
@@ -401,22 +401,22 @@ discard block |
||
| 401 | 401 | */ |
| 402 | 402 | function removeBlankDir($path) |
| 403 | 403 | { |
| 404 | - if(($path = self::isDir($path)) === FALSE) |
|
| 404 | + if (($path = self::isDir($path)) === FALSE) |
|
| 405 | 405 | { |
| 406 | 406 | return; |
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | $files = array_diff(scandir($path), array('..', '.')); |
| 410 | 410 | |
| 411 | - if(count($files) < 1) |
|
| 411 | + if (count($files) < 1) |
|
| 412 | 412 | { |
| 413 | 413 | rmdir($path); |
| 414 | 414 | return; |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | - foreach($files as $file) |
|
| 417 | + foreach ($files as $file) |
|
| 418 | 418 | { |
| 419 | - if(($target = self::isDir($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
| 419 | + if (($target = self::isDir($path.DIRECTORY_SEPARATOR.$file)) === FALSE) |
|
| 420 | 420 | { |
| 421 | 421 | continue; |
| 422 | 422 | } |
@@ -435,23 +435,23 @@ discard block |
||
| 435 | 435 | */ |
| 436 | 436 | function removeFilesInDir($path) |
| 437 | 437 | { |
| 438 | - if(($path = self::getRealPath($path)) === FALSE) |
|
| 438 | + if (($path = self::getRealPath($path)) === FALSE) |
|
| 439 | 439 | { |
| 440 | 440 | return; |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | - if(is_dir($path)) |
|
| 443 | + if (is_dir($path)) |
|
| 444 | 444 | { |
| 445 | 445 | $files = array_diff(scandir($path), array('..', '.')); |
| 446 | 446 | |
| 447 | - foreach($files as $file) |
|
| 447 | + foreach ($files as $file) |
|
| 448 | 448 | { |
| 449 | - if(($target = self::getRealPath($path . DIRECTORY_SEPARATOR . $file)) === FALSE) |
|
| 449 | + if (($target = self::getRealPath($path.DIRECTORY_SEPARATOR.$file)) === FALSE) |
|
| 450 | 450 | { |
| 451 | 451 | continue; |
| 452 | 452 | } |
| 453 | 453 | |
| 454 | - if(is_dir($target)) |
|
| 454 | + if (is_dir($target)) |
|
| 455 | 455 | { |
| 456 | 456 | self::removeFilesInDir($target); |
| 457 | 457 | } |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | } |
| 464 | 464 | else |
| 465 | 465 | { |
| 466 | - if(self::exists($path)) unlink($path); |
|
| 466 | + if (self::exists($path)) unlink($path); |
|
| 467 | 467 | } |
| 468 | 468 | |
| 469 | 469 | } |
@@ -477,22 +477,22 @@ discard block |
||
| 477 | 477 | */ |
| 478 | 478 | function filesize($size) |
| 479 | 479 | { |
| 480 | - if(!$size) |
|
| 480 | + if (!$size) |
|
| 481 | 481 | { |
| 482 | 482 | return '0Byte'; |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | - if($size === 1) |
|
| 485 | + if ($size === 1) |
|
| 486 | 486 | { |
| 487 | 487 | return '1Byte'; |
| 488 | 488 | } |
| 489 | 489 | |
| 490 | - if($size < 1024) |
|
| 490 | + if ($size < 1024) |
|
| 491 | 491 | { |
| 492 | - return $size . 'Bytes'; |
|
| 492 | + return $size.'Bytes'; |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | - if($size >= 1024 && $size < 1024 * 1024) |
|
| 495 | + if ($size >= 1024 && $size < 1024 * 1024) |
|
| 496 | 496 | { |
| 497 | 497 | return sprintf("%0.1fKB", $size / 1024); |
| 498 | 498 | } |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | */ |
| 518 | 518 | function getRemoteResource($url, $body = null, $timeout = 3, $method = 'GET', $content_type = null, $headers = array(), $cookies = array(), $post_data = array(), $request_config = array()) |
| 519 | 519 | { |
| 520 | - require_once(_XE_PATH_ . 'libs/idna_convert/idna_convert.class.php'); |
|
| 520 | + require_once(_XE_PATH_.'libs/idna_convert/idna_convert.class.php'); |
|
| 521 | 521 | $IDN = new idna_convert(array('idn_version' => 2008)); |
| 522 | 522 | $url = $IDN->encode($url); |
| 523 | 523 | |
@@ -527,7 +527,7 @@ discard block |
||
| 527 | 527 | require_once('HTTP/Request.php'); |
| 528 | 528 | |
| 529 | 529 | $parsed_url = parse_url(__PROXY_SERVER__); |
| 530 | - if($parsed_url["host"] && $parsed_url["path"]) |
|
| 530 | + if ($parsed_url["host"] && $parsed_url["path"]) |
|
| 531 | 531 | { |
| 532 | 532 | // Old style proxy server support (POST payload to proxy script) |
| 533 | 533 | $oRequest = new HTTP_Request(__PROXY_SERVER__); |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | $oRequest = new HTTP_Request($url); |
| 540 | 540 | |
| 541 | 541 | // New style proxy server support (Use HTTP_Request2 native config format) |
| 542 | - if($parsed_url['host']) |
|
| 542 | + if ($parsed_url['host']) |
|
| 543 | 543 | { |
| 544 | 544 | $request_config['proxy_host'] = $parsed_url['host']; |
| 545 | 545 | $request_config['proxy_port'] = $parsed_url['port'] ? $parsed_url['port'] : ''; |
@@ -548,13 +548,13 @@ discard block |
||
| 548 | 548 | $request_config['proxy_type'] = $parsed_url['scheme'] ? $parsed_url['scheme'] : 'http'; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - if(count($request_config) && method_exists($oRequest, 'setConfig')) |
|
| 551 | + if (count($request_config) && method_exists($oRequest, 'setConfig')) |
|
| 552 | 552 | { |
| 553 | - foreach($request_config as $key=>$val) |
|
| 553 | + foreach ($request_config as $key=>$val) |
|
| 554 | 554 | { |
| 555 | - if($key === 'observers') |
|
| 555 | + if ($key === 'observers') |
|
| 556 | 556 | { |
| 557 | - foreach($val as $observer) |
|
| 557 | + foreach ($val as $observer) |
|
| 558 | 558 | { |
| 559 | 559 | $oRequest->attach($observer); |
| 560 | 560 | } |
@@ -565,58 +565,58 @@ discard block |
||
| 565 | 565 | } |
| 566 | 566 | } |
| 567 | 567 | } |
| 568 | - if(method_exists($oRequest, 'setConfig')) |
|
| 568 | + if (method_exists($oRequest, 'setConfig')) |
|
| 569 | 569 | { |
| 570 | - if(extension_loaded('curl')) |
|
| 570 | + if (extension_loaded('curl')) |
|
| 571 | 571 | { |
| 572 | 572 | $oRequest->setConfig('adapter', 'curl'); |
| 573 | 573 | } |
| 574 | - elseif(version_compare(PHP_VERSION, '5.6', '<')) |
|
| 574 | + elseif (version_compare(PHP_VERSION, '5.6', '<')) |
|
| 575 | 575 | { |
| 576 | 576 | $oRequest->setConfig('ssl_verify_host', false); |
| 577 | 577 | } |
| 578 | - if(file_exists(_XE_PATH_ . 'libs/cacert/cacert.pem')) |
|
| 578 | + if (file_exists(_XE_PATH_.'libs/cacert/cacert.pem')) |
|
| 579 | 579 | { |
| 580 | - $oRequest->setConfig('ssl_cafile', _XE_PATH_ . 'libs/cacert/cacert.pem'); |
|
| 580 | + $oRequest->setConfig('ssl_cafile', _XE_PATH_.'libs/cacert/cacert.pem'); |
|
| 581 | 581 | } |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | - if(count($headers) > 0) |
|
| 584 | + if (count($headers) > 0) |
|
| 585 | 585 | { |
| 586 | - foreach($headers as $key => $val) |
|
| 586 | + foreach ($headers as $key => $val) |
|
| 587 | 587 | { |
| 588 | 588 | $oRequest->addHeader($key, $val); |
| 589 | 589 | } |
| 590 | 590 | } |
| 591 | 591 | $host = parse_url($url, PHP_URL_HOST); |
| 592 | - if($cookies[$host]) |
|
| 592 | + if ($cookies[$host]) |
|
| 593 | 593 | { |
| 594 | - foreach($cookies[$host] as $key => $val) |
|
| 594 | + foreach ($cookies[$host] as $key => $val) |
|
| 595 | 595 | { |
| 596 | 596 | $oRequest->addCookie($key, $val); |
| 597 | 597 | } |
| 598 | 598 | } |
| 599 | - if(count($post_data) > 0) |
|
| 599 | + if (count($post_data) > 0) |
|
| 600 | 600 | { |
| 601 | - foreach($post_data as $key => $val) |
|
| 601 | + foreach ($post_data as $key => $val) |
|
| 602 | 602 | { |
| 603 | 603 | $oRequest->addPostData($key, $val); |
| 604 | 604 | } |
| 605 | 605 | } |
| 606 | - if(!$content_type) |
|
| 606 | + if (!$content_type) |
|
| 607 | 607 | $oRequest->addHeader('Content-Type', 'text/html'); |
| 608 | 608 | else |
| 609 | 609 | $oRequest->addHeader('Content-Type', $content_type); |
| 610 | 610 | $oRequest->setMethod($method); |
| 611 | - if($body) |
|
| 611 | + if ($body) |
|
| 612 | 612 | $oRequest->setBody($body); |
| 613 | 613 | } |
| 614 | 614 | |
| 615 | - if(method_exists($oRequest, 'setConfig')) |
|
| 615 | + if (method_exists($oRequest, 'setConfig')) |
|
| 616 | 616 | { |
| 617 | 617 | $oRequest->setConfig('timeout', $timeout); |
| 618 | 618 | } |
| 619 | - elseif(property_exists($oRequest, '_timeout')) |
|
| 619 | + elseif (property_exists($oRequest, '_timeout')) |
|
| 620 | 620 | { |
| 621 | 621 | $oRequest->_timeout = $timeout; |
| 622 | 622 | } |
@@ -626,25 +626,25 @@ discard block |
||
| 626 | 626 | $code = $oRequest->getResponseCode(); |
| 627 | 627 | $header = $oRequest->getResponseHeader(); |
| 628 | 628 | $response = $oRequest->getResponseBody(); |
| 629 | - if($c = $oRequest->getResponseCookies()) |
|
| 629 | + if ($c = $oRequest->getResponseCookies()) |
|
| 630 | 630 | { |
| 631 | - foreach($c as $k => $v) |
|
| 631 | + foreach ($c as $k => $v) |
|
| 632 | 632 | { |
| 633 | 633 | $cookies[$host][$v['name']] = $v['value']; |
| 634 | 634 | } |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | - if($code > 300 && $code < 399 && $header['location']) |
|
| 637 | + if ($code > 300 && $code < 399 && $header['location']) |
|
| 638 | 638 | { |
| 639 | 639 | return self::getRemoteResource($header['location'], $body, $timeout, $method, $content_type, $headers, $cookies, $post_data); |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - if($code != 200) |
|
| 642 | + if ($code != 200) |
|
| 643 | 643 | { |
| 644 | 644 | return; |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | - if(isset($request_config['store_body']) && !$request_config['store_body']) |
|
| 647 | + if (isset($request_config['store_body']) && !$request_config['store_body']) |
|
| 648 | 648 | { |
| 649 | 649 | return TRUE; |
| 650 | 650 | } |
@@ -653,7 +653,7 @@ discard block |
||
| 653 | 653 | return $response; |
| 654 | 654 | } |
| 655 | 655 | } |
| 656 | - catch(Exception $e) |
|
| 656 | + catch (Exception $e) |
|
| 657 | 657 | { |
| 658 | 658 | return NULL; |
| 659 | 659 | } |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | { |
| 686 | 686 | $result = self::getRemoteResource($url, $body, $timeout, $method, $content_type, $headers, $cookies, $post_data, $request_config); |
| 687 | 687 | } |
| 688 | - catch(Exception $e) |
|
| 688 | + catch (Exception $e) |
|
| 689 | 689 | { |
| 690 | 690 | return FALSE; |
| 691 | 691 | } |
@@ -702,7 +702,7 @@ discard block |
||
| 702 | 702 | function returnBytes($val) |
| 703 | 703 | { |
| 704 | 704 | $unit = strtoupper(substr($val, -1)); |
| 705 | - $val = (float)$val; |
|
| 705 | + $val = (float) $val; |
|
| 706 | 706 | |
| 707 | 707 | switch ($unit) |
| 708 | 708 | { |
@@ -725,13 +725,13 @@ discard block |
||
| 725 | 725 | $K64 = 65536; |
| 726 | 726 | $TWEAKFACTOR = 2.0; |
| 727 | 727 | $channels = $imageInfo['channels']; |
| 728 | - if(!$channels) |
|
| 728 | + if (!$channels) |
|
| 729 | 729 | { |
| 730 | 730 | $channels = 6; //for png |
| 731 | 731 | } |
| 732 | - $memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64 ) * $TWEAKFACTOR); |
|
| 732 | + $memoryNeeded = round(($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $channels / 8 + $K64) * $TWEAKFACTOR); |
|
| 733 | 733 | $availableMemory = self::returnBytes(ini_get('memory_limit')) - memory_get_usage(); |
| 734 | - if($availableMemory < $memoryNeeded) |
|
| 734 | + if ($availableMemory < $memoryNeeded) |
|
| 735 | 735 | { |
| 736 | 736 | return FALSE; |
| 737 | 737 | } |
@@ -758,30 +758,30 @@ discard block |
||
| 758 | 758 | } |
| 759 | 759 | |
| 760 | 760 | $target_file = self::getRealPath($target_file); |
| 761 | - if(!$resize_width) |
|
| 761 | + if (!$resize_width) |
|
| 762 | 762 | { |
| 763 | 763 | $resize_width = 100; |
| 764 | 764 | } |
| 765 | 765 | |
| 766 | - if(!$resize_height) |
|
| 766 | + if (!$resize_height) |
|
| 767 | 767 | { |
| 768 | 768 | $resize_height = $resize_width; |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | // retrieve source image's information |
| 772 | 772 | $imageInfo = getimagesize($source_file); |
| 773 | - if(!self::checkMemoryLoadImage($imageInfo)) |
|
| 773 | + if (!self::checkMemoryLoadImage($imageInfo)) |
|
| 774 | 774 | { |
| 775 | 775 | return FALSE; |
| 776 | 776 | } |
| 777 | 777 | |
| 778 | 778 | list($width, $height, $type, $attrs) = $imageInfo; |
| 779 | - if($width < 1 || $height < 1) |
|
| 779 | + if ($width < 1 || $height < 1) |
|
| 780 | 780 | { |
| 781 | 781 | return; |
| 782 | 782 | } |
| 783 | 783 | |
| 784 | - switch($type) |
|
| 784 | + switch ($type) |
|
| 785 | 785 | { |
| 786 | 786 | case '1' : |
| 787 | 787 | $type = 'gif'; |
@@ -799,7 +799,7 @@ discard block |
||
| 799 | 799 | return; |
| 800 | 800 | } |
| 801 | 801 | |
| 802 | - if(!$target_type) |
|
| 802 | + if (!$target_type) |
|
| 803 | 803 | { |
| 804 | 804 | $target_type = $type; |
| 805 | 805 | } |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | $height_per = ($resize_height > 0 && $height >= $resize_height) ? $resize_height / $height : 1; |
| 811 | 811 | |
| 812 | 812 | $per = NULL; |
| 813 | - if($thumbnail_type == 'ratio') |
|
| 813 | + if ($thumbnail_type == 'ratio') |
|
| 814 | 814 | { |
| 815 | 815 | $per = ($width_per > $height_per) ? $height_per : $width_per; |
| 816 | 816 | $resize_width = $width * $per; |
@@ -823,16 +823,16 @@ discard block |
||
| 823 | 823 | |
| 824 | 824 | // create temporary image with target size |
| 825 | 825 | $thumb = NULL; |
| 826 | - if(function_exists('imagecreateTRUEcolor')) |
|
| 826 | + if (function_exists('imagecreateTRUEcolor')) |
|
| 827 | 827 | { |
| 828 | 828 | $thumb = imagecreateTRUEcolor($resize_width, $resize_height); |
| 829 | 829 | } |
| 830 | - else if(function_exists('imagecreate')) |
|
| 830 | + else if (function_exists('imagecreate')) |
|
| 831 | 831 | { |
| 832 | 832 | $thumb = imagecreate($resize_width, $resize_height); |
| 833 | 833 | } |
| 834 | 834 | |
| 835 | - if(!$thumb) |
|
| 835 | + if (!$thumb) |
|
| 836 | 836 | { |
| 837 | 837 | return FALSE; |
| 838 | 838 | } |
@@ -841,37 +841,37 @@ discard block |
||
| 841 | 841 | |
| 842 | 842 | // create temporary image having original type |
| 843 | 843 | $source = NULL; |
| 844 | - switch($type) |
|
| 844 | + switch ($type) |
|
| 845 | 845 | { |
| 846 | 846 | case 'gif' : |
| 847 | - if(function_exists('imagecreatefromgif')) |
|
| 847 | + if (function_exists('imagecreatefromgif')) |
|
| 848 | 848 | { |
| 849 | 849 | $source = @imagecreatefromgif($source_file); |
| 850 | 850 | } |
| 851 | 851 | break; |
| 852 | 852 | case 'jpeg' : |
| 853 | 853 | case 'jpg' : |
| 854 | - if(function_exists('imagecreatefromjpeg')) |
|
| 854 | + if (function_exists('imagecreatefromjpeg')) |
|
| 855 | 855 | { |
| 856 | 856 | $source = @imagecreatefromjpeg($source_file); |
| 857 | 857 | } |
| 858 | 858 | break; |
| 859 | 859 | case 'png' : |
| 860 | - if(function_exists('imagecreatefrompng')) |
|
| 860 | + if (function_exists('imagecreatefrompng')) |
|
| 861 | 861 | { |
| 862 | 862 | $source = @imagecreatefrompng($source_file); |
| 863 | 863 | } |
| 864 | 864 | break; |
| 865 | 865 | case 'wbmp' : |
| 866 | 866 | case 'bmp' : |
| 867 | - if(function_exists('imagecreatefromwbmp')) |
|
| 867 | + if (function_exists('imagecreatefromwbmp')) |
|
| 868 | 868 | { |
| 869 | 869 | $source = @imagecreatefromwbmp($source_file); |
| 870 | 870 | } |
| 871 | 871 | break; |
| 872 | 872 | } |
| 873 | 873 | |
| 874 | - if(!$source) |
|
| 874 | + if (!$source) |
|
| 875 | 875 | { |
| 876 | 876 | imagedestroy($thumb); |
| 877 | 877 | return FALSE; |
@@ -883,13 +883,13 @@ discard block |
||
| 883 | 883 | |
| 884 | 884 | $x = 0; |
| 885 | 885 | $y = 0; |
| 886 | - if($thumbnail_type == 'crop') |
|
| 886 | + if ($thumbnail_type == 'crop') |
|
| 887 | 887 | { |
| 888 | 888 | $x = (int) ($resize_width / 2 - $new_width / 2); |
| 889 | 889 | $y = (int) ($resize_height / 2 - $new_height / 2); |
| 890 | 890 | } |
| 891 | 891 | |
| 892 | - if(function_exists('imagecopyresampled')) |
|
| 892 | + if (function_exists('imagecopyresampled')) |
|
| 893 | 893 | { |
| 894 | 894 | imagecopyresampled($thumb, $source, $x, $y, 0, 0, $new_width, $new_height, $width, $height); |
| 895 | 895 | } |
@@ -903,30 +903,30 @@ discard block |
||
| 903 | 903 | |
| 904 | 904 | // write into the file |
| 905 | 905 | $output = NULL; |
| 906 | - switch($target_type) |
|
| 906 | + switch ($target_type) |
|
| 907 | 907 | { |
| 908 | 908 | case 'gif' : |
| 909 | - if(function_exists('imagegif')) |
|
| 909 | + if (function_exists('imagegif')) |
|
| 910 | 910 | { |
| 911 | 911 | $output = imagegif($thumb, $target_file); |
| 912 | 912 | } |
| 913 | 913 | break; |
| 914 | 914 | case 'jpeg' : |
| 915 | 915 | case 'jpg' : |
| 916 | - if(function_exists('imagejpeg')) |
|
| 916 | + if (function_exists('imagejpeg')) |
|
| 917 | 917 | { |
| 918 | 918 | $output = imagejpeg($thumb, $target_file, 100); |
| 919 | 919 | } |
| 920 | 920 | break; |
| 921 | 921 | case 'png' : |
| 922 | - if(function_exists('imagepng')) |
|
| 922 | + if (function_exists('imagepng')) |
|
| 923 | 923 | { |
| 924 | 924 | $output = imagepng($thumb, $target_file, 9); |
| 925 | 925 | } |
| 926 | 926 | break; |
| 927 | 927 | case 'wbmp' : |
| 928 | 928 | case 'bmp' : |
| 929 | - if(function_exists('imagewbmp')) |
|
| 929 | + if (function_exists('imagewbmp')) |
|
| 930 | 930 | { |
| 931 | 931 | $output = imagewbmp($thumb, $target_file, 100); |
| 932 | 932 | } |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | imagedestroy($thumb); |
| 937 | 937 | imagedestroy($source); |
| 938 | 938 | |
| 939 | - if(!$output) |
|
| 939 | + if (!$output) |
|
| 940 | 940 | { |
| 941 | 941 | return FALSE; |
| 942 | 942 | } |
@@ -954,12 +954,12 @@ discard block |
||
| 954 | 954 | */ |
| 955 | 955 | function readIniFile($filename) |
| 956 | 956 | { |
| 957 | - if(($filename = self::exists($filename)) === FALSE) |
|
| 957 | + if (($filename = self::exists($filename)) === FALSE) |
|
| 958 | 958 | { |
| 959 | 959 | return FALSE; |
| 960 | 960 | } |
| 961 | 961 | $arr = parse_ini_file($filename, TRUE); |
| 962 | - if(is_array($arr) && count($arr) > 0) |
|
| 962 | + if (is_array($arr) && count($arr) > 0) |
|
| 963 | 963 | { |
| 964 | 964 | return $arr; |
| 965 | 965 | } |
@@ -985,7 +985,7 @@ discard block |
||
| 985 | 985 | */ |
| 986 | 986 | function writeIniFile($filename, $arr) |
| 987 | 987 | { |
| 988 | - if(!is_array($arr) || count($arr) == 0) |
|
| 988 | + if (!is_array($arr) || count($arr) == 0) |
|
| 989 | 989 | { |
| 990 | 990 | return FALSE; |
| 991 | 991 | } |
@@ -1002,19 +1002,19 @@ discard block |
||
| 1002 | 1002 | function _makeIniBuff($arr) |
| 1003 | 1003 | { |
| 1004 | 1004 | $return = array(); |
| 1005 | - foreach($arr as $key => $val) |
|
| 1005 | + foreach ($arr as $key => $val) |
|
| 1006 | 1006 | { |
| 1007 | 1007 | // section |
| 1008 | - if(is_array($val)) |
|
| 1008 | + if (is_array($val)) |
|
| 1009 | 1009 | { |
| 1010 | 1010 | $return[] = sprintf("[%s]", $key); |
| 1011 | - foreach($val as $k => $v) |
|
| 1011 | + foreach ($val as $k => $v) |
|
| 1012 | 1012 | { |
| 1013 | 1013 | $return[] = sprintf("%s=\"%s\"", $k, $v); |
| 1014 | 1014 | } |
| 1015 | 1015 | // value |
| 1016 | 1016 | } |
| 1017 | - else if(is_object($val)) |
|
| 1017 | + else if (is_object($val)) |
|
| 1018 | 1018 | { |
| 1019 | 1019 | continue; |
| 1020 | 1020 | } |
@@ -1089,15 +1089,15 @@ discard block |
||
| 1089 | 1089 | function isWritableDir($path) |
| 1090 | 1090 | { |
| 1091 | 1091 | $path = self::getRealPath($path); |
| 1092 | - if(is_dir($path)==FALSE) |
|
| 1092 | + if (is_dir($path) == FALSE) |
|
| 1093 | 1093 | { |
| 1094 | 1094 | return FALSE; |
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | - $checkFile = $path . '/_CheckWritableDir'; |
|
| 1097 | + $checkFile = $path.'/_CheckWritableDir'; |
|
| 1098 | 1098 | |
| 1099 | 1099 | $fp = fopen($checkFile, 'w'); |
| 1100 | - if(!is_resource($fp)) |
|
| 1100 | + if (!is_resource($fp)) |
|
| 1101 | 1101 | { |
| 1102 | 1102 | return FALSE; |
| 1103 | 1103 | } |
@@ -39,7 +39,9 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | // Check the point name |
| 41 | 41 | $config->point_name = $args->point_name; |
| 42 | - if(!$config->point_name) $config->point_name = 'point'; |
|
| 42 | + if(!$config->point_name) { |
|
| 43 | + $config->point_name = 'point'; |
|
| 44 | + } |
|
| 43 | 45 | // Specify the default points |
| 44 | 46 | $config->signup_point = (int)$args->signup_point; |
| 45 | 47 | $config->login_point = (int)$args->login_point; |
@@ -52,16 +54,26 @@ discard block |
||
| 52 | 54 | $config->blamed = (int)$args->blamed; |
| 53 | 55 | // The highest level |
| 54 | 56 | $config->max_level = $args->max_level; |
| 55 | - if($config->max_level>1000) $config->max_level = 1000; |
|
| 56 | - if($config->max_level<1) $config->max_level = 1; |
|
| 57 | + if($config->max_level>1000) { |
|
| 58 | + $config->max_level = 1000; |
|
| 59 | + } |
|
| 60 | + if($config->max_level<1) { |
|
| 61 | + $config->max_level = 1; |
|
| 62 | + } |
|
| 57 | 63 | // Set the level icon |
| 58 | 64 | $config->level_icon = $args->level_icon; |
| 59 | 65 | // Check if downloads are not allowed |
| 60 | - if($args->disable_download == 'Y') $config->disable_download = 'Y'; |
|
| 61 | - else $config->disable_download = 'N'; |
|
| 66 | + if($args->disable_download == 'Y') { |
|
| 67 | + $config->disable_download = 'Y'; |
|
| 68 | + } else { |
|
| 69 | + $config->disable_download = 'N'; |
|
| 70 | + } |
|
| 62 | 71 | // Check if reading a document is not allowed |
| 63 | - if($args->disable_read_document == 'Y') $config->disable_read_document = 'Y'; |
|
| 64 | - else $config->disable_read_document = 'N'; |
|
| 72 | + if($args->disable_read_document == 'Y') { |
|
| 73 | + $config->disable_read_document = 'Y'; |
|
| 74 | + } else { |
|
| 75 | + $config->disable_read_document = 'N'; |
|
| 76 | + } |
|
| 65 | 77 | |
| 66 | 78 | $oMemberModel = getModel('member'); |
| 67 | 79 | $group_list = $oMemberModel->getGroups(); |
@@ -71,7 +83,9 @@ discard block |
||
| 71 | 83 | foreach($group_list as $group) |
| 72 | 84 | { |
| 73 | 85 | // Admin group should not be connected to point. |
| 74 | - if($group->is_admin == 'Y' || $group->is_default == 'Y') continue; |
|
| 86 | + if($group->is_admin == 'Y' || $group->is_default == 'Y') { |
|
| 87 | + continue; |
|
| 88 | + } |
|
| 75 | 89 | |
| 76 | 90 | $group_srl = $group->group_srl; |
| 77 | 91 | |
@@ -102,8 +116,7 @@ discard block |
||
| 102 | 116 | } |
| 103 | 117 | // A function to calculate per-level points |
| 104 | 118 | $config->expression = $args->expression; |
| 105 | - } |
|
| 106 | - else |
|
| 119 | + } else |
|
| 107 | 120 | { |
| 108 | 121 | //module IO config is OFF, Other settings will not be modified. |
| 109 | 122 | $config->able_module = 'N'; |
@@ -165,16 +178,23 @@ discard block |
||
| 165 | 178 | function procPointAdminInsertPointModuleConfig() |
| 166 | 179 | { |
| 167 | 180 | $module_srl = Context::get('target_module_srl'); |
| 168 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 181 | + if(!$module_srl) { |
|
| 182 | + return new Object(-1, 'msg_invalid_request'); |
|
| 183 | + } |
|
| 169 | 184 | // In case of batch configuration of several modules |
| 170 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
| 171 | - else $module_srl = array($module_srl); |
|
| 185 | + if(preg_match('/^([0-9,]+)$/',$module_srl)) { |
|
| 186 | + $module_srl = explode(',',$module_srl); |
|
| 187 | + } else { |
|
| 188 | + $module_srl = array($module_srl); |
|
| 189 | + } |
|
| 172 | 190 | // Save configurations |
| 173 | 191 | $oModuleController = getController('module'); |
| 174 | 192 | for($i=0;$i<count($module_srl);$i++) |
| 175 | 193 | { |
| 176 | 194 | $srl = trim($module_srl[$i]); |
| 177 | - if(!$srl) continue; |
|
| 195 | + if(!$srl) { |
|
| 196 | + continue; |
|
| 197 | + } |
|
| 178 | 198 | unset($config); |
| 179 | 199 | $config['insert_document'] = (int)Context::get('insert_document'); |
| 180 | 200 | $config['insert_comment'] = (int)Context::get('insert_comment'); |
@@ -244,29 +264,40 @@ discard block |
||
| 244 | 264 | |
| 245 | 265 | // Get member infomation |
| 246 | 266 | $output = executeQueryArray('point.getMemberCount'); |
| 247 | - if(!$output->toBool()) return $output; |
|
| 267 | + if(!$output->toBool()) { |
|
| 268 | + return $output; |
|
| 269 | + } |
|
| 248 | 270 | |
| 249 | 271 | if($output->data) |
| 250 | 272 | { |
| 251 | 273 | foreach($output->data as $key => $val) |
| 252 | 274 | { |
| 253 | - if(!$val->member_srl) continue; |
|
| 275 | + if(!$val->member_srl) { |
|
| 276 | + continue; |
|
| 277 | + } |
|
| 254 | 278 | $member[$val->member_srl] = 0; |
| 255 | 279 | } |
| 256 | 280 | } |
| 257 | 281 | |
| 258 | 282 | // Get post information |
| 259 | 283 | $output = executeQueryArray('point.getDocumentPoint'); |
| 260 | - if(!$output->toBool()) return $output; |
|
| 284 | + if(!$output->toBool()) { |
|
| 285 | + return $output; |
|
| 286 | + } |
|
| 261 | 287 | |
| 262 | 288 | if($output->data) |
| 263 | 289 | { |
| 264 | 290 | foreach($output->data as $key => $val) |
| 265 | 291 | { |
| 266 | - if($module_config[$val->module_srl]['insert_document']) $insert_point = $module_config[$val->module_srl]['insert_document']; |
|
| 267 | - else $insert_point = $config->insert_document; |
|
| 292 | + if($module_config[$val->module_srl]['insert_document']) { |
|
| 293 | + $insert_point = $module_config[$val->module_srl]['insert_document']; |
|
| 294 | + } else { |
|
| 295 | + $insert_point = $config->insert_document; |
|
| 296 | + } |
|
| 268 | 297 | |
| 269 | - if(!$val->member_srl) continue; |
|
| 298 | + if(!$val->member_srl) { |
|
| 299 | + continue; |
|
| 300 | + } |
|
| 270 | 301 | $point = $insert_point * $val->count; |
| 271 | 302 | $member[$val->member_srl] += $point; |
| 272 | 303 | } |
@@ -275,16 +306,23 @@ discard block |
||
| 275 | 306 | $output = null; |
| 276 | 307 | // Get comments information |
| 277 | 308 | $output = executeQueryArray('point.getCommentPoint'); |
| 278 | - if(!$output->toBool()) return $output; |
|
| 309 | + if(!$output->toBool()) { |
|
| 310 | + return $output; |
|
| 311 | + } |
|
| 279 | 312 | |
| 280 | 313 | if($output->data) |
| 281 | 314 | { |
| 282 | 315 | foreach($output->data as $key => $val) |
| 283 | 316 | { |
| 284 | - if($module_config[$val->module_srl]['insert_comment']) $insert_point = $module_config[$val->module_srl]['insert_comment']; |
|
| 285 | - else $insert_point = $config->insert_comment; |
|
| 317 | + if($module_config[$val->module_srl]['insert_comment']) { |
|
| 318 | + $insert_point = $module_config[$val->module_srl]['insert_comment']; |
|
| 319 | + } else { |
|
| 320 | + $insert_point = $config->insert_comment; |
|
| 321 | + } |
|
| 286 | 322 | |
| 287 | - if(!$val->member_srl) continue; |
|
| 323 | + if(!$val->member_srl) { |
|
| 324 | + continue; |
|
| 325 | + } |
|
| 288 | 326 | $point = $insert_point * $val->count; |
| 289 | 327 | $member[$val->member_srl] += $point; |
| 290 | 328 | } |
@@ -292,16 +330,23 @@ discard block |
||
| 292 | 330 | $output = null; |
| 293 | 331 | // Get the attached files' information |
| 294 | 332 | $output = executeQueryArray('point.getFilePoint'); |
| 295 | - if(!$output->toBool()) return $output; |
|
| 333 | + if(!$output->toBool()) { |
|
| 334 | + return $output; |
|
| 335 | + } |
|
| 296 | 336 | |
| 297 | 337 | if($output->data) |
| 298 | 338 | { |
| 299 | 339 | foreach($output->data as $key => $val) |
| 300 | 340 | { |
| 301 | - if($module_config[$val->module_srl]['upload_file']) $insert_point = $module_config[$val->module_srl]['upload_file']; |
|
| 302 | - else $insert_point = $config->upload_file; |
|
| 341 | + if($module_config[$val->module_srl]['upload_file']) { |
|
| 342 | + $insert_point = $module_config[$val->module_srl]['upload_file']; |
|
| 343 | + } else { |
|
| 344 | + $insert_point = $config->upload_file; |
|
| 345 | + } |
|
| 303 | 346 | |
| 304 | - if(!$val->member_srl) continue; |
|
| 347 | + if(!$val->member_srl) { |
|
| 348 | + continue; |
|
| 349 | + } |
|
| 305 | 350 | $point = $insert_point * $val->count; |
| 306 | 351 | $member[$val->member_srl] += $point; |
| 307 | 352 | } |
@@ -309,7 +354,9 @@ discard block |
||
| 309 | 354 | $output = null; |
| 310 | 355 | // Set all members' points to 0 |
| 311 | 356 | $output = executeQuery("point.initMemberPoint"); |
| 312 | - if(!$output->toBool()) return $output; |
|
| 357 | + if(!$output->toBool()) { |
|
| 358 | + return $output; |
|
| 359 | + } |
|
| 313 | 360 | // Save the file temporarily |
| 314 | 361 | |
| 315 | 362 | $str = ''; |
@@ -334,7 +381,9 @@ discard block |
||
| 334 | 381 | $position = (int)Context::get('position'); |
| 335 | 382 | $total = (int)Context::get('total'); |
| 336 | 383 | |
| 337 | - if(!file_exists('./files/cache/pointRecal.txt')) return new Object(-1, 'msg_invalid_request'); |
|
| 384 | + if(!file_exists('./files/cache/pointRecal.txt')) { |
|
| 385 | + return new Object(-1, 'msg_invalid_request'); |
|
| 386 | + } |
|
| 338 | 387 | |
| 339 | 388 | $idx = 0; |
| 340 | 389 | $f = fopen("./files/cache/pointRecal.txt","r"); |
@@ -350,7 +399,9 @@ discard block |
||
| 350 | 399 | $args->member_srl = $member_srl; |
| 351 | 400 | $args->point = $point; |
| 352 | 401 | $output = executeQuery('point.insertPoint',$args); |
| 353 | - if($idx%5000==0) break; |
|
| 402 | + if($idx%5000==0) { |
|
| 403 | + break; |
|
| 404 | + } |
|
| 354 | 405 | } |
| 355 | 406 | } |
| 356 | 407 | |
@@ -377,16 +428,23 @@ discard block |
||
| 377 | 428 | function procPointAdminReset() |
| 378 | 429 | { |
| 379 | 430 | $module_srl = Context::get('module_srls'); |
| 380 | - if(!$module_srl) return new Object(-1, 'msg_invalid_request'); |
|
| 431 | + if(!$module_srl) { |
|
| 432 | + return new Object(-1, 'msg_invalid_request'); |
|
| 433 | + } |
|
| 381 | 434 | // In case of batch configuration of several modules |
| 382 | - if(preg_match('/^([0-9,]+)$/',$module_srl)) $module_srl = explode(',',$module_srl); |
|
| 383 | - else $module_srl = array($module_srl); |
|
| 435 | + if(preg_match('/^([0-9,]+)$/',$module_srl)) { |
|
| 436 | + $module_srl = explode(',',$module_srl); |
|
| 437 | + } else { |
|
| 438 | + $module_srl = array($module_srl); |
|
| 439 | + } |
|
| 384 | 440 | // Save configurations |
| 385 | 441 | $oModuleController = getController('module'); |
| 386 | 442 | for($i=0;$i<count($module_srl);$i++) |
| 387 | 443 | { |
| 388 | 444 | $srl = trim($module_srl[$i]); |
| 389 | - if(!$srl) continue; |
|
| 445 | + if(!$srl) { |
|
| 446 | + continue; |
|
| 447 | + } |
|
| 390 | 448 | $args = new stdClass(); |
| 391 | 449 | $args->module = 'point'; |
| 392 | 450 | $args->module_srl = $srl; |
@@ -23,15 +23,15 @@ discard block |
||
| 23 | 23 | /** |
| 24 | 24 | * setup the module general information |
| 25 | 25 | **/ |
| 26 | - if($this->module_info->list_count) |
|
| 26 | + if ($this->module_info->list_count) |
|
| 27 | 27 | { |
| 28 | 28 | $this->list_count = $this->module_info->list_count; |
| 29 | 29 | } |
| 30 | - if($this->module_info->search_list_count) |
|
| 30 | + if ($this->module_info->search_list_count) |
|
| 31 | 31 | { |
| 32 | 32 | $this->search_list_count = $this->module_info->search_list_count; |
| 33 | 33 | } |
| 34 | - if($this->module_info->page_count) |
|
| 34 | + if ($this->module_info->page_count) |
|
| 35 | 35 | { |
| 36 | 36 | $this->page_count = $this->module_info->page_count; |
| 37 | 37 | } |
@@ -41,20 +41,20 @@ discard block |
||
| 41 | 41 | $oDocumentModel = getModel('document'); |
| 42 | 42 | |
| 43 | 43 | $statusList = $this->_getStatusNameList($oDocumentModel); |
| 44 | - if(isset($statusList['SECRET'])) |
|
| 44 | + if (isset($statusList['SECRET'])) |
|
| 45 | 45 | { |
| 46 | 46 | $this->module_info->secret = 'Y'; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | // use_category <=1.5.x, hide_category >=1.7.x |
| 50 | 50 | $count_category = count($oDocumentModel->getCategoryList($this->module_info->module_srl)); |
| 51 | - if($count_category) |
|
| 51 | + if ($count_category) |
|
| 52 | 52 | { |
| 53 | - if($this->module_info->hide_category) |
|
| 53 | + if ($this->module_info->hide_category) |
|
| 54 | 54 | { |
| 55 | 55 | $this->module_info->use_category = ($this->module_info->hide_category == 'Y') ? 'N' : 'Y'; |
| 56 | 56 | } |
| 57 | - else if($this->module_info->use_category) |
|
| 57 | + else if ($this->module_info->use_category) |
|
| 58 | 58 | { |
| 59 | 59 | $this->module_info->hide_category = ($this->module_info->use_category == 'Y') ? 'N' : 'Y'; |
| 60 | 60 | } |
@@ -74,10 +74,10 @@ discard block |
||
| 74 | 74 | * check the consultation function, if the user is admin then swich off consultation function |
| 75 | 75 | * if the user is not logged, then disppear write document/write comment./ view document |
| 76 | 76 | **/ |
| 77 | - if($this->module_info->consultation == 'Y' && !$this->grant->manager && !$this->grant->consultation_read) |
|
| 77 | + if ($this->module_info->consultation == 'Y' && !$this->grant->manager && !$this->grant->consultation_read) |
|
| 78 | 78 | { |
| 79 | 79 | $this->consultation = TRUE; |
| 80 | - if(!Context::get('is_logged')) |
|
| 80 | + if (!Context::get('is_logged')) |
|
| 81 | 81 | { |
| 82 | 82 | $this->grant->list = FALSE; |
| 83 | 83 | $this->grant->write_document = FALSE; |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | * setup the template path based on the skin |
| 95 | 95 | * the default skin is default |
| 96 | 96 | **/ |
| 97 | - $template_path = sprintf("%sskins/%s/",$this->module_path, $this->module_info->skin); |
|
| 98 | - if(!is_dir($template_path)||!$this->module_info->skin) |
|
| 97 | + $template_path = sprintf("%sskins/%s/", $this->module_path, $this->module_info->skin); |
|
| 98 | + if (!is_dir($template_path) || !$this->module_info->skin) |
|
| 99 | 99 | { |
| 100 | 100 | $this->module_info->skin = 'default'; |
| 101 | - $template_path = sprintf("%sskins/%s/",$this->module_path, $this->module_info->skin); |
|
| 101 | + $template_path = sprintf("%sskins/%s/", $this->module_path, $this->module_info->skin); |
|
| 102 | 102 | } |
| 103 | 103 | $this->setTemplatePath($template_path); |
| 104 | 104 | |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | **/ |
| 115 | 115 | if (is_array($extra_keys)) |
| 116 | 116 | { |
| 117 | - foreach($extra_keys as $val) |
|
| 117 | + foreach ($extra_keys as $val) |
|
| 118 | 118 | { |
| 119 | 119 | $this->order_target[] = $val->eid; |
| 120 | 120 | } |
@@ -127,9 +127,9 @@ discard block |
||
| 127 | 127 | |
| 128 | 128 | // remove [document_srl]_cpage from get_vars |
| 129 | 129 | $args = Context::getRequestVars(); |
| 130 | - foreach($args as $name => $value) |
|
| 130 | + foreach ($args as $name => $value) |
|
| 131 | 131 | { |
| 132 | - if(preg_match('/[0-9]+_cpage/', $name)) |
|
| 132 | + if (preg_match('/[0-9]+_cpage/', $name)) |
|
| 133 | 133 | { |
| 134 | 134 | Context::set($name, '', TRUE); |
| 135 | 135 | Context::set($name, $value); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | /** |
| 146 | 146 | * check the access grant (all the grant has been set by the module object) |
| 147 | 147 | **/ |
| 148 | - if(!$this->grant->access || !$this->grant->list) |
|
| 148 | + if (!$this->grant->access || !$this->grant->list) |
|
| 149 | 149 | { |
| 150 | 150 | return $this->dispBoardMessage('msg_not_permitted'); |
| 151 | 151 | } |
@@ -160,22 +160,22 @@ discard block |
||
| 160 | 160 | * add extra vaiables to the search options |
| 161 | 161 | **/ |
| 162 | 162 | // use search options on the template (the search options key has been declared, based on the language selected) |
| 163 | - foreach($this->search_option as $opt) $search_option[$opt] = Context::getLang($opt); |
|
| 163 | + foreach ($this->search_option as $opt) $search_option[$opt] = Context::getLang($opt); |
|
| 164 | 164 | $extra_keys = Context::get('extra_keys'); |
| 165 | - if($extra_keys) |
|
| 165 | + if ($extra_keys) |
|
| 166 | 166 | { |
| 167 | - foreach($extra_keys as $key => $val) |
|
| 167 | + foreach ($extra_keys as $key => $val) |
|
| 168 | 168 | { |
| 169 | - if($val->search == 'Y') $search_option['extra_vars'.$val->idx] = $val->name; |
|
| 169 | + if ($val->search == 'Y') $search_option['extra_vars'.$val->idx] = $val->name; |
|
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | // remove a search option that is not public in member config |
| 173 | 173 | $memberConfig = getModel('module')->getModuleConfig('member'); |
| 174 | - foreach($memberConfig->signupForm as $signupFormElement) |
|
| 174 | + foreach ($memberConfig->signupForm as $signupFormElement) |
|
| 175 | 175 | { |
| 176 | - if(in_array($signupFormElement->title, $search_option)) |
|
| 176 | + if (in_array($signupFormElement->title, $search_option)) |
|
| 177 | 177 | { |
| 178 | - if($signupFormElement->isPublic == 'N') |
|
| 178 | + if ($signupFormElement->isPublic == 'N') |
|
| 179 | 179 | unset($search_option[$signupFormElement->name]); |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | $oDocumentModel = getModel('document'); |
| 185 | 185 | $statusNameList = $this->_getStatusNameList($oDocumentModel); |
| 186 | - if(count($statusNameList) > 0) |
|
| 186 | + if (count($statusNameList) > 0) |
|
| 187 | 187 | { |
| 188 | 188 | Context::set('status_list', $statusNameList); |
| 189 | 189 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | // list config, columnList setting |
| 195 | 195 | $oBoardModel = getModel('board'); |
| 196 | 196 | $this->listConfig = $oBoardModel->getListConfig($this->module_info->module_srl); |
| 197 | - if(!$this->listConfig) $this->listConfig = array(); |
|
| 197 | + if (!$this->listConfig) $this->listConfig = array(); |
|
| 198 | 198 | $this->_makeListColumnList(); |
| 199 | 199 | |
| 200 | 200 | // display the notice list |
@@ -218,12 +218,12 @@ discard block |
||
| 218 | 218 | /** |
| 219 | 219 | * @brief display the category list |
| 220 | 220 | **/ |
| 221 | - function dispBoardCategoryList(){ |
|
| 221 | + function dispBoardCategoryList() { |
|
| 222 | 222 | // check if the use_category option is enabled |
| 223 | - if($this->module_info->use_category=='Y') |
|
| 223 | + if ($this->module_info->use_category == 'Y') |
|
| 224 | 224 | { |
| 225 | 225 | // check the grant |
| 226 | - if(!$this->grant->list) |
|
| 226 | + if (!$this->grant->list) |
|
| 227 | 227 | { |
| 228 | 228 | Context::set('category_list', array()); |
| 229 | 229 | return; |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | /** |
| 241 | 241 | * @brief display the board conent view |
| 242 | 242 | **/ |
| 243 | - function dispBoardContentView(){ |
|
| 243 | + function dispBoardContentView() { |
|
| 244 | 244 | // get the variable value |
| 245 | 245 | $document_srl = Context::get('document_srl'); |
| 246 | 246 | $page = Context::get('page'); |
@@ -251,36 +251,36 @@ discard block |
||
| 251 | 251 | /** |
| 252 | 252 | * if the document exists, then get the document information |
| 253 | 253 | **/ |
| 254 | - if($document_srl) |
|
| 254 | + if ($document_srl) |
|
| 255 | 255 | { |
| 256 | 256 | $oDocument = $oDocumentModel->getDocument($document_srl, false, true); |
| 257 | 257 | |
| 258 | 258 | // if the document is existed |
| 259 | - if($oDocument->isExists()) |
|
| 259 | + if ($oDocument->isExists()) |
|
| 260 | 260 | { |
| 261 | 261 | // if the module srl is not consistent |
| 262 | - if($oDocument->get('module_srl')!=$this->module_info->module_srl ) |
|
| 262 | + if ($oDocument->get('module_srl') != $this->module_info->module_srl) |
|
| 263 | 263 | { |
| 264 | 264 | return $this->stop('msg_invalid_request'); |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | // check the manage grant |
| 268 | - if($this->grant->manager) $oDocument->setGrant(); |
|
| 268 | + if ($this->grant->manager) $oDocument->setGrant(); |
|
| 269 | 269 | |
| 270 | 270 | // if the consultation function is enabled, and the document is not a notice |
| 271 | - if($this->consultation && !$oDocument->isNotice()) |
|
| 271 | + if ($this->consultation && !$oDocument->isNotice()) |
|
| 272 | 272 | { |
| 273 | 273 | $logged_info = Context::get('logged_info'); |
| 274 | - if($oDocument->get('member_srl')!=$logged_info->member_srl) |
|
| 274 | + if ($oDocument->get('member_srl') != $logged_info->member_srl) |
|
| 275 | 275 | { |
| 276 | 276 | $oDocument = $oDocumentModel->getDocument(0); |
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | // if the document is TEMP saved, check Grant |
| 281 | - if($oDocument->getStatus() == 'TEMP') |
|
| 281 | + if ($oDocument->getStatus() == 'TEMP') |
|
| 282 | 282 | { |
| 283 | - if(!$oDocument->isGranted()) |
|
| 283 | + if (!$oDocument->isGranted()) |
|
| 284 | 284 | { |
| 285 | 285 | $oDocument = $oDocumentModel->getDocument(0); |
| 286 | 286 | } |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | else |
| 291 | 291 | { |
| 292 | 292 | // if the document is not existed, then alert a warning message |
| 293 | - Context::set('document_srl','',true); |
|
| 293 | + Context::set('document_srl', '', true); |
|
| 294 | 294 | $this->alertMessage('msg_not_founded'); |
| 295 | 295 | } |
| 296 | 296 | |
@@ -306,12 +306,12 @@ discard block |
||
| 306 | 306 | /** |
| 307 | 307 | *check the document view grant |
| 308 | 308 | **/ |
| 309 | - if($oDocument->isExists()) |
|
| 309 | + if ($oDocument->isExists()) |
|
| 310 | 310 | { |
| 311 | - if(!$this->grant->view && !$oDocument->isGranted()) |
|
| 311 | + if (!$this->grant->view && !$oDocument->isGranted()) |
|
| 312 | 312 | { |
| 313 | 313 | $oDocument = $oDocumentModel->getDocument(0); |
| 314 | - Context::set('document_srl','',true); |
|
| 314 | + Context::set('document_srl', '', true); |
|
| 315 | 315 | $this->alertMessage('msg_not_permitted'); |
| 316 | 316 | } |
| 317 | 317 | else |
@@ -320,15 +320,15 @@ discard block |
||
| 320 | 320 | Context::addBrowserTitle($oDocument->getTitleText()); |
| 321 | 321 | |
| 322 | 322 | // update the document view count (if the document is not secret) |
| 323 | - if(!$oDocument->isSecret() || $oDocument->isGranted()) |
|
| 323 | + if (!$oDocument->isSecret() || $oDocument->isGranted()) |
|
| 324 | 324 | { |
| 325 | 325 | $oDocument->updateReadedCount(); |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | // disappear the document if it is secret |
| 329 | - if($oDocument->isSecret() && !$oDocument->isGranted()) |
|
| 329 | + if ($oDocument->isSecret() && !$oDocument->isGranted()) |
|
| 330 | 330 | { |
| 331 | - $oDocument->add('content',Context::getLang('thisissecret')); |
|
| 331 | + $oDocument->add('content', Context::getLang('thisissecret')); |
|
| 332 | 332 | } |
| 333 | 333 | } |
| 334 | 334 | } |
@@ -348,11 +348,11 @@ discard block |
||
| 348 | 348 | /** |
| 349 | 349 | * @brief display the document file list (can be used by API) |
| 350 | 350 | **/ |
| 351 | - function dispBoardContentFileList(){ |
|
| 351 | + function dispBoardContentFileList() { |
|
| 352 | 352 | /** |
| 353 | 353 | * check the access grant (all the grant has been set by the module object) |
| 354 | 354 | **/ |
| 355 | - if(!$this->grant->access) |
|
| 355 | + if (!$this->grant->access) |
|
| 356 | 356 | { |
| 357 | 357 | return $this->dispBoardMessage('msg_not_permitted'); |
| 358 | 358 | } |
@@ -363,41 +363,41 @@ discard block |
||
| 363 | 363 | // Check if a permission for file download is granted |
| 364 | 364 | // Get configurations (using module model object) |
| 365 | 365 | $oModuleModel = getModel('module'); |
| 366 | - $file_module_config = $oModuleModel->getModulePartConfig('file',$this->module_srl); |
|
| 366 | + $file_module_config = $oModuleModel->getModulePartConfig('file', $this->module_srl); |
|
| 367 | 367 | |
| 368 | 368 | $downloadGrantCount = 0; |
| 369 | - if(is_array($file_module_config->download_grant)) |
|
| 369 | + if (is_array($file_module_config->download_grant)) |
|
| 370 | 370 | { |
| 371 | - foreach($file_module_config->download_grant AS $value) |
|
| 372 | - if($value) $downloadGrantCount++; |
|
| 371 | + foreach ($file_module_config->download_grant AS $value) |
|
| 372 | + if ($value) $downloadGrantCount++; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - if(is_array($file_module_config->download_grant) && $downloadGrantCount>0) |
|
| 375 | + if (is_array($file_module_config->download_grant) && $downloadGrantCount > 0) |
|
| 376 | 376 | { |
| 377 | - if(!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); |
|
| 377 | + if (!Context::get('is_logged')) return $this->stop('msg_not_permitted_download'); |
|
| 378 | 378 | $logged_info = Context::get('logged_info'); |
| 379 | - if($logged_info->is_admin != 'Y') |
|
| 379 | + if ($logged_info->is_admin != 'Y') |
|
| 380 | 380 | { |
| 381 | - $oModuleModel =& getModel('module'); |
|
| 381 | + $oModuleModel = & getModel('module'); |
|
| 382 | 382 | $columnList = array('module_srl', 'site_srl'); |
| 383 | 383 | $module_info = $oModuleModel->getModuleInfoByModuleSrl($this->module_srl, $columnList); |
| 384 | 384 | |
| 385 | - if(!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl)) |
|
| 385 | + if (!$oModuleModel->isSiteAdmin($logged_info, $module_info->site_srl)) |
|
| 386 | 386 | { |
| 387 | - $oMemberModel =& getModel('member'); |
|
| 387 | + $oMemberModel = & getModel('member'); |
|
| 388 | 388 | $member_groups = $oMemberModel->getMemberGroups($logged_info->member_srl, $module_info->site_srl); |
| 389 | 389 | |
| 390 | 390 | $is_permitted = false; |
| 391 | - for($i=0;$i<count($file_module_config->download_grant);$i++) |
|
| 391 | + for ($i = 0; $i < count($file_module_config->download_grant); $i++) |
|
| 392 | 392 | { |
| 393 | 393 | $group_srl = $file_module_config->download_grant[$i]; |
| 394 | - if($member_groups[$group_srl]) |
|
| 394 | + if ($member_groups[$group_srl]) |
|
| 395 | 395 | { |
| 396 | 396 | $is_permitted = true; |
| 397 | 397 | break; |
| 398 | 398 | } |
| 399 | 399 | } |
| 400 | - if(!$is_permitted) return $this->stop('msg_not_permitted_download'); |
|
| 400 | + if (!$is_permitted) return $this->stop('msg_not_permitted_download'); |
|
| 401 | 401 | } |
| 402 | 402 | } |
| 403 | 403 | } |
@@ -405,7 +405,7 @@ discard block |
||
| 405 | 405 | $oDocumentModel = getModel('document'); |
| 406 | 406 | $document_srl = Context::get('document_srl'); |
| 407 | 407 | $oDocument = $oDocumentModel->getDocument($document_srl); |
| 408 | - Context::set('file_list',$oDocument->getUploadedFiles()); |
|
| 408 | + Context::set('file_list', $oDocument->getUploadedFiles()); |
|
| 409 | 409 | |
| 410 | 410 | $oSecurity = new Security(); |
| 411 | 411 | $oSecurity->encodeHTML('file_list..source_filename'); |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | /** |
| 415 | 415 | * @brief display the document comment list (can be used by API) |
| 416 | 416 | **/ |
| 417 | - function dispBoardContentCommentList(){ |
|
| 417 | + function dispBoardContentCommentList() { |
|
| 418 | 418 | // check document view grant |
| 419 | 419 | $this->dispBoardContentView(); |
| 420 | 420 | |
@@ -424,26 +424,26 @@ discard block |
||
| 424 | 424 | $comment_list = $oDocument->getComments(); |
| 425 | 425 | |
| 426 | 426 | // setup the comment list |
| 427 | - if(is_array($comment_list)) |
|
| 427 | + if (is_array($comment_list)) |
|
| 428 | 428 | { |
| 429 | - foreach($comment_list as $key => $val) |
|
| 429 | + foreach ($comment_list as $key => $val) |
|
| 430 | 430 | { |
| 431 | - if(!$val->isAccessible()) |
|
| 431 | + if (!$val->isAccessible()) |
|
| 432 | 432 | { |
| 433 | - $val->add('content',Context::getLang('thisissecret')); |
|
| 433 | + $val->add('content', Context::getLang('thisissecret')); |
|
| 434 | 434 | } |
| 435 | 435 | } |
| 436 | 436 | } |
| 437 | - Context::set('comment_list',$comment_list); |
|
| 437 | + Context::set('comment_list', $comment_list); |
|
| 438 | 438 | |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | /** |
| 442 | 442 | * @brief display notice list (can be used by API) |
| 443 | 443 | **/ |
| 444 | - function dispBoardNoticeList(){ |
|
| 444 | + function dispBoardNoticeList() { |
|
| 445 | 445 | // check the grant |
| 446 | - if(!$this->grant->list) |
|
| 446 | + if (!$this->grant->list) |
|
| 447 | 447 | { |
| 448 | 448 | Context::set('notice_list', array()); |
| 449 | 449 | return; |
@@ -459,15 +459,15 @@ discard block |
||
| 459 | 459 | /** |
| 460 | 460 | * @brief display board content list |
| 461 | 461 | **/ |
| 462 | - function dispBoardContentList(){ |
|
| 462 | + function dispBoardContentList() { |
|
| 463 | 463 | // check the grant |
| 464 | - if(!$this->grant->list) |
|
| 464 | + if (!$this->grant->list) |
|
| 465 | 465 | { |
| 466 | 466 | Context::set('document_list', array()); |
| 467 | 467 | Context::set('total_count', 0); |
| 468 | 468 | Context::set('total_page', 1); |
| 469 | 469 | Context::set('page', 1); |
| 470 | - Context::set('page_navigation', new PageHandler(0,0,1,10)); |
|
| 470 | + Context::set('page_navigation', new PageHandler(0, 0, 1, 10)); |
|
| 471 | 471 | return; |
| 472 | 472 | } |
| 473 | 473 | |
@@ -485,17 +485,17 @@ discard block |
||
| 485 | 485 | $args->search_keyword = Context::get('search_keyword'); |
| 486 | 486 | |
| 487 | 487 | $search_option = Context::get('search_option'); |
| 488 | - if($search_option==FALSE) |
|
| 488 | + if ($search_option == FALSE) |
|
| 489 | 489 | { |
| 490 | 490 | $search_option = $this->search_option; |
| 491 | 491 | } |
| 492 | - if(isset($search_option[$args->search_target])==FALSE) |
|
| 492 | + if (isset($search_option[$args->search_target]) == FALSE) |
|
| 493 | 493 | { |
| 494 | 494 | $args->search_target = ''; |
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | // if the category is enabled, then get the category |
| 498 | - if($this->module_info->use_category=='Y') |
|
| 498 | + if ($this->module_info->use_category == 'Y') |
|
| 499 | 499 | { |
| 500 | 500 | $args->category_srl = Context::get('category'); |
| 501 | 501 | } |
@@ -503,21 +503,21 @@ discard block |
||
| 503 | 503 | // setup the sort index and order index |
| 504 | 504 | $args->sort_index = Context::get('sort_index'); |
| 505 | 505 | $args->order_type = Context::get('order_type'); |
| 506 | - if(!in_array($args->sort_index, $this->order_target)) |
|
| 506 | + if (!in_array($args->sort_index, $this->order_target)) |
|
| 507 | 507 | { |
| 508 | - $args->sort_index = $this->module_info->order_target?$this->module_info->order_target:'list_order'; |
|
| 508 | + $args->sort_index = $this->module_info->order_target ? $this->module_info->order_target : 'list_order'; |
|
| 509 | 509 | } |
| 510 | - if(!in_array($args->order_type, array('asc','desc'))) |
|
| 510 | + if (!in_array($args->order_type, array('asc', 'desc'))) |
|
| 511 | 511 | { |
| 512 | - $args->order_type = $this->module_info->order_type?$this->module_info->order_type:'asc'; |
|
| 512 | + $args->order_type = $this->module_info->order_type ? $this->module_info->order_type : 'asc'; |
|
| 513 | 513 | } |
| 514 | 514 | |
| 515 | 515 | // set the current page of documents |
| 516 | 516 | $document_srl = Context::get('document_srl'); |
| 517 | - if(!$args->page && $document_srl) |
|
| 517 | + if (!$args->page && $document_srl) |
|
| 518 | 518 | { |
| 519 | 519 | $oDocument = $oDocumentModel->getDocument($document_srl); |
| 520 | - if($oDocument->isExists() && !$oDocument->isNotice()) |
|
| 520 | + if ($oDocument->isExists() && !$oDocument->isNotice()) |
|
| 521 | 521 | { |
| 522 | 522 | $page = $oDocumentModel->getDocumentPage($oDocument, $args); |
| 523 | 523 | Context::set('page', $page); |
@@ -526,13 +526,13 @@ discard block |
||
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | // setup the list count to be serach list count, if the category or search keyword has been set |
| 529 | - if($args->category_srl || $args->search_keyword) |
|
| 529 | + if ($args->category_srl || $args->search_keyword) |
|
| 530 | 530 | { |
| 531 | 531 | $args->list_count = $this->search_list_count; |
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | // if the consultation function is enabled, the get the logged user information |
| 535 | - if($this->consultation) |
|
| 535 | + if ($this->consultation) |
|
| 536 | 536 | { |
| 537 | 537 | $logged_info = Context::get('logged_info'); |
| 538 | 538 | $args->member_srl = $logged_info->member_srl; |
@@ -560,18 +560,18 @@ discard block |
||
| 560 | 560 | 'allow_trackback', 'notify_message', 'status', 'comment_status'); |
| 561 | 561 | $this->columnList = array_intersect($configColumList, $tableColumnList); |
| 562 | 562 | |
| 563 | - if(in_array('summary', $configColumList)) array_push($this->columnList, 'content'); |
|
| 563 | + if (in_array('summary', $configColumList)) array_push($this->columnList, 'content'); |
|
| 564 | 564 | |
| 565 | 565 | // default column list add |
| 566 | 566 | $defaultColumn = array('document_srl', 'module_srl', 'category_srl', 'lang_code', 'member_srl', 'last_update', 'comment_count', 'trackback_count', 'uploaded_count', 'status', 'regdate', 'title_bold', 'title_color'); |
| 567 | 567 | |
| 568 | 568 | //TODO guestbook, blog style supports legacy codes. |
| 569 | - if($this->module_info->skin == 'xe_guestbook' || $this->module_info->default_style == 'blog') |
|
| 569 | + if ($this->module_info->skin == 'xe_guestbook' || $this->module_info->default_style == 'blog') |
|
| 570 | 570 | { |
| 571 | 571 | $defaultColumn = $tableColumnList; |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | - if (in_array('last_post', $configColumList)){ |
|
| 574 | + if (in_array('last_post', $configColumList)) { |
|
| 575 | 575 | array_push($this->columnList, 'last_updater'); |
| 576 | 576 | } |
| 577 | 577 | |
@@ -583,9 +583,9 @@ discard block |
||
| 583 | 583 | $this->columnList = array_unique(array_merge($this->columnList, $defaultColumn)); |
| 584 | 584 | |
| 585 | 585 | // add table name |
| 586 | - foreach($this->columnList as $no => $value) |
|
| 586 | + foreach ($this->columnList as $no => $value) |
|
| 587 | 587 | { |
| 588 | - $this->columnList[$no] = 'documents.' . $value; |
|
| 588 | + $this->columnList[$no] = 'documents.'.$value; |
|
| 589 | 589 | } |
| 590 | 590 | } |
| 591 | 591 | |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | function dispBoardTagList() |
| 596 | 596 | { |
| 597 | 597 | // check if there is not grant fot view list, then alert an warning message |
| 598 | - if(!$this->grant->list) |
|
| 598 | + if (!$this->grant->list) |
|
| 599 | 599 | { |
| 600 | 600 | return $this->dispBoardMessage('msg_not_permitted'); |
| 601 | 601 | } |
@@ -609,14 +609,14 @@ discard block |
||
| 609 | 609 | $output = $oTagModel->getTagList($obj); |
| 610 | 610 | |
| 611 | 611 | // automatically order |
| 612 | - if(count($output->data)) |
|
| 612 | + if (count($output->data)) |
|
| 613 | 613 | { |
| 614 | 614 | $numbers = array_keys($output->data); |
| 615 | 615 | shuffle($numbers); |
| 616 | 616 | |
| 617 | - if(count($output->data)) |
|
| 617 | + if (count($output->data)) |
|
| 618 | 618 | { |
| 619 | - foreach($numbers as $k => $v) |
|
| 619 | + foreach ($numbers as $k => $v) |
|
| 620 | 620 | { |
| 621 | 621 | $tag_list[] = $output->data[$v]; |
| 622 | 622 | } |
@@ -637,7 +637,7 @@ discard block |
||
| 637 | 637 | function dispBoardWrite() |
| 638 | 638 | { |
| 639 | 639 | // check grant |
| 640 | - if(!$this->grant->write_document) |
|
| 640 | + if (!$this->grant->write_document) |
|
| 641 | 641 | { |
| 642 | 642 | return $this->dispBoardMessage('msg_not_permitted'); |
| 643 | 643 | } |
@@ -647,10 +647,10 @@ discard block |
||
| 647 | 647 | /** |
| 648 | 648 | * check if the category option is enabled not not |
| 649 | 649 | **/ |
| 650 | - if($this->module_info->use_category=='Y') |
|
| 650 | + if ($this->module_info->use_category == 'Y') |
|
| 651 | 651 | { |
| 652 | 652 | // get the user group information |
| 653 | - if(Context::get('is_logged')) |
|
| 653 | + if (Context::get('is_logged')) |
|
| 654 | 654 | { |
| 655 | 655 | $logged_info = Context::get('logged_info'); |
| 656 | 656 | $group_srls = array_keys($logged_info->group_list); |
@@ -663,19 +663,19 @@ discard block |
||
| 663 | 663 | |
| 664 | 664 | // check the grant after obtained the category list |
| 665 | 665 | $normal_category_list = $oDocumentModel->getCategoryList($this->module_srl); |
| 666 | - if(count($normal_category_list)) |
|
| 666 | + if (count($normal_category_list)) |
|
| 667 | 667 | { |
| 668 | - foreach($normal_category_list as $category_srl => $category) |
|
| 668 | + foreach ($normal_category_list as $category_srl => $category) |
|
| 669 | 669 | { |
| 670 | 670 | $is_granted = TRUE; |
| 671 | - if($category->group_srls) |
|
| 671 | + if ($category->group_srls) |
|
| 672 | 672 | { |
| 673 | - $category_group_srls = explode(',',$category->group_srls); |
|
| 673 | + $category_group_srls = explode(',', $category->group_srls); |
|
| 674 | 674 | $is_granted = FALSE; |
| 675 | - if(count(array_intersect($group_srls, $category_group_srls))) $is_granted = TRUE; |
|
| 675 | + if (count(array_intersect($group_srls, $category_group_srls))) $is_granted = TRUE; |
|
| 676 | 676 | |
| 677 | 677 | } |
| 678 | - if($is_granted) $category_list[$category_srl] = $category; |
|
| 678 | + if ($is_granted) $category_list[$category_srl] = $category; |
|
| 679 | 679 | } |
| 680 | 680 | } |
| 681 | 681 | Context::set('category_list', $category_list); |
@@ -686,46 +686,46 @@ discard block |
||
| 686 | 686 | $oDocument = $oDocumentModel->getDocument(0, $this->grant->manager); |
| 687 | 687 | $oDocument->setDocument($document_srl); |
| 688 | 688 | |
| 689 | - if($oDocument->get('module_srl') == $oDocument->get('member_srl')) $savedDoc = TRUE; |
|
| 689 | + if ($oDocument->get('module_srl') == $oDocument->get('member_srl')) $savedDoc = TRUE; |
|
| 690 | 690 | $oDocument->add('module_srl', $this->module_srl); |
| 691 | 691 | |
| 692 | - if($oDocument->isExists() && $this->module_info->protect_content=="Y" && $oDocument->get('comment_count')>0 && $this->grant->manager==false) |
|
| 692 | + if ($oDocument->isExists() && $this->module_info->protect_content == "Y" && $oDocument->get('comment_count') > 0 && $this->grant->manager == false) |
|
| 693 | 693 | { |
| 694 | 694 | return new Object(-1, 'msg_protect_content'); |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | // if the document is not granted, then back to the password input form |
| 698 | 698 | $oModuleModel = getModel('module'); |
| 699 | - if($oDocument->isExists()&&!$oDocument->isGranted()) |
|
| 699 | + if ($oDocument->isExists() && !$oDocument->isGranted()) |
|
| 700 | 700 | { |
| 701 | 701 | return $this->setTemplateFile('input_password_form'); |
| 702 | 702 | } |
| 703 | 703 | |
| 704 | - if(!$oDocument->isExists()) |
|
| 704 | + if (!$oDocument->isExists()) |
|
| 705 | 705 | { |
| 706 | - $point_config = $oModuleModel->getModulePartConfig('point',$this->module_srl); |
|
| 706 | + $point_config = $oModuleModel->getModulePartConfig('point', $this->module_srl); |
|
| 707 | 707 | $logged_info = Context::get('logged_info'); |
| 708 | 708 | $oPointModel = getModel('point'); |
| 709 | 709 | $pointForInsert = $point_config["insert_document"]; |
| 710 | - if($pointForInsert < 0) |
|
| 710 | + if ($pointForInsert < 0) |
|
| 711 | 711 | { |
| 712 | - if( !$logged_info ) |
|
| 712 | + if (!$logged_info) |
|
| 713 | 713 | { |
| 714 | 714 | return $this->dispBoardMessage('msg_not_permitted'); |
| 715 | 715 | } |
| 716 | - else if (($oPointModel->getPoint($logged_info->member_srl) + $pointForInsert )< 0 ) |
|
| 716 | + else if (($oPointModel->getPoint($logged_info->member_srl) + $pointForInsert) < 0) |
|
| 717 | 717 | { |
| 718 | 718 | return $this->dispBoardMessage('msg_not_enough_point'); |
| 719 | 719 | } |
| 720 | 720 | } |
| 721 | 721 | } |
| 722 | - if(!$oDocument->get('status')) $oDocument->add('status', $oDocumentModel->getDefaultStatus()); |
|
| 722 | + if (!$oDocument->get('status')) $oDocument->add('status', $oDocumentModel->getDefaultStatus()); |
|
| 723 | 723 | |
| 724 | 724 | $statusList = $this->_getStatusNameList($oDocumentModel); |
| 725 | - if(count($statusList) > 0) Context::set('status_list', $statusList); |
|
| 725 | + if (count($statusList) > 0) Context::set('status_list', $statusList); |
|
| 726 | 726 | |
| 727 | 727 | // get Document status config value |
| 728 | - Context::set('document_srl',$document_srl); |
|
| 728 | + Context::set('document_srl', $document_srl); |
|
| 729 | 729 | Context::set('oDocument', $oDocument); |
| 730 | 730 | |
| 731 | 731 | // apply xml_js_filter on header |
@@ -733,12 +733,12 @@ discard block |
||
| 733 | 733 | $oDocumentController->addXmlJsFilter($this->module_info->module_srl); |
| 734 | 734 | |
| 735 | 735 | // if the document exists, then setup extra variabels on context |
| 736 | - if($oDocument->isExists() && !$savedDoc) Context::set('extra_keys', $oDocument->getExtraVars()); |
|
| 736 | + if ($oDocument->isExists() && !$savedDoc) Context::set('extra_keys', $oDocument->getExtraVars()); |
|
| 737 | 737 | |
| 738 | 738 | /** |
| 739 | 739 | * add JS filters |
| 740 | 740 | **/ |
| 741 | - if(Context::get('logged_info')->is_admin=='Y') Context::addJsFilter($this->module_path.'tpl/filter', 'insert_admin.xml'); |
|
| 741 | + if (Context::get('logged_info')->is_admin == 'Y') Context::addJsFilter($this->module_path.'tpl/filter', 'insert_admin.xml'); |
|
| 742 | 742 | else Context::addJsFilter($this->module_path.'tpl/filter', 'insert.xml'); |
| 743 | 743 | |
| 744 | 744 | $oSecurity = new Security(); |
@@ -750,14 +750,14 @@ discard block |
||
| 750 | 750 | function _getStatusNameList(&$oDocumentModel) |
| 751 | 751 | { |
| 752 | 752 | $resultList = array(); |
| 753 | - if(!empty($this->module_info->use_status)) |
|
| 753 | + if (!empty($this->module_info->use_status)) |
|
| 754 | 754 | { |
| 755 | 755 | $statusNameList = $oDocumentModel->getStatusNameList(); |
| 756 | 756 | $statusList = explode('|@|', $this->module_info->use_status); |
| 757 | 757 | |
| 758 | - if(is_array($statusList)) |
|
| 758 | + if (is_array($statusList)) |
|
| 759 | 759 | { |
| 760 | - foreach($statusList as $key => $value) |
|
| 760 | + foreach ($statusList as $key => $value) |
|
| 761 | 761 | { |
| 762 | 762 | $resultList[$value] = $statusNameList[$value]; |
| 763 | 763 | } |
@@ -772,7 +772,7 @@ discard block |
||
| 772 | 772 | function dispBoardDelete() |
| 773 | 773 | { |
| 774 | 774 | // check grant |
| 775 | - if(!$this->grant->write_document) |
|
| 775 | + if (!$this->grant->write_document) |
|
| 776 | 776 | { |
| 777 | 777 | return $this->dispBoardMessage('msg_not_permitted'); |
| 778 | 778 | } |
@@ -781,30 +781,30 @@ discard block |
||
| 781 | 781 | $document_srl = Context::get('document_srl'); |
| 782 | 782 | |
| 783 | 783 | // if document exists, get the document information |
| 784 | - if($document_srl) |
|
| 784 | + if ($document_srl) |
|
| 785 | 785 | { |
| 786 | 786 | $oDocumentModel = getModel('document'); |
| 787 | 787 | $oDocument = $oDocumentModel->getDocument($document_srl); |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | // if the document is not existed, then back to the board content page |
| 791 | - if(!$oDocument || !$oDocument->isExists()) |
|
| 791 | + if (!$oDocument || !$oDocument->isExists()) |
|
| 792 | 792 | { |
| 793 | 793 | return $this->dispBoardContent(); |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | // if the document is not granted, then back to the password input form |
| 797 | - if(!$oDocument->isGranted()) |
|
| 797 | + if (!$oDocument->isGranted()) |
|
| 798 | 798 | { |
| 799 | 799 | return $this->setTemplateFile('input_password_form'); |
| 800 | 800 | } |
| 801 | 801 | |
| 802 | - if($this->module_info->protect_content=="Y" && $oDocument->get('comment_count')>0 && $this->grant->manager==false) |
|
| 802 | + if ($this->module_info->protect_content == "Y" && $oDocument->get('comment_count') > 0 && $this->grant->manager == false) |
|
| 803 | 803 | { |
| 804 | 804 | return $this->dispBoardMessage('msg_protect_content'); |
| 805 | 805 | } |
| 806 | 806 | |
| 807 | - Context::set('oDocument',$oDocument); |
|
| 807 | + Context::set('oDocument', $oDocument); |
|
| 808 | 808 | |
| 809 | 809 | /** |
| 810 | 810 | * add JS filters |
@@ -822,7 +822,7 @@ discard block |
||
| 822 | 822 | $document_srl = Context::get('document_srl'); |
| 823 | 823 | |
| 824 | 824 | // check grant |
| 825 | - if(!$this->grant->write_comment) |
|
| 825 | + if (!$this->grant->write_comment) |
|
| 826 | 826 | { |
| 827 | 827 | return $this->dispBoardMessage('msg_not_permitted'); |
| 828 | 828 | } |
@@ -830,13 +830,13 @@ discard block |
||
| 830 | 830 | // get the document information |
| 831 | 831 | $oDocumentModel = getModel('document'); |
| 832 | 832 | $oDocument = $oDocumentModel->getDocument($document_srl); |
| 833 | - if(!$oDocument->isExists()) |
|
| 833 | + if (!$oDocument->isExists()) |
|
| 834 | 834 | { |
| 835 | 835 | return $this->dispBoardMessage('msg_invalid_request'); |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | 838 | // Check allow comment |
| 839 | - if(!$oDocument->allowComment()) |
|
| 839 | + if (!$oDocument->allowComment()) |
|
| 840 | 840 | { |
| 841 | 841 | return $this->dispBoardMessage('msg_not_allow_comment'); |
| 842 | 842 | } |
@@ -848,9 +848,9 @@ discard block |
||
| 848 | 848 | $oComment->add('module_srl', $this->module_srl); |
| 849 | 849 | |
| 850 | 850 | // setup document variables on context |
| 851 | - Context::set('oDocument',$oDocument); |
|
| 852 | - Context::set('oSourceComment',$oSourceComment); |
|
| 853 | - Context::set('oComment',$oComment); |
|
| 851 | + Context::set('oDocument', $oDocument); |
|
| 852 | + Context::set('oSourceComment', $oSourceComment); |
|
| 853 | + Context::set('oComment', $oComment); |
|
| 854 | 854 | |
| 855 | 855 | /** |
| 856 | 856 | * add JS filter |
@@ -866,7 +866,7 @@ discard block |
||
| 866 | 866 | function dispBoardReplyComment() |
| 867 | 867 | { |
| 868 | 868 | // check grant |
| 869 | - if(!$this->grant->write_comment) |
|
| 869 | + if (!$this->grant->write_comment) |
|
| 870 | 870 | { |
| 871 | 871 | return $this->dispBoardMessage('msg_not_permitted'); |
| 872 | 872 | } |
@@ -875,7 +875,7 @@ discard block |
||
| 875 | 875 | $parent_srl = Context::get('comment_srl'); |
| 876 | 876 | |
| 877 | 877 | // if the parent comment is not existed |
| 878 | - if(!$parent_srl) |
|
| 878 | + if (!$parent_srl) |
|
| 879 | 879 | { |
| 880 | 880 | return new Object(-1, 'msg_invalid_request'); |
| 881 | 881 | } |
@@ -885,11 +885,11 @@ discard block |
||
| 885 | 885 | $oSourceComment = $oCommentModel->getComment($parent_srl, $this->grant->manager); |
| 886 | 886 | |
| 887 | 887 | // if the comment is not existed, opoup an error message |
| 888 | - if(!$oSourceComment->isExists()) |
|
| 888 | + if (!$oSourceComment->isExists()) |
|
| 889 | 889 | { |
| 890 | 890 | return $this->dispBoardMessage('msg_invalid_request'); |
| 891 | 891 | } |
| 892 | - if(Context::get('document_srl') && $oSourceComment->get('document_srl') != Context::get('document_srl')) |
|
| 892 | + if (Context::get('document_srl') && $oSourceComment->get('document_srl') != Context::get('document_srl')) |
|
| 893 | 893 | { |
| 894 | 894 | return $this->dispBoardMessage('msg_invalid_request'); |
| 895 | 895 | } |
@@ -897,7 +897,7 @@ discard block |
||
| 897 | 897 | // Check allow comment |
| 898 | 898 | $oDocumentModel = getModel('document'); |
| 899 | 899 | $oDocument = $oDocumentModel->getDocument($oSourceComment->get('document_srl')); |
| 900 | - if(!$oDocument->allowComment()) |
|
| 900 | + if (!$oDocument->allowComment()) |
|
| 901 | 901 | { |
| 902 | 902 | return $this->dispBoardMessage('msg_not_allow_comment'); |
| 903 | 903 | } |
@@ -908,9 +908,9 @@ discard block |
||
| 908 | 908 | $oComment->add('document_srl', $oSourceComment->get('document_srl')); |
| 909 | 909 | |
| 910 | 910 | // setup comment variables |
| 911 | - Context::set('oSourceComment',$oSourceComment); |
|
| 912 | - Context::set('oComment',$oComment); |
|
| 913 | - Context::set('module_srl',$this->module_info->module_srl); |
|
| 911 | + Context::set('oSourceComment', $oSourceComment); |
|
| 912 | + Context::set('oComment', $oComment); |
|
| 913 | + Context::set('module_srl', $this->module_info->module_srl); |
|
| 914 | 914 | |
| 915 | 915 | /** |
| 916 | 916 | * add JS filters |
@@ -926,7 +926,7 @@ discard block |
||
| 926 | 926 | function dispBoardModifyComment() |
| 927 | 927 | { |
| 928 | 928 | // check grant |
| 929 | - if(!$this->grant->write_comment) |
|
| 929 | + if (!$this->grant->write_comment) |
|
| 930 | 930 | { |
| 931 | 931 | return $this->dispBoardMessage('msg_not_permitted'); |
| 932 | 932 | } |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | $comment_srl = Context::get('comment_srl'); |
| 937 | 937 | |
| 938 | 938 | // if the comment is not existed |
| 939 | - if(!$comment_srl) |
|
| 939 | + if (!$comment_srl) |
|
| 940 | 940 | { |
| 941 | 941 | return new Object(-1, 'msg_invalid_request'); |
| 942 | 942 | } |
@@ -946,13 +946,13 @@ discard block |
||
| 946 | 946 | $oComment = $oCommentModel->getComment($comment_srl, $this->grant->manager); |
| 947 | 947 | |
| 948 | 948 | // if the comment is not exited, alert an error message |
| 949 | - if(!$oComment->isExists()) |
|
| 949 | + if (!$oComment->isExists()) |
|
| 950 | 950 | { |
| 951 | 951 | return $this->dispBoardMessage('msg_invalid_request'); |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | 954 | // if the comment is not granted, then back to the password input form |
| 955 | - if(!$oComment->isGranted()) |
|
| 955 | + if (!$oComment->isGranted()) |
|
| 956 | 956 | { |
| 957 | 957 | return $this->setTemplateFile('input_password_form'); |
| 958 | 958 | } |
@@ -975,7 +975,7 @@ discard block |
||
| 975 | 975 | function dispBoardDeleteComment() |
| 976 | 976 | { |
| 977 | 977 | // check grant |
| 978 | - if(!$this->grant->write_comment) |
|
| 978 | + if (!$this->grant->write_comment) |
|
| 979 | 979 | { |
| 980 | 980 | return $this->dispBoardMessage('msg_not_permitted'); |
| 981 | 981 | } |
@@ -984,25 +984,25 @@ discard block |
||
| 984 | 984 | $comment_srl = Context::get('comment_srl'); |
| 985 | 985 | |
| 986 | 986 | // if the comment exists, then get the comment information |
| 987 | - if($comment_srl) |
|
| 987 | + if ($comment_srl) |
|
| 988 | 988 | { |
| 989 | 989 | $oCommentModel = getModel('comment'); |
| 990 | 990 | $oComment = $oCommentModel->getComment($comment_srl, $this->grant->manager); |
| 991 | 991 | } |
| 992 | 992 | |
| 993 | 993 | // if the comment is not existed, then back to the board content page |
| 994 | - if(!$oComment->isExists() ) |
|
| 994 | + if (!$oComment->isExists()) |
|
| 995 | 995 | { |
| 996 | 996 | return $this->dispBoardContent(); |
| 997 | 997 | } |
| 998 | 998 | |
| 999 | 999 | // if the comment is not granted, then back to the password input form |
| 1000 | - if(!$oComment->isGranted()) |
|
| 1000 | + if (!$oComment->isGranted()) |
|
| 1001 | 1001 | { |
| 1002 | 1002 | return $this->setTemplateFile('input_password_form'); |
| 1003 | 1003 | } |
| 1004 | 1004 | |
| 1005 | - Context::set('oComment',$oComment); |
|
| 1005 | + Context::set('oComment', $oComment); |
|
| 1006 | 1006 | |
| 1007 | 1007 | /** |
| 1008 | 1008 | * add JS filters |
@@ -1019,7 +1019,7 @@ discard block |
||
| 1019 | 1019 | { |
| 1020 | 1020 | $oTrackbackModel = getModel('trackback'); |
| 1021 | 1021 | |
| 1022 | - if(!$oTrackbackModel) |
|
| 1022 | + if (!$oTrackbackModel) |
|
| 1023 | 1023 | { |
| 1024 | 1024 | return; |
| 1025 | 1025 | } |
@@ -1033,7 +1033,7 @@ discard block |
||
| 1033 | 1033 | $trackback = $output->data; |
| 1034 | 1034 | |
| 1035 | 1035 | // if no trackback, then display the board content |
| 1036 | - if(!$trackback) |
|
| 1036 | + if (!$trackback) |
|
| 1037 | 1037 | { |
| 1038 | 1038 | return $this->dispBoardContent(); |
| 1039 | 1039 | } |
@@ -1054,7 +1054,7 @@ discard block |
||
| 1054 | 1054 | function dispBoardMessage($msg_code) |
| 1055 | 1055 | { |
| 1056 | 1056 | $msg = Context::getLang($msg_code); |
| 1057 | - if(!$msg) $msg = $msg_code; |
|
| 1057 | + if (!$msg) $msg = $msg_code; |
|
| 1058 | 1058 | Context::set('message', $msg); |
| 1059 | 1059 | $this->setTemplateFile('message'); |
| 1060 | 1060 | } |
@@ -1065,8 +1065,8 @@ discard block |
||
| 1065 | 1065 | **/ |
| 1066 | 1066 | function alertMessage($message) |
| 1067 | 1067 | { |
| 1068 | - $script = sprintf('<script> jQuery(function(){ alert("%s"); } );</script>', Context::getLang($message)); |
|
| 1069 | - Context::addHtmlFooter( $script ); |
|
| 1068 | + $script = sprintf('<script> jQuery(function(){ alert("%s"); } );</script>', Context::getLang($message)); |
|
| 1069 | + Context::addHtmlFooter($script); |
|
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | 1072 | } |
@@ -10,32 +10,32 @@ discard block |
||
| 10 | 10 | $oSecurity = new Security(); |
| 11 | 11 | $oSecurity->encodeHTML('document_srl', 'comment_srl', 'vid', 'mid', 'page', 'category', 'search_target', 'search_keyword', 'sort_index', 'order_type', 'trackback_srl');
|
| 12 | 12 | |
| 13 | - if($this->module_info->list_count) $this->list_count = $this->module_info->list_count; |
|
| 14 | - if($this->module_info->mobile_list_count) $this->list_count = $this->module_info->mobile_list_count; |
|
| 15 | - if($this->module_info->search_list_count) $this->search_list_count = $this->module_info->search_list_count; |
|
| 16 | - if($this->module_info->mobile_search_list_count) $this->list_count = $this->module_info->mobile_search_list_count; |
|
| 17 | - if($this->module_info->page_count) $this->page_count = $this->module_info->page_count; |
|
| 18 | - if($this->module_info->mobile_page_count) $this->page_count = $this->module_info->mobile_page_count; |
|
| 13 | + if ($this->module_info->list_count) $this->list_count = $this->module_info->list_count; |
|
| 14 | + if ($this->module_info->mobile_list_count) $this->list_count = $this->module_info->mobile_list_count; |
|
| 15 | + if ($this->module_info->search_list_count) $this->search_list_count = $this->module_info->search_list_count; |
|
| 16 | + if ($this->module_info->mobile_search_list_count) $this->list_count = $this->module_info->mobile_search_list_count; |
|
| 17 | + if ($this->module_info->page_count) $this->page_count = $this->module_info->page_count; |
|
| 18 | + if ($this->module_info->mobile_page_count) $this->page_count = $this->module_info->mobile_page_count; |
|
| 19 | 19 | $this->except_notice = $this->module_info->except_notice == 'N' ? false : true; |
| 20 | 20 | |
| 21 | 21 | // $this->_getStatusNameListecret option backward compatibility |
| 22 | 22 | $oDocumentModel = getModel('document');
|
| 23 | 23 | |
| 24 | 24 | $statusList = $this->_getStatusNameList($oDocumentModel); |
| 25 | - if(isset($statusList['SECRET'])) |
|
| 25 | + if (isset($statusList['SECRET'])) |
|
| 26 | 26 | {
|
| 27 | 27 | $this->module_info->secret = 'Y'; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | // use_category <=1.5.x, hide_category >=1.7.x |
| 31 | 31 | $count_category = count($oDocumentModel->getCategoryList($this->module_info->module_srl)); |
| 32 | - if($count_category) |
|
| 32 | + if ($count_category) |
|
| 33 | 33 | {
|
| 34 | - if($this->module_info->hide_category) |
|
| 34 | + if ($this->module_info->hide_category) |
|
| 35 | 35 | {
|
| 36 | 36 | $this->module_info->use_category = ($this->module_info->hide_category == 'Y') ? 'N' : 'Y'; |
| 37 | 37 | } |
| 38 | - else if($this->module_info->use_category) |
|
| 38 | + else if ($this->module_info->use_category) |
|
| 39 | 39 | {
|
| 40 | 40 | $this->module_info->hide_category = ($this->module_info->use_category == 'Y') ? 'N' : 'Y'; |
| 41 | 41 | } |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | * check the consultation function, if the user is admin then swich off consultation function |
| 56 | 56 | * if the user is not logged, then disppear write document/write comment./ view document |
| 57 | 57 | **/ |
| 58 | - if($this->module_info->consultation == 'Y' && !$this->grant->manager && !$this->grant->consultation_read) |
|
| 58 | + if ($this->module_info->consultation == 'Y' && !$this->grant->manager && !$this->grant->consultation_read) |
|
| 59 | 59 | {
|
| 60 | 60 | $this->consultation = true; |
| 61 | - if(!Context::get('is_logged')) $this->grant->list = $this->grant->write_document = $this->grant->write_comment = $this->grant->view = false;
|
|
| 61 | + if (!Context::get('is_logged')) $this->grant->list = $this->grant->write_document = $this->grant->write_comment = $this->grant->view = false;
|
|
| 62 | 62 | } else {
|
| 63 | 63 | $this->consultation = false; |
| 64 | 64 | } |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | $extra_keys = $oDocumentModel->getExtraKeys($this->module_info->module_srl); |
| 68 | 68 | Context::set('extra_keys', $extra_keys);
|
| 69 | 69 | |
| 70 | - $template_path = sprintf("%sm.skins/%s/",$this->module_path, $this->module_info->mskin);
|
|
| 71 | - if(!is_dir($template_path)||!$this->module_info->mskin) |
|
| 70 | + $template_path = sprintf("%sm.skins/%s/", $this->module_path, $this->module_info->mskin);
|
|
| 71 | + if (!is_dir($template_path) || !$this->module_info->mskin) |
|
| 72 | 72 | {
|
| 73 | 73 | $this->module_info->mskin = 'default'; |
| 74 | - $template_path = sprintf("%sm.skins/%s/",$this->module_path, $this->module_info->mskin);
|
|
| 74 | + $template_path = sprintf("%sm.skins/%s/", $this->module_path, $this->module_info->mskin);
|
|
| 75 | 75 | } |
| 76 | 76 | $this->setTemplatePath($template_path); |
| 77 | 77 | Context::addJsFilter($this->module_path.'tpl/filter', 'input_password.xml'); |
@@ -87,13 +87,13 @@ discard block |
||
| 87 | 87 | function getBoardCommentPage() |
| 88 | 88 | {
|
| 89 | 89 | $document_srl = Context::get('document_srl');
|
| 90 | - $oDocumentModel =& getModel('document');
|
|
| 91 | - if(!$document_srl) |
|
| 90 | + $oDocumentModel = & getModel('document');
|
|
| 91 | + if (!$document_srl) |
|
| 92 | 92 | {
|
| 93 | 93 | return new Object(-1, "msg_invalid_request"); |
| 94 | 94 | } |
| 95 | 95 | $oDocument = $oDocumentModel->getDocument($document_srl); |
| 96 | - if(!$oDocument->isExists()) |
|
| 96 | + if (!$oDocument->isExists()) |
|
| 97 | 97 | {
|
| 98 | 98 | return new Object(-1, "msg_invalid_request"); |
| 99 | 99 | } |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | function dispBoardMessage($msg_code) |
| 107 | 107 | {
|
| 108 | 108 | $msg = Context::getLang($msg_code); |
| 109 | - $oMessageObject = &ModuleHandler::getModuleInstance('message','mobile');
|
|
| 109 | + $oMessageObject = &ModuleHandler::getModuleInstance('message', 'mobile');
|
|
| 110 | 110 | $oMessageObject->setError(-1); |
| 111 | 111 | $oMessageObject->setMessage($msg); |
| 112 | 112 | $oMessageObject->dispMessage(); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | { |
| 27 | 27 | static $member_config; |
| 28 | 28 | |
| 29 | - if($member_config) |
|
| 29 | + if ($member_config) |
|
| 30 | 30 | { |
| 31 | 31 | return $member_config; |
| 32 | 32 | } |
@@ -35,42 +35,42 @@ discard block |
||
| 35 | 35 | $oModuleModel = getModel('module'); |
| 36 | 36 | $config = $oModuleModel->getModuleConfig('member'); |
| 37 | 37 | |
| 38 | - if(!$config->signupForm || !is_array($config->signupForm)) |
|
| 38 | + if (!$config->signupForm || !is_array($config->signupForm)) |
|
| 39 | 39 | { |
| 40 | 40 | $oMemberAdminController = getAdminController('member'); |
| 41 | 41 | $identifier = ($config->identifier) ? $config->identifier : 'email_address'; |
| 42 | 42 | $config->signupForm = $oMemberAdminController->createSignupForm($identifier); |
| 43 | 43 | } |
| 44 | 44 | //for multi language |
| 45 | - foreach($config->signupForm AS $key=>$value) |
|
| 45 | + foreach ($config->signupForm AS $key=>$value) |
|
| 46 | 46 | { |
| 47 | 47 | $config->signupForm[$key]->title = ($value->isDefaultForm) ? Context::getLang($value->name) : $value->title; |
| 48 | - if($config->signupForm[$key]->isPublic != 'N') $config->signupForm[$key]->isPublic = 'Y'; |
|
| 49 | - if($value->name == 'find_account_question') $config->signupForm[$key]->isPublic = 'N'; |
|
| 48 | + if ($config->signupForm[$key]->isPublic != 'N') $config->signupForm[$key]->isPublic = 'Y'; |
|
| 49 | + if ($value->name == 'find_account_question') $config->signupForm[$key]->isPublic = 'N'; |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | // Get terms of user |
| 53 | 53 | $config->agreement = memberModel::_getAgreement(); |
| 54 | 54 | |
| 55 | - if(!$config->webmaster_name) $config->webmaster_name = 'webmaster'; |
|
| 56 | - if(!$config->image_name_max_width) $config->image_name_max_width = 90; |
|
| 57 | - if(!$config->image_name_max_height) $config->image_name_max_height = 20; |
|
| 58 | - if(!$config->image_mark_max_width) $config->image_mark_max_width = 20; |
|
| 59 | - if(!$config->image_mark_max_height) $config->image_mark_max_height = 20; |
|
| 60 | - if(!$config->profile_image_max_width) $config->profile_image_max_width = 90; |
|
| 61 | - if(!$config->profile_image_max_height) $config->profile_image_max_height = 90; |
|
| 62 | - if(!$config->skin) $config->skin = 'default'; |
|
| 63 | - if(!$config->colorset) $config->colorset = 'white'; |
|
| 64 | - if(!$config->editor_skin || $config->editor_skin == 'default') $config->editor_skin = 'ckeditor'; |
|
| 65 | - if(!$config->group_image_mark) $config->group_image_mark = "N"; |
|
| 55 | + if (!$config->webmaster_name) $config->webmaster_name = 'webmaster'; |
|
| 56 | + if (!$config->image_name_max_width) $config->image_name_max_width = 90; |
|
| 57 | + if (!$config->image_name_max_height) $config->image_name_max_height = 20; |
|
| 58 | + if (!$config->image_mark_max_width) $config->image_mark_max_width = 20; |
|
| 59 | + if (!$config->image_mark_max_height) $config->image_mark_max_height = 20; |
|
| 60 | + if (!$config->profile_image_max_width) $config->profile_image_max_width = 90; |
|
| 61 | + if (!$config->profile_image_max_height) $config->profile_image_max_height = 90; |
|
| 62 | + if (!$config->skin) $config->skin = 'default'; |
|
| 63 | + if (!$config->colorset) $config->colorset = 'white'; |
|
| 64 | + if (!$config->editor_skin || $config->editor_skin == 'default') $config->editor_skin = 'ckeditor'; |
|
| 65 | + if (!$config->group_image_mark) $config->group_image_mark = "N"; |
|
| 66 | 66 | |
| 67 | - if(!$config->identifier) $config->identifier = 'user_id'; |
|
| 67 | + if (!$config->identifier) $config->identifier = 'user_id'; |
|
| 68 | 68 | |
| 69 | - if(!$config->max_error_count) $config->max_error_count = 10; |
|
| 70 | - if(!$config->max_error_count_time) $config->max_error_count_time = 300; |
|
| 69 | + if (!$config->max_error_count) $config->max_error_count = 10; |
|
| 70 | + if (!$config->max_error_count_time) $config->max_error_count_time = 300; |
|
| 71 | 71 | |
| 72 | - if(!$config->signature_editor_skin || $config->signature_editor_skin == 'default') $config->signature_editor_skin = 'ckeditor'; |
|
| 73 | - if(!$config->sel_editor_colorset) $config->sel_editor_colorset = 'moono'; |
|
| 72 | + if (!$config->signature_editor_skin || $config->signature_editor_skin == 'default') $config->signature_editor_skin = 'ckeditor'; |
|
| 73 | + if (!$config->sel_editor_colorset) $config->sel_editor_colorset = 'moono'; |
|
| 74 | 74 | |
| 75 | 75 | $member_config = $config; |
| 76 | 76 | |
@@ -79,24 +79,24 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | function _getAgreement() |
| 81 | 81 | { |
| 82 | - $agreement_file = _XE_PATH_.'files/member_extra_info/agreement_' . Context::get('lang_type') . '.txt'; |
|
| 83 | - if(is_readable($agreement_file)) |
|
| 82 | + $agreement_file = _XE_PATH_.'files/member_extra_info/agreement_'.Context::get('lang_type').'.txt'; |
|
| 83 | + if (is_readable($agreement_file)) |
|
| 84 | 84 | { |
| 85 | 85 | return FileHandler::readFile($agreement_file); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $db_info = Context::getDBInfo(); |
| 89 | - $agreement_file = _XE_PATH_.'files/member_extra_info/agreement_' . $db_info->lang_type . '.txt'; |
|
| 90 | - if(is_readable($agreement_file)) |
|
| 89 | + $agreement_file = _XE_PATH_.'files/member_extra_info/agreement_'.$db_info->lang_type.'.txt'; |
|
| 90 | + if (is_readable($agreement_file)) |
|
| 91 | 91 | { |
| 92 | 92 | return FileHandler::readFile($agreement_file); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $lang_selected = Context::loadLangSelected(); |
| 96 | - foreach($lang_selected as $key => $val) |
|
| 96 | + foreach ($lang_selected as $key => $val) |
|
| 97 | 97 | { |
| 98 | - $agreement_file = _XE_PATH_.'files/member_extra_info/agreement_' . $key . '.txt'; |
|
| 99 | - if(is_readable($agreement_file)) |
|
| 98 | + $agreement_file = _XE_PATH_.'files/member_extra_info/agreement_'.$key.'.txt'; |
|
| 99 | + if (is_readable($agreement_file)) |
|
| 100 | 100 | { |
| 101 | 101 | return FileHandler::readFile($agreement_file); |
| 102 | 102 | } |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | $logged_info = Context::get('logged_info'); |
| 117 | 117 | $act = Context::get('cur_act'); |
| 118 | 118 | // When click user's own nickname |
| 119 | - if($member_srl == $logged_info->member_srl) $member_info = $logged_info; |
|
| 119 | + if ($member_srl == $logged_info->member_srl) $member_info = $logged_info; |
|
| 120 | 120 | // When click other's nickname |
| 121 | 121 | else $member_info = $this->getMemberInfoByMemberSrl($member_srl); |
| 122 | 122 | |
| 123 | 123 | $member_srl = $member_info->member_srl; |
| 124 | - if(!$member_srl) return; |
|
| 124 | + if (!$member_srl) return; |
|
| 125 | 125 | // List variables |
| 126 | 126 | $user_id = $member_info->user_id; |
| 127 | 127 | $user_name = $member_info->user_name; |
@@ -130,18 +130,18 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | $oMemberController = getController('member'); |
| 132 | 132 | // Display member information (Don't display to non-logged user) |
| 133 | - if($logged_info->member_srl) |
|
| 133 | + if ($logged_info->member_srl) |
|
| 134 | 134 | { |
| 135 | - $url = getUrl('','mid',$mid,'act','dispMemberInfo','member_srl',$member_srl); |
|
| 136 | - $oMemberController->addMemberPopupMenu($url,'cmd_view_member_info',$icon_path,'self'); |
|
| 135 | + $url = getUrl('', 'mid', $mid, 'act', 'dispMemberInfo', 'member_srl', $member_srl); |
|
| 136 | + $oMemberController->addMemberPopupMenu($url, 'cmd_view_member_info', $icon_path, 'self'); |
|
| 137 | 137 | } |
| 138 | 138 | // When click other's nickname |
| 139 | - if($member_srl != $logged_info->member_srl && $logged_info->member_srl) |
|
| 139 | + if ($member_srl != $logged_info->member_srl && $logged_info->member_srl) |
|
| 140 | 140 | { |
| 141 | 141 | // Get email config |
| 142 | - foreach($this->module_config->signupForm as $field) |
|
| 142 | + foreach ($this->module_config->signupForm as $field) |
|
| 143 | 143 | { |
| 144 | - if($field->name == 'email_address') |
|
| 144 | + if ($field->name == 'email_address') |
|
| 145 | 145 | { |
| 146 | 146 | $email_config = $field; |
| 147 | 147 | break; |
@@ -149,36 +149,36 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | // Send an email only if email address is public |
| 152 | - if(($logged_info->is_admin == 'Y' || $email_config->isPublic == 'Y') && $member_info->email_address) |
|
| 152 | + if (($logged_info->is_admin == 'Y' || $email_config->isPublic == 'Y') && $member_info->email_address) |
|
| 153 | 153 | { |
| 154 | 154 | $url = 'mailto:'.htmlspecialchars($member_info->email_address, ENT_COMPAT | ENT_HTML401, 'UTF-8', false); |
| 155 | - $oMemberController->addMemberPopupMenu($url,'cmd_send_email',$icon_path); |
|
| 155 | + $oMemberController->addMemberPopupMenu($url, 'cmd_send_email', $icon_path); |
|
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | // View homepage info |
| 159 | - if($member_info->homepage) |
|
| 159 | + if ($member_info->homepage) |
|
| 160 | 160 | $oMemberController->addMemberPopupMenu(htmlspecialchars($member_info->homepage, ENT_COMPAT | ENT_HTML401, 'UTF-8', false), 'homepage', '', 'blank'); |
| 161 | 161 | // View blog info |
| 162 | - if($member_info->blog) |
|
| 162 | + if ($member_info->blog) |
|
| 163 | 163 | $oMemberController->addMemberPopupMenu(htmlspecialchars($member_info->blog, ENT_COMPAT | ENT_HTML401, 'UTF-8', false), 'blog', '', 'blank'); |
| 164 | 164 | // Call a trigger (after) |
| 165 | 165 | ModuleHandler::triggerCall('member.getMemberMenu', 'after', $null); |
| 166 | 166 | // Display a menu for editting member info to a top administrator |
| 167 | - if($logged_info->is_admin == 'Y') |
|
| 167 | + if ($logged_info->is_admin == 'Y') |
|
| 168 | 168 | { |
| 169 | - $url = getUrl('','module','admin','act','dispMemberAdminInsert','member_srl',$member_srl); |
|
| 170 | - $oMemberController->addMemberPopupMenu($url,'cmd_manage_member_info',$icon_path,'MemberModifyInfo'); |
|
| 169 | + $url = getUrl('', 'module', 'admin', 'act', 'dispMemberAdminInsert', 'member_srl', $member_srl); |
|
| 170 | + $oMemberController->addMemberPopupMenu($url, 'cmd_manage_member_info', $icon_path, 'MemberModifyInfo'); |
|
| 171 | 171 | |
| 172 | - $url = getUrl('','module','admin','act','dispDocumentAdminList','search_target','member_srl','search_keyword',$member_srl); |
|
| 173 | - $oMemberController->addMemberPopupMenu($url,'cmd_trace_document',$icon_path,'TraceMemberDocument'); |
|
| 172 | + $url = getUrl('', 'module', 'admin', 'act', 'dispDocumentAdminList', 'search_target', 'member_srl', 'search_keyword', $member_srl); |
|
| 173 | + $oMemberController->addMemberPopupMenu($url, 'cmd_trace_document', $icon_path, 'TraceMemberDocument'); |
|
| 174 | 174 | |
| 175 | - $url = getUrl('','module','admin','act','dispCommentAdminList','search_target','member_srl','search_keyword',$member_srl); |
|
| 176 | - $oMemberController->addMemberPopupMenu($url,'cmd_trace_comment',$icon_path,'TraceMemberComment'); |
|
| 175 | + $url = getUrl('', 'module', 'admin', 'act', 'dispCommentAdminList', 'search_target', 'member_srl', 'search_keyword', $member_srl); |
|
| 176 | + $oMemberController->addMemberPopupMenu($url, 'cmd_trace_comment', $icon_path, 'TraceMemberComment'); |
|
| 177 | 177 | } |
| 178 | 178 | // Change a language of pop-up menu |
| 179 | 179 | $menus = Context::get('member_popup_menu_list'); |
| 180 | 180 | $menus_count = count($menus); |
| 181 | - for($i=0;$i<$menus_count;$i++) |
|
| 181 | + for ($i = 0; $i < $menus_count; $i++) |
|
| 182 | 182 | { |
| 183 | 183 | $menus[$i]->str = Context::getLang($menus[$i]->str); |
| 184 | 184 | } |
@@ -190,15 +190,15 @@ discard block |
||
| 190 | 190 | * @brief Check if logged-in |
| 191 | 191 | */ |
| 192 | 192 | function isLogged() { |
| 193 | - if($_SESSION['is_logged']) |
|
| 193 | + if ($_SESSION['is_logged']) |
|
| 194 | 194 | { |
| 195 | - if(Mobile::isFromMobilePhone()) |
|
| 195 | + if (Mobile::isFromMobilePhone()) |
|
| 196 | 196 | { |
| 197 | 197 | return true; |
| 198 | 198 | } |
| 199 | 199 | else |
| 200 | 200 | { |
| 201 | - if(ip2long($_SESSION['ipaddress']) >> 8 == ip2long($_SERVER['REMOTE_ADDR']) >> 8) |
|
| 201 | + if (ip2long($_SESSION['ipaddress']) >> 8 == ip2long($_SERVER['REMOTE_ADDR']) >> 8) |
|
| 202 | 202 | { |
| 203 | 203 | return true; |
| 204 | 204 | } |
@@ -215,23 +215,23 @@ discard block |
||
| 215 | 215 | function getLoggedInfo() |
| 216 | 216 | { |
| 217 | 217 | // Return session info if session info is requested and the user is logged-in |
| 218 | - if($this->isLogged()) |
|
| 218 | + if ($this->isLogged()) |
|
| 219 | 219 | { |
| 220 | 220 | $logged_info = Context::get('logged_info'); |
| 221 | 221 | // Admin/Group list defined depending on site_module_info |
| 222 | 222 | $site_module_info = Context::get('site_module_info'); |
| 223 | - if($site_module_info->site_srl) |
|
| 223 | + if ($site_module_info->site_srl) |
|
| 224 | 224 | { |
| 225 | 225 | $logged_info->group_list = $this->getMemberGroups($logged_info->member_srl, $site_module_info->site_srl); |
| 226 | 226 | // Add is_site_admin bool variable into logged_info if site_administrator is |
| 227 | 227 | $oModuleModel = getModel('module'); |
| 228 | - if($oModuleModel->isSiteAdmin($logged_info)) $logged_info->is_site_admin = true; |
|
| 228 | + if ($oModuleModel->isSiteAdmin($logged_info)) $logged_info->is_site_admin = true; |
|
| 229 | 229 | else $logged_info->is_site_admin = false; |
| 230 | 230 | } |
| 231 | 231 | else |
| 232 | 232 | { |
| 233 | 233 | // Register a default group if the site doesn't have a member group |
| 234 | - if(count($logged_info->group_list) === 0) |
|
| 234 | + if (count($logged_info->group_list) === 0) |
|
| 235 | 235 | { |
| 236 | 236 | $default_group = $this->getDefaultGroup(0); |
| 237 | 237 | $oMemberController = getController('member'); |
@@ -254,13 +254,13 @@ discard block |
||
| 254 | 254 | */ |
| 255 | 255 | function getMemberInfoByUserID($user_id, $columnList = array()) |
| 256 | 256 | { |
| 257 | - if(!$user_id) return; |
|
| 257 | + if (!$user_id) return; |
|
| 258 | 258 | |
| 259 | 259 | $args = new stdClass; |
| 260 | 260 | $args->user_id = $user_id; |
| 261 | 261 | $output = executeQuery('member.getMemberInfo', $args); |
| 262 | - if(!$output->toBool()) return $output; |
|
| 263 | - if(!$output->data) return; |
|
| 262 | + if (!$output->toBool()) return $output; |
|
| 263 | + if (!$output->data) return; |
|
| 264 | 264 | |
| 265 | 265 | $member_info = $this->arrangeMemberInfo($output->data); |
| 266 | 266 | |
@@ -272,12 +272,12 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | function getMemberInfoByEmailAddress($email_address) |
| 274 | 274 | { |
| 275 | - if(!$email_address) return; |
|
| 275 | + if (!$email_address) return; |
|
| 276 | 276 | |
| 277 | 277 | $args = new stdClass(); |
| 278 | 278 | |
| 279 | - $db_info = Context::getDBInfo (); |
|
| 280 | - if($db_info->master_db['db_type'] == "cubrid") |
|
| 279 | + $db_info = Context::getDBInfo(); |
|
| 280 | + if ($db_info->master_db['db_type'] == "cubrid") |
|
| 281 | 281 | { |
| 282 | 282 | $args->email_address = strtolower($email_address); |
| 283 | 283 | $output = executeQuery('member.getMemberInfoByEmailAddressForCubrid', $args); |
@@ -288,8 +288,8 @@ discard block |
||
| 288 | 288 | $output = executeQuery('member.getMemberInfoByEmailAddress', $args); |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - if(!$output->toBool()) return $output; |
|
| 292 | - if(!$output->data) return; |
|
| 291 | + if (!$output->toBool()) return $output; |
|
| 292 | + if (!$output->data) return; |
|
| 293 | 293 | |
| 294 | 294 | $member_info = $this->arrangeMemberInfo($output->data); |
| 295 | 295 | return $member_info; |
@@ -300,36 +300,36 @@ discard block |
||
| 300 | 300 | */ |
| 301 | 301 | function getMemberInfoByMemberSrl($member_srl, $site_srl = 0, $columnList = array()) |
| 302 | 302 | { |
| 303 | - if(!$member_srl) return; |
|
| 303 | + if (!$member_srl) return; |
|
| 304 | 304 | |
| 305 | 305 | //columnList size zero... get full member info |
| 306 | - if(!$GLOBALS['__member_info__'][$member_srl] || count($columnList) == 0) |
|
| 306 | + if (!$GLOBALS['__member_info__'][$member_srl] || count($columnList) == 0) |
|
| 307 | 307 | { |
| 308 | 308 | $GLOBALS['__member_info__'][$member_srl] = false; |
| 309 | 309 | |
| 310 | 310 | $oCacheHandler = CacheHandler::getInstance('object'); |
| 311 | - if($oCacheHandler->isSupport()) |
|
| 311 | + if ($oCacheHandler->isSupport()) |
|
| 312 | 312 | { |
| 313 | 313 | $columnList = array(); |
| 314 | - $object_key = 'member_info:' . getNumberingPath($member_srl) . $member_srl; |
|
| 314 | + $object_key = 'member_info:'.getNumberingPath($member_srl).$member_srl; |
|
| 315 | 315 | $cache_key = $oCacheHandler->getGroupKey('member', $object_key); |
| 316 | 316 | $GLOBALS['__member_info__'][$member_srl] = $oCacheHandler->get($cache_key); |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | - if($GLOBALS['__member_info__'][$member_srl] === false) |
|
| 319 | + if ($GLOBALS['__member_info__'][$member_srl] === false) |
|
| 320 | 320 | { |
| 321 | 321 | $args = new stdClass(); |
| 322 | 322 | $args->member_srl = $member_srl; |
| 323 | 323 | $output = executeQuery('member.getMemberInfoByMemberSrl', $args, $columnList); |
| 324 | - if(!$output->data) |
|
| 324 | + if (!$output->data) |
|
| 325 | 325 | { |
| 326 | - if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, new stdClass); |
|
| 326 | + if ($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, new stdClass); |
|
| 327 | 327 | return; |
| 328 | 328 | } |
| 329 | 329 | $this->arrangeMemberInfo($output->data, $site_srl); |
| 330 | 330 | |
| 331 | 331 | //insert in cache |
| 332 | - if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $GLOBALS['__member_info__'][$member_srl]); |
|
| 332 | + if ($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $GLOBALS['__member_info__'][$member_srl]); |
|
| 333 | 333 | } |
| 334 | 334 | } |
| 335 | 335 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | function arrangeMemberInfo($info, $site_srl = 0) |
| 343 | 343 | { |
| 344 | - if(!$GLOBALS['__member_info__'][$info->member_srl]) |
|
| 344 | + if (!$GLOBALS['__member_info__'][$info->member_srl]) |
|
| 345 | 345 | { |
| 346 | 346 | $oModuleModel = getModel('module'); |
| 347 | 347 | $config = $oModuleModel->getModuleConfig('member'); |
@@ -350,25 +350,25 @@ discard block |
||
| 350 | 350 | $info->profile_image = $this->getProfileImage($info->member_srl); |
| 351 | 351 | $info->image_name = $this->getImageName($info->member_srl); |
| 352 | 352 | $info->image_mark = $this->getImageMark($info->member_srl); |
| 353 | - if($config->group_image_mark=='Y') |
|
| 353 | + if ($config->group_image_mark == 'Y') |
|
| 354 | 354 | { |
| 355 | - $info->group_mark = $this->getGroupImageMark($info->member_srl,$site_srl); |
|
| 355 | + $info->group_mark = $this->getGroupImageMark($info->member_srl, $site_srl); |
|
| 356 | 356 | } |
| 357 | 357 | $info->signature = $this->getSignature($info->member_srl); |
| 358 | 358 | $info->group_list = $this->getMemberGroups($info->member_srl, $site_srl); |
| 359 | 359 | |
| 360 | 360 | $extra_vars = unserialize($info->extra_vars); |
| 361 | 361 | unset($info->extra_vars); |
| 362 | - if($extra_vars) |
|
| 362 | + if ($extra_vars) |
|
| 363 | 363 | { |
| 364 | - foreach($extra_vars as $key => $val) |
|
| 364 | + foreach ($extra_vars as $key => $val) |
|
| 365 | 365 | { |
| 366 | - if(!is_array($val) && strpos($val, '|@|') !== FALSE) $val = explode('|@|', $val); |
|
| 367 | - if(!$info->{$key}) $info->{$key} = $val; |
|
| 366 | + if (!is_array($val) && strpos($val, '|@|') !== FALSE) $val = explode('|@|', $val); |
|
| 367 | + if (!$info->{$key}) $info->{$key} = $val; |
|
| 368 | 368 | } |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | - if(strlen($info->find_account_answer) == 32 && preg_match('/[a-zA-Z0-9]+/', $info->find_account_answer)) |
|
| 371 | + if (strlen($info->find_account_answer) == 32 && preg_match('/[a-zA-Z0-9]+/', $info->find_account_answer)) |
|
| 372 | 372 | { |
| 373 | 373 | $info->find_account_answer = null; |
| 374 | 374 | } |
@@ -380,13 +380,13 @@ discard block |
||
| 380 | 380 | $info->homepage = strip_tags($info->homepage); |
| 381 | 381 | $info->blog = strip_tags($info->blog); |
| 382 | 382 | |
| 383 | - if($extra_vars) |
|
| 383 | + if ($extra_vars) |
|
| 384 | 384 | { |
| 385 | - foreach($extra_vars as $key => $val) |
|
| 385 | + foreach ($extra_vars as $key => $val) |
|
| 386 | 386 | { |
| 387 | - if(is_array($val)) |
|
| 387 | + if (is_array($val)) |
|
| 388 | 388 | { |
| 389 | - $oSecurity->encodeHTML($key . '.'); |
|
| 389 | + $oSecurity->encodeHTML($key.'.'); |
|
| 390 | 390 | } |
| 391 | 391 | else |
| 392 | 392 | { |
@@ -397,12 +397,12 @@ discard block |
||
| 397 | 397 | |
| 398 | 398 | // Check format. |
| 399 | 399 | $oValidator = new Validator(); |
| 400 | - if(!$oValidator->applyRule('url', $info->homepage)) |
|
| 400 | + if (!$oValidator->applyRule('url', $info->homepage)) |
|
| 401 | 401 | { |
| 402 | 402 | $info->homepage = ''; |
| 403 | 403 | } |
| 404 | 404 | |
| 405 | - if(!$oValidator->applyRule('url', $info->blog)) |
|
| 405 | + if (!$oValidator->applyRule('url', $info->blog)) |
|
| 406 | 406 | { |
| 407 | 407 | $info->blog = ''; |
| 408 | 408 | } |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | */ |
| 452 | 452 | function getLoggedMemberSrl() |
| 453 | 453 | { |
| 454 | - if(!$this->isLogged()) return; |
|
| 454 | + if (!$this->isLogged()) return; |
|
| 455 | 455 | return $_SESSION['member_srl']; |
| 456 | 456 | } |
| 457 | 457 | |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | */ |
| 461 | 461 | function getLoggedUserID() |
| 462 | 462 | { |
| 463 | - if(!$this->isLogged()) return; |
|
| 463 | + if (!$this->isLogged()) return; |
|
| 464 | 464 | $logged_info = Context::get('logged_info'); |
| 465 | 465 | return $logged_info->user_id; |
| 466 | 466 | } |
@@ -475,16 +475,16 @@ discard block |
||
| 475 | 475 | // cache controll |
| 476 | 476 | $group_list = false; |
| 477 | 477 | $oCacheHandler = CacheHandler::getInstance('object', null, true); |
| 478 | - if($oCacheHandler->isSupport()) |
|
| 478 | + if ($oCacheHandler->isSupport()) |
|
| 479 | 479 | { |
| 480 | - $object_key = 'member_groups:' . getNumberingPath($member_srl) . $member_srl . '_'.$site_srl; |
|
| 480 | + $object_key = 'member_groups:'.getNumberingPath($member_srl).$member_srl.'_'.$site_srl; |
|
| 481 | 481 | $cache_key = $oCacheHandler->getGroupKey('member', $object_key); |
| 482 | 482 | $group_list = $oCacheHandler->get($cache_key); |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | - if(!$member_groups[$member_srl][$site_srl] || $force_reload) |
|
| 485 | + if (!$member_groups[$member_srl][$site_srl] || $force_reload) |
|
| 486 | 486 | { |
| 487 | - if($group_list === false) |
|
| 487 | + if ($group_list === false) |
|
| 488 | 488 | { |
| 489 | 489 | $args = new stdClass(); |
| 490 | 490 | $args->member_srl = $member_srl; |
@@ -492,11 +492,11 @@ discard block |
||
| 492 | 492 | $output = executeQueryArray('member.getMemberGroups', $args); |
| 493 | 493 | $group_list = $output->data; |
| 494 | 494 | //insert in cache |
| 495 | - if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $group_list); |
|
| 495 | + if ($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $group_list); |
|
| 496 | 496 | } |
| 497 | - if(!$group_list) return array(); |
|
| 497 | + if (!$group_list) return array(); |
|
| 498 | 498 | |
| 499 | - foreach($group_list as $group) |
|
| 499 | + foreach ($group_list as $group) |
|
| 500 | 500 | { |
| 501 | 501 | $result[$group->group_srl] = $group->title; |
| 502 | 502 | } |
@@ -510,14 +510,14 @@ discard block |
||
| 510 | 510 | */ |
| 511 | 511 | function getMembersGroups($member_srls, $site_srl = 0) |
| 512 | 512 | { |
| 513 | - $args->member_srls = implode(',',$member_srls); |
|
| 513 | + $args->member_srls = implode(',', $member_srls); |
|
| 514 | 514 | $args->site_srl = $site_srl; |
| 515 | 515 | $args->sort_index = 'list_order'; |
| 516 | 516 | $output = executeQueryArray('member.getMembersGroups', $args); |
| 517 | - if(!$output->data) return array(); |
|
| 517 | + if (!$output->data) return array(); |
|
| 518 | 518 | |
| 519 | 519 | $result = array(); |
| 520 | - foreach($output->data as $key=>$val) |
|
| 520 | + foreach ($output->data as $key=>$val) |
|
| 521 | 521 | { |
| 522 | 522 | $result[$val->member_srl][] = $val->title; |
| 523 | 523 | } |
@@ -531,21 +531,21 @@ discard block |
||
| 531 | 531 | { |
| 532 | 532 | $default_group = false; |
| 533 | 533 | $oCacheHandler = CacheHandler::getInstance('object', null, true); |
| 534 | - if($oCacheHandler->isSupport()) |
|
| 534 | + if ($oCacheHandler->isSupport()) |
|
| 535 | 535 | { |
| 536 | 536 | $columnList = array(); |
| 537 | - $object_key = 'default_group_' . $site_srl; |
|
| 537 | + $object_key = 'default_group_'.$site_srl; |
|
| 538 | 538 | $cache_key = $oCacheHandler->getGroupKey('member', $object_key); |
| 539 | 539 | $default_group = $oCacheHandler->get($cache_key); |
| 540 | 540 | } |
| 541 | 541 | |
| 542 | - if($default_group === false) |
|
| 542 | + if ($default_group === false) |
|
| 543 | 543 | { |
| 544 | 544 | $args = new stdClass(); |
| 545 | 545 | $args->site_srl = $site_srl; |
| 546 | 546 | $output = executeQuery('member.getDefaultGroup', $args, $columnList); |
| 547 | 547 | $default_group = $output->data; |
| 548 | - if($oCacheHandler->isSupport()) |
|
| 548 | + if ($oCacheHandler->isSupport()) |
|
| 549 | 549 | { |
| 550 | 550 | $oCacheHandler->put($cache_key, $default_group); |
| 551 | 551 | } |
@@ -579,25 +579,25 @@ discard block |
||
| 579 | 579 | */ |
| 580 | 580 | function getGroups($site_srl = 0) |
| 581 | 581 | { |
| 582 | - if(!$GLOBALS['__group_info__'][$site_srl]) |
|
| 582 | + if (!$GLOBALS['__group_info__'][$site_srl]) |
|
| 583 | 583 | { |
| 584 | 584 | $result = array(); |
| 585 | 585 | |
| 586 | - if(!isset($site_srl)) |
|
| 586 | + if (!isset($site_srl)) |
|
| 587 | 587 | { |
| 588 | 588 | $site_srl = 0; |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | $group_list = false; |
| 592 | 592 | $oCacheHandler = CacheHandler::getInstance('object', null, true); |
| 593 | - if($oCacheHandler->isSupport()) |
|
| 593 | + if ($oCacheHandler->isSupport()) |
|
| 594 | 594 | { |
| 595 | 595 | $object_key = 'member_groups:site_'.$site_srl; |
| 596 | 596 | $cache_key = $oCacheHandler->getGroupKey('member', $object_key); |
| 597 | 597 | $group_list = $oCacheHandler->get($cache_key); |
| 598 | 598 | } |
| 599 | 599 | |
| 600 | - if($group_list === false) |
|
| 600 | + if ($group_list === false) |
|
| 601 | 601 | { |
| 602 | 602 | $args = new stdClass(); |
| 603 | 603 | $args->site_srl = $site_srl; |
@@ -606,16 +606,16 @@ discard block |
||
| 606 | 606 | $output = executeQueryArray('member.getGroups', $args); |
| 607 | 607 | $group_list = $output->data; |
| 608 | 608 | //insert in cache |
| 609 | - if($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $group_list); |
|
| 609 | + if ($oCacheHandler->isSupport()) $oCacheHandler->put($cache_key, $group_list); |
|
| 610 | 610 | } |
| 611 | 611 | |
| 612 | - if(!$group_list) |
|
| 612 | + if (!$group_list) |
|
| 613 | 613 | { |
| 614 | 614 | return array(); |
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | |
| 618 | - foreach($group_list as $val) |
|
| 618 | + foreach ($group_list as $val) |
|
| 619 | 619 | { |
| 620 | 620 | $result[$val->group_srl] = $val; |
| 621 | 621 | } |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | // Set to ignore if a super administrator. |
| 647 | 647 | $logged_info = Context::get('logged_info'); |
| 648 | 648 | |
| 649 | - if(!$this->join_form_list) |
|
| 649 | + if (!$this->join_form_list) |
|
| 650 | 650 | { |
| 651 | 651 | // Argument setting to sort list_order column |
| 652 | 652 | $args = new stdClass(); |
@@ -654,11 +654,11 @@ discard block |
||
| 654 | 654 | $output = executeQuery('member.getJoinFormList', $args); |
| 655 | 655 | // NULL if output data deosn't exist |
| 656 | 656 | $join_form_list = $output->data; |
| 657 | - if(!$join_form_list) return NULL; |
|
| 657 | + if (!$join_form_list) return NULL; |
|
| 658 | 658 | // Need to unserialize because serialized array is inserted into DB in case of default_value |
| 659 | - if(!is_array($join_form_list)) $join_form_list = array($join_form_list); |
|
| 659 | + if (!is_array($join_form_list)) $join_form_list = array($join_form_list); |
|
| 660 | 660 | $join_form_count = count($join_form_list); |
| 661 | - for($i=0;$i<$join_form_count;$i++) |
|
| 661 | + for ($i = 0; $i < $join_form_count; $i++) |
|
| 662 | 662 | { |
| 663 | 663 | $join_form_list[$i]->column_name = strtolower($join_form_list[$i]->column_name); |
| 664 | 664 | |
@@ -670,10 +670,10 @@ discard block |
||
| 670 | 670 | // Add language variable |
| 671 | 671 | $lang->extend_vars[$column_name] = $column_title; |
| 672 | 672 | // unserialize if the data type if checkbox, select and so on |
| 673 | - if(in_array($column_type, array('checkbox','select','radio'))) |
|
| 673 | + if (in_array($column_type, array('checkbox', 'select', 'radio'))) |
|
| 674 | 674 | { |
| 675 | 675 | $join_form_list[$i]->default_value = unserialize($default_value); |
| 676 | - if(!$join_form_list[$i]->default_value[0]) $join_form_list[$i]->default_value = ''; |
|
| 676 | + if (!$join_form_list[$i]->default_value[0]) $join_form_list[$i]->default_value = ''; |
|
| 677 | 677 | } |
| 678 | 678 | else |
| 679 | 679 | { |
@@ -685,16 +685,16 @@ discard block |
||
| 685 | 685 | $this->join_form_list = $list; |
| 686 | 686 | } |
| 687 | 687 | // Get object style if the filter_response is true |
| 688 | - if($filter_response && count($this->join_form_list)) |
|
| 688 | + if ($filter_response && count($this->join_form_list)) |
|
| 689 | 689 | { |
| 690 | - foreach($this->join_form_list as $key => $val) |
|
| 690 | + foreach ($this->join_form_list as $key => $val) |
|
| 691 | 691 | { |
| 692 | - if($val->is_active != 'Y') continue; |
|
| 692 | + if ($val->is_active != 'Y') continue; |
|
| 693 | 693 | unset($obj); |
| 694 | 694 | $obj->type = $val->column_type; |
| 695 | 695 | $obj->name = $val->column_name; |
| 696 | 696 | $obj->lang = $val->column_title; |
| 697 | - if($logged_info->is_admin != 'Y') $obj->required = $val->required=='Y'?true:false; |
|
| 697 | + if ($logged_info->is_admin != 'Y') $obj->required = $val->required == 'Y' ? true : false; |
|
| 698 | 698 | else $obj->required = false; |
| 699 | 699 | $filter_output[] = $obj; |
| 700 | 700 | |
@@ -721,15 +721,15 @@ discard block |
||
| 721 | 721 | $args->sort_index = "list_order"; |
| 722 | 722 | $output = executeQueryArray('member.getJoinFormList', $args); |
| 723 | 723 | |
| 724 | - if(!$output->toBool()) |
|
| 724 | + if (!$output->toBool()) |
|
| 725 | 725 | { |
| 726 | 726 | return array(); |
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | $joinFormList = array(); |
| 730 | - foreach($output->data as $val) |
|
| 730 | + foreach ($output->data as $val) |
|
| 731 | 731 | { |
| 732 | - if($val->is_active != 'Y') |
|
| 732 | + if ($val->is_active != 'Y') |
|
| 733 | 733 | { |
| 734 | 734 | continue; |
| 735 | 735 | } |
@@ -746,20 +746,20 @@ discard block |
||
| 746 | 746 | function getCombineJoinForm($member_info) |
| 747 | 747 | { |
| 748 | 748 | $extend_form_list = $this->getJoinFormlist(); |
| 749 | - if(!$extend_form_list) return; |
|
| 749 | + if (!$extend_form_list) return; |
|
| 750 | 750 | // Member info is open only to an administrator and him/herself when is_private is true. |
| 751 | 751 | $logged_info = Context::get('logged_info'); |
| 752 | 752 | |
| 753 | - foreach($extend_form_list as $srl => $item) |
|
| 753 | + foreach ($extend_form_list as $srl => $item) |
|
| 754 | 754 | { |
| 755 | 755 | $column_name = $item->column_name; |
| 756 | 756 | $value = $member_info->{$column_name}; |
| 757 | 757 | |
| 758 | 758 | // Change values depening on the type of extend form |
| 759 | - switch($item->column_type) |
|
| 759 | + switch ($item->column_type) |
|
| 760 | 760 | { |
| 761 | 761 | case 'checkbox' : |
| 762 | - if($value && !is_array($value)) $value = array($value); |
|
| 762 | + if ($value && !is_array($value)) $value = array($value); |
|
| 763 | 763 | break; |
| 764 | 764 | case 'text' : |
| 765 | 765 | case 'homepage' : |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | |
| 774 | 774 | $extend_form_list[$srl]->value = $value; |
| 775 | 775 | |
| 776 | - if($member_info->{'open_'.$column_name}=='Y') $extend_form_list[$srl]->is_opened = true; |
|
| 776 | + if ($member_info->{'open_'.$column_name} == 'Y') $extend_form_list[$srl]->is_opened = true; |
|
| 777 | 777 | else $extend_form_list[$srl]->is_opened = false; |
| 778 | 778 | } |
| 779 | 779 | return $extend_form_list; |
@@ -787,12 +787,12 @@ discard block |
||
| 787 | 787 | $args->member_join_form_srl = $member_join_form_srl; |
| 788 | 788 | $output = executeQuery('member.getJoinForm', $args); |
| 789 | 789 | $join_form = $output->data; |
| 790 | - if(!$join_form) return NULL; |
|
| 790 | + if (!$join_form) return NULL; |
|
| 791 | 791 | |
| 792 | 792 | $column_type = $join_form->column_type; |
| 793 | 793 | $default_value = $join_form->default_value; |
| 794 | 794 | |
| 795 | - if(in_array($column_type, array('checkbox','select','radio'))) |
|
| 795 | + if (in_array($column_type, array('checkbox', 'select', 'radio'))) |
|
| 796 | 796 | { |
| 797 | 797 | $join_form->default_value = unserialize($default_value); |
| 798 | 798 | } |
@@ -809,7 +809,7 @@ discard block |
||
| 809 | 809 | */ |
| 810 | 810 | function getDeniedIDList() |
| 811 | 811 | { |
| 812 | - if(!$this->denied_id_list) |
|
| 812 | + if (!$this->denied_id_list) |
|
| 813 | 813 | { |
| 814 | 814 | $args->sort_index = "list_order"; |
| 815 | 815 | $args->page = Context::get('page'); |
@@ -825,14 +825,14 @@ discard block |
||
| 825 | 825 | function getDeniedIDs() |
| 826 | 826 | { |
| 827 | 827 | $output = executeQueryArray('member.getDeniedIDs'); |
| 828 | - if(!$output->toBool()) return array(); |
|
| 828 | + if (!$output->toBool()) return array(); |
|
| 829 | 829 | return $output->data; |
| 830 | 830 | } |
| 831 | 831 | |
| 832 | 832 | function getDeniedNickNames() |
| 833 | 833 | { |
| 834 | 834 | $output = executeQueryArray('member.getDeniedNickNames'); |
| 835 | - if(!$output->toBool()) |
|
| 835 | + if (!$output->toBool()) |
|
| 836 | 836 | { |
| 837 | 837 | return array(); |
| 838 | 838 | } |
@@ -848,7 +848,7 @@ discard block |
||
| 848 | 848 | $args = new stdClass(); |
| 849 | 849 | $args->user_id = $user_id; |
| 850 | 850 | $output = executeQuery('member.chkDeniedID', $args); |
| 851 | - if($output->data->count) return true; |
|
| 851 | + if ($output->data->count) return true; |
|
| 852 | 852 | return false; |
| 853 | 853 | } |
| 854 | 854 | |
@@ -860,8 +860,8 @@ discard block |
||
| 860 | 860 | $args = new stdClass(); |
| 861 | 861 | $args->nick_name = $nickName; |
| 862 | 862 | $output = executeQuery('member.chkDeniedNickName', $args); |
| 863 | - if($output->data->count) return true; |
|
| 864 | - if(!$output->toBool()) |
|
| 863 | + if ($output->data->count) return true; |
|
| 864 | + if (!$output->toBool()) |
|
| 865 | 865 | { |
| 866 | 866 | return true; |
| 867 | 867 | } |
@@ -872,20 +872,20 @@ discard block |
||
| 872 | 872 | */ |
| 873 | 873 | function getProfileImage($member_srl) |
| 874 | 874 | { |
| 875 | - if(!isset($GLOBALS['__member_info__']['profile_image'][$member_srl])) |
|
| 875 | + if (!isset($GLOBALS['__member_info__']['profile_image'][$member_srl])) |
|
| 876 | 876 | { |
| 877 | 877 | $GLOBALS['__member_info__']['profile_image'][$member_srl] = null; |
| 878 | - $exts = array('gif','jpg','png'); |
|
| 879 | - for($i=0;$i<3;$i++) |
|
| 878 | + $exts = array('gif', 'jpg', 'png'); |
|
| 879 | + for ($i = 0; $i < 3; $i++) |
|
| 880 | 880 | { |
| 881 | 881 | $image_name_file = sprintf('files/member_extra_info/profile_image/%s%d.%s', getNumberingPath($member_srl), $member_srl, $exts[$i]); |
| 882 | - if(file_exists($image_name_file)) |
|
| 882 | + if (file_exists($image_name_file)) |
|
| 883 | 883 | { |
| 884 | 884 | list($width, $height, $type, $attrs) = getimagesize($image_name_file); |
| 885 | 885 | $info = new stdClass(); |
| 886 | 886 | $info->width = $width; |
| 887 | 887 | $info->height = $height; |
| 888 | - $info->src = Context::getRequestUri().$image_name_file . '?' . date('YmdHis', filemtime($image_name_file)); |
|
| 888 | + $info->src = Context::getRequestUri().$image_name_file.'?'.date('YmdHis', filemtime($image_name_file)); |
|
| 889 | 889 | $info->file = './'.$image_name_file; |
| 890 | 890 | $GLOBALS['__member_info__']['profile_image'][$member_srl] = $info; |
| 891 | 891 | break; |
@@ -901,16 +901,16 @@ discard block |
||
| 901 | 901 | */ |
| 902 | 902 | function getImageName($member_srl) |
| 903 | 903 | { |
| 904 | - if(!isset($GLOBALS['__member_info__']['image_name'][$member_srl])) |
|
| 904 | + if (!isset($GLOBALS['__member_info__']['image_name'][$member_srl])) |
|
| 905 | 905 | { |
| 906 | 906 | $image_name_file = sprintf('files/member_extra_info/image_name/%s%d.gif', getNumberingPath($member_srl), $member_srl); |
| 907 | - if(file_exists($image_name_file)) |
|
| 907 | + if (file_exists($image_name_file)) |
|
| 908 | 908 | { |
| 909 | 909 | list($width, $height, $type, $attrs) = getimagesize($image_name_file); |
| 910 | 910 | $info = new stdClass; |
| 911 | 911 | $info->width = $width; |
| 912 | 912 | $info->height = $height; |
| 913 | - $info->src = Context::getRequestUri().$image_name_file. '?' . date('YmdHis', filemtime($image_name_file)); |
|
| 913 | + $info->src = Context::getRequestUri().$image_name_file.'?'.date('YmdHis', filemtime($image_name_file)); |
|
| 914 | 914 | $info->file = './'.$image_name_file; |
| 915 | 915 | $GLOBALS['__member_info__']['image_name'][$member_srl] = $info; |
| 916 | 916 | } |
@@ -924,15 +924,15 @@ discard block |
||
| 924 | 924 | */ |
| 925 | 925 | function getImageMark($member_srl) |
| 926 | 926 | { |
| 927 | - if(!isset($GLOBALS['__member_info__']['image_mark'][$member_srl])) |
|
| 927 | + if (!isset($GLOBALS['__member_info__']['image_mark'][$member_srl])) |
|
| 928 | 928 | { |
| 929 | 929 | $image_mark_file = sprintf('files/member_extra_info/image_mark/%s%d.gif', getNumberingPath($member_srl), $member_srl); |
| 930 | - if(file_exists($image_mark_file)) |
|
| 930 | + if (file_exists($image_mark_file)) |
|
| 931 | 931 | { |
| 932 | 932 | list($width, $height, $type, $attrs) = getimagesize($image_mark_file); |
| 933 | 933 | $info->width = $width; |
| 934 | 934 | $info->height = $height; |
| 935 | - $info->src = Context::getRequestUri().$image_mark_file . '?' . date('YmdHis', filemtime($image_mark_file)); |
|
| 935 | + $info->src = Context::getRequestUri().$image_mark_file.'?'.date('YmdHis', filemtime($image_mark_file)); |
|
| 936 | 936 | $info->file = './'.$image_mark_file; |
| 937 | 937 | $GLOBALS['__member_info__']['image_mark'][$member_srl] = $info; |
| 938 | 938 | } |
@@ -946,27 +946,27 @@ discard block |
||
| 946 | 946 | /** |
| 947 | 947 | * @brief Get the image mark of the group |
| 948 | 948 | */ |
| 949 | - function getGroupImageMark($member_srl,$site_srl=0) |
|
| 949 | + function getGroupImageMark($member_srl, $site_srl = 0) |
|
| 950 | 950 | { |
| 951 | - if(!isset($GLOBALS['__member_info__']['group_image_mark'][$member_srl])) |
|
| 951 | + if (!isset($GLOBALS['__member_info__']['group_image_mark'][$member_srl])) |
|
| 952 | 952 | { |
| 953 | 953 | $oModuleModel = getModel('module'); |
| 954 | 954 | $config = $oModuleModel->getModuleConfig('member'); |
| 955 | - if($config->group_image_mark!='Y') |
|
| 955 | + if ($config->group_image_mark != 'Y') |
|
| 956 | 956 | { |
| 957 | 957 | return null; |
| 958 | 958 | } |
| 959 | - $member_group = $this->getMemberGroups($member_srl,$site_srl); |
|
| 959 | + $member_group = $this->getMemberGroups($member_srl, $site_srl); |
|
| 960 | 960 | $groups_info = $this->getGroups($site_srl); |
| 961 | - if(count($member_group) > 0 && is_array($member_group)) |
|
| 961 | + if (count($member_group) > 0 && is_array($member_group)) |
|
| 962 | 962 | { |
| 963 | 963 | $memberGroups = array_keys($member_group); |
| 964 | 964 | |
| 965 | - foreach($groups_info as $group_srl=>$group_info) |
|
| 965 | + foreach ($groups_info as $group_srl=>$group_info) |
|
| 966 | 966 | { |
| 967 | - if(in_array($group_srl, $memberGroups)) |
|
| 967 | + if (in_array($group_srl, $memberGroups)) |
|
| 968 | 968 | { |
| 969 | - if($group_info->image_mark) |
|
| 969 | + if ($group_info->image_mark) |
|
| 970 | 970 | { |
| 971 | 971 | $info = new stdClass(); |
| 972 | 972 | $info->title = $group_info->title; |
@@ -990,10 +990,10 @@ discard block |
||
| 990 | 990 | */ |
| 991 | 991 | function getSignature($member_srl) |
| 992 | 992 | { |
| 993 | - if(!isset($GLOBALS['__member_info__']['signature'][$member_srl])) |
|
| 993 | + if (!isset($GLOBALS['__member_info__']['signature'][$member_srl])) |
|
| 994 | 994 | { |
| 995 | 995 | $filename = sprintf('files/member_extra_info/signature/%s%d.signature.php', getNumberingPath($member_srl), $member_srl); |
| 996 | - if(file_exists($filename)) |
|
| 996 | + if (file_exists($filename)) |
|
| 997 | 997 | { |
| 998 | 998 | $buff = FileHandler::readFile($filename); |
| 999 | 999 | $signature = preg_replace('/<\?.*\?>/', '', $buff); |
@@ -1011,10 +1011,10 @@ discard block |
||
| 1011 | 1011 | * @param int $member_srl Set this to member_srl when comparing a member's password (optional) |
| 1012 | 1012 | * @return bool |
| 1013 | 1013 | */ |
| 1014 | - function isValidPassword($hashed_password, $password_text, $member_srl=null) |
|
| 1014 | + function isValidPassword($hashed_password, $password_text, $member_srl = null) |
|
| 1015 | 1015 | { |
| 1016 | 1016 | // False if no password in entered |
| 1017 | - if(!$password_text) |
|
| 1017 | + if (!$password_text) |
|
| 1018 | 1018 | { |
| 1019 | 1019 | return false; |
| 1020 | 1020 | } |
@@ -1023,31 +1023,31 @@ discard block |
||
| 1023 | 1023 | $oPassword = new Password(); |
| 1024 | 1024 | $current_algorithm = $oPassword->checkAlgorithm($hashed_password); |
| 1025 | 1025 | $match = $oPassword->checkPassword($password_text, $hashed_password, $current_algorithm); |
| 1026 | - if(!$match) |
|
| 1026 | + if (!$match) |
|
| 1027 | 1027 | { |
| 1028 | 1028 | return false; |
| 1029 | 1029 | } |
| 1030 | 1030 | |
| 1031 | 1031 | // Update the encryption method if necessary |
| 1032 | 1032 | $config = $this->getMemberConfig(); |
| 1033 | - if($member_srl > 0 && $config->password_hashing_auto_upgrade != 'N') |
|
| 1033 | + if ($member_srl > 0 && $config->password_hashing_auto_upgrade != 'N') |
|
| 1034 | 1034 | { |
| 1035 | 1035 | $need_upgrade = false; |
| 1036 | 1036 | |
| 1037 | - if(!$need_upgrade) |
|
| 1037 | + if (!$need_upgrade) |
|
| 1038 | 1038 | { |
| 1039 | 1039 | $required_algorithm = $oPassword->getCurrentlySelectedAlgorithm(); |
| 1040 | - if($required_algorithm !== $current_algorithm) $need_upgrade = true; |
|
| 1040 | + if ($required_algorithm !== $current_algorithm) $need_upgrade = true; |
|
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | - if(!$need_upgrade) |
|
| 1043 | + if (!$need_upgrade) |
|
| 1044 | 1044 | { |
| 1045 | 1045 | $required_work_factor = $oPassword->getWorkFactor(); |
| 1046 | 1046 | $current_work_factor = $oPassword->checkWorkFactor($hashed_password); |
| 1047 | - if($current_work_factor !== false && $required_work_factor > $current_work_factor) $need_upgrade = true; |
|
| 1047 | + if ($current_work_factor !== false && $required_work_factor > $current_work_factor) $need_upgrade = true; |
|
| 1048 | 1048 | } |
| 1049 | 1049 | |
| 1050 | - if($need_upgrade === true) |
|
| 1050 | + if ($need_upgrade === true) |
|
| 1051 | 1051 | { |
| 1052 | 1052 | $args = new stdClass(); |
| 1053 | 1053 | $args->member_srl = $member_srl; |
@@ -1075,27 +1075,27 @@ discard block |
||
| 1075 | 1075 | function checkPasswordStrength($password, $strength) |
| 1076 | 1076 | { |
| 1077 | 1077 | $logged_info = Context::get('logged_info'); |
| 1078 | - if($logged_info->is_admin == 'Y') return true; |
|
| 1078 | + if ($logged_info->is_admin == 'Y') return true; |
|
| 1079 | 1079 | |
| 1080 | - if($strength == NULL) |
|
| 1080 | + if ($strength == NULL) |
|
| 1081 | 1081 | { |
| 1082 | 1082 | $config = $this->getMemberConfig(); |
| 1083 | - $strength = $config->password_strength?$config->password_strength:'normal'; |
|
| 1083 | + $strength = $config->password_strength ? $config->password_strength : 'normal'; |
|
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | 1086 | $length = strlen($password); |
| 1087 | 1087 | |
| 1088 | 1088 | switch ($strength) { |
| 1089 | 1089 | case 'high': |
| 1090 | - if($length < 8 || !preg_match('/[^a-zA-Z0-9]/', $password)) return false; |
|
| 1090 | + if ($length < 8 || !preg_match('/[^a-zA-Z0-9]/', $password)) return false; |
|
| 1091 | 1091 | /* no break */ |
| 1092 | 1092 | |
| 1093 | 1093 | case 'normal': |
| 1094 | - if($length < 6 || !preg_match('/[a-zA-Z]/', $password) || !preg_match('/[0-9]/', $password)) return false; |
|
| 1094 | + if ($length < 6 || !preg_match('/[a-zA-Z]/', $password) || !preg_match('/[0-9]/', $password)) return false; |
|
| 1095 | 1095 | break; |
| 1096 | 1096 | |
| 1097 | 1097 | case 'low': |
| 1098 | - if($length < 4) return false; |
|
| 1098 | + if ($length < 4) return false; |
|
| 1099 | 1099 | break; |
| 1100 | 1100 | } |
| 1101 | 1101 | |
@@ -1106,11 +1106,11 @@ discard block |
||
| 1106 | 1106 | { |
| 1107 | 1107 | $groupSrl = 0; |
| 1108 | 1108 | $output = $this->getGroups($site_srl); |
| 1109 | - if(is_array($output)) |
|
| 1109 | + if (is_array($output)) |
|
| 1110 | 1110 | { |
| 1111 | - foreach($output AS $key=>$value) |
|
| 1111 | + foreach ($output AS $key=>$value) |
|
| 1112 | 1112 | { |
| 1113 | - if($value->is_admin == 'Y') |
|
| 1113 | + if ($value->is_admin == 'Y') |
|
| 1114 | 1114 | { |
| 1115 | 1115 | $groupSrl = $value->group_srl; |
| 1116 | 1116 | break; |
@@ -8,12 +8,12 @@ discard block |
||
| 8 | 8 | { |
| 9 | 9 | // If member_srl < 0, then return text only in the body |
| 10 | 10 | $member_srl = $matches[3]; |
| 11 | - if($member_srl < 0) |
|
| 11 | + if ($member_srl < 0) |
|
| 12 | 12 | { |
| 13 | 13 | return $matches[5]; |
| 14 | 14 | } |
| 15 | 15 | // If member_srl=o(not a member), return the entire body |
| 16 | - if(!$member_srl) |
|
| 16 | + if (!$member_srl) |
|
| 17 | 17 | { |
| 18 | 18 | return $matches[0]; |
| 19 | 19 | } |
@@ -22,22 +22,22 @@ discard block |
||
| 22 | 22 | $nick_name = $matches[5]; |
| 23 | 23 | |
| 24 | 24 | // Initialize global variable for cache |
| 25 | - if(!isset($GLOBALS['_transImageNameList'][$member_srl])) |
|
| 25 | + if (!isset($GLOBALS['_transImageNameList'][$member_srl])) |
|
| 26 | 26 | { |
| 27 | 27 | $GLOBALS['_transImageNameList'][$member_srl] = new stdClass(); |
| 28 | 28 | } |
| 29 | 29 | $_tmp = &$GLOBALS['_transImageNameList'][$member_srl]; |
| 30 | 30 | |
| 31 | 31 | // If pre-defined data in the global variables, return it |
| 32 | - if(!$_tmp->cached) |
|
| 32 | + if (!$_tmp->cached) |
|
| 33 | 33 | { |
| 34 | 34 | $_tmp->cached = true; |
| 35 | 35 | $image_name_file = sprintf('files/member_extra_info/image_name/%s%d.gif', getNumberingPath($member_srl), $member_srl); |
| 36 | 36 | $image_mark_file = sprintf('files/member_extra_info/image_mark/%s%d.gif', getNumberingPath($member_srl), $member_srl); |
| 37 | 37 | |
| 38 | - if(file_exists(_XE_PATH_ . $image_name_file)) |
|
| 38 | + if (file_exists(_XE_PATH_.$image_name_file)) |
|
| 39 | 39 | { |
| 40 | - $_tmp->image_name_file = $image_name_file . '?' . date('YmdHis', filemtime(_XE_PATH_ . $image_name_file)); |
|
| 40 | + $_tmp->image_name_file = $image_name_file.'?'.date('YmdHis', filemtime(_XE_PATH_.$image_name_file)); |
|
| 41 | 41 | $image_name_file = $_tmp->image_name_file; |
| 42 | 42 | } |
| 43 | 43 | else |
@@ -45,9 +45,9 @@ discard block |
||
| 45 | 45 | $image_name_file = ''; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if(file_exists(_XE_PATH_ . $image_mark_file)) |
|
| 48 | + if (file_exists(_XE_PATH_.$image_mark_file)) |
|
| 49 | 49 | { |
| 50 | - $_tmp->image_mark_file = $image_mark_file . '?' . date('YmdHis', filemtime(_XE_PATH_ . $image_mark_file)); |
|
| 50 | + $_tmp->image_mark_file = $image_mark_file.'?'.date('YmdHis', filemtime(_XE_PATH_.$image_mark_file)); |
|
| 51 | 51 | $image_mark_file = $_tmp->image_mark_file; |
| 52 | 52 | } |
| 53 | 53 | else |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // If image name and mark doesn't exist, set the original information |
| 70 | - if(!$image_name_file && !$image_mark_file && !$group_image) |
|
| 70 | + if (!$image_name_file && !$image_mark_file && !$group_image) |
|
| 71 | 71 | { |
| 72 | 72 | return $matches[0]; |
| 73 | 73 | } |
@@ -76,21 +76,21 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | $config = $oMemberModel->getMemberConfig(); |
| 78 | 78 | |
| 79 | - if($config->image_name == 'Y' && $image_name_file) |
|
| 79 | + if ($config->image_name == 'Y' && $image_name_file) |
|
| 80 | 80 | { |
| 81 | 81 | $nick_name = sprintf('<img src="%s%s" alt="id: %s" title="id: %s" style="border:0;vertical-align:middle;margin-right:3px" />', Context::getRequestUri(), $image_name_file, strip_tags($nick_name), strip_tags($nick_name)); |
| 82 | 82 | } |
| 83 | - if($config->image_mark == 'Y' && $image_mark_file) |
|
| 83 | + if ($config->image_mark == 'Y' && $image_mark_file) |
|
| 84 | 84 | { |
| 85 | 85 | $nick_name = sprintf('<img src="%s%s" alt="id: %s" title="id : %s" style="border:0;vertical-align:middle;margin-right:3px"/>%s', Context::getRequestUri(), $image_mark_file, strip_tags($nick_name), strip_tags($nick_name), $nick_name); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if($group_image) |
|
| 88 | + if ($group_image) |
|
| 89 | 89 | { |
| 90 | 90 | $nick_name = sprintf('<img src="%s" style="border:0;max-height:16px;vertical-align:middle;margin-right:3px" alt="%s" title="%s" />%s', $group_image->src, $group_image->title, $group_image->description, $nick_name); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - return preg_replace('/' . preg_quote($matches[5], '/') . '<\/' . $matches[6] . '>$/', '', $matches[0]) . $nick_name . '</' . $matches[6] . '>'; |
|
| 93 | + return preg_replace('/'.preg_quote($matches[5], '/').'<\/'.$matches[6].'>$/', '', $matches[0]).$nick_name.'</'.$matches[6].'>'; |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | /* End of file member_extra_info.lib.php */ |