@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | include_once('common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 4 | 4 | |
| 5 | -if(sn_module_get_active_count('payment') && !defined('SN_GOOGLE')) { |
|
| 5 | +if (sn_module_get_active_count('payment') && !defined('SN_GOOGLE')) { |
|
| 6 | 6 | sys_redirect('metamatter.php'); |
| 7 | 7 | } |
| 8 | 8 | |
@@ -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 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | $args = func_get_args(); |
| 62 | 62 | |
| 63 | - switch(func_num_args()) |
|
| 63 | + switch (func_num_args()) |
|
| 64 | 64 | { |
| 65 | 65 | case 0: |
| 66 | 66 | // trigger_error('median() requires at least one parameter',E_USER_WARNING); |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | // fallthrough |
| 73 | 73 | |
| 74 | 74 | default: |
| 75 | - if(!is_array($args)) |
|
| 75 | + if (!is_array($args)) |
|
| 76 | 76 | { |
| 77 | 77 | // trigger_error('median() requires a list of numbers to operate on or an array of numbers', E_USER_NOTICE); |
| 78 | 78 | return false; |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | $n = count($args); |
| 84 | 84 | $h = intval($n / 2); |
| 85 | 85 | |
| 86 | - if($n % 2 == 0) |
|
| 86 | + if ($n % 2 == 0) |
|
| 87 | 87 | { |
| 88 | - $median = ($args[$h] + $args[$h-1]) / 2; |
|
| 88 | + $median = ($args[$h] + $args[$h - 1]) / 2; |
|
| 89 | 89 | } |
| 90 | 90 | else |
| 91 | 91 | { |
@@ -103,47 +103,47 @@ discard block |
||
| 103 | 103 | } |
| 104 | 104 | function linear_calc(&$linear, $from = 0, $debug = false) |
| 105 | 105 | { |
| 106 | - for($i = $from; $i < count($linear); $i++) |
|
| 106 | + for ($i = $from; $i < count($linear); $i++) |
|
| 107 | 107 | { |
| 108 | 108 | $eq = &$linear[$i]; |
| 109 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
| 109 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
| 110 | 110 | { |
| 111 | 111 | $eq[$j] /= $eq[$from]; |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | - if($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
| 114 | + if ($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
| 115 | 115 | |
| 116 | - for($i = $from + 1; $i < count($linear); $i++) |
|
| 116 | + for ($i = $from + 1; $i < count($linear); $i++) |
|
| 117 | 117 | { |
| 118 | 118 | $eq = &$linear[$i]; |
| 119 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
| 119 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
| 120 | 120 | { |
| 121 | 121 | $eq[$j] -= $linear[$from][$j]; |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | - if($debug) pdump($linear, 'Подставили х' . $from); |
|
| 124 | + if ($debug) pdump($linear, 'Подставили х' . $from); |
|
| 125 | 125 | |
| 126 | - if($from < count($linear) - 1) |
|
| 126 | + if ($from < count($linear) - 1) |
|
| 127 | 127 | { |
| 128 | 128 | linear_calc($linear, $from + 1, $debug); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if($from) |
|
| 131 | + if ($from) |
|
| 132 | 132 | { |
| 133 | - for($i = 0; $i < $from; $i++) |
|
| 133 | + for ($i = 0; $i < $from; $i++) |
|
| 134 | 134 | { |
| 135 | 135 | $eq = &$linear[$i]; |
| 136 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
| 136 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
| 137 | 137 | { |
| 138 | 138 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
| 139 | 139 | } |
| 140 | 140 | } |
| 141 | - if($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
| 141 | + if ($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
| 142 | 142 | } |
| 143 | 143 | else |
| 144 | 144 | { |
| 145 | - if($debug) pdump($linear, 'Результат' . $from); |
|
| 146 | - foreach($linear as $index => &$eq) |
|
| 145 | + if ($debug) pdump($linear, 'Результат' . $from); |
|
| 146 | + foreach ($linear as $index => &$eq) |
|
| 147 | 147 | { |
| 148 | 148 | pdump($eq[count($linear)], 'x' . $index); |
| 149 | 149 | } |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | /** |
| 38 | 38 | * @param float $range_start - Начало диапазона |
| 39 | 39 | * @param float $range_end - Конец диапазона |
| 40 | - * @param bool|int $round - До скольки знаков округлять результат. False - не округлять, True - округлять до целого, 1 - округлять до десятков, 2 - до сотен итд |
|
| 40 | + * @param boolean $round - До скольки знаков округлять результат. False - не округлять, True - округлять до целого, 1 - округлять до десятков, 2 - до сотен итд |
|
| 41 | 41 | * @param int $strict - В сколько сигм надо уложить результат |
| 42 | 42 | * @param bool|false $cut_extreme - надо ли обрезать крайние значения. Например, при $strict = 2 их слишком много |
| 43 | 43 | * |
@@ -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++; |
@@ -56,8 +54,7 @@ discard block |
||
| 56 | 54 | return $result; |
| 57 | 55 | } |
| 58 | 56 | |
| 59 | -function median() |
|
| 60 | -{ |
|
| 57 | +function median() { |
|
| 61 | 58 | $args = func_get_args(); |
| 62 | 59 | |
| 63 | 60 | switch(func_num_args()) |
@@ -86,8 +83,7 @@ discard block |
||
| 86 | 83 | if($n % 2 == 0) |
| 87 | 84 | { |
| 88 | 85 | $median = ($args[$h] + $args[$h-1]) / 2; |
| 89 | - } |
|
| 90 | - else |
|
| 86 | + } else |
|
| 91 | 87 | { |
| 92 | 88 | $median = $args[$h]; |
| 93 | 89 | } |
@@ -97,12 +93,10 @@ discard block |
||
| 97 | 93 | |
| 98 | 94 | return $median; |
| 99 | 95 | } |
| 100 | -function average($arr) |
|
| 101 | -{ |
|
| 96 | +function average($arr) { |
|
| 102 | 97 | return is_array($arr) && count($arr) ? array_sum($arr) / count($arr) : 0; |
| 103 | 98 | } |
| 104 | -function linear_calc(&$linear, $from = 0, $debug = false) |
|
| 105 | -{ |
|
| 99 | +function linear_calc(&$linear, $from = 0, $debug = false) { |
|
| 106 | 100 | for($i = $from; $i < count($linear); $i++) |
| 107 | 101 | { |
| 108 | 102 | $eq = &$linear[$i]; |
@@ -111,7 +105,9 @@ discard block |
||
| 111 | 105 | $eq[$j] /= $eq[$from]; |
| 112 | 106 | } |
| 113 | 107 | } |
| 114 | - if($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
| 108 | + if($debug) { |
|
| 109 | + pdump($linear, 'Нормализовано по х' . $from); |
|
| 110 | + } |
|
| 115 | 111 | |
| 116 | 112 | for($i = $from + 1; $i < count($linear); $i++) |
| 117 | 113 | { |
@@ -121,7 +117,9 @@ discard block |
||
| 121 | 117 | $eq[$j] -= $linear[$from][$j]; |
| 122 | 118 | } |
| 123 | 119 | } |
| 124 | - if($debug) pdump($linear, 'Подставили х' . $from); |
|
| 120 | + if($debug) { |
|
| 121 | + pdump($linear, 'Подставили х' . $from); |
|
| 122 | + } |
|
| 125 | 123 | |
| 126 | 124 | if($from < count($linear) - 1) |
| 127 | 125 | { |
@@ -138,11 +136,14 @@ discard block |
||
| 138 | 136 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
| 139 | 137 | } |
| 140 | 138 | } |
| 141 | - if($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
| 142 | - } |
|
| 143 | - else |
|
| 139 | + if($debug) { |
|
| 140 | + pdump($linear, 'Подставили обратно х' . $from); |
|
| 141 | + } |
|
| 142 | + } else |
|
| 144 | 143 | { |
| 145 | - if($debug) pdump($linear, 'Результат' . $from); |
|
| 144 | + if($debug) { |
|
| 145 | + pdump($linear, 'Результат' . $from); |
|
| 146 | + } |
|
| 146 | 147 | foreach($linear as $index => &$eq) |
| 147 | 148 | { |
| 148 | 149 | pdump($eq[count($linear)], 'x' . $index); |
@@ -815,7 +815,7 @@ |
||
| 815 | 815 | '%H' => '(?P<H>[0-9]{2})', |
| 816 | 816 | '%M' => '(?P<M>[0-9]{2})', |
| 817 | 817 | '%S' => '(?P<S>[0-9]{2})', |
| 818 | - // usw.. |
|
| 818 | + // usw.. |
|
| 819 | 819 | ); |
| 820 | 820 | |
| 821 | 821 | $rexep = "#".strtr(preg_quote($format), $masks)."#"; |
@@ -283,7 +283,7 @@ |
||
| 283 | 283 | */ |
| 284 | 284 | function sys_get_param($param_name, $default = '') |
| 285 | 285 | { |
| 286 | - return $_POST[$param_name] !== NULL ? $_POST[$param_name] : ($_GET[$param_name] !== NULL ? $_GET[$param_name] : $default); |
|
| 286 | + return $_POST[$param_name] !== null ? $_POST[$param_name] : ($_GET[$param_name] !== null ? $_GET[$param_name] : $default); |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | function sys_get_param_id($param_name, $default = 0) |
@@ -12,6 +12,9 @@ discard block |
||
| 12 | 12 | require_once('general/compatibility.php'); |
| 13 | 13 | require_once('general_pname.php'); |
| 14 | 14 | |
| 15 | +/** |
|
| 16 | + * @param string $func_name |
|
| 17 | + */ |
|
| 15 | 18 | function sn_function_call($func_name, $func_arg = array()) |
| 16 | 19 | { |
| 17 | 20 | global $functions; // All data in $functions should be normalized to valid 'callable' state: '<function_name>'|array('<object_name>', '<method_name>') |
@@ -65,6 +68,9 @@ discard block |
||
| 65 | 68 | |
| 66 | 69 | // ---------------------------------------------------------------------------------------------------------------- |
| 67 | 70 | // Fonction de lecture / ecriture / exploitation de templates |
| 71 | +/** |
|
| 72 | + * @param string $filename |
|
| 73 | + */ |
|
| 68 | 74 | function sys_file_read($filename) |
| 69 | 75 | { |
| 70 | 76 | return @file_get_contents($filename); |
@@ -111,7 +117,7 @@ discard block |
||
| 111 | 117 | /** |
| 112 | 118 | * Получение курса обмены валюты в серверную валюту |
| 113 | 119 | * |
| 114 | - * @param $currency_symbol |
|
| 120 | + * @param string $currency_symbol |
|
| 115 | 121 | * |
| 116 | 122 | * @return float |
| 117 | 123 | */ |
@@ -148,6 +154,7 @@ discard block |
||
| 148 | 154 | null - standard result |
| 149 | 155 | true - return only style class for current params |
| 150 | 156 | false - return array('text' => $ret, 'class' => $class), where $ret - unstyled |
| 157 | + * @param boolean $style |
|
| 151 | 158 | */ |
| 152 | 159 | |
| 153 | 160 | function pretty_number($n, $floor = true, $color = false, $limit = false, $style = null) |
@@ -267,6 +274,9 @@ discard block |
||
| 267 | 274 | return preg_replace($ListCensure, '*', $String); |
| 268 | 275 | } |
| 269 | 276 | |
| 277 | +/** |
|
| 278 | + * @param string $email |
|
| 279 | + */ |
|
| 270 | 280 | function is_email($email) { |
| 271 | 281 | return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email)); |
| 272 | 282 | } |
@@ -303,6 +313,9 @@ discard block |
||
| 303 | 313 | return floatval(sys_get_param($param_name, $default)); |
| 304 | 314 | } |
| 305 | 315 | |
| 316 | +/** |
|
| 317 | + * @param string $param_name |
|
| 318 | + */ |
|
| 306 | 319 | function sys_get_param_escaped($param_name, $default = '') |
| 307 | 320 | { |
| 308 | 321 | return db_escape(sys_get_param($param_name, $default)); |
@@ -547,6 +560,9 @@ discard block |
||
| 547 | 560 | } |
| 548 | 561 | |
| 549 | 562 | // Generates random string of $length symbols from $allowed_chars charset |
| 563 | +/** |
|
| 564 | + * @param string $allowed_chars |
|
| 565 | + */ |
|
| 550 | 566 | function sys_random_string($length = 16, $allowed_chars = SN_SYS_SEC_CHARS_ALLOWED) { |
| 551 | 567 | $allowed_length = strlen($allowed_chars); |
| 552 | 568 | |
@@ -672,6 +688,9 @@ discard block |
||
| 672 | 688 | return implode(';', $fleet_string); |
| 673 | 689 | } |
| 674 | 690 | |
| 691 | +/** |
|
| 692 | + * @param string $body |
|
| 693 | + */ |
|
| 675 | 694 | function mymail($email_unsafe, $title, $body, $from = '', $html = false) { |
| 676 | 695 | global $config, $lang; |
| 677 | 696 | |
@@ -959,6 +978,9 @@ discard block |
||
| 959 | 978 | return serialize($nick_array); |
| 960 | 979 | } |
| 961 | 980 | |
| 981 | +/** |
|
| 982 | + * @param string $nick_string |
|
| 983 | + */ |
|
| 962 | 984 | function player_nick_uncompact($nick_string) { |
| 963 | 985 | try { |
| 964 | 986 | $result = unserialize($nick_string); |
@@ -1262,6 +1284,9 @@ discard block |
||
| 1262 | 1284 | return $ranks; |
| 1263 | 1285 | } |
| 1264 | 1286 | |
| 1287 | +/** |
|
| 1288 | + * @param boolean $planet_id |
|
| 1289 | + */ |
|
| 1265 | 1290 | function sys_player_new_adjust($user_id, $planet_id){return sn_function_call('sys_player_new_adjust', array($user_id, $planet_id, &$result));} |
| 1266 | 1291 | function sn_sys_player_new_adjust($user_id, $planet_id, &$result) { |
| 1267 | 1292 | return $result; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | { |
| 17 | 17 | global $functions; // All data in $functions should be normalized to valid 'callable' state: '<function_name>'|array('<object_name>', '<method_name>') |
| 18 | 18 | |
| 19 | - if(is_array($functions[$func_name]) && !is_callable($functions[$func_name])) |
|
| 19 | + if (is_array($functions[$func_name]) && !is_callable($functions[$func_name])) |
|
| 20 | 20 | { |
| 21 | 21 | // Chain-callable functions should be made as following: |
| 22 | 22 | // 1. Never use incomplete calls with parameters "by default" |
@@ -24,11 +24,11 @@ discard block |
||
| 24 | 24 | // 3. Use same format for original value and cumulative result (if there is original value) |
| 25 | 25 | // 4. Honor cumulative result |
| 26 | 26 | // 5. Return cumulative result |
| 27 | - foreach($functions[$func_name] as $func_chain_name) |
|
| 27 | + foreach ($functions[$func_name] as $func_chain_name) |
|
| 28 | 28 | { |
| 29 | 29 | // По идее - это уже тут не нужно, потому что оно все должно быть callable к этому моменту |
| 30 | 30 | // Но для старых модулей... |
| 31 | - if(is_callable($func_chain_name)) |
|
| 31 | + if (is_callable($func_chain_name)) |
|
| 32 | 32 | { |
| 33 | 33 | $result = call_user_func_array($func_chain_name, $func_arg); |
| 34 | 34 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | // TODO: This is left for backward compatibility. Appropriate code should be rewrote! |
| 40 | 40 | $func_name = isset($functions[$func_name]) && is_callable($functions[$func_name]) ? $functions[$func_name] : ('sn_' . $func_name); |
| 41 | - if(is_callable($func_name)) |
|
| 41 | + if (is_callable($func_name)) |
|
| 42 | 42 | { |
| 43 | 43 | $result = call_user_func_array($func_name, $func_arg); |
| 44 | 44 | } |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | * @param string $page_name - имя страницы, для которого должен был быть выполнен хук |
| 55 | 55 | */ |
| 56 | 56 | function execute_hooks(&$hook_list, &$template, $hook_type = null, $page_name = null) { |
| 57 | - if(!empty($hook_list)) { |
|
| 58 | - foreach($hook_list as $hook) { |
|
| 59 | - if(is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) { |
|
| 57 | + if (!empty($hook_list)) { |
|
| 58 | + foreach ($hook_list as $hook) { |
|
| 59 | + if (is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) { |
|
| 60 | 60 | $template = call_user_func($hook_call, $template, $hook_type, $page_name); |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -75,19 +75,19 @@ discard block |
||
| 75 | 75 | return @file_put_contents($filename, $content, FILE_APPEND); |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | -function get_game_speed($plain = false){return sn_function_call('get_game_speed', array($plain, &$result));} |
|
| 78 | +function get_game_speed($plain = false) {return sn_function_call('get_game_speed', array($plain, &$result)); } |
|
| 79 | 79 | function sn_get_game_speed($plain = false, &$result) { |
| 80 | 80 | return $result = classSupernova::$config->game_speed ? classSupernova::$config->game_speed : 1; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | -function flt_server_flight_speed_multiplier($plain = false){return sn_function_call('flt_server_flight_speed_multiplier', array($plain, &$result));} |
|
| 83 | +function flt_server_flight_speed_multiplier($plain = false) {return sn_function_call('flt_server_flight_speed_multiplier', array($plain, &$result)); } |
|
| 84 | 84 | function sn_flt_server_flight_speed_multiplier($plain = false, &$result) { |
| 85 | 85 | global $config; |
| 86 | 86 | |
| 87 | 87 | return $result = classSupernova::$config->fleet_speed; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | -function game_resource_multiplier($plain = false){return sn_function_call('game_resource_multiplier', array($plain,&$result));} |
|
| 90 | +function game_resource_multiplier($plain = false) {return sn_function_call('game_resource_multiplier', array($plain, &$result)); } |
|
| 91 | 91 | function sn_game_resource_multiplier($plain = false, &$result) { |
| 92 | 92 | global $config; |
| 93 | 93 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * |
| 102 | 102 | * @return mixed |
| 103 | 103 | */ |
| 104 | -function get_mm_cost($plain = false){return sn_function_call('get_mm_cost', array($plain, &$result));} |
|
| 104 | +function get_mm_cost($plain = false) {return sn_function_call('get_mm_cost', array($plain, &$result)); } |
|
| 105 | 105 | function sn_get_mm_cost($plain = false, &$result) { |
| 106 | 106 | global $config; |
| 107 | 107 | |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | function pretty_number($n, $floor = true, $color = false, $limit = false, $style = null) |
| 154 | 154 | { |
| 155 | 155 | $n = floatval($n); |
| 156 | - if(is_int($floor)) |
|
| 156 | + if (is_int($floor)) |
|
| 157 | 157 | { |
| 158 | 158 | $n = round($n, $floor); |
| 159 | 159 | } |
| 160 | - elseif($floor === true) |
|
| 160 | + elseif ($floor === true) |
|
| 161 | 161 | { |
| 162 | 162 | $n = floor($n); |
| 163 | 163 | $floor = 0; |
@@ -170,11 +170,11 @@ discard block |
||
| 170 | 170 | $ret = $n; |
| 171 | 171 | |
| 172 | 172 | $suffix = ''; |
| 173 | - if($limit) |
|
| 173 | + if ($limit) |
|
| 174 | 174 | { |
| 175 | - if($ret > 0) |
|
| 175 | + if ($ret > 0) |
|
| 176 | 176 | { |
| 177 | - while($ret > $limit) |
|
| 177 | + while ($ret > $limit) |
|
| 178 | 178 | { |
| 179 | 179 | $suffix .= 'k'; |
| 180 | 180 | $ret = round($ret / 1000); |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | else |
| 184 | 184 | { |
| 185 | - while($ret < -$limit) |
|
| 185 | + while ($ret < -$limit) |
|
| 186 | 186 | { |
| 187 | 187 | $suffix .= 'k'; |
| 188 | 188 | $ret = round($ret / 1000); |
@@ -193,13 +193,13 @@ discard block |
||
| 193 | 193 | $ret = number_format($ret, $floor, ',', '.'); |
| 194 | 194 | $ret .= $suffix; |
| 195 | 195 | |
| 196 | - if($color !== false) |
|
| 196 | + if ($color !== false) |
|
| 197 | 197 | { |
| 198 | - if($color === true) |
|
| 198 | + if ($color === true) |
|
| 199 | 199 | { |
| 200 | 200 | $class = $n == 0 ? 'zero' : ($n > 0 ? 'positive' : 'negative'); |
| 201 | 201 | } |
| 202 | - elseif($color >= 0) |
|
| 202 | + elseif ($color >= 0) |
|
| 203 | 203 | { |
| 204 | 204 | $class = $n == $color ? 'zero' : ($n < $color ? 'positive' : 'negative'); |
| 205 | 205 | } |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $class = ($n == -$color) ? 'zero' : ($n < -$color ? 'negative' : 'positive'); |
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - if(!isset($style)) |
|
| 211 | + if (!isset($style)) |
|
| 212 | 212 | { |
| 213 | 213 | $ret = "<span class='{$class}'>{$ret}</span>"; |
| 214 | 214 | } |
@@ -343,13 +343,13 @@ discard block |
||
| 343 | 343 | function sys_get_param_phone($param_name, $default = '') |
| 344 | 344 | { |
| 345 | 345 | $phone_raw = sys_get_param_str_unsafe($param_name, $default = ''); |
| 346 | - if($phone_raw) |
|
| 346 | + if ($phone_raw) |
|
| 347 | 347 | { |
| 348 | 348 | $phone = $phone_raw[0] == '+' ? '+' : ''; |
| 349 | - for($i = 0; $i < strlen($phone_raw); $i++) |
|
| 349 | + for ($i = 0; $i < strlen($phone_raw); $i++) |
|
| 350 | 350 | { |
| 351 | 351 | $ord = ord($phone_raw[$i]); |
| 352 | - if($ord >= 48 && $ord <= 57) |
|
| 352 | + if ($ord >= 48 && $ord <= 57) |
|
| 353 | 353 | { |
| 354 | 354 | $phone .= $phone_raw[$i]; |
| 355 | 355 | } |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | */ |
| 377 | 377 | function CheckAbandonPlanetState(&$planet) |
| 378 | 378 | { |
| 379 | - if($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) |
|
| 379 | + if ($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) |
|
| 380 | 380 | { |
| 381 | 381 | DBStaticPlanet::db_planet_delete_by_id($planet['id']); |
| 382 | 382 | return true; |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | global $config; |
| 390 | 390 | |
| 391 | 391 | static $rate, $sn_group_resources_all, $sn_group_resources_loot; |
| 392 | - if(!$rate) |
|
| 392 | + if (!$rate) |
|
| 393 | 393 | { |
| 394 | 394 | $sn_group_resources_all = sn_get_groups('resources_all'); |
| 395 | 395 | $sn_group_resources_loot = sn_get_groups('resources_loot'); |
@@ -400,22 +400,22 @@ discard block |
||
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | $unit_cost_data = get_unit_param($unit_id, 'cost'); |
| 403 | - if(!is_array($unit_cost_data)) |
|
| 403 | + if (!is_array($unit_cost_data)) |
|
| 404 | 404 | { |
| 405 | 405 | return array('total' => 0); |
| 406 | 406 | } |
| 407 | 407 | $factor = isset($unit_cost_data['factor']) ? $unit_cost_data['factor'] : 1; |
| 408 | 408 | $cost_array = array(BUILD_CREATE => array(), 'total' => 0); |
| 409 | 409 | $unit_level = $unit_level > 0 ? $unit_level : 0; |
| 410 | - foreach($unit_cost_data as $resource_id => $resource_amount) |
|
| 410 | + foreach ($unit_cost_data as $resource_id => $resource_amount) |
|
| 411 | 411 | { |
| 412 | - if(!in_array($resource_id, $sn_group_resources_all)) |
|
| 412 | + if (!in_array($resource_id, $sn_group_resources_all)) |
|
| 413 | 413 | { |
| 414 | 414 | continue; |
| 415 | 415 | } |
| 416 | 416 | // $cost_array[BUILD_CREATE][$resource_id] = $resource_amount * ($factor == 1 ? $unit_level : ((pow($factor, $unit_level) - $factor) / ($factor - 1))); |
| 417 | 417 | $cost_array[BUILD_CREATE][$resource_id] = round($resource_amount * ($factor == 1 ? $unit_level : ((1 - pow($factor, $unit_level)) / (1 - $factor)))); |
| 418 | - if(in_array($resource_id, $sn_group_resources_loot)) |
|
| 418 | + if (in_array($resource_id, $sn_group_resources_loot)) |
|
| 419 | 419 | { |
| 420 | 420 | $cost_array['total'] += $cost_array[BUILD_CREATE][$resource_id] * $rate[$resource_id]; |
| 421 | 421 | } |
@@ -424,9 +424,9 @@ discard block |
||
| 424 | 424 | return $cost_array; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | -function sn_unit_purchase($unit_id){} |
|
| 427 | +function sn_unit_purchase($unit_id) {} |
|
| 428 | 428 | |
| 429 | -function sn_unit_relocate($unit_id, $from, $to){} |
|
| 429 | +function sn_unit_relocate($unit_id, $from, $to) {} |
|
| 430 | 430 | |
| 431 | 431 | /* |
| 432 | 432 | ЭТО ПРОСТОЙ ВРАППЕР ДЛЯ БД! Здесь НЕТ никаких проверок! ВСЕ проверки должны быть сделаны заранее! |
@@ -485,48 +485,48 @@ discard block |
||
| 485 | 485 | } |
| 486 | 486 | */ |
| 487 | 487 | |
| 488 | -function mrc_get_level(&$user, $planet = array(), $unit_id, $for_update = false, $plain = false){return sn_function_call(__FUNCTION__, array(&$user, $planet, $unit_id, $for_update, $plain, &$result));} |
|
| 488 | +function mrc_get_level(&$user, $planet = array(), $unit_id, $for_update = false, $plain = false) {return sn_function_call(__FUNCTION__, array(&$user, $planet, $unit_id, $for_update, $plain, &$result)); } |
|
| 489 | 489 | function sn_mrc_get_level(&$user, $planet = array(), $unit_id, $for_update = false, $plain = false, &$result) { |
| 490 | 490 | $mercenary_level = 0; |
| 491 | 491 | $unit_db_name = pname_resource_name($unit_id); |
| 492 | 492 | |
| 493 | - if(in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { |
|
| 493 | + if (in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { |
|
| 494 | 494 | $unit = classSupernova::db_get_unit_by_location($user['id'], LOC_USER, $user['id'], $unit_id); |
| 495 | 495 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0; |
| 496 | - } elseif(in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { |
|
| 496 | + } elseif (in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { |
|
| 497 | 497 | $unit = classSupernova::db_get_unit_by_location(is_array($user) ? $user['id'] : $planet['id_owner'], LOC_PLANET, $planet['id'], $unit_id); |
| 498 | 498 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0; |
| 499 | - } elseif(in_array($unit_id, sn_get_groups('governors'))) { |
|
| 499 | + } elseif (in_array($unit_id, sn_get_groups('governors'))) { |
|
| 500 | 500 | $mercenary_level = $unit_id == $planet['PLANET_GOVERNOR_ID'] ? $planet['PLANET_GOVERNOR_LEVEL'] : 0; |
| 501 | - } elseif($unit_id == RES_DARK_MATTER) { |
|
| 501 | + } elseif ($unit_id == RES_DARK_MATTER) { |
|
| 502 | 502 | $mercenary_level = $user[$unit_db_name] + ($plain || $user['user_as_ally'] ? 0 : classSupernova::$auth->account->account_metamatter); |
| 503 | - } elseif($unit_id == RES_METAMATTER) { |
|
| 503 | + } elseif ($unit_id == RES_METAMATTER) { |
|
| 504 | 504 | $mercenary_level = classSupernova::$auth->account->account_metamatter; //$user[$unit_db_name]; |
| 505 | - } elseif(in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { |
|
| 505 | + } elseif (in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { |
|
| 506 | 506 | $mercenary_level = !empty($planet) ? $planet[$unit_db_name] : $user[$unit_db_name]; |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | return $result = $mercenary_level; |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | -function mrc_modify_value(&$user, $planet = array(), $mercenaries, $value) {return sn_function_call('mrc_modify_value', array(&$user, $planet, $mercenaries, $value));} |
|
| 512 | +function mrc_modify_value(&$user, $planet = array(), $mercenaries, $value) {return sn_function_call('mrc_modify_value', array(&$user, $planet, $mercenaries, $value)); } |
|
| 513 | 513 | function sn_mrc_modify_value(&$user, $planet = array(), $mercenaries, $value, $base_value = null) |
| 514 | 514 | { |
| 515 | - if(!is_array($mercenaries)) |
|
| 515 | + if (!is_array($mercenaries)) |
|
| 516 | 516 | { |
| 517 | 517 | $mercenaries = array($mercenaries); |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | 520 | $base_value = isset($base_value) ? $base_value : $value; |
| 521 | 521 | |
| 522 | - foreach($mercenaries as $mercenary_id) |
|
| 522 | + foreach ($mercenaries as $mercenary_id) |
|
| 523 | 523 | { |
| 524 | 524 | $mercenary_level = mrc_get_level($user, $planet, $mercenary_id); |
| 525 | 525 | |
| 526 | 526 | $mercenary = get_unit_param($mercenary_id); |
| 527 | 527 | $mercenary_bonus = $mercenary['bonus']; |
| 528 | 528 | |
| 529 | - switch($mercenary['bonus_type']) |
|
| 529 | + switch ($mercenary['bonus_type']) |
|
| 530 | 530 | { |
| 531 | 531 | case BONUS_PERCENT_CUMULATIVE: |
| 532 | 532 | $value *= 1 + $mercenary_level * $mercenary_bonus / 100; |
@@ -558,7 +558,7 @@ discard block |
||
| 558 | 558 | $allowed_length = strlen($allowed_chars); |
| 559 | 559 | |
| 560 | 560 | $random_string = ''; |
| 561 | - for($i = 0; $i < $length; $i++) { |
|
| 561 | + for ($i = 0; $i < $length; $i++) { |
|
| 562 | 562 | $random_string .= $allowed_chars[mt_rand(0, $allowed_length - 1)]; |
| 563 | 563 | } |
| 564 | 564 | |
@@ -581,10 +581,10 @@ discard block |
||
| 581 | 581 | |
| 582 | 582 | $options = ''; |
| 583 | 583 | $option_list = array(); |
| 584 | - foreach($user_option_list as $option_group_id => $option_group) |
|
| 584 | + foreach ($user_option_list as $option_group_id => $option_group) |
|
| 585 | 585 | { |
| 586 | 586 | $option_list[$option_group_id] = array(); |
| 587 | - foreach($option_group as $option_name => $option_value) |
|
| 587 | + foreach ($option_group as $option_name => $option_value) |
|
| 588 | 588 | { |
| 589 | 589 | if (!isset($user[$option_name])) |
| 590 | 590 | { |
@@ -610,19 +610,19 @@ discard block |
||
| 610 | 610 | $option_list = array(); |
| 611 | 611 | $option_string_list = explode('|', $user['options']); |
| 612 | 612 | |
| 613 | - foreach($option_string_list as $option_string) |
|
| 613 | + foreach ($option_string_list as $option_string) |
|
| 614 | 614 | { |
| 615 | 615 | list($option_name, $option_value) = explode('^', $option_string); |
| 616 | 616 | $option_list[$option_name] = $option_value; |
| 617 | 617 | } |
| 618 | 618 | |
| 619 | 619 | $final_list = array(); |
| 620 | - foreach($user_option_list as $option_group_id => $option_group) |
|
| 620 | + foreach ($user_option_list as $option_group_id => $option_group) |
|
| 621 | 621 | { |
| 622 | 622 | $final_list[$option_group_id] = array(); |
| 623 | - foreach($option_group as $option_name => $option_value) |
|
| 623 | + foreach ($option_group as $option_name => $option_value) |
|
| 624 | 624 | { |
| 625 | - if(!isset($option_list[$option_name])) |
|
| 625 | + if (!isset($option_list[$option_name])) |
|
| 626 | 626 | { |
| 627 | 627 | $option_list[$option_name] = $option_value; |
| 628 | 628 | } |
@@ -638,15 +638,15 @@ discard block |
||
| 638 | 638 | function sys_unit_str2arr($fleet_string) |
| 639 | 639 | { |
| 640 | 640 | $fleet_array = array(); |
| 641 | - if(!empty($fleet_string)) |
|
| 641 | + if (!empty($fleet_string)) |
|
| 642 | 642 | { |
| 643 | 643 | $arrTemp = explode(';', $fleet_string); |
| 644 | - foreach($arrTemp as $temp) |
|
| 644 | + foreach ($arrTemp as $temp) |
|
| 645 | 645 | { |
| 646 | - if($temp) |
|
| 646 | + if ($temp) |
|
| 647 | 647 | { |
| 648 | 648 | $temp = explode(',', $temp); |
| 649 | - if(!empty($temp[0]) && !empty($temp[1])) |
|
| 649 | + if (!empty($temp[0]) && !empty($temp[1])) |
|
| 650 | 650 | { |
| 651 | 651 | $fleet_array[$temp[0]] += $temp[1]; |
| 652 | 652 | } |
@@ -660,16 +660,16 @@ discard block |
||
| 660 | 660 | function sys_unit_arr2str($unit_list) |
| 661 | 661 | { |
| 662 | 662 | $fleet_string = array(); |
| 663 | - if(isset($unit_list)) |
|
| 663 | + if (isset($unit_list)) |
|
| 664 | 664 | { |
| 665 | - if(!is_array($unit_list)) |
|
| 665 | + if (!is_array($unit_list)) |
|
| 666 | 666 | { |
| 667 | 667 | $unit_list = array($unit_list => 1); |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | - foreach($unit_list as $unit_id => $unit_count) |
|
| 670 | + foreach ($unit_list as $unit_id => $unit_count) |
|
| 671 | 671 | { |
| 672 | - if($unit_id && $unit_count) |
|
| 672 | + if ($unit_id && $unit_count) |
|
| 673 | 673 | { |
| 674 | 674 | $fleet_string[] = "{$unit_id},{$unit_count}"; |
| 675 | 675 | } |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | $from = trim($from ? $from : classSupernova::$config->game_adminEmail); |
| 686 | 686 | |
| 687 | 687 | $head = ''; |
| 688 | - $head .= "Content-Type: text/" . ($html ? 'html' : 'plain'). "; charset=utf-8 \r\n"; |
|
| 688 | + $head .= "Content-Type: text/" . ($html ? 'html' : 'plain') . "; charset=utf-8 \r\n"; |
|
| 689 | 689 | $head .= "Date: " . date('r') . " \r\n"; |
| 690 | 690 | $head .= "Return-Path: {classSupernova::$config->game_adminEmail} \r\n"; |
| 691 | 691 | $head .= "From: {$from} \r\n"; |
@@ -697,7 +697,7 @@ discard block |
||
| 697 | 697 | $body = str_replace("\r\n", "\n", $body); |
| 698 | 698 | $body = str_replace("\n", "\r\n", $body); |
| 699 | 699 | |
| 700 | - if($html) { |
|
| 700 | + if ($html) { |
|
| 701 | 701 | $body = '<html><head><base href="' . SN_ROOT_VIRTUAL . '"></head><body>' . nl2br($body) . '</body></html>'; |
| 702 | 702 | } |
| 703 | 703 | |
@@ -711,15 +711,15 @@ discard block |
||
| 711 | 711 | global $lang; |
| 712 | 712 | |
| 713 | 713 | $seconds = $time % 60; |
| 714 | - $time = floor($time/60); |
|
| 714 | + $time = floor($time / 60); |
|
| 715 | 715 | $minutes = $time % 60; |
| 716 | - $time = floor($time/60); |
|
| 716 | + $time = floor($time / 60); |
|
| 717 | 717 | $hours = $time % 24; |
| 718 | - $time = floor($time/24); |
|
| 718 | + $time = floor($time / 24); |
|
| 719 | 719 | |
| 720 | 720 | return |
| 721 | - ($full || $time ? "{$time} {$lang['sys_day']} " : '') . |
|
| 722 | - ($full || $hours ? "{$hours} {$lang['sys_hrs']} " : '') . |
|
| 721 | + ($full || $time ? "{$time} {$lang['sys_day']} " : '') . |
|
| 722 | + ($full || $hours ? "{$hours} {$lang['sys_hrs']} " : '') . |
|
| 723 | 723 | ($full || $minutes ? "{$minutes} {$lang['sys_min']} " : '') . |
| 724 | 724 | ($full || !$time || $seconds ? "{$seconds} {$lang['sys_sec']}" : ''); |
| 725 | 725 | } |
@@ -763,35 +763,35 @@ discard block |
||
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | // TODO Для полноценного функионирования апдейтера пакет функций, включая эту должен быть вынесен раньше - или грузить general.php до апдейтера |
| 766 | -function sys_get_unit_location($user, $planet, $unit_id){return sn_function_call('sys_get_unit_location', array($user, $planet, $unit_id));} |
|
| 766 | +function sys_get_unit_location($user, $planet, $unit_id) {return sn_function_call('sys_get_unit_location', array($user, $planet, $unit_id)); } |
|
| 767 | 767 | function sn_sys_get_unit_location($user, $planet, $unit_id) |
| 768 | 768 | { |
| 769 | 769 | return get_unit_param($unit_id, 'location'); |
| 770 | 770 | } |
| 771 | 771 | |
| 772 | 772 | function sn_ali_fill_user_ally(&$user) { |
| 773 | - if(!$user['ally_id']) { |
|
| 773 | + if (!$user['ally_id']) { |
|
| 774 | 774 | return; |
| 775 | 775 | } |
| 776 | 776 | |
| 777 | - if(!isset($user['ally'])) { |
|
| 777 | + if (!isset($user['ally'])) { |
|
| 778 | 778 | $user['ally'] = doquery("SELECT * FROM {{alliance}} WHERE `id` = {$user['ally_id']} LIMIT 1;", true); |
| 779 | 779 | } |
| 780 | 780 | |
| 781 | - if(!isset($user['ally']['player'])) { |
|
| 781 | + if (!isset($user['ally']['player'])) { |
|
| 782 | 782 | $user['ally']['player'] = db_user_by_id($user['ally']['ally_user_id'], true, '*', false); |
| 783 | 783 | } |
| 784 | 784 | } |
| 785 | 785 | |
| 786 | 786 | function sn_get_url_contents($url) |
| 787 | 787 | { |
| 788 | - if(function_exists('curl_init')) |
|
| 788 | + if (function_exists('curl_init')) |
|
| 789 | 789 | { |
| 790 | 790 | $crl = curl_init(); |
| 791 | 791 | $timeout = 5; |
| 792 | - curl_setopt ($crl, CURLOPT_URL,$url); |
|
| 793 | - curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); |
|
| 794 | - curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); |
|
| 792 | + curl_setopt($crl, CURLOPT_URL, $url); |
|
| 793 | + curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1); |
|
| 794 | + curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, $timeout); |
|
| 795 | 795 | $return = curl_exec($crl); |
| 796 | 796 | curl_close($crl); |
| 797 | 797 | } |
@@ -825,12 +825,12 @@ discard block |
||
| 825 | 825 | function get_ship_data($ship_id, $user) |
| 826 | 826 | { |
| 827 | 827 | $ship_data = array(); |
| 828 | - if(in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) |
|
| 828 | + if (in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) |
|
| 829 | 829 | { |
| 830 | - foreach(get_unit_param($ship_id, 'engine') as $engine_info) |
|
| 830 | + foreach (get_unit_param($ship_id, 'engine') as $engine_info) |
|
| 831 | 831 | { |
| 832 | 832 | $tech_level = intval(mrc_get_level($user, false, $engine_info['tech'])); |
| 833 | - if(empty($ship_data) || $tech_level >= $engine_info['min_level']) |
|
| 833 | + if (empty($ship_data) || $tech_level >= $engine_info['min_level']) |
|
| 834 | 834 | { |
| 835 | 835 | $ship_data = $engine_info; |
| 836 | 836 | $ship_data['tech_level'] = $tech_level; |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | return $ship_data; |
| 844 | 844 | } |
| 845 | 845 | |
| 846 | -if(!function_exists('strptime')) |
|
| 846 | +if (!function_exists('strptime')) |
|
| 847 | 847 | { |
| 848 | 848 | function strptime($date, $format) |
| 849 | 849 | { |
@@ -857,8 +857,8 @@ discard block |
||
| 857 | 857 | // usw.. |
| 858 | 858 | ); |
| 859 | 859 | |
| 860 | - $rexep = "#".strtr(preg_quote($format), $masks)."#"; |
|
| 861 | - if(preg_match($rexep, $date, $out)) |
|
| 860 | + $rexep = "#" . strtr(preg_quote($format), $masks) . "#"; |
|
| 861 | + if (preg_match($rexep, $date, $out)) |
|
| 862 | 862 | { |
| 863 | 863 | $ret = array( |
| 864 | 864 | "tm_sec" => (int) $out['S'], |
@@ -880,7 +880,7 @@ discard block |
||
| 880 | 880 | function sn_sys_sector_buy($redirect = 'overview.php') { |
| 881 | 881 | global $lang, $user, $planetrow; |
| 882 | 882 | |
| 883 | - if(!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { |
|
| 883 | + if (!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { |
|
| 884 | 884 | return; |
| 885 | 885 | } |
| 886 | 886 | |
@@ -893,9 +893,9 @@ discard block |
||
| 893 | 893 | // $planetrow = $planetrow['planet']; |
| 894 | 894 | $sector_cost = eco_get_build_data($user, $planetrow, UNIT_SECTOR, mrc_get_level($user, $planetrow, UNIT_SECTOR), true); |
| 895 | 895 | $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER]; |
| 896 | - if($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { |
|
| 896 | + if ($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { |
|
| 897 | 897 | $planet_name_text = uni_render_planet($planetrow); |
| 898 | - if(rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf($lang['sys_sector_purchase_log'], |
|
| 898 | + if (rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf($lang['sys_sector_purchase_log'], |
|
| 899 | 899 | $user['username'], $user['id'], $planet_name_text, $lang['sys_planet_type'][$planetrow['planet_type']], $planetrow['id'], $sector_cost) |
| 900 | 900 | )) { |
| 901 | 901 | $sector_db_name = pname_resource_name(UNIT_SECTOR); |
@@ -911,43 +911,43 @@ discard block |
||
| 911 | 911 | |
| 912 | 912 | function sn_sys_handler_add(&$functions, $handler_list, $class_module_name = '', $sub_type = '') |
| 913 | 913 | { |
| 914 | - if(isset($handler_list) && is_array($handler_list) && !empty($handler_list)) |
|
| 914 | + if (isset($handler_list) && is_array($handler_list) && !empty($handler_list)) |
|
| 915 | 915 | { |
| 916 | - foreach($handler_list as $function_name => $function_data) |
|
| 916 | + foreach ($handler_list as $function_name => $function_data) |
|
| 917 | 917 | { |
| 918 | - if(is_string($function_data)) |
|
| 918 | + if (is_string($function_data)) |
|
| 919 | 919 | { |
| 920 | 920 | $override_with = &$function_data; |
| 921 | 921 | } |
| 922 | - elseif(isset($function_data['callable'])) |
|
| 922 | + elseif (isset($function_data['callable'])) |
|
| 923 | 923 | { |
| 924 | 924 | $override_with = &$function_data['callable']; |
| 925 | 925 | } |
| 926 | 926 | |
| 927 | 927 | $overwrite = $override_with[0] == '*'; |
| 928 | - if($overwrite) |
|
| 928 | + if ($overwrite) |
|
| 929 | 929 | { |
| 930 | 930 | $override_with = substr($override_with, 1); |
| 931 | 931 | } |
| 932 | 932 | |
| 933 | - if(($point_position = strpos($override_with, '.')) === false && $class_module_name) |
|
| 933 | + if (($point_position = strpos($override_with, '.')) === false && $class_module_name) |
|
| 934 | 934 | { |
| 935 | 935 | $override_with = array($class_module_name, $override_with); |
| 936 | 936 | } |
| 937 | - elseif($point_position == 0) |
|
| 937 | + elseif ($point_position == 0) |
|
| 938 | 938 | { |
| 939 | 939 | $override_with = substr($override_with, 1); |
| 940 | 940 | } |
| 941 | - elseif($point_position > 0) |
|
| 941 | + elseif ($point_position > 0) |
|
| 942 | 942 | { |
| 943 | 943 | $override_with = array(substr($override_with, 0, $point_position), substr($override_with, $point_position + 1)); |
| 944 | 944 | } |
| 945 | 945 | |
| 946 | - if($overwrite) |
|
| 946 | + if ($overwrite) |
|
| 947 | 947 | { |
| 948 | 948 | $functions[$function_name] = array(); |
| 949 | 949 | } |
| 950 | - elseif(!isset($functions[$function_name])) |
|
| 950 | + elseif (!isset($functions[$function_name])) |
|
| 951 | 951 | { |
| 952 | 952 | $functions[$function_name] = array(); |
| 953 | 953 | $sn_function_name = 'sn_' . $function_name . ($sub_type ? '_' . $sub_type : ''); |
@@ -964,18 +964,18 @@ discard block |
||
| 964 | 964 | |
| 965 | 965 | // TODO - поменять название |
| 966 | 966 | // Может принимать: (array)$user, $nick_render_array, $nick_render_array_html, $nick_render_string_compact |
| 967 | -function player_nick_render_to_html($result, $options = false){ |
|
| 967 | +function player_nick_render_to_html($result, $options = false) { |
|
| 968 | 968 | // TODO - обрабатывать разные случаи: $user, $render_nick_array, $string |
| 969 | 969 | |
| 970 | - if(is_string($result) && strpos($result, ':{i:')) { |
|
| 970 | + if (is_string($result) && strpos($result, ':{i:')) { |
|
| 971 | 971 | $result = player_nick_uncompact($result); |
| 972 | 972 | } |
| 973 | 973 | |
| 974 | - if(is_array($result)) { |
|
| 975 | - if(isset($result['id'])) { |
|
| 974 | + if (is_array($result)) { |
|
| 975 | + if (isset($result['id'])) { |
|
| 976 | 976 | $result = player_nick_render_current_to_array($result, $options); |
| 977 | 977 | } |
| 978 | - if(!isset($result[NICK_HTML])) { |
|
| 978 | + if (!isset($result[NICK_HTML])) { |
|
| 979 | 979 | $result = player_nick_render_array_to_html($result); |
| 980 | 980 | } |
| 981 | 981 | unset($result[NICK_HTML]); |
@@ -997,19 +997,19 @@ discard block |
||
| 997 | 997 | try { |
| 998 | 998 | $result = unserialize($nick_string); |
| 999 | 999 | // ksort($result); // Всегда ksort-ый в player_nick_compact() |
| 1000 | - } catch(exception $e) { |
|
| 1000 | + } catch (exception $e) { |
|
| 1001 | 1001 | $result = strpos($nick_string, ':{i:') ? null : $nick_string; // fallback if it is already string - for old chat strings, for example |
| 1002 | 1002 | } |
| 1003 | 1003 | return $result; |
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | -function player_nick_render_array_to_html($nick_array){return sn_function_call('player_nick_render_array_to_html', array($nick_array, &$result));} |
|
| 1006 | +function player_nick_render_array_to_html($nick_array) {return sn_function_call('player_nick_render_array_to_html', array($nick_array, &$result)); } |
|
| 1007 | 1007 | function sn_player_nick_render_array_to_html($nick_array, &$result) { |
| 1008 | 1008 | global $config, $user; |
| 1009 | 1009 | |
| 1010 | 1010 | static $iconCache = array(); |
| 1011 | 1011 | |
| 1012 | - if(empty($iconCache['gender_' . $nick_array[NICK_GENDER]])) { |
|
| 1012 | + if (empty($iconCache['gender_' . $nick_array[NICK_GENDER]])) { |
|
| 1013 | 1013 | $iconCache['gender_' . $nick_array[NICK_GENDER]] = classSupernova::$gc->skinModel->getImageCurrent("gender_{$nick_array[NICK_GENDER]}|html"); |
| 1014 | 1014 | $iconCache['icon_vacation'] = classSupernova::$gc->skinModel->getImageCurrent('icon_vacation|html'); |
| 1015 | 1015 | $iconCache['icon_birthday'] = classSupernova::$gc->skinModel->getImageCurrent('icon_birthday|html'); |
@@ -1017,25 +1017,25 @@ discard block |
||
| 1017 | 1017 | $iconGender = $iconCache['gender_' . $nick_array[NICK_GENDER]]; |
| 1018 | 1018 | |
| 1019 | 1019 | // ALL STRING ARE UNSAFE!!! |
| 1020 | - if(isset($nick_array[NICK_BIRTHSDAY])) { |
|
| 1020 | + if (isset($nick_array[NICK_BIRTHSDAY])) { |
|
| 1021 | 1021 | // $result[NICK_BIRTHSDAY] = '<img src="design/images/birthday.png" />'; |
| 1022 | 1022 | $result[NICK_BIRTHSDAY] = $iconCache['icon_birthday']; |
| 1023 | 1023 | } |
| 1024 | 1024 | |
| 1025 | - if(isset($nick_array[NICK_VACATION])) { |
|
| 1025 | + if (isset($nick_array[NICK_VACATION])) { |
|
| 1026 | 1026 | // $result[NICK_VACATION] = '<img src="design/images/icon_vacation.png" />'; |
| 1027 | 1027 | // $result[NICK_VACATION] = classSupernova::$gc->skinModel->getImageCurrent('icon_vacation|html'); |
| 1028 | 1028 | $result[NICK_VACATION] = $iconCache['icon_vacation']; |
| 1029 | 1029 | } |
| 1030 | 1030 | |
| 1031 | - if(isset($nick_array[NICK_GENDER])) { |
|
| 1031 | + if (isset($nick_array[NICK_GENDER])) { |
|
| 1032 | 1032 | // $result[NICK_GENDER] = '<img src="' . classSupernova::$gc->theUser->getSkinPath() . 'images/gender_' . $nick_array[NICK_GENDER] . '.png" />'; |
| 1033 | 1033 | // $result[NICK_GENDER] = classSupernova::$gc->skinModel->getImageCurrent("gender_{$nick_array[NICK_GENDER]}|html"); |
| 1034 | 1034 | $result[NICK_GENDER] = $iconGender; |
| 1035 | 1035 | } |
| 1036 | 1036 | |
| 1037 | - if(isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { |
|
| 1038 | - switch($nick_array[NICK_AUTH_LEVEL]) { |
|
| 1037 | + if (isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { |
|
| 1038 | + switch ($nick_array[NICK_AUTH_LEVEL]) { |
|
| 1039 | 1039 | case 4: |
| 1040 | 1040 | $highlight = classSupernova::$config->chat_highlight_developer; |
| 1041 | 1041 | break; |
@@ -1056,20 +1056,20 @@ discard block |
||
| 1056 | 1056 | $highlight = isset($nick_array[NICK_PREMIUM]) ? classSupernova::$config->chat_highlight_premium : ''; |
| 1057 | 1057 | } |
| 1058 | 1058 | |
| 1059 | - if($highlight) { |
|
| 1059 | + if ($highlight) { |
|
| 1060 | 1060 | list($result[NICK_HIGHLIGHT], $result[NICK_HIGHLIGHT_END]) = explode('$1', $highlight); |
| 1061 | 1061 | } |
| 1062 | 1062 | // $result = preg_replace("#(.+)#", $highlight, $result); |
| 1063 | 1063 | } |
| 1064 | 1064 | |
| 1065 | - if(isset($nick_array[NICK_CLASS])) { |
|
| 1066 | - $result[NICK_CLASS] = '<span ' . $nick_array[NICK_CLASS] .'>'; |
|
| 1065 | + if (isset($nick_array[NICK_CLASS])) { |
|
| 1066 | + $result[NICK_CLASS] = '<span ' . $nick_array[NICK_CLASS] . '>'; |
|
| 1067 | 1067 | $result[NICK_CLASS_END] = '</span>'; |
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | 1070 | $result[NICK_NICK] = sys_safe_output($nick_array[NICK_NICK]); |
| 1071 | 1071 | |
| 1072 | - if(isset($nick_array[NICK_ALLY])) { |
|
| 1072 | + if (isset($nick_array[NICK_ALLY])) { |
|
| 1073 | 1073 | $result[NICK_ALLY] = '[' . sys_safe_output($nick_array[NICK_ALLY]) . ']'; |
| 1074 | 1074 | } |
| 1075 | 1075 | |
@@ -1078,7 +1078,7 @@ discard block |
||
| 1078 | 1078 | return $result; |
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | -function player_nick_render_current_to_array($render_user, $options = false){return sn_function_call('player_nick_render_current_to_array', array($render_user, $options, &$result));} |
|
| 1081 | +function player_nick_render_current_to_array($render_user, $options = false) {return sn_function_call('player_nick_render_current_to_array', array($render_user, $options, &$result)); } |
|
| 1082 | 1082 | function sn_player_nick_render_current_to_array($render_user, $options = false, &$result) { |
| 1083 | 1083 | /* |
| 1084 | 1084 | $options = $options !== true ? $options : |
@@ -1092,32 +1092,32 @@ discard block |
||
| 1092 | 1092 | */ |
| 1093 | 1093 | |
| 1094 | 1094 | |
| 1095 | - if($render_user['user_birthday'] && ($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))) { |
|
| 1095 | + if ($render_user['user_birthday'] && ($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))) { |
|
| 1096 | 1096 | $result[NICK_BIRTHSDAY] = ''; |
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | - if($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { |
|
| 1099 | + if ($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { |
|
| 1100 | 1100 | $result[NICK_GENDER] = $render_user['gender'] == GENDER_UNKNOWN ? 'unknown' : ($render_user['gender'] == GENDER_FEMALE ? 'female' : 'male'); |
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | - if(($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
|
| 1103 | + if (($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
|
| 1104 | 1104 | $result[NICK_VACATION] = $render_user['vacation']; |
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | - if($options === true || (isset($options['color']) && $options['color'])) { |
|
| 1108 | - if($user_auth_level = $render_user['authlevel']) { |
|
| 1107 | + if ($options === true || (isset($options['color']) && $options['color'])) { |
|
| 1108 | + if ($user_auth_level = $render_user['authlevel']) { |
|
| 1109 | 1109 | $result[NICK_AUTH_LEVEL] = $user_auth_level; |
| 1110 | 1110 | } |
| 1111 | - if($user_premium = mrc_get_level($render_user, false, UNIT_PREMIUM)) { |
|
| 1111 | + if ($user_premium = mrc_get_level($render_user, false, UNIT_PREMIUM)) { |
|
| 1112 | 1112 | $result[NICK_PREMIUM] = $user_premium; |
| 1113 | 1113 | } |
| 1114 | 1114 | } |
| 1115 | 1115 | |
| 1116 | - if((isset($options['class']) && $options['class'])) { |
|
| 1116 | + if ((isset($options['class']) && $options['class'])) { |
|
| 1117 | 1117 | $result[NICK_CLASS] = (isset($result_options[NICK_CLASS]) ? ' ' . $result_options[NICK_CLASS] : '') . $options['class']; |
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | - if($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
|
| 1120 | + if ($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
|
| 1121 | 1121 | $result[NICK_ALLY] = $render_user['ally_tag']; |
| 1122 | 1122 | } |
| 1123 | 1123 | |
@@ -1168,25 +1168,25 @@ discard block |
||
| 1168 | 1168 | |
| 1169 | 1169 | $user_skip_list = array(); |
| 1170 | 1170 | |
| 1171 | - if(classSupernova::$config->stats_hide_admins) { |
|
| 1171 | + if (classSupernova::$config->stats_hide_admins) { |
|
| 1172 | 1172 | $user_skip_list[] = '`authlevel` > 0'; |
| 1173 | 1173 | } |
| 1174 | 1174 | |
| 1175 | - if(classSupernova::$config->stats_hide_player_list) { |
|
| 1175 | + if (classSupernova::$config->stats_hide_player_list) { |
|
| 1176 | 1176 | $temp = explode(',', classSupernova::$config->stats_hide_player_list); |
| 1177 | - foreach($temp as $user_id) { |
|
| 1177 | + foreach ($temp as $user_id) { |
|
| 1178 | 1178 | $user_id = floatval($user_id); |
| 1179 | - if($user_id) { |
|
| 1179 | + if ($user_id) { |
|
| 1180 | 1180 | $user_skip_list[] = '`id` = ' . $user_id; |
| 1181 | 1181 | } |
| 1182 | 1182 | } |
| 1183 | 1183 | } |
| 1184 | 1184 | |
| 1185 | - if(!empty($user_skip_list)) { |
|
| 1185 | + if (!empty($user_skip_list)) { |
|
| 1186 | 1186 | $user_skip_list = implode(' OR ', $user_skip_list); |
| 1187 | 1187 | $user_skip_query = db_user_list($user_skip_list); |
| 1188 | - if(!empty($user_skip_query)) { |
|
| 1189 | - foreach($user_skip_query as $user_skip_row) { |
|
| 1188 | + if (!empty($user_skip_query)) { |
|
| 1189 | + foreach ($user_skip_query as $user_skip_row) { |
|
| 1190 | 1190 | $result[$user_skip_row['id']] = $user_skip_row['id']; |
| 1191 | 1191 | } |
| 1192 | 1192 | } |
@@ -1198,7 +1198,7 @@ discard block |
||
| 1198 | 1198 | // function player_nick_render_to_html($render_user, $options = false){return sn_function_call('player_nick_render_to_html', array($render_user, $options, &$result));} |
| 1199 | 1199 | // function sn_render_player_nick($render_user, $options = false, &$result) |
| 1200 | 1200 | |
| 1201 | -function get_unit_param($unit_id, $param_name = null, $user = null, $planet = null){return sn_function_call('get_unit_param', array($unit_id, $param_name, $user, $planet, &$result));} |
|
| 1201 | +function get_unit_param($unit_id, $param_name = null, $user = null, $planet = null) {return sn_function_call('get_unit_param', array($unit_id, $param_name, $user, $planet, &$result)); } |
|
| 1202 | 1202 | function sn_get_unit_param($unit_id, $param_name = null, $user = null, $planet = null, &$result) |
| 1203 | 1203 | { |
| 1204 | 1204 | global $sn_data; |
@@ -1213,11 +1213,11 @@ discard block |
||
| 1213 | 1213 | return $result; |
| 1214 | 1214 | } |
| 1215 | 1215 | |
| 1216 | -function sn_get_groups($groups){return sn_function_call('sn_get_groups', array($groups, &$result));} |
|
| 1216 | +function sn_get_groups($groups) {return sn_function_call('sn_get_groups', array($groups, &$result)); } |
|
| 1217 | 1217 | function sn_sn_get_groups($groups, &$result) |
| 1218 | 1218 | { |
| 1219 | 1219 | $result = is_array($result) ? $result : array(); |
| 1220 | - foreach($groups = is_array($groups) ? $groups : array($groups) as $group_name) |
|
| 1220 | + foreach ($groups = is_array($groups) ? $groups : array($groups) as $group_name) |
|
| 1221 | 1221 | { |
| 1222 | 1222 | $result += is_array($a_group = get_unit_param(UNIT_GROUP, $group_name)) ? $a_group : array(); |
| 1223 | 1223 | } |
@@ -1238,7 +1238,7 @@ discard block |
||
| 1238 | 1238 | return preg_match('#^(\d*)#', $value, $matches) && $matches[1] ? floatval($matches[1]) : $default; |
| 1239 | 1239 | } |
| 1240 | 1240 | |
| 1241 | -function unit_requirements_render($user, $planetrow, $unit_id, $field = 'require'){return sn_function_call('unit_requirements_render', array($user, $planetrow, $unit_id, $field, &$result));} |
|
| 1241 | +function unit_requirements_render($user, $planetrow, $unit_id, $field = 'require') {return sn_function_call('unit_requirements_render', array($user, $planetrow, $unit_id, $field, &$result)); } |
|
| 1242 | 1242 | function sn_unit_requirements_render($user, $planetrow, $unit_id, $field = 'require', &$result) |
| 1243 | 1243 | { |
| 1244 | 1244 | global $lang, $config; |
@@ -1246,9 +1246,9 @@ discard block |
||
| 1246 | 1246 | $sn_data_unit = get_unit_param($unit_id); |
| 1247 | 1247 | |
| 1248 | 1248 | $result = is_array($result) ? $result : array(); |
| 1249 | - if($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && classSupernova::$config->empire_mercenary_temporary)) |
|
| 1249 | + if ($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && classSupernova::$config->empire_mercenary_temporary)) |
|
| 1250 | 1250 | { |
| 1251 | - foreach($sn_data_unit[$field] as $require_id => $require_level) |
|
| 1251 | + foreach ($sn_data_unit[$field] as $require_id => $require_level) |
|
| 1252 | 1252 | { |
| 1253 | 1253 | $level_got = mrc_get_level($user, $planetrow, $require_id); |
| 1254 | 1254 | $level_basic = mrc_get_level($user, $planetrow, $require_id, false, true); |
@@ -1274,19 +1274,19 @@ discard block |
||
| 1274 | 1274 | |
| 1275 | 1275 | $ranks = array(); |
| 1276 | 1276 | |
| 1277 | - if($ally['ranklist']) |
|
| 1277 | + if ($ally['ranklist']) |
|
| 1278 | 1278 | { |
| 1279 | 1279 | $str_ranks = explode(';', $ally['ranklist']); |
| 1280 | - foreach($str_ranks as $str_rank) |
|
| 1280 | + foreach ($str_ranks as $str_rank) |
|
| 1281 | 1281 | { |
| 1282 | - if(!$str_rank) |
|
| 1282 | + if (!$str_rank) |
|
| 1283 | 1283 | { |
| 1284 | 1284 | continue; |
| 1285 | 1285 | } |
| 1286 | 1286 | |
| 1287 | 1287 | $tmp = explode(',', $str_rank); |
| 1288 | 1288 | $rank_id = count($ranks); |
| 1289 | - foreach($ally_rights as $key => $value) |
|
| 1289 | + foreach ($ally_rights as $key => $value) |
|
| 1290 | 1290 | { |
| 1291 | 1291 | $ranks[$rank_id][$value] = $tmp[$key]; |
| 1292 | 1292 | } |
@@ -1296,14 +1296,14 @@ discard block |
||
| 1296 | 1296 | return $ranks; |
| 1297 | 1297 | } |
| 1298 | 1298 | |
| 1299 | -function sys_player_new_adjust($user_id, $planet_id){return sn_function_call('sys_player_new_adjust', array($user_id, $planet_id, &$result));} |
|
| 1299 | +function sys_player_new_adjust($user_id, $planet_id) {return sn_function_call('sys_player_new_adjust', array($user_id, $planet_id, &$result)); } |
|
| 1300 | 1300 | function sn_sys_player_new_adjust($user_id, $planet_id, &$result) { |
| 1301 | 1301 | return $result; |
| 1302 | 1302 | } |
| 1303 | 1303 | |
| 1304 | 1304 | function array_merge_recursive_numeric($array1, $array2) { |
| 1305 | - if(!empty($array2) && is_array($array2)) { |
|
| 1306 | - foreach($array2 as $key => $value) { |
|
| 1305 | + if (!empty($array2) && is_array($array2)) { |
|
| 1306 | + foreach ($array2 as $key => $value) { |
|
| 1307 | 1307 | // if(!isset($array1[$key]) || !is_array($array1[$key])) { |
| 1308 | 1308 | // $array1[$key] = $value; |
| 1309 | 1309 | // } else { |
@@ -1319,7 +1319,7 @@ discard block |
||
| 1319 | 1319 | function sn_sys_array_cumulative_sum(&$array) |
| 1320 | 1320 | { |
| 1321 | 1321 | $accum = 0; |
| 1322 | - foreach($array as &$value) |
|
| 1322 | + foreach ($array as &$value) |
|
| 1323 | 1323 | { |
| 1324 | 1324 | $accum += $value; |
| 1325 | 1325 | $value = $accum; |
@@ -1330,7 +1330,7 @@ discard block |
||
| 1330 | 1330 | $sn_data_density = sn_get_groups('planet_density'); |
| 1331 | 1331 | $density_price_chart = array(); |
| 1332 | 1332 | |
| 1333 | - foreach($sn_data_density as $density_id => $density_data) { |
|
| 1333 | + foreach ($sn_data_density as $density_id => $density_data) { |
|
| 1334 | 1334 | // Отсекаем записи с RARITY = 0 - служебные записи и супер-ядра |
| 1335 | 1335 | $density_data[UNIT_PLANET_DENSITY_RARITY] ? $density_price_chart[$density_id] = $density_data[UNIT_PLANET_DENSITY_RARITY] : false; |
| 1336 | 1336 | } |
@@ -1338,7 +1338,7 @@ discard block |
||
| 1338 | 1338 | |
| 1339 | 1339 | $total_rarity = array_sum($density_price_chart); |
| 1340 | 1340 | |
| 1341 | - foreach($density_price_chart as &$density_data) { |
|
| 1341 | + foreach ($density_price_chart as &$density_data) { |
|
| 1342 | 1342 | $density_data = ceil($total_rarity / $density_data * $planet_row['field_max'] * PLANET_DENSITY_TO_DARK_MATTER_RATE); |
| 1343 | 1343 | } |
| 1344 | 1344 | |
@@ -1346,18 +1346,18 @@ discard block |
||
| 1346 | 1346 | } |
| 1347 | 1347 | |
| 1348 | 1348 | function sn_sys_planet_core_transmute(&$user, &$planetrow) { |
| 1349 | - if(!sys_get_param_str('transmute')) { |
|
| 1349 | + if (!sys_get_param_str('transmute')) { |
|
| 1350 | 1350 | return array(); |
| 1351 | 1351 | } |
| 1352 | 1352 | |
| 1353 | 1353 | global $lang; |
| 1354 | 1354 | |
| 1355 | 1355 | try { |
| 1356 | - if($planetrow['planet_type'] != PT_PLANET) { |
|
| 1356 | + if ($planetrow['planet_type'] != PT_PLANET) { |
|
| 1357 | 1357 | throw new exception($lang['ov_core_err_not_a_planet'], ERR_ERROR); |
| 1358 | 1358 | } |
| 1359 | 1359 | |
| 1360 | - if($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { |
|
| 1360 | + if ($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { |
|
| 1361 | 1361 | throw new exception($lang['ov_core_err_same_density'], ERR_WARNING); |
| 1362 | 1362 | } |
| 1363 | 1363 | |
@@ -1371,7 +1371,7 @@ discard block |
||
| 1371 | 1371 | $planet_density_index = $planetrow['density_index']; |
| 1372 | 1372 | |
| 1373 | 1373 | $density_price_chart = planet_density_price_chart($planetrow); |
| 1374 | - if(!isset($density_price_chart[$new_density_index])) { |
|
| 1374 | + if (!isset($density_price_chart[$new_density_index])) { |
|
| 1375 | 1375 | // Hack attempt |
| 1376 | 1376 | throw new exception($lang['ov_core_err_denisty_type_wrong'], ERR_ERROR); |
| 1377 | 1377 | } |
@@ -1380,13 +1380,13 @@ discard block |
||
| 1380 | 1380 | // $transmute_cost = get_unit_param(UNIT_PLANET_DENSITY, 'cost'); |
| 1381 | 1381 | // $transmute_cost = $transmute_cost[RES_DARK_MATTER] * $density_price_chart[$new_density_index]; |
| 1382 | 1382 | $transmute_cost = $density_price_chart[$new_density_index]; |
| 1383 | - if($user_dark_matter < $transmute_cost) { |
|
| 1383 | + if ($user_dark_matter < $transmute_cost) { |
|
| 1384 | 1384 | throw new exception($lang['ov_core_err_no_dark_matter'], ERR_ERROR); |
| 1385 | 1385 | } |
| 1386 | 1386 | |
| 1387 | 1387 | $sn_data_planet_density = sn_get_groups('planet_density'); |
| 1388 | - foreach($sn_data_planet_density as $key => $value) { |
|
| 1389 | - if($key == $new_density_index) { |
|
| 1388 | + foreach ($sn_data_planet_density as $key => $value) { |
|
| 1389 | + if ($key == $new_density_index) { |
|
| 1390 | 1390 | break; |
| 1391 | 1391 | } |
| 1392 | 1392 | $prev_density_index = $key; |
@@ -1417,7 +1417,7 @@ discard block |
||
| 1417 | 1417 | 'STATUS' => ERR_NONE, |
| 1418 | 1418 | 'MESSAGE' => sprintf($lang['ov_core_err_none'], $lang['uni_planet_density_types'][$planet_density_index], $lang['uni_planet_density_types'][$new_density_index], $new_density), |
| 1419 | 1419 | ); |
| 1420 | - } catch(exception $e) { |
|
| 1420 | + } catch (exception $e) { |
|
| 1421 | 1421 | sn_db_transaction_rollback(); |
| 1422 | 1422 | $result = array( |
| 1423 | 1423 | 'STATUS' => $e->getCode(), |
@@ -1433,9 +1433,9 @@ discard block |
||
| 1433 | 1433 | global $sn_module_list; |
| 1434 | 1434 | |
| 1435 | 1435 | $active_modules = 0; |
| 1436 | - if(isset($sn_module_list[$group]) && is_array($sn_module_list[$group])) |
|
| 1436 | + if (isset($sn_module_list[$group]) && is_array($sn_module_list[$group])) |
|
| 1437 | 1437 | { |
| 1438 | - foreach($sn_module_list[$group] as $payment_module) |
|
| 1438 | + foreach ($sn_module_list[$group] as $payment_module) |
|
| 1439 | 1439 | { |
| 1440 | 1440 | $active_modules += $payment_module->manifest['active']; |
| 1441 | 1441 | } |
@@ -1448,7 +1448,7 @@ discard block |
||
| 1448 | 1448 | { |
| 1449 | 1449 | static $rates; |
| 1450 | 1450 | |
| 1451 | - if(!$rates) |
|
| 1451 | + if (!$rates) |
|
| 1452 | 1452 | { |
| 1453 | 1453 | global $config; |
| 1454 | 1454 | |
@@ -1459,7 +1459,7 @@ discard block |
||
| 1459 | 1459 | RES_DARK_MATTER => 'rpg_exchange_darkMatter', |
| 1460 | 1460 | ); |
| 1461 | 1461 | |
| 1462 | - foreach($rates as &$rate) |
|
| 1462 | + foreach ($rates as &$rate) |
|
| 1463 | 1463 | { |
| 1464 | 1464 | $rate = classSupernova::$config->$rate; |
| 1465 | 1465 | } |
@@ -1472,13 +1472,13 @@ discard block |
||
| 1472 | 1472 | { |
| 1473 | 1473 | static $rates; |
| 1474 | 1474 | |
| 1475 | - if(!$rates) |
|
| 1475 | + if (!$rates) |
|
| 1476 | 1476 | { |
| 1477 | 1477 | $rates = get_resource_exchange(); |
| 1478 | 1478 | } |
| 1479 | 1479 | |
| 1480 | 1480 | $metal_cost = 0; |
| 1481 | - foreach($cost as $resource_id => $resource_value) |
|
| 1481 | + foreach ($cost as $resource_id => $resource_value) |
|
| 1482 | 1482 | { |
| 1483 | 1483 | $metal_cost += $rates[$resource_id] * $resource_value; |
| 1484 | 1484 | } |
@@ -1486,11 +1486,11 @@ discard block |
||
| 1486 | 1486 | return $metal_cost; |
| 1487 | 1487 | } |
| 1488 | 1488 | |
| 1489 | -function get_player_max_expeditons(&$user, $astrotech = -1){return sn_function_call('get_player_max_expeditons', array(&$user, $astrotech, &$result));} |
|
| 1489 | +function get_player_max_expeditons(&$user, $astrotech = -1) {return sn_function_call('get_player_max_expeditons', array(&$user, $astrotech, &$result)); } |
|
| 1490 | 1490 | function sn_get_player_max_expeditons(&$user, $astrotech = -1, &$result = 0) |
| 1491 | 1491 | { |
| 1492 | - if($astrotech == -1) { |
|
| 1493 | - if(!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) |
|
| 1492 | + if ($astrotech == -1) { |
|
| 1493 | + if (!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) |
|
| 1494 | 1494 | { |
| 1495 | 1495 | $astrotech = mrc_get_level($user, false, TECH_ASTROTECH); |
| 1496 | 1496 | $user[UNIT_PLAYER_EXPEDITIONS_MAX] = $astrotech >= 1 ? floor(sqrt($astrotech - 1)) : 0; |
@@ -1510,8 +1510,8 @@ discard block |
||
| 1510 | 1510 | function get_player_max_colonies(&$user, $astrotech = -1) { |
| 1511 | 1511 | global $config; |
| 1512 | 1512 | |
| 1513 | - if($astrotech == -1) { |
|
| 1514 | - if(!isset($user[UNIT_PLAYER_COLONIES_MAX])) { |
|
| 1513 | + if ($astrotech == -1) { |
|
| 1514 | + if (!isset($user[UNIT_PLAYER_COLONIES_MAX])) { |
|
| 1515 | 1515 | |
| 1516 | 1516 | $expeditions = get_player_max_expeditons($user); |
| 1517 | 1517 | $astrotech = mrc_get_level($user, false, TECH_ASTROTECH); |
@@ -1544,7 +1544,7 @@ discard block |
||
| 1544 | 1544 | } |
| 1545 | 1545 | |
| 1546 | 1546 | |
| 1547 | -function sn_powerup_get_price_matrix($powerup_id, $powerup_unit = false, $level_max = null, $plain = false){return sn_function_call('sn_powerup_get_price_matrix', array($powerup_id, $powerup_unit, $level_max, $plain, &$result));} |
|
| 1547 | +function sn_powerup_get_price_matrix($powerup_id, $powerup_unit = false, $level_max = null, $plain = false) {return sn_function_call('sn_powerup_get_price_matrix', array($powerup_id, $powerup_unit, $level_max, $plain, &$result)); } |
|
| 1548 | 1548 | function sn_sn_powerup_get_price_matrix($powerup_id, $powerup_unit = false, $level_max = null, $plain = false, &$result) { |
| 1549 | 1549 | global $sn_powerup_buy_discounts; |
| 1550 | 1550 | |
@@ -1554,10 +1554,10 @@ discard block |
||
| 1554 | 1554 | $is_upgrade = !empty($powerup_unit) && $powerup_unit; |
| 1555 | 1555 | |
| 1556 | 1556 | $level_current = $term_original = $time_left = 0; |
| 1557 | - if($is_upgrade) { |
|
| 1557 | + if ($is_upgrade) { |
|
| 1558 | 1558 | $time_finish = strtotime($powerup_unit['unit_time_finish']); |
| 1559 | 1559 | $time_left = max(0, $time_finish - SN_TIME_NOW); |
| 1560 | - if($time_left > 0) { |
|
| 1560 | + if ($time_left > 0) { |
|
| 1561 | 1561 | $term_original = $time_finish - strtotime($powerup_unit['unit_time_start']); |
| 1562 | 1562 | $level_current = $powerup_unit['unit_level']; |
| 1563 | 1563 | } |
@@ -1565,17 +1565,17 @@ discard block |
||
| 1565 | 1565 | |
| 1566 | 1566 | $level_max = $level_max > $powerup_data[P_MAX_STACK] ? $level_max : $powerup_data[P_MAX_STACK]; |
| 1567 | 1567 | $original_cost = 0; |
| 1568 | - for($i = 1; $i <= $level_max; $i++) { |
|
| 1568 | + for ($i = 1; $i <= $level_max; $i++) { |
|
| 1569 | 1569 | $base_cost = eco_get_total_cost($powerup_id, $i); |
| 1570 | 1570 | $base_cost = $base_cost[BUILD_CREATE][RES_DARK_MATTER]; |
| 1571 | - foreach($sn_powerup_buy_discounts as $period => $discount) { |
|
| 1571 | + foreach ($sn_powerup_buy_discounts as $period => $discount) { |
|
| 1572 | 1572 | $upgrade_price = floor($base_cost * $discount * $period / PERIOD_MONTH); |
| 1573 | 1573 | $result[$i][$period] = $upgrade_price; |
| 1574 | 1574 | $original_cost = $is_upgrade && $i == $level_current && $period <= $term_original ? $upgrade_price : $original_cost; |
| 1575 | 1575 | } |
| 1576 | 1576 | } |
| 1577 | 1577 | |
| 1578 | - if($is_upgrade && $time_left) { |
|
| 1578 | + if ($is_upgrade && $time_left) { |
|
| 1579 | 1579 | $term_original = round($term_original / PERIOD_DAY); |
| 1580 | 1580 | $time_left = min(floor($time_left / PERIOD_DAY), $term_original); |
| 1581 | 1581 | $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0; |
@@ -1636,14 +1636,14 @@ discard block |
||
| 1636 | 1636 | |
| 1637 | 1637 | function print_rr($var, $capture = false) { |
| 1638 | 1638 | $print = '<pre>' . htmlspecialchars(print_r($var, true)) . '</pre>'; |
| 1639 | - if($capture) { |
|
| 1639 | + if ($capture) { |
|
| 1640 | 1640 | return $print; |
| 1641 | 1641 | } else { |
| 1642 | 1642 | print($print); |
| 1643 | 1643 | } |
| 1644 | 1644 | } |
| 1645 | 1645 | |
| 1646 | -function can_capture_planet(){return sn_function_call('can_capture_planet', array(&$result));} |
|
| 1646 | +function can_capture_planet() {return sn_function_call('can_capture_planet', array(&$result)); } |
|
| 1647 | 1647 | function sn_can_capture_planet(&$result) { |
| 1648 | 1648 | return $result = false; |
| 1649 | 1649 | } |
@@ -1674,9 +1674,9 @@ discard block |
||
| 1674 | 1674 | |
| 1675 | 1675 | function price_matrix_templatize(&$price_matrix_plain, &$price_matrix_original, &$price_matrix_upgrade, $user_dark_matter) { |
| 1676 | 1676 | $prices = array(); |
| 1677 | - foreach($price_matrix_original as $level_num => $level_data) { |
|
| 1677 | + foreach ($price_matrix_original as $level_num => $level_data) { |
|
| 1678 | 1678 | $price_per_period = array(); |
| 1679 | - foreach($level_data as $period => $price) { |
|
| 1679 | + foreach ($level_data as $period => $price) { |
|
| 1680 | 1680 | $price_text = pretty_number($price, true, $user_dark_matter, false, false); |
| 1681 | 1681 | $price_per_period[$period] = array( |
| 1682 | 1682 | 'PERIOD' => $period, |
@@ -1686,7 +1686,7 @@ discard block |
||
| 1686 | 1686 | 'PRICE_UPGRADE' => $price_matrix_upgrade[$level_num][$period], |
| 1687 | 1687 | 'PRICE_UPGRADE_TEXT' => pretty_number($price_matrix_upgrade[$level_num][$period], true), |
| 1688 | 1688 | ); |
| 1689 | - if(isset($price_matrix_plain[$level_num][$period])) { |
|
| 1689 | + if (isset($price_matrix_plain[$level_num][$period])) { |
|
| 1690 | 1690 | $price_per_period[$period] += array( |
| 1691 | 1691 | 'PRICE_PLAIN_PERCENT' => ceil(100 - ($price / $price_matrix_plain[$level_num][$period]) * 100), |
| 1692 | 1692 | 'PRICE_PLAIN' => $price_matrix_plain[$level_num][$period], |
@@ -1706,25 +1706,25 @@ discard block |
||
| 1706 | 1706 | |
| 1707 | 1707 | // ------------------------------------------------------------------------------------------------------------------------------ |
| 1708 | 1708 | function sn_sys_load_php_files($dir_name, $load_extension = 'php', $modules = false) { |
| 1709 | - if(file_exists($dir_name)) { |
|
| 1709 | + if (file_exists($dir_name)) { |
|
| 1710 | 1710 | $dir = opendir($dir_name); |
| 1711 | - while(($file = readdir($dir)) !== false) { |
|
| 1712 | - if($file == '..' || $file == '.') { |
|
| 1711 | + while (($file = readdir($dir)) !== false) { |
|
| 1712 | + if ($file == '..' || $file == '.') { |
|
| 1713 | 1713 | continue; |
| 1714 | 1714 | } |
| 1715 | 1715 | |
| 1716 | 1716 | $full_filename = $dir_name . $file; |
| 1717 | - if($modules && is_dir($full_filename)) { |
|
| 1718 | - if(file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) { |
|
| 1717 | + if ($modules && is_dir($full_filename)) { |
|
| 1718 | + if (file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) { |
|
| 1719 | 1719 | require_once($full_filename); |
| 1720 | 1720 | // Registering module |
| 1721 | - if(class_exists($file)) { |
|
| 1721 | + if (class_exists($file)) { |
|
| 1722 | 1722 | new $file($full_filename); |
| 1723 | 1723 | } |
| 1724 | 1724 | } |
| 1725 | 1725 | } else { |
| 1726 | 1726 | $extension = substr($full_filename, -strlen($load_extension)); |
| 1727 | - if($extension == $load_extension) { |
|
| 1727 | + if ($extension == $load_extension) { |
|
| 1728 | 1728 | require_once($full_filename); |
| 1729 | 1729 | } |
| 1730 | 1730 | } |
@@ -12,8 +12,7 @@ discard block |
||
| 12 | 12 | require_once('general/compatibility.php'); |
| 13 | 13 | require_once('general_pname.php'); |
| 14 | 14 | |
| 15 | -function sn_function_call($func_name, $func_arg = array()) |
|
| 16 | -{ |
|
| 15 | +function sn_function_call($func_name, $func_arg = array()) { |
|
| 17 | 16 | global $functions; // All data in $functions should be normalized to valid 'callable' state: '<function_name>'|array('<object_name>', '<method_name>') |
| 18 | 17 | |
| 19 | 18 | if(is_array($functions[$func_name]) && !is_callable($functions[$func_name])) |
@@ -33,8 +32,7 @@ discard block |
||
| 33 | 32 | $result = call_user_func_array($func_chain_name, $func_arg); |
| 34 | 33 | } |
| 35 | 34 | } |
| 36 | - } |
|
| 37 | - else |
|
| 35 | + } else |
|
| 38 | 36 | { |
| 39 | 37 | // TODO: This is left for backward compatibility. Appropriate code should be rewrote! |
| 40 | 38 | $func_name = isset($functions[$func_name]) && is_callable($functions[$func_name]) ? $functions[$func_name] : ('sn_' . $func_name); |
@@ -65,13 +63,11 @@ discard block |
||
| 65 | 63 | |
| 66 | 64 | // ---------------------------------------------------------------------------------------------------------------- |
| 67 | 65 | // Fonction de lecture / ecriture / exploitation de templates |
| 68 | -function sys_file_read($filename) |
|
| 69 | -{ |
|
| 66 | +function sys_file_read($filename) { |
|
| 70 | 67 | return @file_get_contents($filename); |
| 71 | 68 | } |
| 72 | 69 | |
| 73 | -function sys_file_write($filename, $content) |
|
| 74 | -{ |
|
| 70 | +function sys_file_write($filename, $content) { |
|
| 75 | 71 | return @file_put_contents($filename, $content, FILE_APPEND); |
| 76 | 72 | } |
| 77 | 73 | |
@@ -150,19 +146,16 @@ discard block |
||
| 150 | 146 | false - return array('text' => $ret, 'class' => $class), where $ret - unstyled |
| 151 | 147 | */ |
| 152 | 148 | |
| 153 | -function pretty_number($n, $floor = true, $color = false, $limit = false, $style = null) |
|
| 154 | -{ |
|
| 149 | +function pretty_number($n, $floor = true, $color = false, $limit = false, $style = null) { |
|
| 155 | 150 | $n = floatval($n); |
| 156 | 151 | if(is_int($floor)) |
| 157 | 152 | { |
| 158 | 153 | $n = round($n, $floor); |
| 159 | - } |
|
| 160 | - elseif($floor === true) |
|
| 154 | + } elseif($floor === true) |
|
| 161 | 155 | { |
| 162 | 156 | $n = floor($n); |
| 163 | 157 | $floor = 0; |
| 164 | - } |
|
| 165 | - else |
|
| 158 | + } else |
|
| 166 | 159 | { |
| 167 | 160 | $floor = 2; |
| 168 | 161 | } |
@@ -179,8 +172,7 @@ discard block |
||
| 179 | 172 | $suffix .= 'k'; |
| 180 | 173 | $ret = round($ret / 1000); |
| 181 | 174 | } |
| 182 | - } |
|
| 183 | - else |
|
| 175 | + } else |
|
| 184 | 176 | { |
| 185 | 177 | while($ret < -$limit) |
| 186 | 178 | { |
@@ -198,12 +190,10 @@ discard block |
||
| 198 | 190 | if($color === true) |
| 199 | 191 | { |
| 200 | 192 | $class = $n == 0 ? 'zero' : ($n > 0 ? 'positive' : 'negative'); |
| 201 | - } |
|
| 202 | - elseif($color >= 0) |
|
| 193 | + } elseif($color >= 0) |
|
| 203 | 194 | { |
| 204 | 195 | $class = $n == $color ? 'zero' : ($n < $color ? 'positive' : 'negative'); |
| 205 | - } |
|
| 206 | - else |
|
| 196 | + } else |
|
| 207 | 197 | { |
| 208 | 198 | $class = ($n == -$color) ? 'zero' : ($n < -$color ? 'negative' : 'positive'); |
| 209 | 199 | } |
@@ -211,8 +201,7 @@ discard block |
||
| 211 | 201 | if(!isset($style)) |
| 212 | 202 | { |
| 213 | 203 | $ret = "<span class='{$class}'>{$ret}</span>"; |
| 214 | - } |
|
| 215 | - else |
|
| 204 | + } else |
|
| 216 | 205 | { |
| 217 | 206 | $ret = $style ? $ret = $class : $ret = array('text' => $ret, 'class' => $class); |
| 218 | 207 | } |
@@ -260,8 +249,7 @@ discard block |
||
| 260 | 249 | // ---------------------------------------------------------------------------------------------------------------- |
| 261 | 250 | // Check input string for forbidden words |
| 262 | 251 | // |
| 263 | -function CheckInputStrings($String) |
|
| 264 | -{ |
|
| 252 | +function CheckInputStrings($String) { |
|
| 265 | 253 | global $ListCensure; |
| 266 | 254 | |
| 267 | 255 | return preg_replace($ListCensure, '*', $String); |
@@ -271,8 +259,7 @@ discard block |
||
| 271 | 259 | return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i", $email)); |
| 272 | 260 | } |
| 273 | 261 | |
| 274 | -function is_id($value) |
|
| 275 | -{ |
|
| 262 | +function is_id($value) { |
|
| 276 | 263 | return preg_match('/^\d+$/', $value) && ($value >= 0); |
| 277 | 264 | } |
| 278 | 265 | |
@@ -282,29 +269,24 @@ discard block |
||
| 282 | 269 | * |
| 283 | 270 | * @return string|array |
| 284 | 271 | */ |
| 285 | -function sys_get_param($param_name, $default = '') |
|
| 286 | -{ |
|
| 272 | +function sys_get_param($param_name, $default = '') { |
|
| 287 | 273 | return $_POST[$param_name] !== NULL ? $_POST[$param_name] : ($_GET[$param_name] !== NULL ? $_GET[$param_name] : $default); |
| 288 | 274 | } |
| 289 | 275 | |
| 290 | -function sys_get_param_id($param_name, $default = 0) |
|
| 291 | -{ |
|
| 276 | +function sys_get_param_id($param_name, $default = 0) { |
|
| 292 | 277 | return is_id($value = sys_get_param($param_name, $default)) ? $value : $default; |
| 293 | 278 | } |
| 294 | 279 | |
| 295 | -function sys_get_param_int($param_name, $default = 0) |
|
| 296 | -{ |
|
| 280 | +function sys_get_param_int($param_name, $default = 0) { |
|
| 297 | 281 | $value = sys_get_param($param_name, $default); |
| 298 | 282 | return $value === 'on' ? 1 : ($value === 'off' ? $default : intval($value)); |
| 299 | 283 | } |
| 300 | 284 | |
| 301 | -function sys_get_param_float($param_name, $default = 0) |
|
| 302 | -{ |
|
| 285 | +function sys_get_param_float($param_name, $default = 0) { |
|
| 303 | 286 | return floatval(sys_get_param($param_name, $default)); |
| 304 | 287 | } |
| 305 | 288 | |
| 306 | -function sys_get_param_escaped($param_name, $default = '') |
|
| 307 | -{ |
|
| 289 | +function sys_get_param_escaped($param_name, $default = '') { |
|
| 308 | 290 | return db_escape(sys_get_param($param_name, $default)); |
| 309 | 291 | } |
| 310 | 292 | /* |
@@ -313,24 +295,20 @@ discard block |
||
| 313 | 295 | return db_escape(strip_tags(sys_get_param($param_name, $default))); |
| 314 | 296 | } |
| 315 | 297 | */ |
| 316 | -function sys_get_param_date_sql($param_name, $default = '2000-01-01') |
|
| 317 | -{ |
|
| 298 | +function sys_get_param_date_sql($param_name, $default = '2000-01-01') { |
|
| 318 | 299 | $val = sys_get_param($param_name, $default); |
| 319 | 300 | return preg_match(PREG_DATE_SQL_RELAXED, $val) ? $val : $default; |
| 320 | 301 | } |
| 321 | 302 | |
| 322 | -function sys_get_param_str_unsafe($param_name, $default = '') |
|
| 323 | -{ |
|
| 303 | +function sys_get_param_str_unsafe($param_name, $default = '') { |
|
| 324 | 304 | return str_raw2unsafe(sys_get_param($param_name, $default)); |
| 325 | 305 | } |
| 326 | 306 | |
| 327 | -function sys_get_param_str($param_name, $default = '') |
|
| 328 | -{ |
|
| 307 | +function sys_get_param_str($param_name, $default = '') { |
|
| 329 | 308 | return db_escape(sys_get_param_str_unsafe($param_name, $default)); |
| 330 | 309 | } |
| 331 | 310 | |
| 332 | -function sys_get_param_str_both($param_name, $default = '') |
|
| 333 | -{ |
|
| 311 | +function sys_get_param_str_both($param_name, $default = '') { |
|
| 334 | 312 | $param = sys_get_param($param_name, $default); |
| 335 | 313 | $param_unsafe = str_raw2unsafe($param); |
| 336 | 314 | return array( |
@@ -340,8 +318,7 @@ discard block |
||
| 340 | 318 | ); |
| 341 | 319 | } |
| 342 | 320 | |
| 343 | -function sys_get_param_phone($param_name, $default = '') |
|
| 344 | -{ |
|
| 321 | +function sys_get_param_phone($param_name, $default = '') { |
|
| 345 | 322 | $phone_raw = sys_get_param_str_unsafe($param_name, $default = ''); |
| 346 | 323 | if($phone_raw) |
| 347 | 324 | { |
@@ -355,8 +332,7 @@ discard block |
||
| 355 | 332 | } |
| 356 | 333 | } |
| 357 | 334 | $phone = strlen($phone) < 11 ? '' : $phone; |
| 358 | - } |
|
| 359 | - else |
|
| 335 | + } else |
|
| 360 | 336 | { |
| 361 | 337 | $phone = ''; |
| 362 | 338 | } |
@@ -364,8 +340,7 @@ discard block |
||
| 364 | 340 | return array('raw' => $phone_raw, 'phone' => $phone); |
| 365 | 341 | } |
| 366 | 342 | |
| 367 | -function GetPhalanxRange($phalanx_level) |
|
| 368 | -{ |
|
| 343 | +function GetPhalanxRange($phalanx_level) { |
|
| 369 | 344 | return $phalanx_level > 1 ? pow($phalanx_level, 2) - 1 : 0; |
| 370 | 345 | } |
| 371 | 346 | |
@@ -374,8 +349,7 @@ discard block |
||
| 374 | 349 | * |
| 375 | 350 | * @return bool |
| 376 | 351 | */ |
| 377 | -function CheckAbandonPlanetState(&$planet) |
|
| 378 | -{ |
|
| 352 | +function CheckAbandonPlanetState(&$planet) { |
|
| 379 | 353 | if($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) |
| 380 | 354 | { |
| 381 | 355 | DBStaticPlanet::db_planet_delete_by_id($planet['id']); |
@@ -384,8 +358,7 @@ discard block |
||
| 384 | 358 | return false; |
| 385 | 359 | } |
| 386 | 360 | |
| 387 | -function eco_get_total_cost($unit_id, $unit_level) |
|
| 388 | -{ |
|
| 361 | +function eco_get_total_cost($unit_id, $unit_level) { |
|
| 389 | 362 | global $config; |
| 390 | 363 | |
| 391 | 364 | static $rate, $sn_group_resources_all, $sn_group_resources_loot; |
@@ -510,8 +483,7 @@ discard block |
||
| 510 | 483 | } |
| 511 | 484 | |
| 512 | 485 | function mrc_modify_value(&$user, $planet = array(), $mercenaries, $value) {return sn_function_call('mrc_modify_value', array(&$user, $planet, $mercenaries, $value));} |
| 513 | -function sn_mrc_modify_value(&$user, $planet = array(), $mercenaries, $value, $base_value = null) |
|
| 514 | -{ |
|
| 486 | +function sn_mrc_modify_value(&$user, $planet = array(), $mercenaries, $value, $base_value = null) { |
|
| 515 | 487 | if(!is_array($mercenaries)) |
| 516 | 488 | { |
| 517 | 489 | $mercenaries = array($mercenaries); |
@@ -565,18 +537,15 @@ discard block |
||
| 565 | 537 | return $random_string; |
| 566 | 538 | } |
| 567 | 539 | |
| 568 | -function js_safe_string($string) |
|
| 569 | -{ |
|
| 540 | +function js_safe_string($string) { |
|
| 570 | 541 | return str_replace(array("\r", "\n"), array('\r', '\n'), addslashes($string)); |
| 571 | 542 | } |
| 572 | 543 | |
| 573 | -function sys_safe_output($string) |
|
| 574 | -{ |
|
| 544 | +function sys_safe_output($string) { |
|
| 575 | 545 | return str_replace(array("&", "\"", "<", ">", "'"), array("&", """, "<", ">", "'"), $string); |
| 576 | 546 | } |
| 577 | 547 | |
| 578 | -function sys_user_options_pack(&$user) |
|
| 579 | -{ |
|
| 548 | +function sys_user_options_pack(&$user) { |
|
| 580 | 549 | global $user_option_list; |
| 581 | 550 | |
| 582 | 551 | $options = ''; |
@@ -603,8 +572,7 @@ discard block |
||
| 603 | 572 | return $options; |
| 604 | 573 | } |
| 605 | 574 | |
| 606 | -function sys_user_options_unpack(&$user) |
|
| 607 | -{ |
|
| 575 | +function sys_user_options_unpack(&$user) { |
|
| 608 | 576 | global $user_option_list; |
| 609 | 577 | |
| 610 | 578 | $option_list = array(); |
@@ -635,8 +603,7 @@ discard block |
||
| 635 | 603 | return $final_list; |
| 636 | 604 | } |
| 637 | 605 | |
| 638 | -function sys_unit_str2arr($fleet_string) |
|
| 639 | -{ |
|
| 606 | +function sys_unit_str2arr($fleet_string) { |
|
| 640 | 607 | $fleet_array = array(); |
| 641 | 608 | if(!empty($fleet_string)) |
| 642 | 609 | { |
@@ -657,8 +624,7 @@ discard block |
||
| 657 | 624 | return $fleet_array; |
| 658 | 625 | } |
| 659 | 626 | |
| 660 | -function sys_unit_arr2str($unit_list) |
|
| 661 | -{ |
|
| 627 | +function sys_unit_arr2str($unit_list) { |
|
| 662 | 628 | $fleet_string = array(); |
| 663 | 629 | if(isset($unit_list)) |
| 664 | 630 | { |
@@ -706,8 +672,7 @@ discard block |
||
| 706 | 672 | return @mail($email_unsafe, $title, $body, $head); |
| 707 | 673 | } |
| 708 | 674 | |
| 709 | -function sys_time_human($time, $full = false) |
|
| 710 | -{ |
|
| 675 | +function sys_time_human($time, $full = false) { |
|
| 711 | 676 | global $lang; |
| 712 | 677 | |
| 713 | 678 | $seconds = $time % 60; |
@@ -728,8 +693,7 @@ discard block |
||
| 728 | 693 | return $time ? date(FMT_DATE_TIME_SQL, $time) . " ({$time}), " . sys_time_human(SN_TIME_NOW - $time) : '{NEVER}'; |
| 729 | 694 | } |
| 730 | 695 | |
| 731 | -function sys_redirect($url) |
|
| 732 | -{ |
|
| 696 | +function sys_redirect($url) { |
|
| 733 | 697 | header("Location: {$url}"); |
| 734 | 698 | ob_end_flush(); |
| 735 | 699 | die(); |
@@ -740,8 +704,7 @@ discard block |
||
| 740 | 704 | * |
| 741 | 705 | * @param string $url |
| 742 | 706 | */ |
| 743 | -function sys_redirect_js($url) |
|
| 744 | -{ |
|
| 707 | +function sys_redirect_js($url) { |
|
| 745 | 708 | ob_end_flush(); |
| 746 | 709 | |
| 747 | 710 | $redirectTemplate = gettemplate('_redirect'); |
@@ -764,8 +727,7 @@ discard block |
||
| 764 | 727 | |
| 765 | 728 | // TODO Для полноценного функионирования апдейтера пакет функций, включая эту должен быть вынесен раньше - или грузить general.php до апдейтера |
| 766 | 729 | function sys_get_unit_location($user, $planet, $unit_id){return sn_function_call('sys_get_unit_location', array($user, $planet, $unit_id));} |
| 767 | -function sn_sys_get_unit_location($user, $planet, $unit_id) |
|
| 768 | -{ |
|
| 730 | +function sn_sys_get_unit_location($user, $planet, $unit_id) { |
|
| 769 | 731 | return get_unit_param($unit_id, 'location'); |
| 770 | 732 | } |
| 771 | 733 | |
@@ -783,8 +745,7 @@ discard block |
||
| 783 | 745 | } |
| 784 | 746 | } |
| 785 | 747 | |
| 786 | -function sn_get_url_contents($url) |
|
| 787 | -{ |
|
| 748 | +function sn_get_url_contents($url) { |
|
| 788 | 749 | if(function_exists('curl_init')) |
| 789 | 750 | { |
| 790 | 751 | $crl = curl_init(); |
@@ -794,8 +755,7 @@ discard block |
||
| 794 | 755 | curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); |
| 795 | 756 | $return = curl_exec($crl); |
| 796 | 757 | curl_close($crl); |
| 797 | - } |
|
| 798 | - else |
|
| 758 | + } else |
|
| 799 | 759 | { |
| 800 | 760 | $return = @file_get_contents($url); |
| 801 | 761 | } |
@@ -803,8 +763,7 @@ discard block |
||
| 803 | 763 | return $return; |
| 804 | 764 | } |
| 805 | 765 | |
| 806 | -function get_engine_data($user, $engine_info) |
|
| 807 | -{ |
|
| 766 | +function get_engine_data($user, $engine_info) { |
|
| 808 | 767 | $sn_data_tech_bonus = get_unit_param($engine_info['tech'], 'bonus'); |
| 809 | 768 | |
| 810 | 769 | $user_tech_level = intval(mrc_get_level($user, false, $engine_info['tech'])); |
@@ -822,8 +781,7 @@ discard block |
||
| 822 | 781 | return $engine_info; |
| 823 | 782 | } |
| 824 | 783 | |
| 825 | -function get_ship_data($ship_id, $user) |
|
| 826 | -{ |
|
| 784 | +function get_ship_data($ship_id, $user) { |
|
| 827 | 785 | $ship_data = array(); |
| 828 | 786 | if(in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) |
| 829 | 787 | { |
@@ -845,8 +803,7 @@ discard block |
||
| 845 | 803 | |
| 846 | 804 | if(!function_exists('strptime')) |
| 847 | 805 | { |
| 848 | - function strptime($date, $format) |
|
| 849 | - { |
|
| 806 | + function strptime($date, $format) { |
|
| 850 | 807 | $masks = array( |
| 851 | 808 | '%d' => '(?P<d>[0-9]{2})', |
| 852 | 809 | '%m' => '(?P<m>[0-9]{2})', |
@@ -868,8 +825,7 @@ discard block |
||
| 868 | 825 | "tm_mon" => $out['m'] ? $out['m'] - 1 : 0, |
| 869 | 826 | "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0, |
| 870 | 827 | ); |
| 871 | - } |
|
| 872 | - else |
|
| 828 | + } else |
|
| 873 | 829 | { |
| 874 | 830 | $ret = false; |
| 875 | 831 | } |
@@ -909,8 +865,7 @@ discard block |
||
| 909 | 865 | sys_redirect($redirect); |
| 910 | 866 | } |
| 911 | 867 | |
| 912 | -function sn_sys_handler_add(&$functions, $handler_list, $class_module_name = '', $sub_type = '') |
|
| 913 | -{ |
|
| 868 | +function sn_sys_handler_add(&$functions, $handler_list, $class_module_name = '', $sub_type = '') { |
|
| 914 | 869 | if(isset($handler_list) && is_array($handler_list) && !empty($handler_list)) |
| 915 | 870 | { |
| 916 | 871 | foreach($handler_list as $function_name => $function_data) |
@@ -918,8 +873,7 @@ discard block |
||
| 918 | 873 | if(is_string($function_data)) |
| 919 | 874 | { |
| 920 | 875 | $override_with = &$function_data; |
| 921 | - } |
|
| 922 | - elseif(isset($function_data['callable'])) |
|
| 876 | + } elseif(isset($function_data['callable'])) |
|
| 923 | 877 | { |
| 924 | 878 | $override_with = &$function_data['callable']; |
| 925 | 879 | } |
@@ -933,12 +887,10 @@ discard block |
||
| 933 | 887 | if(($point_position = strpos($override_with, '.')) === false && $class_module_name) |
| 934 | 888 | { |
| 935 | 889 | $override_with = array($class_module_name, $override_with); |
| 936 | - } |
|
| 937 | - elseif($point_position == 0) |
|
| 890 | + } elseif($point_position == 0) |
|
| 938 | 891 | { |
| 939 | 892 | $override_with = substr($override_with, 1); |
| 940 | - } |
|
| 941 | - elseif($point_position > 0) |
|
| 893 | + } elseif($point_position > 0) |
|
| 942 | 894 | { |
| 943 | 895 | $override_with = array(substr($override_with, 0, $point_position), substr($override_with, $point_position + 1)); |
| 944 | 896 | } |
@@ -946,8 +898,7 @@ discard block |
||
| 946 | 898 | if($overwrite) |
| 947 | 899 | { |
| 948 | 900 | $functions[$function_name] = array(); |
| 949 | - } |
|
| 950 | - elseif(!isset($functions[$function_name])) |
|
| 901 | + } elseif(!isset($functions[$function_name])) |
|
| 951 | 902 | { |
| 952 | 903 | $functions[$function_name] = array(); |
| 953 | 904 | $sn_function_name = 'sn_' . $function_name . ($sub_type ? '_' . $sub_type : ''); |
@@ -964,7 +915,7 @@ discard block |
||
| 964 | 915 | |
| 965 | 916 | // TODO - поменять название |
| 966 | 917 | // Может принимать: (array)$user, $nick_render_array, $nick_render_array_html, $nick_render_string_compact |
| 967 | -function player_nick_render_to_html($result, $options = false){ |
|
| 918 | +function player_nick_render_to_html($result, $options = false) { |
|
| 968 | 919 | // TODO - обрабатывать разные случаи: $user, $render_nick_array, $string |
| 969 | 920 | |
| 970 | 921 | if(is_string($result) && strpos($result, ':{i:')) { |
@@ -1199,8 +1150,7 @@ discard block |
||
| 1199 | 1150 | // function sn_render_player_nick($render_user, $options = false, &$result) |
| 1200 | 1151 | |
| 1201 | 1152 | function get_unit_param($unit_id, $param_name = null, $user = null, $planet = null){return sn_function_call('get_unit_param', array($unit_id, $param_name, $user, $planet, &$result));} |
| 1202 | -function sn_get_unit_param($unit_id, $param_name = null, $user = null, $planet = null, &$result) |
|
| 1203 | -{ |
|
| 1153 | +function sn_get_unit_param($unit_id, $param_name = null, $user = null, $planet = null, &$result) { |
|
| 1204 | 1154 | global $sn_data; |
| 1205 | 1155 | |
| 1206 | 1156 | $result = isset($sn_data[$unit_id]) |
@@ -1214,8 +1164,7 @@ discard block |
||
| 1214 | 1164 | } |
| 1215 | 1165 | |
| 1216 | 1166 | function sn_get_groups($groups){return sn_function_call('sn_get_groups', array($groups, &$result));} |
| 1217 | -function sn_sn_get_groups($groups, &$result) |
|
| 1218 | -{ |
|
| 1167 | +function sn_sn_get_groups($groups, &$result) { |
|
| 1219 | 1168 | $result = is_array($result) ? $result : array(); |
| 1220 | 1169 | foreach($groups = is_array($groups) ? $groups : array($groups) as $group_name) |
| 1221 | 1170 | { |
@@ -1232,15 +1181,13 @@ discard block |
||
| 1232 | 1181 | * |
| 1233 | 1182 | * @return float|int |
| 1234 | 1183 | */ |
| 1235 | -function idval($value, $default = 0) |
|
| 1236 | -{ |
|
| 1184 | +function idval($value, $default = 0) { |
|
| 1237 | 1185 | $value = floatval($value); |
| 1238 | 1186 | return preg_match('#^(\d*)#', $value, $matches) && $matches[1] ? floatval($matches[1]) : $default; |
| 1239 | 1187 | } |
| 1240 | 1188 | |
| 1241 | 1189 | function unit_requirements_render($user, $planetrow, $unit_id, $field = 'require'){return sn_function_call('unit_requirements_render', array($user, $planetrow, $unit_id, $field, &$result));} |
| 1242 | -function sn_unit_requirements_render($user, $planetrow, $unit_id, $field = 'require', &$result) |
|
| 1243 | -{ |
|
| 1190 | +function sn_unit_requirements_render($user, $planetrow, $unit_id, $field = 'require', &$result) { |
|
| 1244 | 1191 | global $lang, $config; |
| 1245 | 1192 | |
| 1246 | 1193 | $sn_data_unit = get_unit_param($unit_id); |
@@ -1268,8 +1215,7 @@ discard block |
||
| 1268 | 1215 | return $result; |
| 1269 | 1216 | } |
| 1270 | 1217 | |
| 1271 | -function ally_get_ranks(&$ally) |
|
| 1272 | -{ |
|
| 1218 | +function ally_get_ranks(&$ally) { |
|
| 1273 | 1219 | global $ally_rights; |
| 1274 | 1220 | |
| 1275 | 1221 | $ranks = array(); |
@@ -1316,8 +1262,7 @@ discard block |
||
| 1316 | 1262 | return $array1; |
| 1317 | 1263 | } |
| 1318 | 1264 | |
| 1319 | -function sn_sys_array_cumulative_sum(&$array) |
|
| 1320 | -{ |
|
| 1265 | +function sn_sys_array_cumulative_sum(&$array) { |
|
| 1321 | 1266 | $accum = 0; |
| 1322 | 1267 | foreach($array as &$value) |
| 1323 | 1268 | { |
@@ -1428,8 +1373,7 @@ discard block |
||
| 1428 | 1373 | return $result; |
| 1429 | 1374 | } |
| 1430 | 1375 | |
| 1431 | -function sn_module_get_active_count($group = '*') |
|
| 1432 | -{ |
|
| 1376 | +function sn_module_get_active_count($group = '*') { |
|
| 1433 | 1377 | global $sn_module_list; |
| 1434 | 1378 | |
| 1435 | 1379 | $active_modules = 0; |
@@ -1444,8 +1388,7 @@ discard block |
||
| 1444 | 1388 | return $active_modules; |
| 1445 | 1389 | } |
| 1446 | 1390 | |
| 1447 | -function get_resource_exchange() |
|
| 1448 | -{ |
|
| 1391 | +function get_resource_exchange() { |
|
| 1449 | 1392 | static $rates; |
| 1450 | 1393 | |
| 1451 | 1394 | if(!$rates) |
@@ -1468,8 +1411,7 @@ discard block |
||
| 1468 | 1411 | return $rates; |
| 1469 | 1412 | } |
| 1470 | 1413 | |
| 1471 | -function get_unit_cost_in(&$cost, $in_resource = RES_METAL) |
|
| 1472 | -{ |
|
| 1414 | +function get_unit_cost_in(&$cost, $in_resource = RES_METAL) { |
|
| 1473 | 1415 | static $rates; |
| 1474 | 1416 | |
| 1475 | 1417 | if(!$rates) |
@@ -1487,8 +1429,7 @@ discard block |
||
| 1487 | 1429 | } |
| 1488 | 1430 | |
| 1489 | 1431 | function get_player_max_expeditons(&$user, $astrotech = -1){return sn_function_call('get_player_max_expeditons', array(&$user, $astrotech, &$result));} |
| 1490 | -function sn_get_player_max_expeditons(&$user, $astrotech = -1, &$result = 0) |
|
| 1491 | -{ |
|
| 1432 | +function sn_get_player_max_expeditons(&$user, $astrotech = -1, &$result = 0) { |
|
| 1492 | 1433 | if($astrotech == -1) { |
| 1493 | 1434 | if(!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) |
| 1494 | 1435 | { |
@@ -1502,8 +1443,7 @@ discard block |
||
| 1502 | 1443 | } |
| 1503 | 1444 | } |
| 1504 | 1445 | |
| 1505 | -function get_player_max_expedition_duration(&$user, $astrotech = -1) |
|
| 1506 | -{ |
|
| 1446 | +function get_player_max_expedition_duration(&$user, $astrotech = -1) { |
|
| 1507 | 1447 | return $astrotech == -1 ? mrc_get_level($user, false, TECH_ASTROTECH) : $astrotech; |
| 1508 | 1448 | } |
| 1509 | 1449 | |
@@ -1530,8 +1470,7 @@ discard block |
||
| 1530 | 1470 | } |
| 1531 | 1471 | } |
| 1532 | 1472 | |
| 1533 | -function get_player_current_colonies(&$user) |
|
| 1534 | -{ |
|
| 1473 | +function get_player_current_colonies(&$user) { |
|
| 1535 | 1474 | return $user[UNIT_PLAYER_COLONIES_CURRENT] = isset($user[UNIT_PLAYER_COLONIES_CURRENT]) ? $user[UNIT_PLAYER_COLONIES_CURRENT] : max(0, DBStaticPlanet::db_planet_count_by_type($user['id']) - 1); |
| 1536 | 1475 | } |
| 1537 | 1476 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if(!defined('INSIDE')) { |
|
| 3 | +if (!defined('INSIDE')) { |
|
| 4 | 4 | die('Hack attempt!'); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | "SELECT `id` AS `ID`, `username` AS `NAME`, `ally_name` AS `ALLY`, `total_points` AS `STAT_POINTS`, |
| 84 | 84 | `onlinetime` AS `ACTIVITY` |
| 85 | 85 | FROM {{users}} |
| 86 | - WHERE `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) ." ORDER BY user_as_ally, `". $TypeSort ."` ASC;"); |
|
| 86 | + WHERE `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) . " ORDER BY user_as_ally, `" . $TypeSort . "` ASC;"); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | return doquery("SELECT u.*, COUNT(r.id) AS referral_count, SUM(r.dark_matter) AS referral_dm FROM {{users}} as u |
| 99 | 99 | LEFT JOIN {{referrals}} as r on r.id_partner = u.id |
| 100 | 100 | WHERE" . |
| 101 | - ($online ? " `onlinetime` >= ". (SN_TIME_NOW - $config->game_users_online_timeout) : ' user_as_ally IS NULL') . |
|
| 101 | + ($online ? " `onlinetime` >= " . (SN_TIME_NOW - $config->game_users_online_timeout) : ' user_as_ally IS NULL') . |
|
| 102 | 102 | " GROUP BY u.id |
| 103 | 103 | ORDER BY user_as_ally, {$sort} ASC"); |
| 104 | 104 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | !is_array($user_id_list) ? $user_id_list = array($user_id_list) : false; |
| 115 | 115 | |
| 116 | 116 | $user_list = array(); |
| 117 | - foreach($user_id_list as $user_id_unsafe) { |
|
| 117 | + foreach ($user_id_list as $user_id_unsafe) { |
|
| 118 | 118 | $user = db_user_by_id($user_id_unsafe); |
| 119 | 119 | !empty($user) ? $user_list[$user_id_unsafe] = $user : false; |
| 120 | 120 | } |
@@ -6,7 +6,7 @@ discard block |
||
| 6 | 6 | * @param int|string $user_id_unsafe |
| 7 | 7 | * @param bool $for_update |
| 8 | 8 | * @param string $fields |
| 9 | - * @param null $player |
|
| 9 | + * @param null|boolean $player |
|
| 10 | 10 | * |
| 11 | 11 | * @return array|false |
| 12 | 12 | */ |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | return classSupernova::db_get_user_by_username($username_unsafe, $for_update, $fields, $player, $like); |
| 22 | 22 | } |
| 23 | 23 | /** |
| 24 | - * @param $username_unsafe |
|
| 24 | + * @param string $username_unsafe |
|
| 25 | 25 | * @param bool $for_update |
| 26 | 26 | * @param string $fields |
| 27 | 27 | * @param null $player |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
| 3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
| 4 | 4 | { |
| 5 | 5 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
| 6 | 6 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
| 3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
| 4 | 4 | { |
| 5 | 5 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
| 6 | 6 | } |
@@ -10,11 +10,11 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | // Changing rank for single user |
| 12 | 12 | $id_user = sys_get_param_id('id_user'); |
| 13 | -if(isset($_GET['id_rank'])) |
|
| 13 | +if (isset($_GET['id_rank'])) |
|
| 14 | 14 | { |
| 15 | 15 | $id_rank = sys_get_param_int('id_rank'); |
| 16 | 16 | } |
| 17 | -if($id_user && isset($id_rank) && $user_admin){ |
|
| 17 | +if ($id_user && isset($id_rank) && $user_admin) { |
|
| 18 | 18 | db_user_set_by_id($id_user, "`ally_rank_id` = {$id_rank}"); |
| 19 | 19 | } |
| 20 | 20 | |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | $sort1 = sys_get_param_int('sort1'); |
| 45 | -if($sort1>5 || $sort1<0) $sort1 = 0; |
|
| 45 | +if ($sort1 > 5 || $sort1 < 0) $sort1 = 0; |
|
| 46 | 46 | $sort1s = array( |
| 47 | 47 | 0 => '`ally_rank_id` %1$s;', |
| 48 | 48 | 1 => '`username` %1$s;', |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | 'id, username, galaxy, system, planet, onlinetime, ally_rank_id, ally_register_time, total_points'); |
| 59 | 59 | |
| 60 | 60 | // while ($userRow = db_fetch($userList)) |
| 61 | -foreach($userList as $userRow) |
|
| 61 | +foreach ($userList as $userRow) |
|
| 62 | 62 | { |
| 63 | 63 | $i++; |
| 64 | 64 | if (!isset($ranks[$userRow['ally_rank_id']])) |
@@ -68,17 +68,17 @@ discard block |
||
| 68 | 68 | |
| 69 | 69 | if ($ally['ally_owner'] == $userRow['id']) |
| 70 | 70 | { |
| 71 | - $ally_range = ($ally['ally_owner_range'])?$ally['ally_owner_range']:$lang['Founder']; |
|
| 71 | + $ally_range = ($ally['ally_owner_range']) ? $ally['ally_owner_range'] : $lang['Founder']; |
|
| 72 | 72 | } |
| 73 | 73 | else |
| 74 | 74 | { |
| 75 | - if($user_admin) |
|
| 75 | + if ($user_admin) |
|
| 76 | 76 | { |
| 77 | 77 | $ally_range = '<select onchange="window.location=\'alliance.php?mode=admin&edit=members&id_user=' . $userRow['id'] . '&id_rank=\' + this.value">'; |
| 78 | 78 | |
| 79 | - foreach($ranks as $rankID => $rankArray){ |
|
| 79 | + foreach ($ranks as $rankID => $rankArray) { |
|
| 80 | 80 | $ally_range .= '<option value="' . $rankID . '"'; |
| 81 | - if($rankID == $userRow['ally_rank_id']) |
|
| 81 | + if ($rankID == $userRow['ally_rank_id']) |
|
| 82 | 82 | $ally_range .= " selected"; |
| 83 | 83 | $ally_range .= '>' . $rankArray['name']; |
| 84 | 84 | $ally_range .= '</option>'; |
@@ -92,9 +92,9 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | $last_active = time() - $userRow["onlinetime"]; |
| 95 | - if($user_admin) |
|
| 95 | + if ($user_admin) |
|
| 96 | 96 | { |
| 97 | - if ( $last_active < 60 ) |
|
| 97 | + if ($last_active < 60) |
|
| 98 | 98 | { |
| 99 | 99 | $tmp = "lime>{$lang['On']}"; |
| 100 | 100 | } |
@@ -105,12 +105,12 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | elseif ($last_active < 60 * 60 * 24) |
| 107 | 107 | { |
| 108 | - $last_active = round( $last_active / (60 * 60)); |
|
| 108 | + $last_active = round($last_active / (60 * 60)); |
|
| 109 | 109 | $tmp = "green>{$last_active} {$lang['sys_hrs_short']}"; |
| 110 | 110 | } |
| 111 | 111 | else |
| 112 | 112 | { |
| 113 | - $last_active = round( $last_active / (60 * 60 * 24)); |
|
| 113 | + $last_active = round($last_active / (60 * 60 * 24)); |
|
| 114 | 114 | if ($last_active < 7) |
| 115 | 115 | { |
| 116 | 116 | $tmp = "yellow"; |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | } |
| 129 | 129 | else |
| 130 | 130 | { |
| 131 | - if($user_onlinestatus) |
|
| 131 | + if ($user_onlinestatus) |
|
| 132 | 132 | { |
| 133 | - if ( $last_active < 60 * 5 ) |
|
| 133 | + if ($last_active < 60 * 5) |
|
| 134 | 134 | { |
| 135 | 135 | $tmp = "lime>{$lang['On']}"; |
| 136 | 136 | } |
@@ -34,15 +34,16 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | $sort2s = "DESC"; |
| 36 | 36 | $sort2 = 0; |
| 37 | -} |
|
| 38 | -else |
|
| 37 | +} else |
|
| 39 | 38 | { |
| 40 | 39 | $sort2s = "ASC"; |
| 41 | 40 | $sort2 = 1; |
| 42 | 41 | } |
| 43 | 42 | |
| 44 | 43 | $sort1 = sys_get_param_int('sort1'); |
| 45 | -if($sort1>5 || $sort1<0) $sort1 = 0; |
|
| 44 | +if($sort1>5 || $sort1<0) { |
|
| 45 | + $sort1 = 0; |
|
| 46 | +} |
|
| 46 | 47 | $sort1s = array( |
| 47 | 48 | 0 => '`ally_rank_id` %1$s;', |
| 48 | 49 | 1 => '`username` %1$s;', |
@@ -69,8 +70,7 @@ discard block |
||
| 69 | 70 | if ($ally['ally_owner'] == $userRow['id']) |
| 70 | 71 | { |
| 71 | 72 | $ally_range = ($ally['ally_owner_range'])?$ally['ally_owner_range']:$lang['Founder']; |
| 72 | - } |
|
| 73 | - else |
|
| 73 | + } else |
|
| 74 | 74 | { |
| 75 | 75 | if($user_admin) |
| 76 | 76 | { |
@@ -78,14 +78,14 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | foreach($ranks as $rankID => $rankArray){ |
| 80 | 80 | $ally_range .= '<option value="' . $rankID . '"'; |
| 81 | - if($rankID == $userRow['ally_rank_id']) |
|
| 82 | - $ally_range .= " selected"; |
|
| 81 | + if($rankID == $userRow['ally_rank_id']) { |
|
| 82 | + $ally_range .= " selected"; |
|
| 83 | + } |
|
| 83 | 84 | $ally_range .= '>' . $rankArray['name']; |
| 84 | 85 | $ally_range .= '</option>'; |
| 85 | 86 | } |
| 86 | 87 | $ally_range .= '</select>'; |
| 87 | - } |
|
| 88 | - else |
|
| 88 | + } else |
|
| 89 | 89 | { |
| 90 | 90 | $ally_range = $ranks[$userRow['ally_rank_id']]['name']; |
| 91 | 91 | } |
@@ -97,53 +97,44 @@ discard block |
||
| 97 | 97 | if ( $last_active < 60 ) |
| 98 | 98 | { |
| 99 | 99 | $tmp = "lime>{$lang['On']}"; |
| 100 | - } |
|
| 101 | - elseif ($last_active < 60 * 60) |
|
| 100 | + } elseif ($last_active < 60 * 60) |
|
| 102 | 101 | { |
| 103 | 102 | $last_active = round($last_active / 60); |
| 104 | 103 | $tmp = "lime>{$last_active} {$lang['sys_min_short']}"; |
| 105 | - } |
|
| 106 | - elseif ($last_active < 60 * 60 * 24) |
|
| 104 | + } elseif ($last_active < 60 * 60 * 24) |
|
| 107 | 105 | { |
| 108 | 106 | $last_active = round( $last_active / (60 * 60)); |
| 109 | 107 | $tmp = "green>{$last_active} {$lang['sys_hrs_short']}"; |
| 110 | - } |
|
| 111 | - else |
|
| 108 | + } else |
|
| 112 | 109 | { |
| 113 | 110 | $last_active = round( $last_active / (60 * 60 * 24)); |
| 114 | 111 | if ($last_active < 7) |
| 115 | 112 | { |
| 116 | 113 | $tmp = "yellow"; |
| 117 | - } |
|
| 118 | - elseif ($last_active < 30) |
|
| 114 | + } elseif ($last_active < 30) |
|
| 119 | 115 | { |
| 120 | 116 | $tmp = "orange"; |
| 121 | - } |
|
| 122 | - else |
|
| 117 | + } else |
|
| 123 | 118 | { |
| 124 | 119 | $tmp = "red"; |
| 125 | 120 | } |
| 126 | 121 | $tmp .= ">{$last_active} {$lang['sys_day_short']}"; |
| 127 | 122 | } |
| 128 | - } |
|
| 129 | - else |
|
| 123 | + } else |
|
| 130 | 124 | { |
| 131 | 125 | if($user_onlinestatus) |
| 132 | 126 | { |
| 133 | 127 | if ( $last_active < 60 * 5 ) |
| 134 | 128 | { |
| 135 | 129 | $tmp = "lime>{$lang['On']}"; |
| 136 | - } |
|
| 137 | - elseif ($last_active < 60 * 15) |
|
| 130 | + } elseif ($last_active < 60 * 15) |
|
| 138 | 131 | { |
| 139 | 132 | $tmp = "yellow>{$lang['ali_lessThen15min']}"; |
| 140 | - } |
|
| 141 | - else |
|
| 133 | + } else |
|
| 142 | 134 | { |
| 143 | 135 | $tmp = "red>{$lang['Off']}"; |
| 144 | 136 | } |
| 145 | - } |
|
| 146 | - else |
|
| 137 | + } else |
|
| 147 | 138 | { |
| 148 | 139 | $sort1 = max($sort1, 4); |
| 149 | 140 | $tmp = "orange>-"; |
@@ -23,8 +23,7 @@ |
||
| 23 | 23 | if($user_request['request_denied']) |
| 24 | 24 | { |
| 25 | 25 | $lang['request_text'] = sprintf($lang['ali_req_deny_msg'], $ally['ally_tag'], $user_request['request_text']); |
| 26 | - } |
|
| 27 | - else |
|
| 26 | + } else |
|
| 28 | 27 | { |
| 29 | 28 | $lang['request_text'] = sprintf($lang['ali_req_waiting'], $ally['ally_tag']); |
| 30 | 29 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
| 3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
| 4 | 4 | { |
| 5 | 5 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
| 6 | 6 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | sys_redirect('alliance.php'); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - if($user_request['request_denied']) |
|
| 23 | + if ($user_request['request_denied']) |
|
| 24 | 24 | { |
| 25 | 25 | $lang['request_text'] = sprintf($lang['ali_req_deny_msg'], $ally['ally_tag'], $user_request['request_text']); |
| 26 | 26 | } |
@@ -43,12 +43,12 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $ally = doquery("SELECT * FROM {{alliance}} WHERE `id` ='{$id_ally}'", true); |
| 45 | 45 | |
| 46 | -if(!$ally) |
|
| 46 | +if (!$ally) |
|
| 47 | 47 | { |
| 48 | 48 | messageBox($lang['ali_sys_notFound'], $lang['ali_req_title']); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | -if($ally['ally_request_notallow']) |
|
| 51 | +if ($ally['ally_request_notallow']) |
|
| 52 | 52 | { |
| 53 | 53 | messageBox($lang['ali_req_not_allowed'], $lang['ali_req_title']); |
| 54 | 54 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
| 3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) { |
|
| 4 | 4 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
| 5 | 5 | } |
| 6 | 6 | |
@@ -9,12 +9,12 @@ discard block |
||
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | $d = sys_get_param_id('d'); |
| 12 | -if($d) { |
|
| 12 | +if ($d) { |
|
| 13 | 13 | doquery("UPDATE {{alliance_requests}} SET `request_denied` = 1, `request_text` = '{$lang['ali_req_deny_reason']}' WHERE `id_user`= {$d} LIMIT 1;"); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | $id_user = sys_get_param_id('id_user'); |
| 17 | -if($id_user) { |
|
| 17 | +if ($id_user) { |
|
| 18 | 18 | $ally_name_safe = db_escape($ally['ally_name']); |
| 19 | 19 | $ally_tag_safe = db_escape($ally['ally_tag']); |
| 20 | 20 | db_user_set_by_id($id_user, "`ally_id` = '{$ally['id']}', `ally_name` = '{$ally_name_safe}', `ally_tag` = '{$ally_tag_safe}', `ally_register_time` = " . SN_TIME_NOW . ", `ally_rank_id` = 0"); |