@@ -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 | |
@@ -24,11 +24,11 @@ |
||
| 24 | 24 | |
| 25 | 25 | // require_once('includes/includes/scheduler_process.php'); |
| 26 | 26 | |
| 27 | -if(($result = scheduler_process()) && !defined('IN_ADMIN')) { |
|
| 27 | +if (($result = scheduler_process()) && !defined('IN_ADMIN')) { |
|
| 28 | 28 | $result = htmlspecialchars($result, ENT_QUOTES, 'UTF-8'); |
| 29 | 29 | print(json_encode($result)); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | -if(!defined('IN_ADMIN')) { |
|
| 32 | +if (!defined('IN_ADMIN')) { |
|
| 33 | 33 | die(); |
| 34 | 34 | } |
@@ -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; |
@@ -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,21 +340,18 @@ 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 | |
| 372 | -function CheckAbandonPlanetState(&$planet) |
|
| 373 | -{ |
|
| 347 | +function CheckAbandonPlanetState(&$planet) { |
|
| 374 | 348 | if($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) |
| 375 | 349 | { |
| 376 | 350 | DBStaticPlanet::db_planet_delete_by_id($planet['id']); |
| 377 | 351 | } |
| 378 | 352 | } |
| 379 | 353 | |
| 380 | -function eco_get_total_cost($unit_id, $unit_level) |
|
| 381 | -{ |
|
| 354 | +function eco_get_total_cost($unit_id, $unit_level) { |
|
| 382 | 355 | global $config; |
| 383 | 356 | |
| 384 | 357 | static $rate, $sn_group_resources_all, $sn_group_resources_loot; |
@@ -503,8 +476,7 @@ discard block |
||
| 503 | 476 | } |
| 504 | 477 | |
| 505 | 478 | function mrc_modify_value(&$user, $planet = array(), $mercenaries, $value) {return sn_function_call('mrc_modify_value', array(&$user, $planet, $mercenaries, $value));} |
| 506 | -function sn_mrc_modify_value(&$user, $planet = array(), $mercenaries, $value, $base_value = null) |
|
| 507 | -{ |
|
| 479 | +function sn_mrc_modify_value(&$user, $planet = array(), $mercenaries, $value, $base_value = null) { |
|
| 508 | 480 | if(!is_array($mercenaries)) |
| 509 | 481 | { |
| 510 | 482 | $mercenaries = array($mercenaries); |
@@ -558,18 +530,15 @@ discard block |
||
| 558 | 530 | return $random_string; |
| 559 | 531 | } |
| 560 | 532 | |
| 561 | -function js_safe_string($string) |
|
| 562 | -{ |
|
| 533 | +function js_safe_string($string) { |
|
| 563 | 534 | return str_replace(array("\r", "\n"), array('\r', '\n'), addslashes($string)); |
| 564 | 535 | } |
| 565 | 536 | |
| 566 | -function sys_safe_output($string) |
|
| 567 | -{ |
|
| 537 | +function sys_safe_output($string) { |
|
| 568 | 538 | return str_replace(array("&", "\"", "<", ">", "'"), array("&", """, "<", ">", "'"), $string); |
| 569 | 539 | } |
| 570 | 540 | |
| 571 | -function sys_user_options_pack(&$user) |
|
| 572 | -{ |
|
| 541 | +function sys_user_options_pack(&$user) { |
|
| 573 | 542 | global $user_option_list; |
| 574 | 543 | |
| 575 | 544 | $options = ''; |
@@ -596,8 +565,7 @@ discard block |
||
| 596 | 565 | return $options; |
| 597 | 566 | } |
| 598 | 567 | |
| 599 | -function sys_user_options_unpack(&$user) |
|
| 600 | -{ |
|
| 568 | +function sys_user_options_unpack(&$user) { |
|
| 601 | 569 | global $user_option_list; |
| 602 | 570 | |
| 603 | 571 | $option_list = array(); |
@@ -628,8 +596,7 @@ discard block |
||
| 628 | 596 | return $final_list; |
| 629 | 597 | } |
| 630 | 598 | |
| 631 | -function sys_unit_str2arr($fleet_string) |
|
| 632 | -{ |
|
| 599 | +function sys_unit_str2arr($fleet_string) { |
|
| 633 | 600 | $fleet_array = array(); |
| 634 | 601 | if(!empty($fleet_string)) |
| 635 | 602 | { |
@@ -650,8 +617,7 @@ discard block |
||
| 650 | 617 | return $fleet_array; |
| 651 | 618 | } |
| 652 | 619 | |
| 653 | -function sys_unit_arr2str($unit_list) |
|
| 654 | -{ |
|
| 620 | +function sys_unit_arr2str($unit_list) { |
|
| 655 | 621 | $fleet_string = array(); |
| 656 | 622 | if(isset($unit_list)) |
| 657 | 623 | { |
@@ -699,8 +665,7 @@ discard block |
||
| 699 | 665 | return @mail($email_unsafe, $title, $body, $head); |
| 700 | 666 | } |
| 701 | 667 | |
| 702 | -function sys_time_human($time, $full = false) |
|
| 703 | -{ |
|
| 668 | +function sys_time_human($time, $full = false) { |
|
| 704 | 669 | global $lang; |
| 705 | 670 | |
| 706 | 671 | $seconds = $time % 60; |
@@ -721,8 +686,7 @@ discard block |
||
| 721 | 686 | return $time ? date(FMT_DATE_TIME_SQL, $time) . " ({$time}), " . sys_time_human(SN_TIME_NOW - $time) : '{NEVER}'; |
| 722 | 687 | } |
| 723 | 688 | |
| 724 | -function sys_redirect($url) |
|
| 725 | -{ |
|
| 689 | +function sys_redirect($url) { |
|
| 726 | 690 | header("Location: {$url}"); |
| 727 | 691 | ob_end_flush(); |
| 728 | 692 | die(); |
@@ -733,8 +697,7 @@ discard block |
||
| 733 | 697 | * |
| 734 | 698 | * @param string $url |
| 735 | 699 | */ |
| 736 | -function sys_redirect_js($url) |
|
| 737 | -{ |
|
| 700 | +function sys_redirect_js($url) { |
|
| 738 | 701 | ob_end_flush(); |
| 739 | 702 | |
| 740 | 703 | $redirectTemplate = gettemplate('_redirect'); |
@@ -757,8 +720,7 @@ discard block |
||
| 757 | 720 | |
| 758 | 721 | // TODO Для полноценного функионирования апдейтера пакет функций, включая эту должен быть вынесен раньше - или грузить general.php до апдейтера |
| 759 | 722 | function sys_get_unit_location($user, $planet, $unit_id){return sn_function_call('sys_get_unit_location', array($user, $planet, $unit_id));} |
| 760 | -function sn_sys_get_unit_location($user, $planet, $unit_id) |
|
| 761 | -{ |
|
| 723 | +function sn_sys_get_unit_location($user, $planet, $unit_id) { |
|
| 762 | 724 | return get_unit_param($unit_id, 'location'); |
| 763 | 725 | } |
| 764 | 726 | |
@@ -776,8 +738,7 @@ discard block |
||
| 776 | 738 | } |
| 777 | 739 | } |
| 778 | 740 | |
| 779 | -function sn_get_url_contents($url) |
|
| 780 | -{ |
|
| 741 | +function sn_get_url_contents($url) { |
|
| 781 | 742 | if(function_exists('curl_init')) |
| 782 | 743 | { |
| 783 | 744 | $crl = curl_init(); |
@@ -787,8 +748,7 @@ discard block |
||
| 787 | 748 | curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); |
| 788 | 749 | $return = curl_exec($crl); |
| 789 | 750 | curl_close($crl); |
| 790 | - } |
|
| 791 | - else |
|
| 751 | + } else |
|
| 792 | 752 | { |
| 793 | 753 | $return = @file_get_contents($url); |
| 794 | 754 | } |
@@ -796,8 +756,7 @@ discard block |
||
| 796 | 756 | return $return; |
| 797 | 757 | } |
| 798 | 758 | |
| 799 | -function get_engine_data($user, $engine_info) |
|
| 800 | -{ |
|
| 759 | +function get_engine_data($user, $engine_info) { |
|
| 801 | 760 | $sn_data_tech_bonus = get_unit_param($engine_info['tech'], 'bonus'); |
| 802 | 761 | |
| 803 | 762 | $user_tech_level = intval(mrc_get_level($user, false, $engine_info['tech'])); |
@@ -815,8 +774,7 @@ discard block |
||
| 815 | 774 | return $engine_info; |
| 816 | 775 | } |
| 817 | 776 | |
| 818 | -function get_ship_data($ship_id, $user) |
|
| 819 | -{ |
|
| 777 | +function get_ship_data($ship_id, $user) { |
|
| 820 | 778 | $ship_data = array(); |
| 821 | 779 | if(in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) |
| 822 | 780 | { |
@@ -838,8 +796,7 @@ discard block |
||
| 838 | 796 | |
| 839 | 797 | if(!function_exists('strptime')) |
| 840 | 798 | { |
| 841 | - function strptime($date, $format) |
|
| 842 | - { |
|
| 799 | + function strptime($date, $format) { |
|
| 843 | 800 | $masks = array( |
| 844 | 801 | '%d' => '(?P<d>[0-9]{2})', |
| 845 | 802 | '%m' => '(?P<m>[0-9]{2})', |
@@ -861,8 +818,7 @@ discard block |
||
| 861 | 818 | "tm_mon" => $out['m'] ? $out['m'] - 1 : 0, |
| 862 | 819 | "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0, |
| 863 | 820 | ); |
| 864 | - } |
|
| 865 | - else |
|
| 821 | + } else |
|
| 866 | 822 | { |
| 867 | 823 | $ret = false; |
| 868 | 824 | } |
@@ -902,8 +858,7 @@ discard block |
||
| 902 | 858 | sys_redirect($redirect); |
| 903 | 859 | } |
| 904 | 860 | |
| 905 | -function sn_sys_handler_add(&$functions, $handler_list, $class_module_name = '', $sub_type = '') |
|
| 906 | -{ |
|
| 861 | +function sn_sys_handler_add(&$functions, $handler_list, $class_module_name = '', $sub_type = '') { |
|
| 907 | 862 | if(isset($handler_list) && is_array($handler_list) && !empty($handler_list)) |
| 908 | 863 | { |
| 909 | 864 | foreach($handler_list as $function_name => $function_data) |
@@ -911,8 +866,7 @@ discard block |
||
| 911 | 866 | if(is_string($function_data)) |
| 912 | 867 | { |
| 913 | 868 | $override_with = &$function_data; |
| 914 | - } |
|
| 915 | - elseif(isset($function_data['callable'])) |
|
| 869 | + } elseif(isset($function_data['callable'])) |
|
| 916 | 870 | { |
| 917 | 871 | $override_with = &$function_data['callable']; |
| 918 | 872 | } |
@@ -926,12 +880,10 @@ discard block |
||
| 926 | 880 | if(($point_position = strpos($override_with, '.')) === false && $class_module_name) |
| 927 | 881 | { |
| 928 | 882 | $override_with = array($class_module_name, $override_with); |
| 929 | - } |
|
| 930 | - elseif($point_position == 0) |
|
| 883 | + } elseif($point_position == 0) |
|
| 931 | 884 | { |
| 932 | 885 | $override_with = substr($override_with, 1); |
| 933 | - } |
|
| 934 | - elseif($point_position > 0) |
|
| 886 | + } elseif($point_position > 0) |
|
| 935 | 887 | { |
| 936 | 888 | $override_with = array(substr($override_with, 0, $point_position), substr($override_with, $point_position + 1)); |
| 937 | 889 | } |
@@ -939,8 +891,7 @@ discard block |
||
| 939 | 891 | if($overwrite) |
| 940 | 892 | { |
| 941 | 893 | $functions[$function_name] = array(); |
| 942 | - } |
|
| 943 | - elseif(!isset($functions[$function_name])) |
|
| 894 | + } elseif(!isset($functions[$function_name])) |
|
| 944 | 895 | { |
| 945 | 896 | $functions[$function_name] = array(); |
| 946 | 897 | $sn_function_name = 'sn_' . $function_name . ($sub_type ? '_' . $sub_type : ''); |
@@ -957,7 +908,7 @@ discard block |
||
| 957 | 908 | |
| 958 | 909 | // TODO - поменять название |
| 959 | 910 | // Может принимать: (array)$user, $nick_render_array, $nick_render_array_html, $nick_render_string_compact |
| 960 | -function player_nick_render_to_html($result, $options = false){ |
|
| 911 | +function player_nick_render_to_html($result, $options = false) { |
|
| 961 | 912 | // TODO - обрабатывать разные случаи: $user, $render_nick_array, $string |
| 962 | 913 | |
| 963 | 914 | if(is_string($result) && strpos($result, ':{i:')) { |
@@ -1192,8 +1143,7 @@ discard block |
||
| 1192 | 1143 | // function sn_render_player_nick($render_user, $options = false, &$result) |
| 1193 | 1144 | |
| 1194 | 1145 | 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));} |
| 1195 | -function sn_get_unit_param($unit_id, $param_name = null, $user = null, $planet = null, &$result) |
|
| 1196 | -{ |
|
| 1146 | +function sn_get_unit_param($unit_id, $param_name = null, $user = null, $planet = null, &$result) { |
|
| 1197 | 1147 | global $sn_data; |
| 1198 | 1148 | |
| 1199 | 1149 | $result = isset($sn_data[$unit_id]) |
@@ -1207,8 +1157,7 @@ discard block |
||
| 1207 | 1157 | } |
| 1208 | 1158 | |
| 1209 | 1159 | function sn_get_groups($groups){return sn_function_call('sn_get_groups', array($groups, &$result));} |
| 1210 | -function sn_sn_get_groups($groups, &$result) |
|
| 1211 | -{ |
|
| 1160 | +function sn_sn_get_groups($groups, &$result) { |
|
| 1212 | 1161 | $result = is_array($result) ? $result : array(); |
| 1213 | 1162 | foreach($groups = is_array($groups) ? $groups : array($groups) as $group_name) |
| 1214 | 1163 | { |
@@ -1225,15 +1174,13 @@ discard block |
||
| 1225 | 1174 | * |
| 1226 | 1175 | * @return float|int |
| 1227 | 1176 | */ |
| 1228 | -function idval($value, $default = 0) |
|
| 1229 | -{ |
|
| 1177 | +function idval($value, $default = 0) { |
|
| 1230 | 1178 | $value = floatval($value); |
| 1231 | 1179 | return preg_match('#^(\d*)#', $value, $matches) && $matches[1] ? floatval($matches[1]) : $default; |
| 1232 | 1180 | } |
| 1233 | 1181 | |
| 1234 | 1182 | function unit_requirements_render($user, $planetrow, $unit_id, $field = 'require'){return sn_function_call('unit_requirements_render', array($user, $planetrow, $unit_id, $field, &$result));} |
| 1235 | -function sn_unit_requirements_render($user, $planetrow, $unit_id, $field = 'require', &$result) |
|
| 1236 | -{ |
|
| 1183 | +function sn_unit_requirements_render($user, $planetrow, $unit_id, $field = 'require', &$result) { |
|
| 1237 | 1184 | global $lang, $config; |
| 1238 | 1185 | |
| 1239 | 1186 | $sn_data_unit = get_unit_param($unit_id); |
@@ -1261,8 +1208,7 @@ discard block |
||
| 1261 | 1208 | return $result; |
| 1262 | 1209 | } |
| 1263 | 1210 | |
| 1264 | -function ally_get_ranks(&$ally) |
|
| 1265 | -{ |
|
| 1211 | +function ally_get_ranks(&$ally) { |
|
| 1266 | 1212 | global $ally_rights; |
| 1267 | 1213 | |
| 1268 | 1214 | $ranks = array(); |
@@ -1309,8 +1255,7 @@ discard block |
||
| 1309 | 1255 | return $array1; |
| 1310 | 1256 | } |
| 1311 | 1257 | |
| 1312 | -function sn_sys_array_cumulative_sum(&$array) |
|
| 1313 | -{ |
|
| 1258 | +function sn_sys_array_cumulative_sum(&$array) { |
|
| 1314 | 1259 | $accum = 0; |
| 1315 | 1260 | foreach($array as &$value) |
| 1316 | 1261 | { |
@@ -1421,8 +1366,7 @@ discard block |
||
| 1421 | 1366 | return $result; |
| 1422 | 1367 | } |
| 1423 | 1368 | |
| 1424 | -function sn_module_get_active_count($group = '*') |
|
| 1425 | -{ |
|
| 1369 | +function sn_module_get_active_count($group = '*') { |
|
| 1426 | 1370 | global $sn_module_list; |
| 1427 | 1371 | |
| 1428 | 1372 | $active_modules = 0; |
@@ -1437,8 +1381,7 @@ discard block |
||
| 1437 | 1381 | return $active_modules; |
| 1438 | 1382 | } |
| 1439 | 1383 | |
| 1440 | -function get_resource_exchange() |
|
| 1441 | -{ |
|
| 1384 | +function get_resource_exchange() { |
|
| 1442 | 1385 | static $rates; |
| 1443 | 1386 | |
| 1444 | 1387 | if(!$rates) |
@@ -1461,8 +1404,7 @@ discard block |
||
| 1461 | 1404 | return $rates; |
| 1462 | 1405 | } |
| 1463 | 1406 | |
| 1464 | -function get_unit_cost_in(&$cost, $in_resource = RES_METAL) |
|
| 1465 | -{ |
|
| 1407 | +function get_unit_cost_in(&$cost, $in_resource = RES_METAL) { |
|
| 1466 | 1408 | static $rates; |
| 1467 | 1409 | |
| 1468 | 1410 | if(!$rates) |
@@ -1480,8 +1422,7 @@ discard block |
||
| 1480 | 1422 | } |
| 1481 | 1423 | |
| 1482 | 1424 | function get_player_max_expeditons(&$user, $astrotech = -1){return sn_function_call('get_player_max_expeditons', array(&$user, $astrotech, &$result));} |
| 1483 | -function sn_get_player_max_expeditons(&$user, $astrotech = -1, &$result = 0) |
|
| 1484 | -{ |
|
| 1425 | +function sn_get_player_max_expeditons(&$user, $astrotech = -1, &$result = 0) { |
|
| 1485 | 1426 | if($astrotech == -1) { |
| 1486 | 1427 | if(!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) |
| 1487 | 1428 | { |
@@ -1495,8 +1436,7 @@ discard block |
||
| 1495 | 1436 | } |
| 1496 | 1437 | } |
| 1497 | 1438 | |
| 1498 | -function get_player_max_expedition_duration(&$user, $astrotech = -1) |
|
| 1499 | -{ |
|
| 1439 | +function get_player_max_expedition_duration(&$user, $astrotech = -1) { |
|
| 1500 | 1440 | return $astrotech == -1 ? mrc_get_level($user, false, TECH_ASTROTECH) : $astrotech; |
| 1501 | 1441 | } |
| 1502 | 1442 | |
@@ -1523,8 +1463,7 @@ discard block |
||
| 1523 | 1463 | } |
| 1524 | 1464 | } |
| 1525 | 1465 | |
| 1526 | -function get_player_current_colonies(&$user) |
|
| 1527 | -{ |
|
| 1466 | +function get_player_current_colonies(&$user) { |
|
| 1528 | 1467 | 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); |
| 1529 | 1468 | } |
| 1530 | 1469 | |
@@ -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 | } |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | |
| 372 | 372 | function CheckAbandonPlanetState(&$planet) |
| 373 | 373 | { |
| 374 | - if($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) |
|
| 374 | + if ($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) |
|
| 375 | 375 | { |
| 376 | 376 | DBStaticPlanet::db_planet_delete_by_id($planet['id']); |
| 377 | 377 | } |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | global $config; |
| 383 | 383 | |
| 384 | 384 | static $rate, $sn_group_resources_all, $sn_group_resources_loot; |
| 385 | - if(!$rate) |
|
| 385 | + if (!$rate) |
|
| 386 | 386 | { |
| 387 | 387 | $sn_group_resources_all = sn_get_groups('resources_all'); |
| 388 | 388 | $sn_group_resources_loot = sn_get_groups('resources_loot'); |
@@ -393,22 +393,22 @@ discard block |
||
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | $unit_cost_data = get_unit_param($unit_id, 'cost'); |
| 396 | - if(!is_array($unit_cost_data)) |
|
| 396 | + if (!is_array($unit_cost_data)) |
|
| 397 | 397 | { |
| 398 | 398 | return array('total' => 0); |
| 399 | 399 | } |
| 400 | 400 | $factor = isset($unit_cost_data['factor']) ? $unit_cost_data['factor'] : 1; |
| 401 | 401 | $cost_array = array(BUILD_CREATE => array(), 'total' => 0); |
| 402 | 402 | $unit_level = $unit_level > 0 ? $unit_level : 0; |
| 403 | - foreach($unit_cost_data as $resource_id => $resource_amount) |
|
| 403 | + foreach ($unit_cost_data as $resource_id => $resource_amount) |
|
| 404 | 404 | { |
| 405 | - if(!in_array($resource_id, $sn_group_resources_all)) |
|
| 405 | + if (!in_array($resource_id, $sn_group_resources_all)) |
|
| 406 | 406 | { |
| 407 | 407 | continue; |
| 408 | 408 | } |
| 409 | 409 | // $cost_array[BUILD_CREATE][$resource_id] = $resource_amount * ($factor == 1 ? $unit_level : ((pow($factor, $unit_level) - $factor) / ($factor - 1))); |
| 410 | 410 | $cost_array[BUILD_CREATE][$resource_id] = round($resource_amount * ($factor == 1 ? $unit_level : ((1 - pow($factor, $unit_level)) / (1 - $factor)))); |
| 411 | - if(in_array($resource_id, $sn_group_resources_loot)) |
|
| 411 | + if (in_array($resource_id, $sn_group_resources_loot)) |
|
| 412 | 412 | { |
| 413 | 413 | $cost_array['total'] += $cost_array[BUILD_CREATE][$resource_id] * $rate[$resource_id]; |
| 414 | 414 | } |
@@ -417,9 +417,9 @@ discard block |
||
| 417 | 417 | return $cost_array; |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | -function sn_unit_purchase($unit_id){} |
|
| 420 | +function sn_unit_purchase($unit_id) {} |
|
| 421 | 421 | |
| 422 | -function sn_unit_relocate($unit_id, $from, $to){} |
|
| 422 | +function sn_unit_relocate($unit_id, $from, $to) {} |
|
| 423 | 423 | |
| 424 | 424 | /* |
| 425 | 425 | ЭТО ПРОСТОЙ ВРАППЕР ДЛЯ БД! Здесь НЕТ никаких проверок! ВСЕ проверки должны быть сделаны заранее! |
@@ -478,48 +478,48 @@ discard block |
||
| 478 | 478 | } |
| 479 | 479 | */ |
| 480 | 480 | |
| 481 | -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));} |
|
| 481 | +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)); } |
|
| 482 | 482 | function sn_mrc_get_level(&$user, $planet = array(), $unit_id, $for_update = false, $plain = false, &$result) { |
| 483 | 483 | $mercenary_level = 0; |
| 484 | 484 | $unit_db_name = pname_resource_name($unit_id); |
| 485 | 485 | |
| 486 | - if(in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { |
|
| 486 | + if (in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { |
|
| 487 | 487 | $unit = classSupernova::db_get_unit_by_location($user['id'], LOC_USER, $user['id'], $unit_id); |
| 488 | 488 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0; |
| 489 | - } elseif(in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { |
|
| 489 | + } elseif (in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { |
|
| 490 | 490 | $unit = classSupernova::db_get_unit_by_location(is_array($user) ? $user['id'] : $planet['id_owner'], LOC_PLANET, $planet['id'], $unit_id); |
| 491 | 491 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0; |
| 492 | - } elseif(in_array($unit_id, sn_get_groups('governors'))) { |
|
| 492 | + } elseif (in_array($unit_id, sn_get_groups('governors'))) { |
|
| 493 | 493 | $mercenary_level = $unit_id == $planet['PLANET_GOVERNOR_ID'] ? $planet['PLANET_GOVERNOR_LEVEL'] : 0; |
| 494 | - } elseif($unit_id == RES_DARK_MATTER) { |
|
| 494 | + } elseif ($unit_id == RES_DARK_MATTER) { |
|
| 495 | 495 | $mercenary_level = $user[$unit_db_name] + ($plain || $user['user_as_ally'] ? 0 : classSupernova::$auth->account->account_metamatter); |
| 496 | - } elseif($unit_id == RES_METAMATTER) { |
|
| 496 | + } elseif ($unit_id == RES_METAMATTER) { |
|
| 497 | 497 | $mercenary_level = classSupernova::$auth->account->account_metamatter; //$user[$unit_db_name]; |
| 498 | - } elseif(in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { |
|
| 498 | + } elseif (in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { |
|
| 499 | 499 | $mercenary_level = !empty($planet) ? $planet[$unit_db_name] : $user[$unit_db_name]; |
| 500 | 500 | } |
| 501 | 501 | |
| 502 | 502 | return $result = $mercenary_level; |
| 503 | 503 | } |
| 504 | 504 | |
| 505 | -function mrc_modify_value(&$user, $planet = array(), $mercenaries, $value) {return sn_function_call('mrc_modify_value', array(&$user, $planet, $mercenaries, $value));} |
|
| 505 | +function mrc_modify_value(&$user, $planet = array(), $mercenaries, $value) {return sn_function_call('mrc_modify_value', array(&$user, $planet, $mercenaries, $value)); } |
|
| 506 | 506 | function sn_mrc_modify_value(&$user, $planet = array(), $mercenaries, $value, $base_value = null) |
| 507 | 507 | { |
| 508 | - if(!is_array($mercenaries)) |
|
| 508 | + if (!is_array($mercenaries)) |
|
| 509 | 509 | { |
| 510 | 510 | $mercenaries = array($mercenaries); |
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | $base_value = isset($base_value) ? $base_value : $value; |
| 514 | 514 | |
| 515 | - foreach($mercenaries as $mercenary_id) |
|
| 515 | + foreach ($mercenaries as $mercenary_id) |
|
| 516 | 516 | { |
| 517 | 517 | $mercenary_level = mrc_get_level($user, $planet, $mercenary_id); |
| 518 | 518 | |
| 519 | 519 | $mercenary = get_unit_param($mercenary_id); |
| 520 | 520 | $mercenary_bonus = $mercenary['bonus']; |
| 521 | 521 | |
| 522 | - switch($mercenary['bonus_type']) |
|
| 522 | + switch ($mercenary['bonus_type']) |
|
| 523 | 523 | { |
| 524 | 524 | case BONUS_PERCENT_CUMULATIVE: |
| 525 | 525 | $value *= 1 + $mercenary_level * $mercenary_bonus / 100; |
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | $allowed_length = strlen($allowed_chars); |
| 552 | 552 | |
| 553 | 553 | $random_string = ''; |
| 554 | - for($i = 0; $i < $length; $i++) { |
|
| 554 | + for ($i = 0; $i < $length; $i++) { |
|
| 555 | 555 | $random_string .= $allowed_chars[mt_rand(0, $allowed_length - 1)]; |
| 556 | 556 | } |
| 557 | 557 | |
@@ -574,10 +574,10 @@ discard block |
||
| 574 | 574 | |
| 575 | 575 | $options = ''; |
| 576 | 576 | $option_list = array(); |
| 577 | - foreach($user_option_list as $option_group_id => $option_group) |
|
| 577 | + foreach ($user_option_list as $option_group_id => $option_group) |
|
| 578 | 578 | { |
| 579 | 579 | $option_list[$option_group_id] = array(); |
| 580 | - foreach($option_group as $option_name => $option_value) |
|
| 580 | + foreach ($option_group as $option_name => $option_value) |
|
| 581 | 581 | { |
| 582 | 582 | if (!isset($user[$option_name])) |
| 583 | 583 | { |
@@ -603,19 +603,19 @@ discard block |
||
| 603 | 603 | $option_list = array(); |
| 604 | 604 | $option_string_list = explode('|', $user['options']); |
| 605 | 605 | |
| 606 | - foreach($option_string_list as $option_string) |
|
| 606 | + foreach ($option_string_list as $option_string) |
|
| 607 | 607 | { |
| 608 | 608 | list($option_name, $option_value) = explode('^', $option_string); |
| 609 | 609 | $option_list[$option_name] = $option_value; |
| 610 | 610 | } |
| 611 | 611 | |
| 612 | 612 | $final_list = array(); |
| 613 | - foreach($user_option_list as $option_group_id => $option_group) |
|
| 613 | + foreach ($user_option_list as $option_group_id => $option_group) |
|
| 614 | 614 | { |
| 615 | 615 | $final_list[$option_group_id] = array(); |
| 616 | - foreach($option_group as $option_name => $option_value) |
|
| 616 | + foreach ($option_group as $option_name => $option_value) |
|
| 617 | 617 | { |
| 618 | - if(!isset($option_list[$option_name])) |
|
| 618 | + if (!isset($option_list[$option_name])) |
|
| 619 | 619 | { |
| 620 | 620 | $option_list[$option_name] = $option_value; |
| 621 | 621 | } |
@@ -631,15 +631,15 @@ discard block |
||
| 631 | 631 | function sys_unit_str2arr($fleet_string) |
| 632 | 632 | { |
| 633 | 633 | $fleet_array = array(); |
| 634 | - if(!empty($fleet_string)) |
|
| 634 | + if (!empty($fleet_string)) |
|
| 635 | 635 | { |
| 636 | 636 | $arrTemp = explode(';', $fleet_string); |
| 637 | - foreach($arrTemp as $temp) |
|
| 637 | + foreach ($arrTemp as $temp) |
|
| 638 | 638 | { |
| 639 | - if($temp) |
|
| 639 | + if ($temp) |
|
| 640 | 640 | { |
| 641 | 641 | $temp = explode(',', $temp); |
| 642 | - if(!empty($temp[0]) && !empty($temp[1])) |
|
| 642 | + if (!empty($temp[0]) && !empty($temp[1])) |
|
| 643 | 643 | { |
| 644 | 644 | $fleet_array[$temp[0]] += $temp[1]; |
| 645 | 645 | } |
@@ -653,16 +653,16 @@ discard block |
||
| 653 | 653 | function sys_unit_arr2str($unit_list) |
| 654 | 654 | { |
| 655 | 655 | $fleet_string = array(); |
| 656 | - if(isset($unit_list)) |
|
| 656 | + if (isset($unit_list)) |
|
| 657 | 657 | { |
| 658 | - if(!is_array($unit_list)) |
|
| 658 | + if (!is_array($unit_list)) |
|
| 659 | 659 | { |
| 660 | 660 | $unit_list = array($unit_list => 1); |
| 661 | 661 | } |
| 662 | 662 | |
| 663 | - foreach($unit_list as $unit_id => $unit_count) |
|
| 663 | + foreach ($unit_list as $unit_id => $unit_count) |
|
| 664 | 664 | { |
| 665 | - if($unit_id && $unit_count) |
|
| 665 | + if ($unit_id && $unit_count) |
|
| 666 | 666 | { |
| 667 | 667 | $fleet_string[] = "{$unit_id},{$unit_count}"; |
| 668 | 668 | } |
@@ -678,7 +678,7 @@ discard block |
||
| 678 | 678 | $from = trim($from ? $from : classSupernova::$config->game_adminEmail); |
| 679 | 679 | |
| 680 | 680 | $head = ''; |
| 681 | - $head .= "Content-Type: text/" . ($html ? 'html' : 'plain'). "; charset=utf-8 \r\n"; |
|
| 681 | + $head .= "Content-Type: text/" . ($html ? 'html' : 'plain') . "; charset=utf-8 \r\n"; |
|
| 682 | 682 | $head .= "Date: " . date('r') . " \r\n"; |
| 683 | 683 | $head .= "Return-Path: {classSupernova::$config->game_adminEmail} \r\n"; |
| 684 | 684 | $head .= "From: {$from} \r\n"; |
@@ -690,7 +690,7 @@ discard block |
||
| 690 | 690 | $body = str_replace("\r\n", "\n", $body); |
| 691 | 691 | $body = str_replace("\n", "\r\n", $body); |
| 692 | 692 | |
| 693 | - if($html) { |
|
| 693 | + if ($html) { |
|
| 694 | 694 | $body = '<html><head><base href="' . SN_ROOT_VIRTUAL . '"></head><body>' . nl2br($body) . '</body></html>'; |
| 695 | 695 | } |
| 696 | 696 | |
@@ -704,15 +704,15 @@ discard block |
||
| 704 | 704 | global $lang; |
| 705 | 705 | |
| 706 | 706 | $seconds = $time % 60; |
| 707 | - $time = floor($time/60); |
|
| 707 | + $time = floor($time / 60); |
|
| 708 | 708 | $minutes = $time % 60; |
| 709 | - $time = floor($time/60); |
|
| 709 | + $time = floor($time / 60); |
|
| 710 | 710 | $hours = $time % 24; |
| 711 | - $time = floor($time/24); |
|
| 711 | + $time = floor($time / 24); |
|
| 712 | 712 | |
| 713 | 713 | return |
| 714 | - ($full || $time ? "{$time} {$lang['sys_day']} " : '') . |
|
| 715 | - ($full || $hours ? "{$hours} {$lang['sys_hrs']} " : '') . |
|
| 714 | + ($full || $time ? "{$time} {$lang['sys_day']} " : '') . |
|
| 715 | + ($full || $hours ? "{$hours} {$lang['sys_hrs']} " : '') . |
|
| 716 | 716 | ($full || $minutes ? "{$minutes} {$lang['sys_min']} " : '') . |
| 717 | 717 | ($full || !$time || $seconds ? "{$seconds} {$lang['sys_sec']}" : ''); |
| 718 | 718 | } |
@@ -756,35 +756,35 @@ discard block |
||
| 756 | 756 | } |
| 757 | 757 | |
| 758 | 758 | // TODO Для полноценного функионирования апдейтера пакет функций, включая эту должен быть вынесен раньше - или грузить general.php до апдейтера |
| 759 | -function sys_get_unit_location($user, $planet, $unit_id){return sn_function_call('sys_get_unit_location', array($user, $planet, $unit_id));} |
|
| 759 | +function sys_get_unit_location($user, $planet, $unit_id) {return sn_function_call('sys_get_unit_location', array($user, $planet, $unit_id)); } |
|
| 760 | 760 | function sn_sys_get_unit_location($user, $planet, $unit_id) |
| 761 | 761 | { |
| 762 | 762 | return get_unit_param($unit_id, 'location'); |
| 763 | 763 | } |
| 764 | 764 | |
| 765 | 765 | function sn_ali_fill_user_ally(&$user) { |
| 766 | - if(!$user['ally_id']) { |
|
| 766 | + if (!$user['ally_id']) { |
|
| 767 | 767 | return; |
| 768 | 768 | } |
| 769 | 769 | |
| 770 | - if(!isset($user['ally'])) { |
|
| 770 | + if (!isset($user['ally'])) { |
|
| 771 | 771 | $user['ally'] = doquery("SELECT * FROM {{alliance}} WHERE `id` = {$user['ally_id']} LIMIT 1;", true); |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | - if(!isset($user['ally']['player'])) { |
|
| 774 | + if (!isset($user['ally']['player'])) { |
|
| 775 | 775 | $user['ally']['player'] = db_user_by_id($user['ally']['ally_user_id'], true, '*', false); |
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | 778 | |
| 779 | 779 | function sn_get_url_contents($url) |
| 780 | 780 | { |
| 781 | - if(function_exists('curl_init')) |
|
| 781 | + if (function_exists('curl_init')) |
|
| 782 | 782 | { |
| 783 | 783 | $crl = curl_init(); |
| 784 | 784 | $timeout = 5; |
| 785 | - curl_setopt ($crl, CURLOPT_URL,$url); |
|
| 786 | - curl_setopt ($crl, CURLOPT_RETURNTRANSFER, 1); |
|
| 787 | - curl_setopt ($crl, CURLOPT_CONNECTTIMEOUT, $timeout); |
|
| 785 | + curl_setopt($crl, CURLOPT_URL, $url); |
|
| 786 | + curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1); |
|
| 787 | + curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, $timeout); |
|
| 788 | 788 | $return = curl_exec($crl); |
| 789 | 789 | curl_close($crl); |
| 790 | 790 | } |
@@ -818,12 +818,12 @@ discard block |
||
| 818 | 818 | function get_ship_data($ship_id, $user) |
| 819 | 819 | { |
| 820 | 820 | $ship_data = array(); |
| 821 | - if(in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) |
|
| 821 | + if (in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) |
|
| 822 | 822 | { |
| 823 | - foreach(get_unit_param($ship_id, 'engine') as $engine_info) |
|
| 823 | + foreach (get_unit_param($ship_id, 'engine') as $engine_info) |
|
| 824 | 824 | { |
| 825 | 825 | $tech_level = intval(mrc_get_level($user, false, $engine_info['tech'])); |
| 826 | - if(empty($ship_data) || $tech_level >= $engine_info['min_level']) |
|
| 826 | + if (empty($ship_data) || $tech_level >= $engine_info['min_level']) |
|
| 827 | 827 | { |
| 828 | 828 | $ship_data = $engine_info; |
| 829 | 829 | $ship_data['tech_level'] = $tech_level; |
@@ -836,7 +836,7 @@ discard block |
||
| 836 | 836 | return $ship_data; |
| 837 | 837 | } |
| 838 | 838 | |
| 839 | -if(!function_exists('strptime')) |
|
| 839 | +if (!function_exists('strptime')) |
|
| 840 | 840 | { |
| 841 | 841 | function strptime($date, $format) |
| 842 | 842 | { |
@@ -850,8 +850,8 @@ discard block |
||
| 850 | 850 | // usw.. |
| 851 | 851 | ); |
| 852 | 852 | |
| 853 | - $rexep = "#".strtr(preg_quote($format), $masks)."#"; |
|
| 854 | - if(preg_match($rexep, $date, $out)) |
|
| 853 | + $rexep = "#" . strtr(preg_quote($format), $masks) . "#"; |
|
| 854 | + if (preg_match($rexep, $date, $out)) |
|
| 855 | 855 | { |
| 856 | 856 | $ret = array( |
| 857 | 857 | "tm_sec" => (int) $out['S'], |
@@ -873,7 +873,7 @@ discard block |
||
| 873 | 873 | function sn_sys_sector_buy($redirect = 'overview.php') { |
| 874 | 874 | global $lang, $user, $planetrow; |
| 875 | 875 | |
| 876 | - if(!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { |
|
| 876 | + if (!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { |
|
| 877 | 877 | return; |
| 878 | 878 | } |
| 879 | 879 | |
@@ -886,9 +886,9 @@ discard block |
||
| 886 | 886 | // $planetrow = $planetrow['planet']; |
| 887 | 887 | $sector_cost = eco_get_build_data($user, $planetrow, UNIT_SECTOR, mrc_get_level($user, $planetrow, UNIT_SECTOR), true); |
| 888 | 888 | $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER]; |
| 889 | - if($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { |
|
| 889 | + if ($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { |
|
| 890 | 890 | $planet_name_text = uni_render_planet($planetrow); |
| 891 | - if(rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf($lang['sys_sector_purchase_log'], |
|
| 891 | + if (rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf($lang['sys_sector_purchase_log'], |
|
| 892 | 892 | $user['username'], $user['id'], $planet_name_text, $lang['sys_planet_type'][$planetrow['planet_type']], $planetrow['id'], $sector_cost) |
| 893 | 893 | )) { |
| 894 | 894 | $sector_db_name = pname_resource_name(UNIT_SECTOR); |
@@ -904,43 +904,43 @@ discard block |
||
| 904 | 904 | |
| 905 | 905 | function sn_sys_handler_add(&$functions, $handler_list, $class_module_name = '', $sub_type = '') |
| 906 | 906 | { |
| 907 | - if(isset($handler_list) && is_array($handler_list) && !empty($handler_list)) |
|
| 907 | + if (isset($handler_list) && is_array($handler_list) && !empty($handler_list)) |
|
| 908 | 908 | { |
| 909 | - foreach($handler_list as $function_name => $function_data) |
|
| 909 | + foreach ($handler_list as $function_name => $function_data) |
|
| 910 | 910 | { |
| 911 | - if(is_string($function_data)) |
|
| 911 | + if (is_string($function_data)) |
|
| 912 | 912 | { |
| 913 | 913 | $override_with = &$function_data; |
| 914 | 914 | } |
| 915 | - elseif(isset($function_data['callable'])) |
|
| 915 | + elseif (isset($function_data['callable'])) |
|
| 916 | 916 | { |
| 917 | 917 | $override_with = &$function_data['callable']; |
| 918 | 918 | } |
| 919 | 919 | |
| 920 | 920 | $overwrite = $override_with[0] == '*'; |
| 921 | - if($overwrite) |
|
| 921 | + if ($overwrite) |
|
| 922 | 922 | { |
| 923 | 923 | $override_with = substr($override_with, 1); |
| 924 | 924 | } |
| 925 | 925 | |
| 926 | - if(($point_position = strpos($override_with, '.')) === false && $class_module_name) |
|
| 926 | + if (($point_position = strpos($override_with, '.')) === false && $class_module_name) |
|
| 927 | 927 | { |
| 928 | 928 | $override_with = array($class_module_name, $override_with); |
| 929 | 929 | } |
| 930 | - elseif($point_position == 0) |
|
| 930 | + elseif ($point_position == 0) |
|
| 931 | 931 | { |
| 932 | 932 | $override_with = substr($override_with, 1); |
| 933 | 933 | } |
| 934 | - elseif($point_position > 0) |
|
| 934 | + elseif ($point_position > 0) |
|
| 935 | 935 | { |
| 936 | 936 | $override_with = array(substr($override_with, 0, $point_position), substr($override_with, $point_position + 1)); |
| 937 | 937 | } |
| 938 | 938 | |
| 939 | - if($overwrite) |
|
| 939 | + if ($overwrite) |
|
| 940 | 940 | { |
| 941 | 941 | $functions[$function_name] = array(); |
| 942 | 942 | } |
| 943 | - elseif(!isset($functions[$function_name])) |
|
| 943 | + elseif (!isset($functions[$function_name])) |
|
| 944 | 944 | { |
| 945 | 945 | $functions[$function_name] = array(); |
| 946 | 946 | $sn_function_name = 'sn_' . $function_name . ($sub_type ? '_' . $sub_type : ''); |
@@ -957,18 +957,18 @@ discard block |
||
| 957 | 957 | |
| 958 | 958 | // TODO - поменять название |
| 959 | 959 | // Может принимать: (array)$user, $nick_render_array, $nick_render_array_html, $nick_render_string_compact |
| 960 | -function player_nick_render_to_html($result, $options = false){ |
|
| 960 | +function player_nick_render_to_html($result, $options = false) { |
|
| 961 | 961 | // TODO - обрабатывать разные случаи: $user, $render_nick_array, $string |
| 962 | 962 | |
| 963 | - if(is_string($result) && strpos($result, ':{i:')) { |
|
| 963 | + if (is_string($result) && strpos($result, ':{i:')) { |
|
| 964 | 964 | $result = player_nick_uncompact($result); |
| 965 | 965 | } |
| 966 | 966 | |
| 967 | - if(is_array($result)) { |
|
| 968 | - if(isset($result['id'])) { |
|
| 967 | + if (is_array($result)) { |
|
| 968 | + if (isset($result['id'])) { |
|
| 969 | 969 | $result = player_nick_render_current_to_array($result, $options); |
| 970 | 970 | } |
| 971 | - if(!isset($result[NICK_HTML])) { |
|
| 971 | + if (!isset($result[NICK_HTML])) { |
|
| 972 | 972 | $result = player_nick_render_array_to_html($result); |
| 973 | 973 | } |
| 974 | 974 | unset($result[NICK_HTML]); |
@@ -990,19 +990,19 @@ discard block |
||
| 990 | 990 | try { |
| 991 | 991 | $result = unserialize($nick_string); |
| 992 | 992 | // ksort($result); // Всегда ksort-ый в player_nick_compact() |
| 993 | - } catch(exception $e) { |
|
| 993 | + } catch (exception $e) { |
|
| 994 | 994 | $result = strpos($nick_string, ':{i:') ? null : $nick_string; // fallback if it is already string - for old chat strings, for example |
| 995 | 995 | } |
| 996 | 996 | return $result; |
| 997 | 997 | } |
| 998 | 998 | |
| 999 | -function player_nick_render_array_to_html($nick_array){return sn_function_call('player_nick_render_array_to_html', array($nick_array, &$result));} |
|
| 999 | +function player_nick_render_array_to_html($nick_array) {return sn_function_call('player_nick_render_array_to_html', array($nick_array, &$result)); } |
|
| 1000 | 1000 | function sn_player_nick_render_array_to_html($nick_array, &$result) { |
| 1001 | 1001 | global $config, $user; |
| 1002 | 1002 | |
| 1003 | 1003 | static $iconCache = array(); |
| 1004 | 1004 | |
| 1005 | - if(empty($iconCache['gender_' . $nick_array[NICK_GENDER]])) { |
|
| 1005 | + if (empty($iconCache['gender_' . $nick_array[NICK_GENDER]])) { |
|
| 1006 | 1006 | $iconCache['gender_' . $nick_array[NICK_GENDER]] = classSupernova::$gc->skinModel->getImageCurrent("gender_{$nick_array[NICK_GENDER]}|html"); |
| 1007 | 1007 | $iconCache['icon_vacation'] = classSupernova::$gc->skinModel->getImageCurrent('icon_vacation|html'); |
| 1008 | 1008 | $iconCache['icon_birthday'] = classSupernova::$gc->skinModel->getImageCurrent('icon_birthday|html'); |
@@ -1010,25 +1010,25 @@ discard block |
||
| 1010 | 1010 | $iconGender = $iconCache['gender_' . $nick_array[NICK_GENDER]]; |
| 1011 | 1011 | |
| 1012 | 1012 | // ALL STRING ARE UNSAFE!!! |
| 1013 | - if(isset($nick_array[NICK_BIRTHSDAY])) { |
|
| 1013 | + if (isset($nick_array[NICK_BIRTHSDAY])) { |
|
| 1014 | 1014 | // $result[NICK_BIRTHSDAY] = '<img src="design/images/birthday.png" />'; |
| 1015 | 1015 | $result[NICK_BIRTHSDAY] = $iconCache['icon_birthday']; |
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | - if(isset($nick_array[NICK_VACATION])) { |
|
| 1018 | + if (isset($nick_array[NICK_VACATION])) { |
|
| 1019 | 1019 | // $result[NICK_VACATION] = '<img src="design/images/icon_vacation.png" />'; |
| 1020 | 1020 | // $result[NICK_VACATION] = classSupernova::$gc->skinModel->getImageCurrent('icon_vacation|html'); |
| 1021 | 1021 | $result[NICK_VACATION] = $iconCache['icon_vacation']; |
| 1022 | 1022 | } |
| 1023 | 1023 | |
| 1024 | - if(isset($nick_array[NICK_GENDER])) { |
|
| 1024 | + if (isset($nick_array[NICK_GENDER])) { |
|
| 1025 | 1025 | // $result[NICK_GENDER] = '<img src="' . classSupernova::$gc->theUser->getSkinPath() . 'images/gender_' . $nick_array[NICK_GENDER] . '.png" />'; |
| 1026 | 1026 | // $result[NICK_GENDER] = classSupernova::$gc->skinModel->getImageCurrent("gender_{$nick_array[NICK_GENDER]}|html"); |
| 1027 | 1027 | $result[NICK_GENDER] = $iconGender; |
| 1028 | 1028 | } |
| 1029 | 1029 | |
| 1030 | - if(isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { |
|
| 1031 | - switch($nick_array[NICK_AUTH_LEVEL]) { |
|
| 1030 | + if (isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { |
|
| 1031 | + switch ($nick_array[NICK_AUTH_LEVEL]) { |
|
| 1032 | 1032 | case 4: |
| 1033 | 1033 | $highlight = classSupernova::$config->chat_highlight_developer; |
| 1034 | 1034 | break; |
@@ -1049,20 +1049,20 @@ discard block |
||
| 1049 | 1049 | $highlight = isset($nick_array[NICK_PREMIUM]) ? classSupernova::$config->chat_highlight_premium : ''; |
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | - if($highlight) { |
|
| 1052 | + if ($highlight) { |
|
| 1053 | 1053 | list($result[NICK_HIGHLIGHT], $result[NICK_HIGHLIGHT_END]) = explode('$1', $highlight); |
| 1054 | 1054 | } |
| 1055 | 1055 | // $result = preg_replace("#(.+)#", $highlight, $result); |
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | - if(isset($nick_array[NICK_CLASS])) { |
|
| 1059 | - $result[NICK_CLASS] = '<span ' . $nick_array[NICK_CLASS] .'>'; |
|
| 1058 | + if (isset($nick_array[NICK_CLASS])) { |
|
| 1059 | + $result[NICK_CLASS] = '<span ' . $nick_array[NICK_CLASS] . '>'; |
|
| 1060 | 1060 | $result[NICK_CLASS_END] = '</span>'; |
| 1061 | 1061 | } |
| 1062 | 1062 | |
| 1063 | 1063 | $result[NICK_NICK] = sys_safe_output($nick_array[NICK_NICK]); |
| 1064 | 1064 | |
| 1065 | - if(isset($nick_array[NICK_ALLY])) { |
|
| 1065 | + if (isset($nick_array[NICK_ALLY])) { |
|
| 1066 | 1066 | $result[NICK_ALLY] = '[' . sys_safe_output($nick_array[NICK_ALLY]) . ']'; |
| 1067 | 1067 | } |
| 1068 | 1068 | |
@@ -1071,7 +1071,7 @@ discard block |
||
| 1071 | 1071 | return $result; |
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | -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));} |
|
| 1074 | +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)); } |
|
| 1075 | 1075 | function sn_player_nick_render_current_to_array($render_user, $options = false, &$result) { |
| 1076 | 1076 | /* |
| 1077 | 1077 | $options = $options !== true ? $options : |
@@ -1085,32 +1085,32 @@ discard block |
||
| 1085 | 1085 | */ |
| 1086 | 1086 | |
| 1087 | 1087 | |
| 1088 | - 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))) { |
|
| 1088 | + 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))) { |
|
| 1089 | 1089 | $result[NICK_BIRTHSDAY] = ''; |
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | - if($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { |
|
| 1092 | + if ($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { |
|
| 1093 | 1093 | $result[NICK_GENDER] = $render_user['gender'] == GENDER_UNKNOWN ? 'unknown' : ($render_user['gender'] == GENDER_FEMALE ? 'female' : 'male'); |
| 1094 | 1094 | } |
| 1095 | 1095 | |
| 1096 | - if(($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
|
| 1096 | + if (($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
|
| 1097 | 1097 | $result[NICK_VACATION] = $render_user['vacation']; |
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | - if($options === true || (isset($options['color']) && $options['color'])) { |
|
| 1101 | - if($user_auth_level = $render_user['authlevel']) { |
|
| 1100 | + if ($options === true || (isset($options['color']) && $options['color'])) { |
|
| 1101 | + if ($user_auth_level = $render_user['authlevel']) { |
|
| 1102 | 1102 | $result[NICK_AUTH_LEVEL] = $user_auth_level; |
| 1103 | 1103 | } |
| 1104 | - if($user_premium = mrc_get_level($render_user, false, UNIT_PREMIUM)) { |
|
| 1104 | + if ($user_premium = mrc_get_level($render_user, false, UNIT_PREMIUM)) { |
|
| 1105 | 1105 | $result[NICK_PREMIUM] = $user_premium; |
| 1106 | 1106 | } |
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | - if((isset($options['class']) && $options['class'])) { |
|
| 1109 | + if ((isset($options['class']) && $options['class'])) { |
|
| 1110 | 1110 | $result[NICK_CLASS] = (isset($result_options[NICK_CLASS]) ? ' ' . $result_options[NICK_CLASS] : '') . $options['class']; |
| 1111 | 1111 | } |
| 1112 | 1112 | |
| 1113 | - if($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
|
| 1113 | + if ($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
|
| 1114 | 1114 | $result[NICK_ALLY] = $render_user['ally_tag']; |
| 1115 | 1115 | } |
| 1116 | 1116 | |
@@ -1161,25 +1161,25 @@ discard block |
||
| 1161 | 1161 | |
| 1162 | 1162 | $user_skip_list = array(); |
| 1163 | 1163 | |
| 1164 | - if(classSupernova::$config->stats_hide_admins) { |
|
| 1164 | + if (classSupernova::$config->stats_hide_admins) { |
|
| 1165 | 1165 | $user_skip_list[] = '`authlevel` > 0'; |
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | - if(classSupernova::$config->stats_hide_player_list) { |
|
| 1168 | + if (classSupernova::$config->stats_hide_player_list) { |
|
| 1169 | 1169 | $temp = explode(',', classSupernova::$config->stats_hide_player_list); |
| 1170 | - foreach($temp as $user_id) { |
|
| 1170 | + foreach ($temp as $user_id) { |
|
| 1171 | 1171 | $user_id = floatval($user_id); |
| 1172 | - if($user_id) { |
|
| 1172 | + if ($user_id) { |
|
| 1173 | 1173 | $user_skip_list[] = '`id` = ' . $user_id; |
| 1174 | 1174 | } |
| 1175 | 1175 | } |
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | - if(!empty($user_skip_list)) { |
|
| 1178 | + if (!empty($user_skip_list)) { |
|
| 1179 | 1179 | $user_skip_list = implode(' OR ', $user_skip_list); |
| 1180 | 1180 | $user_skip_query = db_user_list($user_skip_list); |
| 1181 | - if(!empty($user_skip_query)) { |
|
| 1182 | - foreach($user_skip_query as $user_skip_row) { |
|
| 1181 | + if (!empty($user_skip_query)) { |
|
| 1182 | + foreach ($user_skip_query as $user_skip_row) { |
|
| 1183 | 1183 | $result[$user_skip_row['id']] = $user_skip_row['id']; |
| 1184 | 1184 | } |
| 1185 | 1185 | } |
@@ -1191,7 +1191,7 @@ discard block |
||
| 1191 | 1191 | // function player_nick_render_to_html($render_user, $options = false){return sn_function_call('player_nick_render_to_html', array($render_user, $options, &$result));} |
| 1192 | 1192 | // function sn_render_player_nick($render_user, $options = false, &$result) |
| 1193 | 1193 | |
| 1194 | -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));} |
|
| 1194 | +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)); } |
|
| 1195 | 1195 | function sn_get_unit_param($unit_id, $param_name = null, $user = null, $planet = null, &$result) |
| 1196 | 1196 | { |
| 1197 | 1197 | global $sn_data; |
@@ -1206,11 +1206,11 @@ discard block |
||
| 1206 | 1206 | return $result; |
| 1207 | 1207 | } |
| 1208 | 1208 | |
| 1209 | -function sn_get_groups($groups){return sn_function_call('sn_get_groups', array($groups, &$result));} |
|
| 1209 | +function sn_get_groups($groups) {return sn_function_call('sn_get_groups', array($groups, &$result)); } |
|
| 1210 | 1210 | function sn_sn_get_groups($groups, &$result) |
| 1211 | 1211 | { |
| 1212 | 1212 | $result = is_array($result) ? $result : array(); |
| 1213 | - foreach($groups = is_array($groups) ? $groups : array($groups) as $group_name) |
|
| 1213 | + foreach ($groups = is_array($groups) ? $groups : array($groups) as $group_name) |
|
| 1214 | 1214 | { |
| 1215 | 1215 | $result += is_array($a_group = get_unit_param(UNIT_GROUP, $group_name)) ? $a_group : array(); |
| 1216 | 1216 | } |
@@ -1231,7 +1231,7 @@ discard block |
||
| 1231 | 1231 | return preg_match('#^(\d*)#', $value, $matches) && $matches[1] ? floatval($matches[1]) : $default; |
| 1232 | 1232 | } |
| 1233 | 1233 | |
| 1234 | -function unit_requirements_render($user, $planetrow, $unit_id, $field = 'require'){return sn_function_call('unit_requirements_render', array($user, $planetrow, $unit_id, $field, &$result));} |
|
| 1234 | +function unit_requirements_render($user, $planetrow, $unit_id, $field = 'require') {return sn_function_call('unit_requirements_render', array($user, $planetrow, $unit_id, $field, &$result)); } |
|
| 1235 | 1235 | function sn_unit_requirements_render($user, $planetrow, $unit_id, $field = 'require', &$result) |
| 1236 | 1236 | { |
| 1237 | 1237 | global $lang, $config; |
@@ -1239,9 +1239,9 @@ discard block |
||
| 1239 | 1239 | $sn_data_unit = get_unit_param($unit_id); |
| 1240 | 1240 | |
| 1241 | 1241 | $result = is_array($result) ? $result : array(); |
| 1242 | - if($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && classSupernova::$config->empire_mercenary_temporary)) |
|
| 1242 | + if ($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && classSupernova::$config->empire_mercenary_temporary)) |
|
| 1243 | 1243 | { |
| 1244 | - foreach($sn_data_unit[$field] as $require_id => $require_level) |
|
| 1244 | + foreach ($sn_data_unit[$field] as $require_id => $require_level) |
|
| 1245 | 1245 | { |
| 1246 | 1246 | $level_got = mrc_get_level($user, $planetrow, $require_id); |
| 1247 | 1247 | $level_basic = mrc_get_level($user, $planetrow, $require_id, false, true); |
@@ -1267,19 +1267,19 @@ discard block |
||
| 1267 | 1267 | |
| 1268 | 1268 | $ranks = array(); |
| 1269 | 1269 | |
| 1270 | - if($ally['ranklist']) |
|
| 1270 | + if ($ally['ranklist']) |
|
| 1271 | 1271 | { |
| 1272 | 1272 | $str_ranks = explode(';', $ally['ranklist']); |
| 1273 | - foreach($str_ranks as $str_rank) |
|
| 1273 | + foreach ($str_ranks as $str_rank) |
|
| 1274 | 1274 | { |
| 1275 | - if(!$str_rank) |
|
| 1275 | + if (!$str_rank) |
|
| 1276 | 1276 | { |
| 1277 | 1277 | continue; |
| 1278 | 1278 | } |
| 1279 | 1279 | |
| 1280 | 1280 | $tmp = explode(',', $str_rank); |
| 1281 | 1281 | $rank_id = count($ranks); |
| 1282 | - foreach($ally_rights as $key => $value) |
|
| 1282 | + foreach ($ally_rights as $key => $value) |
|
| 1283 | 1283 | { |
| 1284 | 1284 | $ranks[$rank_id][$value] = $tmp[$key]; |
| 1285 | 1285 | } |
@@ -1289,14 +1289,14 @@ discard block |
||
| 1289 | 1289 | return $ranks; |
| 1290 | 1290 | } |
| 1291 | 1291 | |
| 1292 | -function sys_player_new_adjust($user_id, $planet_id){return sn_function_call('sys_player_new_adjust', array($user_id, $planet_id, &$result));} |
|
| 1292 | +function sys_player_new_adjust($user_id, $planet_id) {return sn_function_call('sys_player_new_adjust', array($user_id, $planet_id, &$result)); } |
|
| 1293 | 1293 | function sn_sys_player_new_adjust($user_id, $planet_id, &$result) { |
| 1294 | 1294 | return $result; |
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | 1297 | function array_merge_recursive_numeric($array1, $array2) { |
| 1298 | - if(!empty($array2) && is_array($array2)) { |
|
| 1299 | - foreach($array2 as $key => $value) { |
|
| 1298 | + if (!empty($array2) && is_array($array2)) { |
|
| 1299 | + foreach ($array2 as $key => $value) { |
|
| 1300 | 1300 | // if(!isset($array1[$key]) || !is_array($array1[$key])) { |
| 1301 | 1301 | // $array1[$key] = $value; |
| 1302 | 1302 | // } else { |
@@ -1312,7 +1312,7 @@ discard block |
||
| 1312 | 1312 | function sn_sys_array_cumulative_sum(&$array) |
| 1313 | 1313 | { |
| 1314 | 1314 | $accum = 0; |
| 1315 | - foreach($array as &$value) |
|
| 1315 | + foreach ($array as &$value) |
|
| 1316 | 1316 | { |
| 1317 | 1317 | $accum += $value; |
| 1318 | 1318 | $value = $accum; |
@@ -1323,7 +1323,7 @@ discard block |
||
| 1323 | 1323 | $sn_data_density = sn_get_groups('planet_density'); |
| 1324 | 1324 | $density_price_chart = array(); |
| 1325 | 1325 | |
| 1326 | - foreach($sn_data_density as $density_id => $density_data) { |
|
| 1326 | + foreach ($sn_data_density as $density_id => $density_data) { |
|
| 1327 | 1327 | // Отсекаем записи с RARITY = 0 - служебные записи и супер-ядра |
| 1328 | 1328 | $density_data[UNIT_PLANET_DENSITY_RARITY] ? $density_price_chart[$density_id] = $density_data[UNIT_PLANET_DENSITY_RARITY] : false; |
| 1329 | 1329 | } |
@@ -1331,7 +1331,7 @@ discard block |
||
| 1331 | 1331 | |
| 1332 | 1332 | $total_rarity = array_sum($density_price_chart); |
| 1333 | 1333 | |
| 1334 | - foreach($density_price_chart as &$density_data) { |
|
| 1334 | + foreach ($density_price_chart as &$density_data) { |
|
| 1335 | 1335 | $density_data = ceil($total_rarity / $density_data * $planet_row['field_max'] * PLANET_DENSITY_TO_DARK_MATTER_RATE); |
| 1336 | 1336 | } |
| 1337 | 1337 | |
@@ -1339,18 +1339,18 @@ discard block |
||
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | 1341 | function sn_sys_planet_core_transmute(&$user, &$planetrow) { |
| 1342 | - if(!sys_get_param_str('transmute')) { |
|
| 1342 | + if (!sys_get_param_str('transmute')) { |
|
| 1343 | 1343 | return array(); |
| 1344 | 1344 | } |
| 1345 | 1345 | |
| 1346 | 1346 | global $lang; |
| 1347 | 1347 | |
| 1348 | 1348 | try { |
| 1349 | - if($planetrow['planet_type'] != PT_PLANET) { |
|
| 1349 | + if ($planetrow['planet_type'] != PT_PLANET) { |
|
| 1350 | 1350 | throw new exception($lang['ov_core_err_not_a_planet'], ERR_ERROR); |
| 1351 | 1351 | } |
| 1352 | 1352 | |
| 1353 | - if($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { |
|
| 1353 | + if ($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { |
|
| 1354 | 1354 | throw new exception($lang['ov_core_err_same_density'], ERR_WARNING); |
| 1355 | 1355 | } |
| 1356 | 1356 | |
@@ -1364,7 +1364,7 @@ discard block |
||
| 1364 | 1364 | $planet_density_index = $planetrow['density_index']; |
| 1365 | 1365 | |
| 1366 | 1366 | $density_price_chart = planet_density_price_chart($planetrow); |
| 1367 | - if(!isset($density_price_chart[$new_density_index])) { |
|
| 1367 | + if (!isset($density_price_chart[$new_density_index])) { |
|
| 1368 | 1368 | // Hack attempt |
| 1369 | 1369 | throw new exception($lang['ov_core_err_denisty_type_wrong'], ERR_ERROR); |
| 1370 | 1370 | } |
@@ -1373,13 +1373,13 @@ discard block |
||
| 1373 | 1373 | // $transmute_cost = get_unit_param(UNIT_PLANET_DENSITY, 'cost'); |
| 1374 | 1374 | // $transmute_cost = $transmute_cost[RES_DARK_MATTER] * $density_price_chart[$new_density_index]; |
| 1375 | 1375 | $transmute_cost = $density_price_chart[$new_density_index]; |
| 1376 | - if($user_dark_matter < $transmute_cost) { |
|
| 1376 | + if ($user_dark_matter < $transmute_cost) { |
|
| 1377 | 1377 | throw new exception($lang['ov_core_err_no_dark_matter'], ERR_ERROR); |
| 1378 | 1378 | } |
| 1379 | 1379 | |
| 1380 | 1380 | $sn_data_planet_density = sn_get_groups('planet_density'); |
| 1381 | - foreach($sn_data_planet_density as $key => $value) { |
|
| 1382 | - if($key == $new_density_index) { |
|
| 1381 | + foreach ($sn_data_planet_density as $key => $value) { |
|
| 1382 | + if ($key == $new_density_index) { |
|
| 1383 | 1383 | break; |
| 1384 | 1384 | } |
| 1385 | 1385 | $prev_density_index = $key; |
@@ -1410,7 +1410,7 @@ discard block |
||
| 1410 | 1410 | 'STATUS' => ERR_NONE, |
| 1411 | 1411 | '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), |
| 1412 | 1412 | ); |
| 1413 | - } catch(exception $e) { |
|
| 1413 | + } catch (exception $e) { |
|
| 1414 | 1414 | sn_db_transaction_rollback(); |
| 1415 | 1415 | $result = array( |
| 1416 | 1416 | 'STATUS' => $e->getCode(), |
@@ -1426,9 +1426,9 @@ discard block |
||
| 1426 | 1426 | global $sn_module_list; |
| 1427 | 1427 | |
| 1428 | 1428 | $active_modules = 0; |
| 1429 | - if(isset($sn_module_list[$group]) && is_array($sn_module_list[$group])) |
|
| 1429 | + if (isset($sn_module_list[$group]) && is_array($sn_module_list[$group])) |
|
| 1430 | 1430 | { |
| 1431 | - foreach($sn_module_list[$group] as $payment_module) |
|
| 1431 | + foreach ($sn_module_list[$group] as $payment_module) |
|
| 1432 | 1432 | { |
| 1433 | 1433 | $active_modules += $payment_module->manifest['active']; |
| 1434 | 1434 | } |
@@ -1441,7 +1441,7 @@ discard block |
||
| 1441 | 1441 | { |
| 1442 | 1442 | static $rates; |
| 1443 | 1443 | |
| 1444 | - if(!$rates) |
|
| 1444 | + if (!$rates) |
|
| 1445 | 1445 | { |
| 1446 | 1446 | global $config; |
| 1447 | 1447 | |
@@ -1452,7 +1452,7 @@ discard block |
||
| 1452 | 1452 | RES_DARK_MATTER => 'rpg_exchange_darkMatter', |
| 1453 | 1453 | ); |
| 1454 | 1454 | |
| 1455 | - foreach($rates as &$rate) |
|
| 1455 | + foreach ($rates as &$rate) |
|
| 1456 | 1456 | { |
| 1457 | 1457 | $rate = classSupernova::$config->$rate; |
| 1458 | 1458 | } |
@@ -1465,13 +1465,13 @@ discard block |
||
| 1465 | 1465 | { |
| 1466 | 1466 | static $rates; |
| 1467 | 1467 | |
| 1468 | - if(!$rates) |
|
| 1468 | + if (!$rates) |
|
| 1469 | 1469 | { |
| 1470 | 1470 | $rates = get_resource_exchange(); |
| 1471 | 1471 | } |
| 1472 | 1472 | |
| 1473 | 1473 | $metal_cost = 0; |
| 1474 | - foreach($cost as $resource_id => $resource_value) |
|
| 1474 | + foreach ($cost as $resource_id => $resource_value) |
|
| 1475 | 1475 | { |
| 1476 | 1476 | $metal_cost += $rates[$resource_id] * $resource_value; |
| 1477 | 1477 | } |
@@ -1479,11 +1479,11 @@ discard block |
||
| 1479 | 1479 | return $metal_cost; |
| 1480 | 1480 | } |
| 1481 | 1481 | |
| 1482 | -function get_player_max_expeditons(&$user, $astrotech = -1){return sn_function_call('get_player_max_expeditons', array(&$user, $astrotech, &$result));} |
|
| 1482 | +function get_player_max_expeditons(&$user, $astrotech = -1) {return sn_function_call('get_player_max_expeditons', array(&$user, $astrotech, &$result)); } |
|
| 1483 | 1483 | function sn_get_player_max_expeditons(&$user, $astrotech = -1, &$result = 0) |
| 1484 | 1484 | { |
| 1485 | - if($astrotech == -1) { |
|
| 1486 | - if(!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) |
|
| 1485 | + if ($astrotech == -1) { |
|
| 1486 | + if (!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) |
|
| 1487 | 1487 | { |
| 1488 | 1488 | $astrotech = mrc_get_level($user, false, TECH_ASTROTECH); |
| 1489 | 1489 | $user[UNIT_PLAYER_EXPEDITIONS_MAX] = $astrotech >= 1 ? floor(sqrt($astrotech - 1)) : 0; |
@@ -1503,8 +1503,8 @@ discard block |
||
| 1503 | 1503 | function get_player_max_colonies(&$user, $astrotech = -1) { |
| 1504 | 1504 | global $config; |
| 1505 | 1505 | |
| 1506 | - if($astrotech == -1) { |
|
| 1507 | - if(!isset($user[UNIT_PLAYER_COLONIES_MAX])) { |
|
| 1506 | + if ($astrotech == -1) { |
|
| 1507 | + if (!isset($user[UNIT_PLAYER_COLONIES_MAX])) { |
|
| 1508 | 1508 | |
| 1509 | 1509 | $expeditions = get_player_max_expeditons($user); |
| 1510 | 1510 | $astrotech = mrc_get_level($user, false, TECH_ASTROTECH); |
@@ -1537,7 +1537,7 @@ discard block |
||
| 1537 | 1537 | } |
| 1538 | 1538 | |
| 1539 | 1539 | |
| 1540 | -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));} |
|
| 1540 | +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)); } |
|
| 1541 | 1541 | function sn_sn_powerup_get_price_matrix($powerup_id, $powerup_unit = false, $level_max = null, $plain = false, &$result) { |
| 1542 | 1542 | global $sn_powerup_buy_discounts; |
| 1543 | 1543 | |
@@ -1547,10 +1547,10 @@ discard block |
||
| 1547 | 1547 | $is_upgrade = !empty($powerup_unit) && $powerup_unit; |
| 1548 | 1548 | |
| 1549 | 1549 | $level_current = $term_original = $time_left = 0; |
| 1550 | - if($is_upgrade) { |
|
| 1550 | + if ($is_upgrade) { |
|
| 1551 | 1551 | $time_finish = strtotime($powerup_unit['unit_time_finish']); |
| 1552 | 1552 | $time_left = max(0, $time_finish - SN_TIME_NOW); |
| 1553 | - if($time_left > 0) { |
|
| 1553 | + if ($time_left > 0) { |
|
| 1554 | 1554 | $term_original = $time_finish - strtotime($powerup_unit['unit_time_start']); |
| 1555 | 1555 | $level_current = $powerup_unit['unit_level']; |
| 1556 | 1556 | } |
@@ -1558,17 +1558,17 @@ discard block |
||
| 1558 | 1558 | |
| 1559 | 1559 | $level_max = $level_max > $powerup_data[P_MAX_STACK] ? $level_max : $powerup_data[P_MAX_STACK]; |
| 1560 | 1560 | $original_cost = 0; |
| 1561 | - for($i = 1; $i <= $level_max; $i++) { |
|
| 1561 | + for ($i = 1; $i <= $level_max; $i++) { |
|
| 1562 | 1562 | $base_cost = eco_get_total_cost($powerup_id, $i); |
| 1563 | 1563 | $base_cost = $base_cost[BUILD_CREATE][RES_DARK_MATTER]; |
| 1564 | - foreach($sn_powerup_buy_discounts as $period => $discount) { |
|
| 1564 | + foreach ($sn_powerup_buy_discounts as $period => $discount) { |
|
| 1565 | 1565 | $upgrade_price = floor($base_cost * $discount * $period / PERIOD_MONTH); |
| 1566 | 1566 | $result[$i][$period] = $upgrade_price; |
| 1567 | 1567 | $original_cost = $is_upgrade && $i == $level_current && $period <= $term_original ? $upgrade_price : $original_cost; |
| 1568 | 1568 | } |
| 1569 | 1569 | } |
| 1570 | 1570 | |
| 1571 | - if($is_upgrade && $time_left) { |
|
| 1571 | + if ($is_upgrade && $time_left) { |
|
| 1572 | 1572 | $term_original = round($term_original / PERIOD_DAY); |
| 1573 | 1573 | $time_left = min(floor($time_left / PERIOD_DAY), $term_original); |
| 1574 | 1574 | $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0; |
@@ -1629,14 +1629,14 @@ discard block |
||
| 1629 | 1629 | |
| 1630 | 1630 | function print_rr($var, $capture = false) { |
| 1631 | 1631 | $print = '<pre>' . htmlspecialchars(print_r($var, true)) . '</pre>'; |
| 1632 | - if($capture) { |
|
| 1632 | + if ($capture) { |
|
| 1633 | 1633 | return $print; |
| 1634 | 1634 | } else { |
| 1635 | 1635 | print($print); |
| 1636 | 1636 | } |
| 1637 | 1637 | } |
| 1638 | 1638 | |
| 1639 | -function can_capture_planet(){return sn_function_call('can_capture_planet', array(&$result));} |
|
| 1639 | +function can_capture_planet() {return sn_function_call('can_capture_planet', array(&$result)); } |
|
| 1640 | 1640 | function sn_can_capture_planet(&$result) { |
| 1641 | 1641 | return $result = false; |
| 1642 | 1642 | } |
@@ -1667,9 +1667,9 @@ discard block |
||
| 1667 | 1667 | |
| 1668 | 1668 | function price_matrix_templatize(&$price_matrix_plain, &$price_matrix_original, &$price_matrix_upgrade, $user_dark_matter) { |
| 1669 | 1669 | $prices = array(); |
| 1670 | - foreach($price_matrix_original as $level_num => $level_data) { |
|
| 1670 | + foreach ($price_matrix_original as $level_num => $level_data) { |
|
| 1671 | 1671 | $price_per_period = array(); |
| 1672 | - foreach($level_data as $period => $price) { |
|
| 1672 | + foreach ($level_data as $period => $price) { |
|
| 1673 | 1673 | $price_text = pretty_number($price, true, $user_dark_matter, false, false); |
| 1674 | 1674 | $price_per_period[$period] = array( |
| 1675 | 1675 | 'PERIOD' => $period, |
@@ -1679,7 +1679,7 @@ discard block |
||
| 1679 | 1679 | 'PRICE_UPGRADE' => $price_matrix_upgrade[$level_num][$period], |
| 1680 | 1680 | 'PRICE_UPGRADE_TEXT' => pretty_number($price_matrix_upgrade[$level_num][$period], true), |
| 1681 | 1681 | ); |
| 1682 | - if(isset($price_matrix_plain[$level_num][$period])) { |
|
| 1682 | + if (isset($price_matrix_plain[$level_num][$period])) { |
|
| 1683 | 1683 | $price_per_period[$period] += array( |
| 1684 | 1684 | 'PRICE_PLAIN_PERCENT' => ceil(100 - ($price / $price_matrix_plain[$level_num][$period]) * 100), |
| 1685 | 1685 | 'PRICE_PLAIN' => $price_matrix_plain[$level_num][$period], |
@@ -1699,25 +1699,25 @@ discard block |
||
| 1699 | 1699 | |
| 1700 | 1700 | // ------------------------------------------------------------------------------------------------------------------------------ |
| 1701 | 1701 | function sn_sys_load_php_files($dir_name, $load_extension = 'php', $modules = false) { |
| 1702 | - if(file_exists($dir_name)) { |
|
| 1702 | + if (file_exists($dir_name)) { |
|
| 1703 | 1703 | $dir = opendir($dir_name); |
| 1704 | - while(($file = readdir($dir)) !== false) { |
|
| 1705 | - if($file == '..' || $file == '.') { |
|
| 1704 | + while (($file = readdir($dir)) !== false) { |
|
| 1705 | + if ($file == '..' || $file == '.') { |
|
| 1706 | 1706 | continue; |
| 1707 | 1707 | } |
| 1708 | 1708 | |
| 1709 | 1709 | $full_filename = $dir_name . $file; |
| 1710 | - if($modules && is_dir($full_filename)) { |
|
| 1711 | - if(file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) { |
|
| 1710 | + if ($modules && is_dir($full_filename)) { |
|
| 1711 | + if (file_exists($full_filename = "{$full_filename}/{$file}.{$load_extension}")) { |
|
| 1712 | 1712 | require_once($full_filename); |
| 1713 | 1713 | // Registering module |
| 1714 | - if(class_exists($file)) { |
|
| 1714 | + if (class_exists($file)) { |
|
| 1715 | 1715 | new $file($full_filename); |
| 1716 | 1716 | } |
| 1717 | 1717 | } |
| 1718 | 1718 | } else { |
| 1719 | 1719 | $extension = substr($full_filename, -strlen($load_extension)); |
| 1720 | - if($extension == $load_extension) { |
|
| 1720 | + if ($extension == $load_extension) { |
|
| 1721 | 1721 | require_once($full_filename); |
| 1722 | 1722 | } |
| 1723 | 1723 | } |
@@ -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 | } |
@@ -2,6 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | 4 | * @deprecated |
| 5 | + * @param boolean $player |
|
| 5 | 6 | */ |
| 6 | 7 | function db_user_by_id($user_id_unsafe, $for_update = false, $fields = '*', $player = null) { |
| 7 | 8 | return classSupernova::db_get_user_by_id($user_id_unsafe, $for_update, $fields, $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 | } |