@@ -239,7 +239,7 @@ |
||
239 | 239 | |
240 | 240 | $factory = $this->values[$id]; |
241 | 241 | |
242 | - $extended = function ($c) use ($callable, $factory) { |
|
242 | + $extended = function($c) use ($callable, $factory) { |
|
243 | 243 | return $callable($factory($c), $c); |
244 | 244 | }; |
245 | 245 |
@@ -47,8 +47,7 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @param array $values The parameters or objects. |
49 | 49 | */ |
50 | - public function __construct(array $values = array()) |
|
51 | - { |
|
50 | + public function __construct(array $values = array()) { |
|
52 | 51 | $this->factories = new \SplObjectStorage(); |
53 | 52 | $this->protected = new \SplObjectStorage(); |
54 | 53 | |
@@ -71,8 +70,7 @@ discard block |
||
71 | 70 | * |
72 | 71 | * @throws \RuntimeException Prevent override of a frozen service |
73 | 72 | */ |
74 | - public function offsetSet($id, $value) |
|
75 | - { |
|
73 | + public function offsetSet($id, $value) { |
|
76 | 74 | if (isset($this->frozen[$id])) { |
77 | 75 | throw new \RuntimeException(sprintf('Cannot override frozen service "%s".', $id)); |
78 | 76 | } |
@@ -90,8 +88,7 @@ discard block |
||
90 | 88 | * |
91 | 89 | * @throws \InvalidArgumentException if the identifier is not defined |
92 | 90 | */ |
93 | - public function offsetGet($id) |
|
94 | - { |
|
91 | + public function offsetGet($id) { |
|
95 | 92 | if (!isset($this->keys[$id])) { |
96 | 93 | throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); |
97 | 94 | } |
@@ -125,8 +122,7 @@ discard block |
||
125 | 122 | * |
126 | 123 | * @return bool |
127 | 124 | */ |
128 | - public function offsetExists($id) |
|
129 | - { |
|
125 | + public function offsetExists($id) { |
|
130 | 126 | return isset($this->keys[$id]); |
131 | 127 | } |
132 | 128 | |
@@ -135,8 +131,7 @@ discard block |
||
135 | 131 | * |
136 | 132 | * @param string $id The unique identifier for the parameter or object |
137 | 133 | */ |
138 | - public function offsetUnset($id) |
|
139 | - { |
|
134 | + public function offsetUnset($id) { |
|
140 | 135 | if (isset($this->keys[$id])) { |
141 | 136 | if (is_object($this->values[$id])) { |
142 | 137 | unset($this->factories[$this->values[$id]], $this->protected[$this->values[$id]]); |
@@ -155,8 +150,7 @@ discard block |
||
155 | 150 | * |
156 | 151 | * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object |
157 | 152 | */ |
158 | - public function factory($callable) |
|
159 | - { |
|
153 | + public function factory($callable) { |
|
160 | 154 | if (!method_exists($callable, '__invoke')) { |
161 | 155 | throw new \InvalidArgumentException('Service definition is not a Closure or invokable object.'); |
162 | 156 | } |
@@ -177,8 +171,7 @@ discard block |
||
177 | 171 | * |
178 | 172 | * @throws \InvalidArgumentException Service definition has to be a closure of an invokable object |
179 | 173 | */ |
180 | - public function protect($callable) |
|
181 | - { |
|
174 | + public function protect($callable) { |
|
182 | 175 | if (!method_exists($callable, '__invoke')) { |
183 | 176 | throw new \InvalidArgumentException('Callable is not a Closure or invokable object.'); |
184 | 177 | } |
@@ -197,8 +190,7 @@ discard block |
||
197 | 190 | * |
198 | 191 | * @throws \InvalidArgumentException if the identifier is not defined |
199 | 192 | */ |
200 | - public function raw($id) |
|
201 | - { |
|
193 | + public function raw($id) { |
|
202 | 194 | if (!isset($this->keys[$id])) { |
203 | 195 | throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); |
204 | 196 | } |
@@ -223,8 +215,7 @@ discard block |
||
223 | 215 | * |
224 | 216 | * @throws \InvalidArgumentException if the identifier is not defined or not a service definition |
225 | 217 | */ |
226 | - public function extend($id, $callable) |
|
227 | - { |
|
218 | + public function extend($id, $callable) { |
|
228 | 219 | if (!isset($this->keys[$id])) { |
229 | 220 | throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id)); |
230 | 221 | } |
@@ -256,8 +247,7 @@ discard block |
||
256 | 247 | * |
257 | 248 | * @return array An array of value names |
258 | 249 | */ |
259 | - public function keys() |
|
260 | - { |
|
250 | + public function keys() { |
|
261 | 251 | return array_keys($this->values); |
262 | 252 | } |
263 | 253 | |
@@ -269,8 +259,7 @@ discard block |
||
269 | 259 | * |
270 | 260 | * @return static |
271 | 261 | */ |
272 | - public function register(ServiceProviderInterface $provider, array $values = array()) |
|
273 | - { |
|
262 | + public function register(ServiceProviderInterface $provider, array $values = array()) { |
|
274 | 263 | $provider->register($this); |
275 | 264 | |
276 | 265 | foreach ($values as $key => $value) { |
@@ -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 | if ($echo_var) |
@@ -288,9 +288,9 @@ discard block |
||
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
291 | - * Compile variables |
|
292 | - * @access private |
|
293 | - */ |
|
291 | + * Compile variables |
|
292 | + * @access private |
|
293 | + */ |
|
294 | 294 | function compile_var_tags(&$text_blocks) |
295 | 295 | { |
296 | 296 | // including $lang variable |
@@ -363,9 +363,9 @@ discard block |
||
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
366 | - * Compile blocks |
|
367 | - * @access private |
|
368 | - */ |
|
366 | + * Compile blocks |
|
367 | + * @access private |
|
368 | + */ |
|
369 | 369 | function compile_tag_block($tag_args) |
370 | 370 | { |
371 | 371 | $no_nesting = false; |
@@ -451,14 +451,14 @@ discard block |
||
451 | 451 | $tag_template_php .= 'if ($_' . $tag_args . '_count) {'; |
452 | 452 | |
453 | 453 | /** |
454 | - * 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 |
|
455 | - * <code> |
|
456 | - * if (!$offset) |
|
457 | - * { |
|
458 | - * $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){'; |
|
459 | - * } |
|
460 | - * </code> |
|
461 | - */ |
|
454 | + * 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 |
|
455 | + * <code> |
|
456 | + * if (!$offset) |
|
457 | + * { |
|
458 | + * $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){'; |
|
459 | + * } |
|
460 | + * </code> |
|
461 | + */ |
|
462 | 462 | |
463 | 463 | $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){'; |
464 | 464 | // $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;'; |
@@ -469,10 +469,10 @@ discard block |
||
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
472 | - * Compile IF tags - much of this is from Smarty with |
|
473 | - * some adaptions for our block level methods |
|
474 | - * @access private |
|
475 | - */ |
|
472 | + * Compile IF tags - much of this is from Smarty with |
|
473 | + * some adaptions for our block level methods |
|
474 | + * @access private |
|
475 | + */ |
|
476 | 476 | function compile_tag_if($tag_args, $elseif) |
477 | 477 | { |
478 | 478 | // Tokenize args for 'if' tag. |
@@ -627,9 +627,9 @@ discard block |
||
627 | 627 | } |
628 | 628 | |
629 | 629 | /** |
630 | - * Compile DEFINE tags |
|
631 | - * @access private |
|
632 | - */ |
|
630 | + * Compile DEFINE tags |
|
631 | + * @access private |
|
632 | + */ |
|
633 | 633 | function compile_tag_define($tag_args, $op) |
634 | 634 | { |
635 | 635 | preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match); |
@@ -680,9 +680,9 @@ discard block |
||
680 | 680 | } |
681 | 681 | |
682 | 682 | /** |
683 | - * Compile INCLUDE tag |
|
684 | - * @access private |
|
685 | - */ |
|
683 | + * Compile INCLUDE tag |
|
684 | + * @access private |
|
685 | + */ |
|
686 | 686 | function compile_tag_include($tag_args) |
687 | 687 | { |
688 | 688 | // Process dynamic includes |
@@ -695,19 +695,19 @@ discard block |
||
695 | 695 | } |
696 | 696 | |
697 | 697 | /** |
698 | - * Compile INCLUDE_PHP tag |
|
699 | - * @access private |
|
700 | - */ |
|
698 | + * Compile INCLUDE_PHP tag |
|
699 | + * @access private |
|
700 | + */ |
|
701 | 701 | function compile_tag_include_php($tag_args) |
702 | 702 | { |
703 | 703 | return "\$this->_php_include('$tag_args');"; |
704 | 704 | } |
705 | 705 | |
706 | 706 | /** |
707 | - * parse expression |
|
708 | - * This is from Smarty |
|
709 | - * @access private |
|
710 | - */ |
|
707 | + * parse expression |
|
708 | + * This is from Smarty |
|
709 | + * @access private |
|
710 | + */ |
|
711 | 711 | function _parse_is_expr($is_arg, $tokens) |
712 | 712 | { |
713 | 713 | $expr_end = 0; |
@@ -800,14 +800,14 @@ discard block |
||
800 | 800 | } |
801 | 801 | |
802 | 802 | /** |
803 | - * Generates a reference to the array of data values for the given |
|
804 | - * (possibly nested) block namespace. This is a string of the form: |
|
805 | - * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] |
|
806 | - * |
|
807 | - * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. |
|
808 | - * NOTE: does not expect a trailing "." on the blockname. |
|
809 | - * @access private |
|
810 | - */ |
|
803 | + * Generates a reference to the array of data values for the given |
|
804 | + * (possibly nested) block namespace. This is a string of the form: |
|
805 | + * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN'] |
|
806 | + * |
|
807 | + * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above. |
|
808 | + * NOTE: does not expect a trailing "." on the blockname. |
|
809 | + * @access private |
|
810 | + */ |
|
811 | 811 | function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) |
812 | 812 | { |
813 | 813 | // Get an array of the blocks involved. |
@@ -843,9 +843,9 @@ discard block |
||
843 | 843 | } |
844 | 844 | |
845 | 845 | /** |
846 | - * Write compiled file to cache directory |
|
847 | - * @access private |
|
848 | - */ |
|
846 | + * Write compiled file to cache directory |
|
847 | + * @access private |
|
848 | + */ |
|
849 | 849 | function compile_write($handle, $data) |
850 | 850 | { |
851 | 851 | $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX; |
@@ -868,9 +868,9 @@ discard block |
||
868 | 868 | |
869 | 869 | // Gorlum's minifier BOF |
870 | 870 | /** |
871 | - * Minifies template w/i PHP code by removing extra spaces |
|
872 | - * @access private |
|
873 | - */ |
|
871 | + * Minifies template w/i PHP code by removing extra spaces |
|
872 | + * @access private |
|
873 | + */ |
|
874 | 874 | function minify($html) |
875 | 875 | { |
876 | 876 | if(!SN::$config->tpl_minifier) |
@@ -141,9 +141,9 @@ discard block |
||
141 | 141 | |
142 | 142 | preg_match_all('#<!-- INCLUDE (\{\$?[A-Z0-9\-_]+\}|[a-zA-Z0-9\_\-\+\./]+) -->#', $code, $matches); |
143 | 143 | $include_blocks = $matches[1]; |
144 | - if($include_blocks) |
|
144 | + if ($include_blocks) |
|
145 | 145 | { |
146 | - foreach($include_blocks as &$included_file) |
|
146 | + foreach ($include_blocks as &$included_file) |
|
147 | 147 | { |
148 | 148 | $included_file .= '.tpl.html'; |
149 | 149 | } |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | $varname = $var_val[3]; |
309 | 309 | $new = $this->generate_block_varref($namespace, $varname, $var_val[2]); |
310 | 310 | |
311 | - if(!empty($var_val[4])) { |
|
311 | + if (!empty($var_val[4])) { |
|
312 | 312 | $new = \Ptl\PtlVariableDecorator::decorate($var_val[0], $new, $this->template); |
313 | 313 | } |
314 | 314 | |
@@ -462,8 +462,8 @@ discard block |
||
462 | 462 | |
463 | 463 | $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){'; |
464 | 464 | // $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;'; |
465 | - $tag_template_php .= '$_'. $tag_args . '_val = &' . $varref . '[$_'. $tag_args. '_i];'; |
|
466 | - $tag_template_php .= '$this->_block_value["'. $tag_args . '"] = &' . $varref . '[$_'. $tag_args. '_i];'; |
|
465 | + $tag_template_php .= '$_' . $tag_args . '_val = &' . $varref . '[$_' . $tag_args . '_i];'; |
|
466 | + $tag_template_php .= '$this->_block_value["' . $tag_args . '"] = &' . $varref . '[$_' . $tag_args . '_i];'; |
|
467 | 467 | |
468 | 468 | return $tag_template_php; |
469 | 469 | } |
@@ -567,10 +567,10 @@ discard block |
||
567 | 567 | break; |
568 | 568 | |
569 | 569 | case 'is': |
570 | - $is_arg_start = ($tokens[$i-1] == ')') ? array_pop($is_arg_stack) : $i-1; |
|
570 | + $is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1; |
|
571 | 571 | $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start)); |
572 | 572 | |
573 | - $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1)); |
|
573 | + $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1)); |
|
574 | 574 | |
575 | 575 | array_splice($tokens, $is_arg_start, sizeof($tokens), $new_tokens); |
576 | 576 | |
@@ -834,11 +834,11 @@ discard block |
||
834 | 834 | } |
835 | 835 | else if ($include_last_iterator) |
836 | 836 | { |
837 | - return '$_'. $blocks[$blockcount] . '_val'; |
|
837 | + return '$_' . $blocks[$blockcount] . '_val'; |
|
838 | 838 | } |
839 | 839 | else |
840 | 840 | { |
841 | - return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']'; |
|
841 | + return '$_' . $blocks[$blockcount - 1] . '_val[\'' . $blocks[$blockcount] . '\']'; |
|
842 | 842 | } |
843 | 843 | } |
844 | 844 | |
@@ -855,7 +855,7 @@ discard block |
||
855 | 855 | if ($fp = @fopen($filename, 'wb')) |
856 | 856 | { |
857 | 857 | @flock($fp, LOCK_EX); |
858 | - @fwrite ($fp, $data); |
|
858 | + @fwrite($fp, $data); |
|
859 | 859 | @flock($fp, LOCK_UN); |
860 | 860 | @fclose($fp); |
861 | 861 | |
@@ -873,7 +873,7 @@ discard block |
||
873 | 873 | */ |
874 | 874 | function minify($html) |
875 | 875 | { |
876 | - if(!SN::$config->tpl_minifier) |
|
876 | + if (!SN::$config->tpl_minifier) |
|
877 | 877 | { |
878 | 878 | return $html; |
879 | 879 | } |
@@ -885,14 +885,14 @@ discard block |
||
885 | 885 | //$html = preg_replace('/[\r\n\t]+/', ' ', $html); |
886 | 886 | $html = preg_replace('/>[\s]*</', '><', $html); // Strip spacechars between tags |
887 | 887 | $html = preg_replace('/[\s]+/', ' ', $html); // Replace several spacechars with one space |
888 | - if(!empty($pre[0])) |
|
888 | + if (!empty($pre[0])) |
|
889 | 889 | { |
890 | - foreach($pre[0] as $tag) |
|
890 | + foreach ($pre[0] as $tag) |
|
891 | 891 | { |
892 | 892 | $tag = preg_replace('/^\ *\/\/[^\<]*?$/m', ' ', $tag); // Strips comments - except those that contains HTML comment inside |
893 | 893 | $tag = preg_replace('/[\ \t]{2,}/', ' ', $tag); // Replace several spaces by one |
894 | 894 | $tag = preg_replace('/\s{2,}/', "\r\n", $tag); // Replace several linefeeds by one |
895 | - $html = preg_replace('/#pre#/', $tag, $html,1); |
|
895 | + $html = preg_replace('/#pre#/', $tag, $html, 1); |
|
896 | 896 | } |
897 | 897 | } |
898 | 898 |
@@ -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 | { |
@@ -74,8 +72,7 @@ discard block |
||
74 | 72 | |
75 | 73 | return; |
76 | 74 | trigger_error("template->_tpl_load_file(): File {$this->template->files[$handle]} does not exist or is empty", E_USER_ERROR); |
77 | - } |
|
78 | - else |
|
75 | + } else |
|
79 | 76 | { |
80 | 77 | $this->template->files[$handle] = $this->template->files_inherit[$handle]; |
81 | 78 | } |
@@ -111,8 +108,7 @@ discard block |
||
111 | 108 | * the ones that exist in zend_language_scanner.l |
112 | 109 | * @access private |
113 | 110 | */ |
114 | - function remove_php_tags(&$code) |
|
115 | - { |
|
111 | + function remove_php_tags(&$code) { |
|
116 | 112 | // This matches the information gathered from the internal PHP lexer |
117 | 113 | $match = array( |
118 | 114 | '#<([\?%])=?.*?\1>#s', |
@@ -127,8 +123,7 @@ discard block |
||
127 | 123 | * The all seeing all doing compile method. Parts are inspired by or directly from Smarty |
128 | 124 | * @access private |
129 | 125 | */ |
130 | - function compile($code, $no_echo = false, $echo_var = '') |
|
131 | - { |
|
126 | + function compile($code, $no_echo = false, $echo_var = '') { |
|
132 | 127 | if ($echo_var) |
133 | 128 | { |
134 | 129 | global $$echo_var; |
@@ -231,15 +226,13 @@ discard block |
||
231 | 226 | $var = substr($temp, 2, -1); |
232 | 227 | //$file = $this->template->_tpldata['DEFINE']['.'][$var]; |
233 | 228 | $temp = "\$this->_tpldata['DEFINE']['.']['$var']"; |
234 | - } |
|
235 | - else |
|
229 | + } else |
|
236 | 230 | { |
237 | 231 | $var = substr($temp, 1, -1); |
238 | 232 | //$file = $this->template->_rootref[$var]; |
239 | 233 | $temp = "\$this->_rootref['$var']"; |
240 | 234 | } |
241 | - } |
|
242 | - else |
|
235 | + } else |
|
243 | 236 | { |
244 | 237 | $file = $temp; |
245 | 238 | } |
@@ -298,8 +291,7 @@ discard block |
||
298 | 291 | * Compile variables |
299 | 292 | * @access private |
300 | 293 | */ |
301 | - function compile_var_tags(&$text_blocks) |
|
302 | - { |
|
294 | + function compile_var_tags(&$text_blocks) { |
|
303 | 295 | // including $lang variable |
304 | 296 | // global $lang, $config; // NOT NEDEED - $lang now is global! |
305 | 297 | |
@@ -373,8 +365,7 @@ discard block |
||
373 | 365 | * Compile blocks |
374 | 366 | * @access private |
375 | 367 | */ |
376 | - function compile_tag_block($tag_args) |
|
377 | - { |
|
368 | + function compile_tag_block($tag_args) { |
|
378 | 369 | $no_nesting = false; |
379 | 370 | |
380 | 371 | // Is the designer wanting to call another loop in a loop? |
@@ -397,8 +388,7 @@ discard block |
||
397 | 388 | if ($match[2] < 0) |
398 | 389 | { |
399 | 390 | $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')'; |
400 | - } |
|
401 | - else |
|
391 | + } else |
|
402 | 392 | { |
403 | 393 | $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')'; |
404 | 394 | } |
@@ -406,17 +396,14 @@ discard block |
||
406 | 396 | if (strlen($match[3]) < 1 || $match[3] == -1) |
407 | 397 | { |
408 | 398 | $loop_end = '$_' . $tag_args . '_count'; |
409 | - } |
|
410 | - else if ($match[3] >= 0) |
|
399 | + } else if ($match[3] >= 0) |
|
411 | 400 | { |
412 | 401 | $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')'; |
413 | - } |
|
414 | - else //if ($match[3] < -1) |
|
402 | + } else //if ($match[3] < -1) |
|
415 | 403 | { |
416 | 404 | $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1); |
417 | 405 | } |
418 | - } |
|
419 | - else |
|
406 | + } else |
|
420 | 407 | { |
421 | 408 | $loop_start = 0; |
422 | 409 | $loop_end = '$_' . $tag_args . '_count'; |
@@ -429,8 +416,7 @@ discard block |
||
429 | 416 | { |
430 | 417 | // We need to implode $no_nesting times from the end... |
431 | 418 | $block = array_slice($this->block_names, -$no_nesting); |
432 | - } |
|
433 | - else |
|
419 | + } else |
|
434 | 420 | { |
435 | 421 | $block = $this->block_names; |
436 | 422 | } |
@@ -440,8 +426,7 @@ discard block |
||
440 | 426 | // Block is not nested. |
441 | 427 | $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;"; |
442 | 428 | $varref = "\$this->_tpldata['$tag_args']"; |
443 | - } |
|
444 | - else |
|
429 | + } else |
|
445 | 430 | { |
446 | 431 | // This block is nested. |
447 | 432 | // Generate a namespace string for this block. |
@@ -480,8 +465,7 @@ discard block |
||
480 | 465 | * some adaptions for our block level methods |
481 | 466 | * @access private |
482 | 467 | */ |
483 | - function compile_tag_if($tag_args, $elseif) |
|
484 | - { |
|
468 | + function compile_tag_if($tag_args, $elseif) { |
|
485 | 469 | // Tokenize args for 'if' tag. |
486 | 470 | preg_match_all('/(?: |
487 | 471 | "[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | |
@@ -589,8 +573,7 @@ discard block |
||
589 | 573 | if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs)) |
590 | 574 | { |
591 | 575 | $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] . '\']'); |
592 | - } |
|
593 | - else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
|
576 | + } else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs)) |
|
594 | 577 | { |
595 | 578 | // Allow checking if loops are set with .loopname |
596 | 579 | // It is also possible to check the loop count by doing <!-- IF .loopname > 1 --> for example |
@@ -606,8 +589,7 @@ discard block |
||
606 | 589 | |
607 | 590 | // Add the block reference for the last child. |
608 | 591 | $varref .= "['" . $block . "']"; |
609 | - } |
|
610 | - else |
|
592 | + } else |
|
611 | 593 | { |
612 | 594 | $varref = '$this->_tpldata'; |
613 | 595 | |
@@ -615,8 +597,7 @@ discard block |
||
615 | 597 | $varref .= "['" . $blocks[0] . "']"; |
616 | 598 | } |
617 | 599 | $token = "(empty($varref) ? 0 : sizeof($varref))"; |
618 | - } |
|
619 | - else if (!empty($token)) |
|
600 | + } else if (!empty($token)) |
|
620 | 601 | { |
621 | 602 | $token = '(' . $token . ')'; |
622 | 603 | } |
@@ -637,8 +618,7 @@ discard block |
||
637 | 618 | * Compile DEFINE tags |
638 | 619 | * @access private |
639 | 620 | */ |
640 | - function compile_tag_define($tag_args, $op) |
|
641 | - { |
|
621 | + function compile_tag_define($tag_args, $op) { |
|
642 | 622 | preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match); |
643 | 623 | |
644 | 624 | if (empty($match[2]) || (!isset($match[4]) && $op)) |
@@ -661,8 +641,7 @@ discard block |
||
661 | 641 | |
662 | 642 | // Now replace the php code |
663 | 643 | $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'"; |
664 | - } |
|
665 | - else |
|
644 | + } else |
|
666 | 645 | { |
667 | 646 | preg_match('#true|false|\.#i', $match[4], $type); |
668 | 647 | |
@@ -690,8 +669,7 @@ discard block |
||
690 | 669 | * Compile INCLUDE tag |
691 | 670 | * @access private |
692 | 671 | */ |
693 | - function compile_tag_include($tag_args) |
|
694 | - { |
|
672 | + function compile_tag_include($tag_args) { |
|
695 | 673 | // Process dynamic includes |
696 | 674 | if ($tag_args[0] == '$') |
697 | 675 | { |
@@ -705,8 +683,7 @@ discard block |
||
705 | 683 | * Compile INCLUDE_PHP tag |
706 | 684 | * @access private |
707 | 685 | */ |
708 | - function compile_tag_include_php($tag_args) |
|
709 | - { |
|
686 | + function compile_tag_include_php($tag_args) { |
|
710 | 687 | return "\$this->_php_include('$tag_args');"; |
711 | 688 | } |
712 | 689 | |
@@ -715,8 +692,7 @@ discard block |
||
715 | 692 | * This is from Smarty |
716 | 693 | * @access private |
717 | 694 | */ |
718 | - function _parse_is_expr($is_arg, $tokens) |
|
719 | - { |
|
695 | + function _parse_is_expr($is_arg, $tokens) { |
|
720 | 696 | $expr_end = 0; |
721 | 697 | $negate_expr = false; |
722 | 698 | |
@@ -724,8 +700,7 @@ discard block |
||
724 | 700 | { |
725 | 701 | $negate_expr = true; |
726 | 702 | $expr_type = array_shift($tokens); |
727 | - } |
|
728 | - else |
|
703 | + } else |
|
729 | 704 | { |
730 | 705 | $expr_type = $first_token; |
731 | 706 | } |
@@ -738,8 +713,7 @@ discard block |
||
738 | 713 | $expr_end++; |
739 | 714 | $expr_arg = $tokens[$expr_end++]; |
740 | 715 | $expr = "!(($is_arg / $expr_arg) % $expr_arg)"; |
741 | - } |
|
742 | - else |
|
716 | + } else |
|
743 | 717 | { |
744 | 718 | $expr = "!($is_arg & 1)"; |
745 | 719 | } |
@@ -751,8 +725,7 @@ discard block |
||
751 | 725 | $expr_end++; |
752 | 726 | $expr_arg = $tokens[$expr_end++]; |
753 | 727 | $expr = "(($is_arg / $expr_arg) % $expr_arg)"; |
754 | - } |
|
755 | - else |
|
728 | + } else |
|
756 | 729 | { |
757 | 730 | $expr = "($is_arg & 1)"; |
758 | 731 | } |
@@ -791,8 +764,7 @@ discard block |
||
791 | 764 | * |
792 | 765 | * @return string |
793 | 766 | */ |
794 | - private function generate_block_varref($namespace, $varname, $defop = false) |
|
795 | - { |
|
767 | + private function generate_block_varref($namespace, $varname, $defop = false) { |
|
796 | 768 | // Strip the trailing period. |
797 | 769 | $namespace = substr($namespace, 0, -1); |
798 | 770 | |
@@ -815,8 +787,7 @@ discard block |
||
815 | 787 | * NOTE: does not expect a trailing "." on the blockname. |
816 | 788 | * @access private |
817 | 789 | */ |
818 | - function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) |
|
819 | - { |
|
790 | + function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) { |
|
820 | 791 | // Get an array of the blocks involved. |
821 | 792 | $blocks = explode('.', $blockname); |
822 | 793 | $blockcount = sizeof($blocks) - 1; |
@@ -838,12 +809,10 @@ discard block |
||
838 | 809 | $varref .= '[$_' . $blocks[$blockcount] . '_i]'; |
839 | 810 | } |
840 | 811 | return $varref; |
841 | - } |
|
842 | - else if ($include_last_iterator) |
|
812 | + } else if ($include_last_iterator) |
|
843 | 813 | { |
844 | 814 | return '$_'. $blocks[$blockcount] . '_val'; |
845 | - } |
|
846 | - else |
|
815 | + } else |
|
847 | 816 | { |
848 | 817 | return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']'; |
849 | 818 | } |
@@ -853,8 +822,7 @@ discard block |
||
853 | 822 | * Write compiled file to cache directory |
854 | 823 | * @access private |
855 | 824 | */ |
856 | - function compile_write($handle, $data) |
|
857 | - { |
|
825 | + function compile_write($handle, $data) { |
|
858 | 826 | $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX; |
859 | 827 | |
860 | 828 | $data = "<?php if (!defined('INSIDE')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data); |
@@ -878,8 +846,7 @@ discard block |
||
878 | 846 | * Minifies template w/i PHP code by removing extra spaces |
879 | 847 | * @access private |
880 | 848 | */ |
881 | - function minify($html) |
|
882 | - { |
|
849 | + function minify($html) { |
|
883 | 850 | if(!SN::$config->tpl_minifier) |
884 | 851 | { |
885 | 852 | return $html; |
@@ -29,19 +29,19 @@ |
||
29 | 29 | 'ID' => self::PAGE_SORT_BY_RANK, |
30 | 30 | 'HTML_ID' => 'byTotalRank', |
31 | 31 | 'HTML_NAME' => '{ byTotalRank }', |
32 | - 'SQL_SORT' => ['u.total_rank',], |
|
32 | + 'SQL_SORT' => ['u.total_rank', ], |
|
33 | 33 | ], |
34 | 34 | self::PAGE_SORT_BY_ID => [ |
35 | 35 | 'ID' => self::PAGE_SORT_BY_ID, |
36 | 36 | 'HTML_ID' => 'byId', |
37 | 37 | 'HTML_NAME' => '{ byId }', |
38 | - 'SQL_SORT' => ['u.id',], |
|
38 | + 'SQL_SORT' => ['u.id', ], |
|
39 | 39 | ], |
40 | 40 | self::PAGE_SORT_BY_NAME => [ |
41 | 41 | 'ID' => self::PAGE_SORT_BY_NAME, |
42 | 42 | 'HTML_ID' => 'byName', |
43 | 43 | 'HTML_NAME' => '{ byName }', |
44 | - 'SQL_SORT' => ['u.username',], |
|
44 | + 'SQL_SORT' => ['u.username', ], |
|
45 | 45 | ], |
46 | 46 | |
47 | 47 | self::PAGE_SORT_BY_POINTS => [ |
@@ -13,8 +13,8 @@ |
||
13 | 13 | const SORT_BY_ACTIVITY = 1; |
14 | 14 | |
15 | 15 | private static $sorting = [ |
16 | - self::SORT_BY_PACKAGE => ['PACKAGE', 'NAME', '!ACTIVE', '!INSTALLED',], |
|
17 | - self::SORT_BY_ACTIVITY => ['!ACTIVE', '!INSTALLED', 'PACKAGE', 'NAME',], |
|
16 | + self::SORT_BY_PACKAGE => ['PACKAGE', 'NAME', '!ACTIVE', '!INSTALLED', ], |
|
17 | + self::SORT_BY_ACTIVITY => ['!ACTIVE', '!INSTALLED', 'PACKAGE', 'NAME', ], |
|
18 | 18 | ]; |
19 | 19 | |
20 | 20 | private static $sortFields = []; |
@@ -7,9 +7,9 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -define('INSIDE' , true); |
|
11 | -define('INSTALL' , false); |
|
12 | -define('IN_ADMIN' , true); |
|
10 | +define('INSIDE', true); |
|
11 | +define('INSTALL', false); |
|
12 | +define('IN_ADMIN', true); |
|
13 | 13 | |
14 | 14 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
15 | 15 | |
@@ -20,12 +20,12 @@ discard block |
||
20 | 20 | function adm_lng_assign_string($lang_id, $locale_string_name, $value) { |
21 | 21 | global $locale_string_template, $languages_info, $languages, $domain; |
22 | 22 | |
23 | - if(is_array($value)) { |
|
24 | - foreach($value as $sub_key => $sub_value) { |
|
23 | + if (is_array($value)) { |
|
24 | + foreach ($value as $sub_key => $sub_value) { |
|
25 | 25 | adm_lng_assign_string($lang_id, "{$locale_string_name}[{$sub_key}]", $sub_value); |
26 | 26 | } |
27 | - } elseif($value) { |
|
28 | - if(!isset($locale_string_template[$locale_string_name])) { |
|
27 | + } elseif ($value) { |
|
28 | + if (!isset($locale_string_template[$locale_string_name])) { |
|
29 | 29 | $locale_string_template[$locale_string_name] = array(); |
30 | 30 | } |
31 | 31 | $locale_string_template[$locale_string_name] = array_merge($locale_string_template[$locale_string_name], array("[{$lang_id}]" => htmlentities($value, ENT_COMPAT, 'utf-8'))); |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | global $domain, $lang_id; |
47 | 47 | |
48 | 48 | $return = "{$ident}'{$string_name}' => "; |
49 | - if(isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) { |
|
49 | + if (isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) { |
|
50 | 50 | $return .= "'" . str_replace(array("\\", "'"), array('\\\\', "\\'"), $string_value[$lang_id]) . "',"; |
51 | 51 | } else { |
52 | 52 | $return .= "array(\r\n"; |
53 | - foreach($string_value as $arr_name => $arr_data) { |
|
53 | + foreach ($string_value as $arr_name => $arr_data) { |
|
54 | 54 | $return .= adm_lng_parse_string($arr_name, $arr_data, $ident . ' '); |
55 | 55 | } |
56 | 56 | $return .= "{$ident}),\r\n"; |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | |
104 | 104 | $string_name_new = false; |
105 | 105 | |
106 | - if(isset($honor_constants[$domain][$string_name_prefix])) { |
|
106 | + if (isset($honor_constants[$domain][$string_name_prefix])) { |
|
107 | 107 | $found_constants = array_keys($constants, $string_name); |
108 | - foreach($found_constants as $constant_name) { |
|
108 | + foreach ($found_constants as $constant_name) { |
|
109 | 109 | $honor_prefix_list = is_array($honor_constants[$domain][$string_name_prefix]) ? $honor_constants[$domain][$string_name_prefix] : array($honor_constants[$domain][$string_name_prefix]); |
110 | - foreach($honor_prefix_list as $honor_prefix) { |
|
111 | - if(strpos($constant_name, $honor_prefix) === 0) { |
|
110 | + foreach ($honor_prefix_list as $honor_prefix) { |
|
111 | + if (strpos($constant_name, $honor_prefix) === 0) { |
|
112 | 112 | $string_name_new = $constant_name; |
113 | 113 | break; |
114 | 114 | } |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | |
119 | 119 | $string_name_new = $string_name_new ? $string_name_new : "'{$string_name}'"; |
120 | 120 | fwrite($file_handler, "{$ident}{$string_name_new} => "); |
121 | - if(isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) { |
|
121 | + if (isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) { |
|
122 | 122 | fwrite($file_handler, "'" . str_replace(array("\\", "'"), array('\\\\', "\\'"), $string_value[$lang_id]) . "',"); |
123 | 123 | // fwrite($file_handler, "'" . addslashes($string_value[$lang_id]) . "',"); |
124 | 124 | } else { |
125 | 125 | $string_name_prefix = $string_name_prefix . "[{$string_name}]"; |
126 | 126 | fwrite($file_handler, "array(\r\n"); |
127 | - foreach($string_value as $arr_name => $arr_data) { |
|
127 | + foreach ($string_value as $arr_name => $arr_data) { |
|
128 | 128 | adm_lng_write_string($arr_name, $arr_data, $ident . ' ', $string_name_prefix); |
129 | 129 | } |
130 | 130 | fwrite($file_handler, "{$ident}),\r\n"); |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | $languages_info = lng_get_list(); |
145 | 145 | $domain = sys_get_param_str('domain'); |
146 | 146 | |
147 | -if($domain) { |
|
147 | +if ($domain) { |
|
148 | 148 | $lang_new = sys_get_param('lang_new'); |
149 | - if(!empty($lang_new) && is_array($lang_new)) { |
|
149 | + if (!empty($lang_new) && is_array($lang_new)) { |
|
150 | 150 | $constants = get_defined_constants(true); |
151 | 151 | $constants = $constants['user']; |
152 | 152 | ksort($constants); |
153 | - foreach($languages_info as $lang_id => $land_data) { |
|
153 | + foreach ($languages_info as $lang_id => $land_data) { |
|
154 | 154 | $file_handler = fopen(SN_ROOT_PHYSICAL . "language/{$lang_id}/{$domain}.mo.php.new", 'w'); |
155 | 155 | fwrite($file_handler, "<?php\r\n\r\n/*\r\n############################################################################# |
156 | 156 | # Filename: {$domain}.mo.php |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | # Website: http://www.supernova.ws |
159 | 159 | # Description: Massive Multiplayer Online Browser Space Strategy Game\r\n#\r\n"); |
160 | 160 | |
161 | - foreach($land_data['LANG_COPYRIGHT'] as $lang_copyright) { |
|
161 | + foreach ($land_data['LANG_COPYRIGHT'] as $lang_copyright) { |
|
162 | 162 | $lang_copyright = str_replace(array('©', '"', '<', '>'), array('©', '"', '<', '>'), $lang_copyright); |
163 | 163 | fwrite($file_handler, "# {$lang_copyright}\r\n"); |
164 | 164 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | /**\r\n*\r\n* @package language\r\n* @system [{$land_data['LANG_NAME_ENGLISH']}]\r\n* @version " . SN_VERSION . "\r\n*\r\n*/\r\n |
167 | 167 | /**\r\n* DO NOT CHANGE\r\n*/\r\n\r\nif (!defined('INSIDE')) die();\r\n |
168 | 168 | \$a_lang_array = array(\r\n"); |
169 | - foreach($lang_new as $string_name => $string_value) { |
|
169 | + foreach ($lang_new as $string_name => $string_value) { |
|
170 | 170 | adm_lng_write_string($string_name, $string_value); |
171 | 171 | } |
172 | 172 | fwrite($file_handler, ");\r\n"); |
@@ -176,21 +176,21 @@ discard block |
||
176 | 176 | sys_redirect("admin_locale.php?domain={$domain}"); |
177 | 177 | } |
178 | 178 | |
179 | - foreach($languages_info as $lang_id => $lang_data) { |
|
179 | + foreach ($languages_info as $lang_id => $lang_data) { |
|
180 | 180 | $template->assign_block_vars('language', $lang_data); |
181 | 181 | $full_filename = SN_ROOT_PHYSICAL . "language/{$lang_id}/{$domain}.mo.php"; |
182 | 182 | $languages[$lang_id] = adm_lng_load($full_filename . (file_exists($full_filename . '.new') ? '.new' : '')); |
183 | - foreach($languages[$lang_id] as $locale_string_name => $cork) { |
|
183 | + foreach ($languages[$lang_id] as $locale_string_name => $cork) { |
|
184 | 184 | adm_lng_assign_string($lang_id, "[{$locale_string_name}]", $languages[$lang_id][$locale_string_name]); |
185 | 185 | } |
186 | 186 | } |
187 | 187 | |
188 | - foreach($locale_string_template as $locale_string_name => $locale_string_list) { |
|
188 | + foreach ($locale_string_template as $locale_string_name => $locale_string_list) { |
|
189 | 189 | $template->assign_block_vars('string', array( |
190 | 190 | 'NAME' => $locale_string_name, |
191 | 191 | )); |
192 | 192 | |
193 | - foreach($languages_info as $lang_id => $cork2) { |
|
193 | + foreach ($languages_info as $lang_id => $cork2) { |
|
194 | 194 | $template->assign_block_vars('string.locale', array( |
195 | 195 | 'LANG' => $lang_id, |
196 | 196 | 'VALUE' => $locale_string_list["[{$lang_id}]"], |
@@ -206,17 +206,17 @@ discard block |
||
206 | 206 | $dir = dir($path); |
207 | 207 | while (false !== ($lang_id = $dir->read())) { |
208 | 208 | $full_path = $path . $lang_id; |
209 | - if($lang_id[0] != "." && is_dir($full_path)) { |
|
209 | + if ($lang_id[0] != "." && is_dir($full_path)) { |
|
210 | 210 | $lang_file_list = dir($full_path); |
211 | 211 | while (false !== ($filename = $lang_file_list->read())) { |
212 | 212 | $lang_domain = strtolower(substr($filename, 0, strpos($filename, '.'))); |
213 | - if(!$lang_domain) { |
|
213 | + if (!$lang_domain) { |
|
214 | 214 | continue; |
215 | 215 | } |
216 | 216 | |
217 | 217 | $file_ext = strtolower(substr($filename, strpos($filename, '.'))); |
218 | - if($lang_domain != 'language') { |
|
219 | - if($file_ext == '.mo.php.new' || ($file_ext == '.mo.php' && empty($languages[$lang_id][$lang_domain]))) { |
|
218 | + if ($lang_domain != 'language') { |
|
219 | + if ($file_ext == '.mo.php.new' || ($file_ext == '.mo.php' && empty($languages[$lang_id][$lang_domain]))) { |
|
220 | 220 | $language_domains[$lang_domain] = $lang_domain; |
221 | 221 | $languages[$lang_id][$lang_domain] = $lang_domain; |
222 | 222 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | } |
227 | 227 | $dir->close(); |
228 | 228 | |
229 | - foreach($language_domains as $lang_domain) { |
|
229 | + foreach ($language_domains as $lang_domain) { |
|
230 | 230 | $template->assign_block_vars('domain', array( |
231 | 231 | 'NAME' => $lang_domain, |
232 | 232 | )); |
@@ -15,7 +15,7 @@ |
||
15 | 15 | define('SN_PAYMENT_REQUEST_OK', 0); |
16 | 16 | define('SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT', 1); |
17 | 17 | define('SN_PAYMENT_REQUEST_ERROR_PAYLINK_UNSUPPORTED', 2); |
18 | -define('SN_PAYMENT_REQUEST_IP_WRONG', 3); // Неправильный IP входящей системы - обычно хак |
|
18 | +define('SN_PAYMENT_REQUEST_IP_WRONG', 3); // Неправильный IP входящей системы - обычно хак |
|
19 | 19 | define('SN_PAYMENT_REQUEST_COMMAND_UNSUPPORTED', 4); // Неподдерживаемая команда - обычно хак |
20 | 20 | define('SN_PAYMENT_REQUEST_SIGNATURE_INVALID', 5); // Неправильная подпись или не сошлась контрольная сумма - обычно хак |
21 | 21 | define('SN_MODULE_DISABLED', 6); // Модуль отключен // УНИВЕРСАЛЬНЫЙ ОТВЕТ! |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function geometry_progression_sum($n, $b1, $q) { |
4 | - return $q != 1 ? ($b1 * (pow($q, $n) - 1)/($q - 1)) : ($n * $b1); |
|
4 | + return $q != 1 ? ($b1 * (pow($q, $n) - 1) / ($q - 1)) : ($n * $b1); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | function sn_floor($value) |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return float|int |
45 | 45 | */ |
46 | -function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | - if($cut_extreme) { |
|
46 | +function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | + if ($cut_extreme) { |
|
48 | 48 | $range_start--; |
49 | 49 | $range_end++; |
50 | 50 | } |
@@ -104,47 +104,47 @@ discard block |
||
104 | 104 | } |
105 | 105 | function linear_calc(&$linear, $from = 0, $debug = false) |
106 | 106 | { |
107 | - for($i = $from; $i < count($linear); $i++) |
|
107 | + for ($i = $from; $i < count($linear); $i++) |
|
108 | 108 | { |
109 | 109 | $eq = &$linear[$i]; |
110 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
110 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
111 | 111 | { |
112 | 112 | $eq[$j] /= $eq[$from]; |
113 | 113 | } |
114 | 114 | } |
115 | - if($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
115 | + if ($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
116 | 116 | |
117 | - for($i = $from + 1; $i < count($linear); $i++) |
|
117 | + for ($i = $from + 1; $i < count($linear); $i++) |
|
118 | 118 | { |
119 | 119 | $eq = &$linear[$i]; |
120 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
120 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
121 | 121 | { |
122 | 122 | $eq[$j] -= $linear[$from][$j]; |
123 | 123 | } |
124 | 124 | } |
125 | - if($debug) pdump($linear, 'Подставили х' . $from); |
|
125 | + if ($debug) pdump($linear, 'Подставили х' . $from); |
|
126 | 126 | |
127 | - if($from < count($linear) - 1) |
|
127 | + if ($from < count($linear) - 1) |
|
128 | 128 | { |
129 | 129 | linear_calc($linear, $from + 1, $debug); |
130 | 130 | } |
131 | 131 | |
132 | - if($from) |
|
132 | + if ($from) |
|
133 | 133 | { |
134 | - for($i = 0; $i < $from; $i++) |
|
134 | + for ($i = 0; $i < $from; $i++) |
|
135 | 135 | { |
136 | 136 | $eq = &$linear[$i]; |
137 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
137 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
138 | 138 | { |
139 | 139 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
140 | 140 | } |
141 | 141 | } |
142 | - if($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
142 | + if ($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
143 | 143 | } |
144 | 144 | else |
145 | 145 | { |
146 | - if($debug) pdump($linear, 'Результат' . $from); |
|
147 | - foreach($linear as $index => &$eq) |
|
146 | + if ($debug) pdump($linear, 'Результат' . $from); |
|
147 | + foreach ($linear as $index => &$eq) |
|
148 | 148 | { |
149 | 149 | pdump($eq[count($linear)], 'x' . $index); |
150 | 150 | } |
@@ -4,16 +4,14 @@ discard block |
||
4 | 4 | return $q != 1 ? ($b1 * (pow($q, $n) - 1)/($q - 1)) : ($n * $b1); |
5 | 5 | } |
6 | 6 | |
7 | -function sn_floor($value) |
|
8 | -{ |
|
7 | +function sn_floor($value) { |
|
9 | 8 | return $value >= 0 ? floor($value) : ceil($value); |
10 | 9 | } |
11 | 10 | |
12 | 11 | // Эта функция выдает нормально распределенное случайное число с матожиднием $mu и стандартным отклонением $sigma |
13 | 12 | // $strict - количество $sigma, по которым идет округление функции. Т.е. $strict = 3 означает, что диапазон значений обрезается по +-3 * $sigma |
14 | 13 | // Используется http://ru.wikipedia.org/wiki/Преобразование_Бокса_—_Мюллера |
15 | -function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false) |
|
16 | -{ |
|
14 | +function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false) { |
|
17 | 15 | // http://ru.wikipedia.org/wiki/Среднеквадратическое_отклонение |
18 | 16 | // При $mu = 0 (график симметричный, цифры только для половины графика) |
19 | 17 | // От 0 до $sigma ~ 34.1% |
@@ -43,7 +41,7 @@ discard block |
||
43 | 41 | * |
44 | 42 | * @return float|int |
45 | 43 | */ |
46 | -function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
44 | +function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | 45 | if($cut_extreme) { |
48 | 46 | $range_start--; |
49 | 47 | $range_end++; |
@@ -98,12 +96,10 @@ discard block |
||
98 | 96 | * |
99 | 97 | * @return float |
100 | 98 | */ |
101 | -function avg($array) |
|
102 | -{ |
|
99 | +function avg($array) { |
|
103 | 100 | return is_array($array) && count($array) ? array_sum($array) / count($array) : 0; |
104 | 101 | } |
105 | -function linear_calc(&$linear, $from = 0, $debug = false) |
|
106 | -{ |
|
102 | +function linear_calc(&$linear, $from = 0, $debug = false) { |
|
107 | 103 | for($i = $from; $i < count($linear); $i++) |
108 | 104 | { |
109 | 105 | $eq = &$linear[$i]; |
@@ -112,7 +108,9 @@ discard block |
||
112 | 108 | $eq[$j] /= $eq[$from]; |
113 | 109 | } |
114 | 110 | } |
115 | - if($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
111 | + if($debug) { |
|
112 | + pdump($linear, 'Нормализовано по х' . $from); |
|
113 | + } |
|
116 | 114 | |
117 | 115 | for($i = $from + 1; $i < count($linear); $i++) |
118 | 116 | { |
@@ -122,7 +120,9 @@ discard block |
||
122 | 120 | $eq[$j] -= $linear[$from][$j]; |
123 | 121 | } |
124 | 122 | } |
125 | - if($debug) pdump($linear, 'Подставили х' . $from); |
|
123 | + if($debug) { |
|
124 | + pdump($linear, 'Подставили х' . $from); |
|
125 | + } |
|
126 | 126 | |
127 | 127 | if($from < count($linear) - 1) |
128 | 128 | { |
@@ -139,11 +139,14 @@ discard block |
||
139 | 139 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
140 | 140 | } |
141 | 141 | } |
142 | - if($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
143 | - } |
|
144 | - else |
|
142 | + if($debug) { |
|
143 | + pdump($linear, 'Подставили обратно х' . $from); |
|
144 | + } |
|
145 | + } else |
|
145 | 146 | { |
146 | - if($debug) pdump($linear, 'Результат' . $from); |
|
147 | + if($debug) { |
|
148 | + pdump($linear, 'Результат' . $from); |
|
149 | + } |
|
147 | 150 | foreach($linear as $index => &$eq) |
148 | 151 | { |
149 | 152 | pdump($eq[count($linear)], 'x' . $index); |
@@ -2,12 +2,10 @@ |
||
2 | 2 | |
3 | 3 | // Эти функции будут переписаны по добавлению инфы в БД |
4 | 4 | |
5 | -function pname_factory_production_field_name($factory_unit_id) |
|
6 | -{ |
|
5 | +function pname_factory_production_field_name($factory_unit_id) { |
|
7 | 6 | return get_unit_param($factory_unit_id, P_NAME) . '_porcent'; |
8 | 7 | } |
9 | 8 | |
10 | -function pname_resource_name($resource_id) |
|
11 | -{ |
|
9 | +function pname_resource_name($resource_id) { |
|
12 | 10 | return get_unit_param($resource_id, P_NAME); |
13 | 11 | } |
14 | 12 | \ No newline at end of file |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | |
272 | 272 | |
273 | 273 | if (($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) { |
274 | - if(!empty($render_user['user_birthday'])) { |
|
274 | + if (!empty($render_user['user_birthday'])) { |
|
275 | 275 | $result[NICK_BIRTHDAY] = ''; |
276 | 276 | } |
277 | 277 | } |
@@ -283,13 +283,13 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | if (($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
286 | - if(isset($render_user['vacation'])) { |
|
286 | + if (isset($render_user['vacation'])) { |
|
287 | 287 | $result[NICK_VACATION] = $render_user['vacation']; |
288 | 288 | } |
289 | 289 | } |
290 | 290 | |
291 | 291 | if ($options === true || !empty($options['icons']) || !empty($options['player_rank'])) { |
292 | - if(isset($render_user['total_points'])) { |
|
292 | + if (isset($render_user['total_points'])) { |
|
293 | 293 | $result[NICK_RANK] = SN::$gc->playerLevelHelper->getPointLevel($render_user['total_points'], $render_user['authlevel']); |
294 | 294 | } |
295 | 295 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | } |
314 | 314 | |
315 | 315 | if ($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
316 | - if(isset($render_user['ally_tag'])) { |
|
316 | + if (isset($render_user['ally_tag'])) { |
|
317 | 317 | $result[NICK_ALLY] = $render_user['ally_tag']; |
318 | 318 | } |
319 | 319 | } |