@@ -136,7 +136,7 @@ |
||
136 | 136 | $dbq->setWhereArray(static::translateNames($propertyFilter, static::PROPERTIES_TO_FIELDS)); |
137 | 137 | } |
138 | 138 | |
139 | - if(static::$_forUpdate == DbQuery::DB_FOR_UPDATE) { |
|
139 | + if (static::$_forUpdate == DbQuery::DB_FOR_UPDATE) { |
|
140 | 140 | $dbq->setForUpdate(); |
141 | 141 | static::$_forUpdate = DbQuery::DB_SHARED; |
142 | 142 | } |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | - * Load template source from file |
|
59 | - * @access private |
|
60 | - */ |
|
58 | + * Load template source from file |
|
59 | + * @access private |
|
60 | + */ |
|
61 | 61 | function _tpl_load_file($handle, $store_in_db = false) |
62 | 62 | { |
63 | 63 | // Try and open template for read |
@@ -100,10 +100,10 @@ discard block |
||
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
103 | - * Remove any PHP tags that do not belong, these regular expressions are derived from |
|
104 | - * the ones that exist in zend_language_scanner.l |
|
105 | - * @access private |
|
106 | - */ |
|
103 | + * Remove any PHP tags that do not belong, these regular expressions are derived from |
|
104 | + * the ones that exist in zend_language_scanner.l |
|
105 | + * @access private |
|
106 | + */ |
|
107 | 107 | function remove_php_tags(&$code) |
108 | 108 | { |
109 | 109 | // This matches the information gathered from the internal PHP lexer |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
120 | - * The all seeing all doing compile method. Parts are inspired by or directly from Smarty |
|
121 | - * @access private |
|
122 | - */ |
|
120 | + * The all seeing all doing compile method. Parts are inspired by or directly from Smarty |
|
121 | + * @access private |
|
122 | + */ |
|
123 | 123 | function compile($code, $no_echo = false, $echo_var = '') |
124 | 124 | { |
125 | 125 | global $config; |
@@ -290,9 +290,9 @@ discard block |
||
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
293 | - * Compile variables |
|
294 | - * @access private |
|
295 | - */ |
|
293 | + * Compile variables |
|
294 | + * @access private |
|
295 | + */ |
|
296 | 296 | function compile_var_tags(&$text_blocks) |
297 | 297 | { |
298 | 298 | // including $lang variable |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | } |
366 | 366 | |
367 | 367 | /** |
368 | - * Compile blocks |
|
369 | - * @access private |
|
370 | - */ |
|
368 | + * Compile blocks |
|
369 | + * @access private |
|
370 | + */ |
|
371 | 371 | function compile_tag_block($tag_args) |
372 | 372 | { |
373 | 373 | $no_nesting = false; |
@@ -453,14 +453,14 @@ discard block |
||
453 | 453 | $tag_template_php .= 'if ($_' . $tag_args . '_count) {'; |
454 | 454 | |
455 | 455 | /** |
456 | - * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory |
|
457 | - * <code> |
|
458 | - * if (!$offset) |
|
459 | - * { |
|
460 | - * $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){'; |
|
461 | - * } |
|
462 | - * </code> |
|
463 | - */ |
|
456 | + * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory |
|
457 | + * <code> |
|
458 | + * if (!$offset) |
|
459 | + * { |
|
460 | + * $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){'; |
|
461 | + * } |
|
462 | + * </code> |
|
463 | + */ |
|
464 | 464 | |
465 | 465 | $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){'; |
466 | 466 | // $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;'; |
@@ -471,10 +471,10 @@ discard block |
||
471 | 471 | } |
472 | 472 | |
473 | 473 | /** |
474 | - * Compile IF tags - much of this is from Smarty with |
|
475 | - * some adaptions for our block level methods |
|
476 | - * @access private |
|
477 | - */ |
|
474 | + * Compile IF tags - much of this is from Smarty with |
|
475 | + * some adaptions for our block level methods |
|
476 | + * @access private |
|
477 | + */ |
|
478 | 478 | function compile_tag_if($tag_args, $elseif) |
479 | 479 | { |
480 | 480 | // Tokenize args for 'if' tag. |
@@ -629,9 +629,9 @@ discard block |
||
629 | 629 | } |
630 | 630 | |
631 | 631 | /** |
632 | - * Compile DEFINE tags |
|
633 | - * @access private |
|
634 | - */ |
|
632 | + * Compile DEFINE tags |
|
633 | + * @access private |
|
634 | + */ |
|
635 | 635 | function compile_tag_define($tag_args, $op) |
636 | 636 | { |
637 | 637 | preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match); |
@@ -682,9 +682,9 @@ discard block |
||
682 | 682 | } |
683 | 683 | |
684 | 684 | /** |
685 | - * Compile INCLUDE tag |
|
686 | - * @access private |
|
687 | - */ |
|
685 | + * Compile INCLUDE tag |
|
686 | + * @access private |
|
687 | + */ |
|
688 | 688 | function compile_tag_include($tag_args) |
689 | 689 | { |
690 | 690 | // Process dynamic includes |
@@ -697,19 +697,19 @@ discard block |
||
697 | 697 | } |
698 | 698 | |
699 | 699 | /** |
700 | - * Compile INCLUDE_PHP tag |
|
701 | - * @access private |
|
702 | - */ |
|
700 | + * Compile INCLUDE_PHP tag |
|
701 | + * @access private |
|
702 | + */ |
|
703 | 703 | function compile_tag_include_php($tag_args) |
704 | 704 | { |
705 | 705 | return "\$this->_php_include('$tag_args');"; |
706 | 706 | } |
707 | 707 | |
708 | 708 | /** |
709 | - * parse expression |
|
710 | - * This is from Smarty |
|
711 | - * @access private |
|
712 | - */ |
|
709 | + * parse expression |
|
710 | + * This is from Smarty |
|
711 | + * @access private |
|
712 | + */ |
|
713 | 713 | function _parse_is_expr($is_arg, $tokens) |
714 | 714 | { |
715 | 715 | $expr_end = 0; |
@@ -802,14 +802,14 @@ discard block |
||
802 | 802 | } |
803 | 803 | |
804 | 804 | /** |
805 | - * Generates a reference to the array of data values for the given |
|
806 | - * (possibly nested) block namespace. This is a string of the form: |
|
807 | - * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] |
|
808 | - * |
|
809 | - * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. |
|
810 | - * NOTE: does not expect a trailing "." on the blockname. |
|
811 | - * @access private |
|
812 | - */ |
|
805 | + * Generates a reference to the array of data values for the given |
|
806 | + * (possibly nested) block namespace. This is a string of the form: |
|
807 | + * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] |
|
808 | + * |
|
809 | + * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. |
|
810 | + * NOTE: does not expect a trailing "." on the blockname. |
|
811 | + * @access private |
|
812 | + */ |
|
813 | 813 | function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) |
814 | 814 | { |
815 | 815 | // Get an array of the blocks involved. |
@@ -845,9 +845,9 @@ discard block |
||
845 | 845 | } |
846 | 846 | |
847 | 847 | /** |
848 | - * Write compiled file to cache directory |
|
849 | - * @access private |
|
850 | - */ |
|
848 | + * Write compiled file to cache directory |
|
849 | + * @access private |
|
850 | + */ |
|
851 | 851 | function compile_write($handle, $data) |
852 | 852 | { |
853 | 853 | $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX; |
@@ -870,9 +870,9 @@ discard block |
||
870 | 870 | |
871 | 871 | // Gorlum's minifier BOF |
872 | 872 | /** |
873 | - * Minifies template w/i PHP code by removing extra spaces |
|
874 | - * @access private |
|
875 | - */ |
|
873 | + * Minifies template w/i PHP code by removing extra spaces |
|
874 | + * @access private |
|
875 | + */ |
|
876 | 876 | function minify($html) |
877 | 877 | { |
878 | 878 | global $config; |
@@ -143,9 +143,9 @@ discard block |
||
143 | 143 | |
144 | 144 | preg_match_all('#<!-- INCLUDE (\{\$?[A-Z0-9\-_]+\}|[a-zA-Z0-9\_\-\+\./]+) -->#', $code, $matches); |
145 | 145 | $include_blocks = $matches[1]; |
146 | - if($include_blocks) |
|
146 | + if ($include_blocks) |
|
147 | 147 | { |
148 | - foreach($include_blocks as &$included_file) |
|
148 | + foreach ($include_blocks as &$included_file) |
|
149 | 149 | { |
150 | 150 | $included_file .= '.tpl.html'; |
151 | 151 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $varname = $var_val[3]; |
311 | 311 | $new = $this->generate_block_varref($namespace, $varname, $var_val[2]); |
312 | 312 | |
313 | - if(!empty($var_val[4])) { |
|
313 | + if (!empty($var_val[4])) { |
|
314 | 314 | $new = \Ptl\PtlVariableDecorator::decorate($var_val[0], $new, $this->template); |
315 | 315 | } |
316 | 316 | |
@@ -464,8 +464,8 @@ discard block |
||
464 | 464 | |
465 | 465 | $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){'; |
466 | 466 | // $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;'; |
467 | - $tag_template_php .= '$_'. $tag_args . '_val = &' . $varref . '[$_'. $tag_args. '_i];'; |
|
468 | - $tag_template_php .= '$this->_block_value["'. $tag_args . '"] = &' . $varref . '[$_'. $tag_args. '_i];'; |
|
467 | + $tag_template_php .= '$_' . $tag_args . '_val = &' . $varref . '[$_' . $tag_args . '_i];'; |
|
468 | + $tag_template_php .= '$this->_block_value["' . $tag_args . '"] = &' . $varref . '[$_' . $tag_args . '_i];'; |
|
469 | 469 | |
470 | 470 | return $tag_template_php; |
471 | 471 | } |
@@ -569,10 +569,10 @@ discard block |
||
569 | 569 | break; |
570 | 570 | |
571 | 571 | case 'is': |
572 | - $is_arg_start = ($tokens[$i-1] == ')') ? array_pop($is_arg_stack) : $i-1; |
|
572 | + $is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1; |
|
573 | 573 | $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start)); |
574 | 574 | |
575 | - $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1)); |
|
575 | + $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1)); |
|
576 | 576 | |
577 | 577 | array_splice($tokens, $is_arg_start, sizeof($tokens), $new_tokens); |
578 | 578 | |
@@ -836,11 +836,11 @@ discard block |
||
836 | 836 | } |
837 | 837 | else if ($include_last_iterator) |
838 | 838 | { |
839 | - return '$_'. $blocks[$blockcount] . '_val'; |
|
839 | + return '$_' . $blocks[$blockcount] . '_val'; |
|
840 | 840 | } |
841 | 841 | else |
842 | 842 | { |
843 | - return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']'; |
|
843 | + return '$_' . $blocks[$blockcount - 1] . '_val[\'' . $blocks[$blockcount] . '\']'; |
|
844 | 844 | } |
845 | 845 | } |
846 | 846 | |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | if ($fp = @fopen($filename, 'wb')) |
858 | 858 | { |
859 | 859 | @flock($fp, LOCK_EX); |
860 | - @fwrite ($fp, $data); |
|
860 | + @fwrite($fp, $data); |
|
861 | 861 | @flock($fp, LOCK_UN); |
862 | 862 | @fclose($fp); |
863 | 863 | |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | { |
878 | 878 | global $config; |
879 | 879 | |
880 | - if(!$config->tpl_minifier) |
|
880 | + if (!$config->tpl_minifier) |
|
881 | 881 | { |
882 | 882 | return $html; |
883 | 883 | } |
@@ -889,14 +889,14 @@ discard block |
||
889 | 889 | //$html = preg_replace('/[\r\n\t]+/', ' ', $html); |
890 | 890 | $html = preg_replace('/>[\s]*</', '><', $html); // Strip spacechars between tags |
891 | 891 | $html = preg_replace('/[\s]+/', ' ', $html); // Replace several spacechars with one space |
892 | - if(!empty($pre[0])) |
|
892 | + if (!empty($pre[0])) |
|
893 | 893 | { |
894 | - foreach($pre[0] as $tag) |
|
894 | + foreach ($pre[0] as $tag) |
|
895 | 895 | { |
896 | 896 | $tag = preg_replace('/^\ *\/\/[^\<]*?$/m', ' ', $tag); // Strips comments - except those that contains HTML comment inside |
897 | 897 | $tag = preg_replace('/[\ \t]{2,}/', ' ', $tag); // Replace several spaces by one |
898 | 898 | $tag = preg_replace('/\s{2,}/', "\r\n", $tag); // Replace several linefeeds by one |
899 | - $html = preg_replace('/#pre#/', $tag, $html,1); |
|
899 | + $html = preg_replace('/#pre#/', $tag, $html, 1); |
|
900 | 900 | } |
901 | 901 | } |
902 | 902 |
@@ -37,8 +37,7 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @package phpBB3 |
39 | 39 | */ |
40 | -class template_compile |
|
41 | -{ |
|
40 | +class template_compile { |
|
42 | 41 | var $template; |
43 | 42 | |
44 | 43 | // Various storage arrays |
@@ -58,8 +57,7 @@ discard block |
||
58 | 57 | * Load template source from file |
59 | 58 | * @access private |
60 | 59 | */ |
61 | - function _tpl_load_file($handle, $store_in_db = false) |
|
62 | - { |
|
60 | + function _tpl_load_file($handle, $store_in_db = false) { |
|
63 | 61 | // Try and open template for read |
64 | 62 | if (!file_exists($this->template->files[$handle])) |
65 | 63 | { |
@@ -67,8 +65,7 @@ discard block |
||
67 | 65 | { |
68 | 66 | return; |
69 | 67 | trigger_error("template->_tpl_load_file(): File {$this->template->files[$handle]} does not exist or is empty", E_USER_ERROR); |
70 | - } |
|
71 | - else |
|
68 | + } else |
|
72 | 69 | { |
73 | 70 | $this->template->files[$handle] = $this->template->files_inherit[$handle]; |
74 | 71 | } |
@@ -104,8 +101,7 @@ discard block |
||
104 | 101 | * the ones that exist in zend_language_scanner.l |
105 | 102 | * @access private |
106 | 103 | */ |
107 | - function remove_php_tags(&$code) |
|
108 | - { |
|
104 | + function remove_php_tags(&$code) { |
|
109 | 105 | // This matches the information gathered from the internal PHP lexer |
110 | 106 | $match = array( |
111 | 107 | '#<([\?%])=?.*?\1>#s', |
@@ -120,8 +116,7 @@ discard block |
||
120 | 116 | * The all seeing all doing compile method. Parts are inspired by or directly from Smarty |
121 | 117 | * @access private |
122 | 118 | */ |
123 | - function compile($code, $no_echo = false, $echo_var = '') |
|
124 | - { |
|
119 | + function compile($code, $no_echo = false, $echo_var = '') { |
|
125 | 120 | global $config; |
126 | 121 | |
127 | 122 | if ($echo_var) |
@@ -226,15 +221,13 @@ discard block |
||
226 | 221 | $var = substr($temp, 2, -1); |
227 | 222 | //$file = $this->template->_tpldata['DEFINE']['.'][$var]; |
228 | 223 | $temp = "\$this->_tpldata['DEFINE']['.']['$var']"; |
229 | - } |
|
230 | - else |
|
224 | + } else |
|
231 | 225 | { |
232 | 226 | $var = substr($temp, 1, -1); |
233 | 227 | //$file = $this->template->_rootref[$var]; |
234 | 228 | $temp = "\$this->_rootref['$var']"; |
235 | 229 | } |
236 | - } |
|
237 | - else |
|
230 | + } else |
|
238 | 231 | { |
239 | 232 | $file = $temp; |
240 | 233 | } |
@@ -293,8 +286,7 @@ discard block |
||
293 | 286 | * Compile variables |
294 | 287 | * @access private |
295 | 288 | */ |
296 | - function compile_var_tags(&$text_blocks) |
|
297 | - { |
|
289 | + function compile_var_tags(&$text_blocks) { |
|
298 | 290 | // including $lang variable |
299 | 291 | global $lang, $config; |
300 | 292 | |
@@ -368,8 +360,7 @@ discard block |
||
368 | 360 | * Compile blocks |
369 | 361 | * @access private |
370 | 362 | */ |
371 | - function compile_tag_block($tag_args) |
|
372 | - { |
|
363 | + function compile_tag_block($tag_args) { |
|
373 | 364 | $no_nesting = false; |
374 | 365 | |
375 | 366 | // Is the designer wanting to call another loop in a loop? |
@@ -392,8 +383,7 @@ discard block |
||
392 | 383 | if ($match[2] < 0) |
393 | 384 | { |
394 | 385 | $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')'; |
395 | - } |
|
396 | - else |
|
386 | + } else |
|
397 | 387 | { |
398 | 388 | $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')'; |
399 | 389 | } |
@@ -401,17 +391,14 @@ discard block |
||
401 | 391 | if (strlen($match[3]) < 1 || $match[3] == -1) |
402 | 392 | { |
403 | 393 | $loop_end = '$_' . $tag_args . '_count'; |
404 | - } |
|
405 | - else if ($match[3] >= 0) |
|
394 | + } else if ($match[3] >= 0) |
|
406 | 395 | { |
407 | 396 | $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')'; |
408 | - } |
|
409 | - else //if ($match[3] < -1) |
|
397 | + } else //if ($match[3] < -1) |
|
410 | 398 | { |
411 | 399 | $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1); |
412 | 400 | } |
413 | - } |
|
414 | - else |
|
401 | + } else |
|
415 | 402 | { |
416 | 403 | $loop_start = 0; |
417 | 404 | $loop_end = '$_' . $tag_args . '_count'; |
@@ -424,8 +411,7 @@ discard block |
||
424 | 411 | { |
425 | 412 | // We need to implode $no_nesting times from the end... |
426 | 413 | $block = array_slice($this->block_names, -$no_nesting); |
427 | - } |
|
428 | - else |
|
414 | + } else |
|
429 | 415 | { |
430 | 416 | $block = $this->block_names; |
431 | 417 | } |
@@ -435,8 +421,7 @@ discard block |
||
435 | 421 | // Block is not nested. |
436 | 422 | $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;"; |
437 | 423 | $varref = "\$this->_tpldata['$tag_args']"; |
438 | - } |
|
439 | - else |
|
424 | + } else |
|
440 | 425 | { |
441 | 426 | // This block is nested. |
442 | 427 | // Generate a namespace string for this block. |
@@ -475,8 +460,7 @@ discard block |
||
475 | 460 | * some adaptions for our block level methods |
476 | 461 | * @access private |
477 | 462 | */ |
478 | - function compile_tag_if($tag_args, $elseif) |
|
479 | - { |
|
463 | + function compile_tag_if($tag_args, $elseif) { |
|
480 | 464 | // Tokenize args for 'if' tag. |
481 | 465 | preg_match_all('/(?: |
482 | 466 | "[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | |
@@ -584,8 +568,7 @@ discard block |
||
584 | 568 | if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs)) |
585 | 569 | { |
586 | 570 | $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$this->_rootref[\'' . $varrefs[3] . '\']'); |
587 | - } |
|
588 | - else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
|
571 | + } else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
|
589 | 572 | { |
590 | 573 | // Allow checking if loops are set with .loopname |
591 | 574 | // It is also possible to check the loop count by doing <!-- IF .loopname > 1 --> for example |
@@ -601,8 +584,7 @@ discard block |
||
601 | 584 | |
602 | 585 | // Add the block reference for the last child. |
603 | 586 | $varref .= "['" . $block . "']"; |
604 | - } |
|
605 | - else |
|
587 | + } else |
|
606 | 588 | { |
607 | 589 | $varref = '$this->_tpldata'; |
608 | 590 | |
@@ -610,8 +592,7 @@ discard block |
||
610 | 592 | $varref .= "['" . $blocks[0] . "']"; |
611 | 593 | } |
612 | 594 | $token = "sizeof($varref)"; |
613 | - } |
|
614 | - else if (!empty($token)) |
|
595 | + } else if (!empty($token)) |
|
615 | 596 | { |
616 | 597 | $token = '(' . $token . ')'; |
617 | 598 | } |
@@ -632,8 +613,7 @@ discard block |
||
632 | 613 | * Compile DEFINE tags |
633 | 614 | * @access private |
634 | 615 | */ |
635 | - function compile_tag_define($tag_args, $op) |
|
636 | - { |
|
616 | + function compile_tag_define($tag_args, $op) { |
|
637 | 617 | preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match); |
638 | 618 | |
639 | 619 | if (empty($match[2]) || (!isset($match[4]) && $op)) |
@@ -656,8 +636,7 @@ discard block |
||
656 | 636 | |
657 | 637 | // Now replace the php code |
658 | 638 | $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'"; |
659 | - } |
|
660 | - else |
|
639 | + } else |
|
661 | 640 | { |
662 | 641 | preg_match('#true|false|\.#i', $match[4], $type); |
663 | 642 | |
@@ -685,8 +664,7 @@ discard block |
||
685 | 664 | * Compile INCLUDE tag |
686 | 665 | * @access private |
687 | 666 | */ |
688 | - function compile_tag_include($tag_args) |
|
689 | - { |
|
667 | + function compile_tag_include($tag_args) { |
|
690 | 668 | // Process dynamic includes |
691 | 669 | if ($tag_args[0] == '$') |
692 | 670 | { |
@@ -700,8 +678,7 @@ discard block |
||
700 | 678 | * Compile INCLUDE_PHP tag |
701 | 679 | * @access private |
702 | 680 | */ |
703 | - function compile_tag_include_php($tag_args) |
|
704 | - { |
|
681 | + function compile_tag_include_php($tag_args) { |
|
705 | 682 | return "\$this->_php_include('$tag_args');"; |
706 | 683 | } |
707 | 684 | |
@@ -710,8 +687,7 @@ discard block |
||
710 | 687 | * This is from Smarty |
711 | 688 | * @access private |
712 | 689 | */ |
713 | - function _parse_is_expr($is_arg, $tokens) |
|
714 | - { |
|
690 | + function _parse_is_expr($is_arg, $tokens) { |
|
715 | 691 | $expr_end = 0; |
716 | 692 | $negate_expr = false; |
717 | 693 | |
@@ -719,8 +695,7 @@ discard block |
||
719 | 695 | { |
720 | 696 | $negate_expr = true; |
721 | 697 | $expr_type = array_shift($tokens); |
722 | - } |
|
723 | - else |
|
698 | + } else |
|
724 | 699 | { |
725 | 700 | $expr_type = $first_token; |
726 | 701 | } |
@@ -733,8 +708,7 @@ discard block |
||
733 | 708 | $expr_end++; |
734 | 709 | $expr_arg = $tokens[$expr_end++]; |
735 | 710 | $expr = "!(($is_arg / $expr_arg) % $expr_arg)"; |
736 | - } |
|
737 | - else |
|
711 | + } else |
|
738 | 712 | { |
739 | 713 | $expr = "!($is_arg & 1)"; |
740 | 714 | } |
@@ -746,8 +720,7 @@ discard block |
||
746 | 720 | $expr_end++; |
747 | 721 | $expr_arg = $tokens[$expr_end++]; |
748 | 722 | $expr = "(($is_arg / $expr_arg) % $expr_arg)"; |
749 | - } |
|
750 | - else |
|
723 | + } else |
|
751 | 724 | { |
752 | 725 | $expr = "($is_arg & 1)"; |
753 | 726 | } |
@@ -786,8 +759,7 @@ discard block |
||
786 | 759 | * |
787 | 760 | * @return string |
788 | 761 | */ |
789 | - private function generate_block_varref($namespace, $varname, $defop = false) |
|
790 | - { |
|
762 | + private function generate_block_varref($namespace, $varname, $defop = false) { |
|
791 | 763 | // Strip the trailing period. |
792 | 764 | $namespace = substr($namespace, 0, -1); |
793 | 765 | |
@@ -810,8 +782,7 @@ discard block |
||
810 | 782 | * NOTE: does not expect a trailing "." on the blockname. |
811 | 783 | * @access private |
812 | 784 | */ |
813 | - function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) |
|
814 | - { |
|
785 | + function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) { |
|
815 | 786 | // Get an array of the blocks involved. |
816 | 787 | $blocks = explode('.', $blockname); |
817 | 788 | $blockcount = sizeof($blocks) - 1; |
@@ -833,12 +804,10 @@ discard block |
||
833 | 804 | $varref .= '[$_' . $blocks[$blockcount] . '_i]'; |
834 | 805 | } |
835 | 806 | return $varref; |
836 | - } |
|
837 | - else if ($include_last_iterator) |
|
807 | + } else if ($include_last_iterator) |
|
838 | 808 | { |
839 | 809 | return '$_'. $blocks[$blockcount] . '_val'; |
840 | - } |
|
841 | - else |
|
810 | + } else |
|
842 | 811 | { |
843 | 812 | return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']'; |
844 | 813 | } |
@@ -848,8 +817,7 @@ discard block |
||
848 | 817 | * Write compiled file to cache directory |
849 | 818 | * @access private |
850 | 819 | */ |
851 | - function compile_write($handle, $data) |
|
852 | - { |
|
820 | + function compile_write($handle, $data) { |
|
853 | 821 | $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX; |
854 | 822 | |
855 | 823 | $data = "<?php if (!defined('INSIDE')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data); |
@@ -873,8 +841,7 @@ discard block |
||
873 | 841 | * Minifies template w/i PHP code by removing extra spaces |
874 | 842 | * @access private |
875 | 843 | */ |
876 | - function minify($html) |
|
877 | - { |
|
844 | + function minify($html) { |
|
878 | 845 | global $config; |
879 | 846 | |
880 | 847 | if(!$config->tpl_minifier) |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } |
113 | 113 | |
114 | 114 | $payment_methods_available = array_combine(array_keys(sn_module_payment::$payment_methods), array_fill(0, count(sn_module_payment::$payment_methods), null)); |
115 | -array_walk($payment_methods_available, function (&$value, $index) { |
|
115 | +array_walk($payment_methods_available, function(&$value, $index) { |
|
116 | 116 | $value = !empty(sn_module_payment::$payment_methods[$index]) ? array_combine(array_keys(sn_module_payment::$payment_methods[$index]), array_fill(0, count(sn_module_payment::$payment_methods[$index]), null)) : $value; |
117 | 117 | }); |
118 | 118 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | 'PLAYER_CURRENCY' => $player_currency, |
301 | 301 | 'PLAYER_CURRENCY_PRICE_PER_MM' => sn_module_payment::currency_convert(1, $player_currency, 'MM_', 10), |
302 | 302 | |
303 | - 'UNIT_AMOUNT' => (float)$request['metamatter'], |
|
303 | + 'UNIT_AMOUNT' => (float) $request['metamatter'], |
|
304 | 304 | 'UNIT_AMOUNT_TEXT' => HelperString::numberFloorAndFormat($request['metamatter']), |
305 | 305 | 'UNIT_AMOUNT_BONUS_PERCENT' => $bonus_percent, |
306 | 306 | 'UNIT_AMOUNT_TEXT_DISCOUNTED' => $income_metamatter_text, |
@@ -165,8 +165,7 @@ discard block |
||
165 | 165 | $planet_info[PLANET_SYSTEM], |
166 | 166 | $planet_info[PLANET_PLANET], |
167 | 167 | htmlentities($planet_info[PLANET_NAME], ENT_COMPAT, 'UTF-8'), |
168 | - $lang[$outcome['UBE_COMBAT_RESULT'] == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : |
|
169 | - ($outcome['UBE_COMBAT_RESULT'] == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')] |
|
168 | + $lang[$outcome['UBE_COMBAT_RESULT'] == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : ($outcome['UBE_COMBAT_RESULT'] == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')] |
|
170 | 169 | ); |
171 | 170 | |
172 | 171 | $text_defender = ''; |
@@ -251,7 +250,7 @@ discard block |
||
251 | 250 | // Просматриваем результаты изменения флотов |
252 | 251 | foreach ($fleet_info[UBE_COUNT] as $unit_id => $unit_count) { |
253 | 252 | // Перебираем аутком на случай восстановления юнитов |
254 | - $units_lost = (float)$fleets_outcome[$fleet_id][UBE_UNITS_LOST][$unit_id]; |
|
253 | + $units_lost = (float) $fleets_outcome[$fleet_id][UBE_UNITS_LOST][$unit_id]; |
|
255 | 254 | |
256 | 255 | $units_left = $unit_count - $units_lost; |
257 | 256 | if ($fleet_id) { |
@@ -275,7 +274,7 @@ discard block |
||
275 | 274 | // Если во флоте остались юниты или это планета - генерируем изменение ресурсов |
276 | 275 | if ($new_fleet_count || !$fleet_id) { |
277 | 276 | foreach (sn_get_groups('resources_loot') as $resource_id) { |
278 | - $resource_change = (float)$fleets_outcome[$fleet_id][UBE_RESOURCES_LOOTED][$resource_id] + (float)$fleets_outcome[$fleet_id][UBE_CARGO_DROPPED][$resource_id]; |
|
277 | + $resource_change = (float) $fleets_outcome[$fleet_id][UBE_RESOURCES_LOOTED][$resource_id] + (float) $fleets_outcome[$fleet_id][UBE_CARGO_DROPPED][$resource_id]; |
|
279 | 278 | if ($resource_change) { |
280 | 279 | $resource_db_name = ($fleet_id ? 'fleet_resource_' : '') . pname_resource_name($resource_id); |
281 | 280 | $fleet_delta[$resource_db_name] = -($resource_change); |
@@ -290,10 +290,12 @@ discard block |
||
290 | 290 | } |
291 | 291 | } |
292 | 292 | |
293 | - if ($fleet_id) // Не планета |
|
293 | + if ($fleet_id) { |
|
294 | + // Не планета |
|
294 | 295 | { |
295 | 296 | if ($fleet_info[UBE_FLEET_TYPE] == UBE_ATTACKERS && $outcome[UBE_MOON_REAPERS] == UBE_MOON_REAPERS_DIED) { |
296 | 297 | $new_fleet_count = 0; |
298 | + } |
|
297 | 299 | } |
298 | 300 | |
299 | 301 | if ($new_fleet_count) { |
@@ -316,10 +318,12 @@ discard block |
||
316 | 318 | } |
317 | 319 | DBStaticPlanet::db_planet_set_by_id($planet_id, implode(',', $temp)); |
318 | 320 | } |
319 | - if (!empty($db_changeset)) // Сохраняем изменения юнитов на планете - если они есть |
|
321 | + if (!empty($db_changeset)) { |
|
322 | + // Сохраняем изменения юнитов на планете - если они есть |
|
320 | 323 | { |
321 | 324 | OldDbChangeSet::db_changeset_apply($db_changeset); |
322 | 325 | } |
326 | + } |
|
323 | 327 | } |
324 | 328 | } |
325 | 329 |
@@ -2,12 +2,12 @@ discard block |
||
2 | 2 | |
3 | 3 | include('common.' . substr(strrchr(__FILE__, '.'), 1)); |
4 | 4 | |
5 | -if($user['authlevel'] < AUTH_LEVEL_DEVELOPER) { |
|
5 | +if ($user['authlevel'] < AUTH_LEVEL_DEVELOPER) { |
|
6 | 6 | $error_message = classSupernova::$config->game_mode == GAME_BLITZ ? 'sys_blitz_page_disabled' : ( |
7 | 7 | !classSupernova::$config->game_blitz_register ? 'sys_blitz_registration_disabled' : '' |
8 | 8 | ); |
9 | 9 | |
10 | - if($error_message) { |
|
10 | + if ($error_message) { |
|
11 | 11 | messageBox($lang[$error_message], $lang['sys_error'], 'overview.php', 10); |
12 | 12 | die(); |
13 | 13 | } |
@@ -17,12 +17,12 @@ discard block |
||
17 | 17 | $current_round = intval(classSupernova::$config->db_loadItem('game_blitz_register_round')); |
18 | 18 | $current_price = intval(classSupernova::$config->db_loadItem('game_blitz_register_price')); |
19 | 19 | |
20 | -if(classSupernova::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) { |
|
20 | +if (classSupernova::$config->db_loadItem('game_blitz_register') == BLITZ_REGISTER_OPEN && (sys_get_param_str('register_me') || sys_get_param_str('register_me_not'))) { |
|
21 | 21 | sn_db_transaction_start(); |
22 | 22 | $user = db_user_by_id($user['id'], true); |
23 | 23 | $is_registered = doquery("SELECT `id` FROM {{blitz_registrations}} WHERE `user_id` = {$user['id']} AND `round_number` = {$current_round} FOR UPDATE;", true); |
24 | - if(sys_get_param_str('register_me')) { |
|
25 | - if(empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) { |
|
24 | + if (sys_get_param_str('register_me')) { |
|
25 | + if (empty($is_registered) && mrc_get_level($user, null, RES_METAMATTER) >= $current_price) { |
|
26 | 26 | doquery("INSERT IGNORE INTO {{blitz_registrations}} SET `user_id` = {$user['id']}, `round_number` = {$current_round};"); |
27 | 27 | //mm_points_change($user['id'], RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица"); |
28 | 28 | classSupernova::$auth->account->metamatter_change(RPG_BLITZ_REGISTRATION, -$current_price, "Регистрация в раунде {$current_round} Блица"); |
@@ -43,17 +43,17 @@ discard block |
||
43 | 43 | $blitz_players = 0; |
44 | 44 | $blitz_prize_dark_matter = 0; |
45 | 45 | $blitz_prize_places = 0; |
46 | -if($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) { |
|
47 | - if(sys_get_param_str('generate')) { |
|
46 | +if ($user['authlevel'] >= AUTH_LEVEL_DEVELOPER) { |
|
47 | + if (sys_get_param_str('generate')) { |
|
48 | 48 | $next_id = 0; |
49 | 49 | $query = doquery("SELECT `id` FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY RAND();"); |
50 | - while($row = db_fetch($query)) { |
|
50 | + while ($row = db_fetch($query)) { |
|
51 | 51 | $next_id++; |
52 | 52 | $blitz_name = 'Игрок' . $next_id; |
53 | 53 | $blitz_password = sys_random_string(8); |
54 | 54 | doquery("UPDATE {{blitz_registrations}} SET blitz_name = '{$blitz_name}', blitz_password = '{$blitz_password}' WHERE `id` = {$row['id']} AND `round_number` = {$current_round};"); |
55 | 55 | } |
56 | - } elseif(sys_get_param_str('import_generated')) { |
|
56 | + } elseif (sys_get_param_str('import_generated')) { |
|
57 | 57 | // ЭТО НА БЛИЦЕ!!! |
58 | 58 | doquery("DELETE FROM {{users}} WHERE username like 'Игрок%';"); |
59 | 59 | doquery("DELETE FROM {{planets}} WHERE id_owner not in (SELECT `id` FROM {{users}});"); |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | $system = $system_step; |
76 | 76 | $planet = round(classSupernova::$config->game_maxPlanet / 2); |
77 | 77 | |
78 | - foreach($imported_string as &$string_data) { |
|
78 | + foreach ($imported_string as &$string_data) { |
|
79 | 79 | $string_data = explode(',', $string_data); |
80 | 80 | $username_safe = $string_data[0]; |
81 | 81 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | $moon_row = uni_create_moon($galaxy, $system, $planet, $user_new['id'], Universe::MOON_MAX_SIZE, false); |
91 | 91 | |
92 | - if(($system += $system_step) >= classSupernova::$config->game_maxSystem) { |
|
92 | + if (($system += $system_step) >= classSupernova::$config->game_maxSystem) { |
|
93 | 93 | $galaxy++; |
94 | 94 | $system = $system_step; |
95 | 95 | } |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | |
99 | 99 | classSupernova::$config->db_saveItem('users_amount', classSupernova::$config->users_amount + $new_players); |
100 | 100 | // generated_string |
101 | - } elseif(sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) { |
|
101 | + } elseif (sys_get_param_str('import_result') && ($blitz_result_string = sys_get_param_str('blitz_result_string'))) { |
|
102 | 102 | $blitz_result = explode(';', $blitz_result_string); |
103 | 103 | $blitz_last_update = $blitz_result[0]; // Пока не используется |
104 | 104 | unset($blitz_result[0]); |
105 | - foreach($blitz_result as $blitz_result_data) { |
|
105 | + foreach ($blitz_result as $blitz_result_data) { |
|
106 | 106 | $blitz_result_data = explode(',', $blitz_result_data); |
107 | - if(count($blitz_result_data) == 5) { |
|
107 | + if (count($blitz_result_data) == 5) { |
|
108 | 108 | $blitz_result_data[1] = db_escape($blitz_result_data[1]); |
109 | 109 | doquery( |
110 | 110 | "UPDATE `{{blitz_registrations}}` SET |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | $blitz_result = array(); |
119 | 119 | } |
120 | 120 | |
121 | - if(classSupernova::$config->game_mode == GAME_BLITZ) { |
|
121 | + if (classSupernova::$config->game_mode == GAME_BLITZ) { |
|
122 | 122 | $blitz_result = array(classSupernova::$config->db_loadItem('var_stat_update')); |
123 | 123 | $query = doquery("SELECT id, username, total_rank, total_points, onlinetime FROM {{users}} ORDER BY `id`;"); |
124 | - while($row = db_fetch($query)) { |
|
124 | + while ($row = db_fetch($query)) { |
|
125 | 125 | $blitz_result[] = "{$row['id']},{$row['username']},{$row['onlinetime']},{$row['total_rank']},{$row['total_points']}"; |
126 | 126 | } |
127 | 127 | } else { |
128 | 128 | $query = doquery("SELECT blitz_name, blitz_password, blitz_online FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY `id`;"); |
129 | - while($row = db_fetch($query)) { |
|
129 | + while ($row = db_fetch($query)) { |
|
130 | 130 | $blitz_generated[] = "{$row['blitz_name']},{$row['blitz_password']}"; |
131 | 131 | $row['blitz_online'] ? $blitz_prize_players_active++ : false; |
132 | 132 | $blitz_players++; |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | 'Игрок40' |
142 | 142 | */ |
143 | 143 | |
144 | - if(sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) { |
|
144 | + if (sys_get_param_str('prize_calculate') && $blitz_prize_players_active && ($blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'))) { |
|
145 | 145 | // $blitz_prize_dark_matter_actual = sys_get_param_int('blitz_prize_dark_matter'); |
146 | 146 | $blitz_prize_places_actual = sys_get_param_int('blitz_prize_places'); |
147 | 147 | sn_db_transaction_start(); |
148 | 148 | $query = doquery("SELECT * FROM {{blitz_registrations}} WHERE `round_number` = {$current_round} ORDER BY `blitz_place` FOR UPDATE;"); |
149 | - while($row = db_fetch($query)) { |
|
150 | - if(!$row['blitz_place']) { |
|
149 | + while ($row = db_fetch($query)) { |
|
150 | + if (!$row['blitz_place']) { |
|
151 | 151 | continue; |
152 | 152 | } |
153 | 153 | |
@@ -155,15 +155,15 @@ discard block |
||
155 | 155 | $blitz_prize_places_actual--; |
156 | 156 | |
157 | 157 | $reward = $blitz_prize_dark_matter_actual - $row['blitz_reward_dark_matter']; |
158 | -pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}",$row['id']); |
|
159 | - if($reward) { |
|
158 | +pdump("{{$row['id']}} {$row['blitz_name']}, Place {$row['blitz_place']}, Prize places {$blitz_prize_places_actual}, Prize {$reward}", $row['id']); |
|
159 | + if ($reward) { |
|
160 | 160 | rpg_points_change($row['user_id'], RPG_BLITZ, $reward, sprintf( |
161 | 161 | $lang['sys_blitz_reward_log_message'], $row['blitz_place'], $row['blitz_name'] |
162 | 162 | )); |
163 | 163 | doquery("UPDATE {{blitz_registrations}} SET blitz_reward_dark_matter = blitz_reward_dark_matter + ($reward) WHERE id = {$row['id']} AND `round_number` = {$current_round};"); |
164 | 164 | } |
165 | 165 | |
166 | - if(!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) { |
|
166 | + if (!$blitz_prize_places_actual || $blitz_prize_dark_matter_actual < 1000) { |
|
167 | 167 | break; |
168 | 168 | } |
169 | 169 | } |
@@ -183,12 +183,12 @@ discard block |
||
183 | 183 | JOIN {{users}} AS u ON u.id = br.user_id |
184 | 184 | WHERE br.`round_number` = {$current_round} |
185 | 185 | order by `blitz_place`, `timestamp`;"); |
186 | -while($row = db_fetch($query)) { |
|
186 | +while ($row = db_fetch($query)) { |
|
187 | 187 | $tpl_player_data = array( |
188 | 188 | 'NAME' => player_nick_render_to_html($row, array('icons' => true, 'color' => true, 'ally' => true)), |
189 | 189 | ); |
190 | 190 | |
191 | - if(classSupernova::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) { |
|
191 | + if (classSupernova::$config->game_blitz_register == BLITZ_REGISTER_DISCLOSURE_NAMES) { |
|
192 | 192 | // Вот так хитро, что бы не было не единого шанса попадания на страницу данных об игроках Блиц-сервера до закрытия раунда |
193 | 193 | $tpl_player_data = array_merge($tpl_player_data, array( |
194 | 194 | 'ID' => $row['id'], |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | } |
202 | 202 | |
203 | 203 | $template->assign_block_vars('registrations', $tpl_player_data); |
204 | - if($row['id'] == $user['id']) { |
|
204 | + if ($row['id'] == $user['id']) { |
|
205 | 205 | $player_registered = $row; |
206 | 206 | } |
207 | 207 | } |
@@ -236,9 +236,11 @@ |
||
236 | 236 | } |
237 | 237 | |
238 | 238 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
239 | - if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
239 | + if (!isset($planet_row['id'])) { |
|
240 | + // || $planet_row['id'] != $user['current_planet'] |
|
240 | 241 | { |
241 | 242 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
243 | + } |
|
242 | 244 | // Если текущей планеты не существует - выставляем Столицу |
243 | 245 | if (!isset($planet_row['id'])) { |
244 | 246 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id'); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | { |
5 | 5 | global $lang; |
6 | 6 | |
7 | - if(!in_array($unit_id, sn_get_groups('artifacts'))) |
|
7 | + if (!in_array($unit_id, sn_get_groups('artifacts'))) |
|
8 | 8 | { |
9 | 9 | return; |
10 | 10 | } |
@@ -13,17 +13,17 @@ discard block |
||
13 | 13 | $user = db_user_by_id($user['id'], true); |
14 | 14 | |
15 | 15 | $unit_level = $artifact_level_old = mrc_get_level($user, array(), $unit_id, true); |
16 | - if($unit_level > 0) |
|
16 | + if ($unit_level > 0) |
|
17 | 17 | { |
18 | 18 | $db_changeset = array(); |
19 | - switch($unit_id) |
|
19 | + switch ($unit_id) |
|
20 | 20 | { |
21 | 21 | case ART_LHC: |
22 | 22 | case ART_HOOK_SMALL: |
23 | 23 | case ART_HOOK_MEDIUM: |
24 | 24 | case ART_HOOK_LARGE: |
25 | 25 | $has_moon = DBStaticPlanet::db_planet_by_parent($planetrow['id'], true, '`id`'); |
26 | - if($planetrow['planet_type'] == PT_PLANET && !$has_moon['id']) |
|
26 | + if ($planetrow['planet_type'] == PT_PLANET && !$has_moon['id']) |
|
27 | 27 | { |
28 | 28 | $unit_level--; |
29 | 29 | $updateDebris = false; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | break; |
45 | 45 | } |
46 | 46 | |
47 | - if($moonSize) |
|
47 | + if ($moonSize) |
|
48 | 48 | { |
49 | 49 | $new_moon_row = uni_create_moon($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], $user['id'], $moonSize, $updateDebris); |
50 | 50 | $message = sprintf($lang['art_moon_create'][$unit_id], $new_moon_row['name'], uni_render_coordinates($planetrow), HelperString::numberFloorAndFormat($moonSize)); |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | case ART_RCD_MEDIUM: |
66 | 66 | case ART_RCD_LARGE: |
67 | 67 | $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true); |
68 | - if($planetrow['planet_type'] != PT_PLANET) |
|
68 | + if ($planetrow['planet_type'] != PT_PLANET) |
|
69 | 69 | { |
70 | 70 | $message = $lang['art_rcd_err_moon']; |
71 | 71 | break; |
72 | 72 | } |
73 | 73 | |
74 | 74 | $que = que_get($user['id'], $planetrow['id'], QUE_STRUCTURES, false); |
75 | - if(!empty($que['items'])) |
|
75 | + if (!empty($que['items'])) |
|
76 | 76 | { |
77 | 77 | $message = $lang['art_rcd_err_que']; |
78 | 78 | break; |
@@ -81,15 +81,15 @@ discard block |
||
81 | 81 | $artifact_deploy = get_unit_param($unit_id, P_DEPLOY); |
82 | 82 | |
83 | 83 | $sectors_used = 0; |
84 | - foreach($artifact_deploy as $deploy_unit_id => $deploy_unit_level) |
|
84 | + foreach ($artifact_deploy as $deploy_unit_id => $deploy_unit_level) |
|
85 | 85 | { |
86 | - if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) |
|
86 | + if (!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) |
|
87 | 87 | continue; |
88 | 88 | $sectors_used += $levels_deployed; |
89 | 89 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($deploy_unit_id, $levels_deployed, $user, $planetrow['id']); |
90 | 90 | } |
91 | 91 | |
92 | - if($sectors_used == 0) |
|
92 | + if ($sectors_used == 0) |
|
93 | 93 | { |
94 | 94 | $message = $lang['art_rcd_err_no_sense']; |
95 | 95 | break; |
@@ -104,13 +104,13 @@ discard block |
||
104 | 104 | $que_item = null; |
105 | 105 | $que = que_get($user['id'], $planetrow['id'], QUE_RESEARCH, true); |
106 | 106 | $current_que = &$que['ques'][QUE_RESEARCH][$user['id']][0]; |
107 | - if(!empty($current_que)) |
|
107 | + if (!empty($current_que)) |
|
108 | 108 | { |
109 | 109 | reset($current_que); |
110 | 110 | $que_item = &$que['ques'][QUE_RESEARCH][$user['id']][0][key($current_que)]; |
111 | 111 | } |
112 | 112 | |
113 | - if(!empty($que_item) && $que_item['que_time_left'] > 60) |
|
113 | + if (!empty($que_item) && $que_item['que_time_left'] > 60) |
|
114 | 114 | { |
115 | 115 | $unit_level--; |
116 | 116 | $old_time = $que_item['que_time_left']; |
@@ -131,13 +131,13 @@ discard block |
||
131 | 131 | $que = que_get($user['id'], $planetrow['id'], QUE_STRUCTURES, true); |
132 | 132 | $current_que = &$que['ques'][QUE_STRUCTURES][$user['id']][$planetrow['id']]; |
133 | 133 | // $que_item = &$que['que'][QUE_STRUCTURES][0]; |
134 | - if(!empty($current_que)) |
|
134 | + if (!empty($current_que)) |
|
135 | 135 | { |
136 | 136 | reset($current_que); |
137 | 137 | $que_item = &$que['ques'][QUE_STRUCTURES][$user['id']][$planetrow['id']][key($current_que)]; |
138 | 138 | } |
139 | 139 | |
140 | - if(isset($que_item) && $que_item['que_time_left'] > 60) |
|
140 | + if (isset($que_item) && $que_item['que_time_left'] > 60) |
|
141 | 141 | { |
142 | 142 | $unit_level--; |
143 | 143 | $old_time = $que_item['que_time_left']; |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | break; |
156 | 156 | |
157 | 157 | } |
158 | - if($unit_level != $artifact_level_old) |
|
158 | + if ($unit_level != $artifact_level_old) |
|
159 | 159 | { |
160 | 160 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, $unit_level - $artifact_level_old, $user); |
161 | 161 | OldDbChangeSet::db_changeset_apply($db_changeset); |
@@ -1,7 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -function art_use(&$user, &$planetrow, $unit_id) |
|
4 | -{ |
|
3 | +function art_use(&$user, &$planetrow, $unit_id) { |
|
5 | 4 | global $lang; |
6 | 5 | |
7 | 6 | if(!in_array($unit_id, sn_get_groups('artifacts'))) |
@@ -48,14 +47,12 @@ discard block |
||
48 | 47 | { |
49 | 48 | $new_moon_row = uni_create_moon($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], $user['id'], $moonSize, $updateDebris); |
50 | 49 | $message = sprintf($lang['art_moon_create'][$unit_id], $new_moon_row['name'], uni_render_coordinates($planetrow), HelperString::numberFloorAndFormat($moonSize)); |
51 | - } |
|
52 | - else |
|
50 | + } else |
|
53 | 51 | { |
54 | 52 | $message = $lang['art_lhc_moon_fail']; |
55 | 53 | } |
56 | 54 | msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_ADMIN, $lang['art_lhc_from'], $lang['art_lhc_subj'], $message); |
57 | - } |
|
58 | - else |
|
55 | + } else |
|
59 | 56 | { |
60 | 57 | $message = $lang['art_moon_exists']; |
61 | 58 | } |
@@ -83,8 +80,9 @@ discard block |
||
83 | 80 | $sectors_used = 0; |
84 | 81 | foreach($artifact_deploy as $deploy_unit_id => $deploy_unit_level) |
85 | 82 | { |
86 | - if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) |
|
87 | - continue; |
|
83 | + if(!($levels_deployed = max(0, $deploy_unit_level - mrc_get_level($user, $planetrow, $deploy_unit_id, true, true)))) { |
|
84 | + continue; |
|
85 | + } |
|
88 | 86 | $sectors_used += $levels_deployed; |
89 | 87 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($deploy_unit_id, $levels_deployed, $user, $planetrow['id']); |
90 | 88 | } |
@@ -118,8 +116,7 @@ discard block |
||
118 | 116 | DBStaticQue::db_que_set_time_left_by_id($que_item['que_id'], $que_item['que_time_left']); |
119 | 117 | $message = sprintf($lang['art_heurestic_chip_ok'], $lang['tech'][$que_item['que_unit_id']], $que_item['que_unit_level'], sys_time_human($old_time - $que_item['que_time_left'])); |
120 | 118 | msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_QUE, $lang['art_heurestic_chip_subj'], $lang['art_heurestic_chip_subj'], $message); |
121 | - } |
|
122 | - else |
|
119 | + } else |
|
123 | 120 | { |
124 | 121 | $message = $lang['art_heurestic_chip_no_research']; |
125 | 122 | } |
@@ -147,8 +144,7 @@ discard block |
||
147 | 144 | $lang['tech'][$que_item['que_unit_id']], $que_item['que_unit_level'], $planetrow['name'], uni_render_coordinates($planetrow), sys_time_human($old_time - $que_item['que_time_left']) |
148 | 145 | ); |
149 | 146 | msg_send_simple_message($user['id'], 0, 0, MSG_TYPE_QUE, $lang['art_nano_builder_subj'], $lang['art_nano_builder_subj'], $message); |
150 | - } |
|
151 | - else |
|
147 | + } else |
|
152 | 148 | { |
153 | 149 | $message = $lang['art_nano_builder_no_que']; |
154 | 150 | } |
@@ -160,8 +156,7 @@ discard block |
||
160 | 156 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, $unit_level - $artifact_level_old, $user); |
161 | 157 | OldDbChangeSet::db_changeset_apply($db_changeset); |
162 | 158 | } |
163 | - } |
|
164 | - else |
|
159 | + } else |
|
165 | 160 | { |
166 | 161 | $message = $lang['art_err_no_artifact']; |
167 | 162 | } |
@@ -72,7 +72,7 @@ |
||
72 | 72 | // Для не-симулятора - рандомизируем каждый раунд значения атаки и щитов |
73 | 73 | $fleet_data[UBE_ATTACK_BASE][$unit_id] = floor($fleet_info[UBE_ATTACK][$unit_id] * ($isSimulatorStatic ? 1 : mt_rand(80, 120) / 100)); |
74 | 74 | $fleet_data[UBE_SHIELD_BASE][$unit_id] = floor($fleet_info[UBE_SHIELD][$unit_id] * ($isSimulatorStatic ? 1 : mt_rand(80, 120) / 100)); |
75 | - $fleet_data[UBE_ARMOR_BASE][$unit_id] = floor($fleet_info[UBE_ARMOR][$unit_id]);// * ($is_simulator ? 1 : mt_rand(80, 120) / 100)); |
|
75 | + $fleet_data[UBE_ARMOR_BASE][$unit_id] = floor($fleet_info[UBE_ARMOR][$unit_id]); // * ($is_simulator ? 1 : mt_rand(80, 120) / 100)); |
|
76 | 76 | |
77 | 77 | $fleet_data[UBE_ATTACK][$unit_id] = $fleet_data[UBE_ATTACK_BASE][$unit_id] * $unit_count; |
78 | 78 | $fleet_data[UBE_SHIELD][$unit_id] = $fleet_data[UBE_SHIELD_BASE][$unit_id] * $unit_count; |
@@ -8,8 +8,8 @@ |
||
8 | 8 | const MOON_MIN_SIZE = 1100; |
9 | 9 | const MOON_MAX_SIZE = 8999; |
10 | 10 | |
11 | - const MOON_DEBRIS_MIN = 1000000; // Minimum amount of debris to span a moon |
|
12 | - const MOON_CHANCE_MIN_PERCENT = 1; // Minimum chance to span a moon |
|
11 | + const MOON_DEBRIS_MIN = 1000000; // Minimum amount of debris to span a moon |
|
12 | + const MOON_CHANCE_MIN_PERCENT = 1; // Minimum chance to span a moon |
|
13 | 13 | const MOON_CHANCE_MAX_PERCENT = 30; // Maximum chance to span a moon |
14 | 14 | |
15 | 15 | /** |