@@ -15,7 +15,7 @@ |
||
15 | 15 | define('SN_PAYMENT_REQUEST_OK', 0); |
16 | 16 | define('SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT', 1); |
17 | 17 | define('SN_PAYMENT_REQUEST_ERROR_PAYLINK_UNSUPPORTED', 2); |
18 | -define('SN_PAYMENT_REQUEST_IP_WRONG', 3); // Неправильный IP входящей системы - обычно хак |
|
18 | +define('SN_PAYMENT_REQUEST_IP_WRONG', 3); // Неправильный IP входящей системы - обычно хак |
|
19 | 19 | define('SN_PAYMENT_REQUEST_COMMAND_UNSUPPORTED', 4); // Неподдерживаемая команда - обычно хак |
20 | 20 | define('SN_PAYMENT_REQUEST_SIGNATURE_INVALID', 5); // Неправильная подпись или не сошлась контрольная сумма - обычно хак |
21 | 21 | define('SN_MODULE_DISABLED', 6); // Модуль отключен // УНИВЕРСАЛЬНЫЙ ОТВЕТ! |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | function geometry_progression_sum($n, $b1, $q) { |
4 | - return $q != 1 ? ($b1 * (pow($q, $n) - 1)/($q - 1)) : ($n * $b1); |
|
4 | + return $q != 1 ? ($b1 * (pow($q, $n) - 1) / ($q - 1)) : ($n * $b1); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | function sn_floor($value) |
@@ -43,8 +43,8 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return float|int |
45 | 45 | */ |
46 | -function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | - if($cut_extreme) { |
|
46 | +function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | + if ($cut_extreme) { |
|
48 | 48 | $range_start--; |
49 | 49 | $range_end++; |
50 | 50 | } |
@@ -104,47 +104,47 @@ discard block |
||
104 | 104 | } |
105 | 105 | function linear_calc(&$linear, $from = 0, $debug = false) |
106 | 106 | { |
107 | - for($i = $from; $i < count($linear); $i++) |
|
107 | + for ($i = $from; $i < count($linear); $i++) |
|
108 | 108 | { |
109 | 109 | $eq = &$linear[$i]; |
110 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
110 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
111 | 111 | { |
112 | 112 | $eq[$j] /= $eq[$from]; |
113 | 113 | } |
114 | 114 | } |
115 | - if($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
115 | + if ($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
116 | 116 | |
117 | - for($i = $from + 1; $i < count($linear); $i++) |
|
117 | + for ($i = $from + 1; $i < count($linear); $i++) |
|
118 | 118 | { |
119 | 119 | $eq = &$linear[$i]; |
120 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
120 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
121 | 121 | { |
122 | 122 | $eq[$j] -= $linear[$from][$j]; |
123 | 123 | } |
124 | 124 | } |
125 | - if($debug) pdump($linear, 'Подставили х' . $from); |
|
125 | + if ($debug) pdump($linear, 'Подставили х' . $from); |
|
126 | 126 | |
127 | - if($from < count($linear) - 1) |
|
127 | + if ($from < count($linear) - 1) |
|
128 | 128 | { |
129 | 129 | linear_calc($linear, $from + 1, $debug); |
130 | 130 | } |
131 | 131 | |
132 | - if($from) |
|
132 | + if ($from) |
|
133 | 133 | { |
134 | - for($i = 0; $i < $from; $i++) |
|
134 | + for ($i = 0; $i < $from; $i++) |
|
135 | 135 | { |
136 | 136 | $eq = &$linear[$i]; |
137 | - for($j = count($eq) - 1; $j >= $from; $j--) |
|
137 | + for ($j = count($eq) - 1; $j >= $from; $j--) |
|
138 | 138 | { |
139 | 139 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
140 | 140 | } |
141 | 141 | } |
142 | - if($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
142 | + if ($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
143 | 143 | } |
144 | 144 | else |
145 | 145 | { |
146 | - if($debug) pdump($linear, 'Результат' . $from); |
|
147 | - foreach($linear as $index => &$eq) |
|
146 | + if ($debug) pdump($linear, 'Результат' . $from); |
|
147 | + foreach ($linear as $index => &$eq) |
|
148 | 148 | { |
149 | 149 | pdump($eq[count($linear)], 'x' . $index); |
150 | 150 | } |
@@ -4,16 +4,14 @@ discard block |
||
4 | 4 | return $q != 1 ? ($b1 * (pow($q, $n) - 1)/($q - 1)) : ($n * $b1); |
5 | 5 | } |
6 | 6 | |
7 | -function sn_floor($value) |
|
8 | -{ |
|
7 | +function sn_floor($value) { |
|
9 | 8 | return $value >= 0 ? floor($value) : ceil($value); |
10 | 9 | } |
11 | 10 | |
12 | 11 | // Эта функция выдает нормально распределенное случайное число с матожиднием $mu и стандартным отклонением $sigma |
13 | 12 | // $strict - количество $sigma, по которым идет округление функции. Т.е. $strict = 3 означает, что диапазон значений обрезается по +-3 * $sigma |
14 | 13 | // Используется http://ru.wikipedia.org/wiki/Преобразование_Бокса_—_Мюллера |
15 | -function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false) |
|
16 | -{ |
|
14 | +function sn_rand_gauss($mu = 0, $sigma = 1, $strict = false) { |
|
17 | 15 | // http://ru.wikipedia.org/wiki/Среднеквадратическое_отклонение |
18 | 16 | // При $mu = 0 (график симметричный, цифры только для половины графика) |
19 | 17 | // От 0 до $sigma ~ 34.1% |
@@ -43,7 +41,7 @@ discard block |
||
43 | 41 | * |
44 | 42 | * @return float|int |
45 | 43 | */ |
46 | -function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
44 | +function sn_rand_gauss_range($range_start, $range_end, $round = true, $strict = 4, $cut_extreme = false) { |
|
47 | 45 | if($cut_extreme) { |
48 | 46 | $range_start--; |
49 | 47 | $range_end++; |
@@ -98,12 +96,10 @@ discard block |
||
98 | 96 | * |
99 | 97 | * @return float |
100 | 98 | */ |
101 | -function avg($array) |
|
102 | -{ |
|
99 | +function avg($array) { |
|
103 | 100 | return is_array($array) && count($array) ? array_sum($array) / count($array) : 0; |
104 | 101 | } |
105 | -function linear_calc(&$linear, $from = 0, $debug = false) |
|
106 | -{ |
|
102 | +function linear_calc(&$linear, $from = 0, $debug = false) { |
|
107 | 103 | for($i = $from; $i < count($linear); $i++) |
108 | 104 | { |
109 | 105 | $eq = &$linear[$i]; |
@@ -112,7 +108,9 @@ discard block |
||
112 | 108 | $eq[$j] /= $eq[$from]; |
113 | 109 | } |
114 | 110 | } |
115 | - if($debug) pdump($linear, 'Нормализовано по х' . $from); |
|
111 | + if($debug) { |
|
112 | + pdump($linear, 'Нормализовано по х' . $from); |
|
113 | + } |
|
116 | 114 | |
117 | 115 | for($i = $from + 1; $i < count($linear); $i++) |
118 | 116 | { |
@@ -122,7 +120,9 @@ discard block |
||
122 | 120 | $eq[$j] -= $linear[$from][$j]; |
123 | 121 | } |
124 | 122 | } |
125 | - if($debug) pdump($linear, 'Подставили х' . $from); |
|
123 | + if($debug) { |
|
124 | + pdump($linear, 'Подставили х' . $from); |
|
125 | + } |
|
126 | 126 | |
127 | 127 | if($from < count($linear) - 1) |
128 | 128 | { |
@@ -139,11 +139,14 @@ discard block |
||
139 | 139 | $eq[$j] = $eq[$j] - $eq[$from] * $linear[$from][$j]; |
140 | 140 | } |
141 | 141 | } |
142 | - if($debug) pdump($linear, 'Подставили обратно х' . $from); |
|
143 | - } |
|
144 | - else |
|
142 | + if($debug) { |
|
143 | + pdump($linear, 'Подставили обратно х' . $from); |
|
144 | + } |
|
145 | + } else |
|
145 | 146 | { |
146 | - if($debug) pdump($linear, 'Результат' . $from); |
|
147 | + if($debug) { |
|
148 | + pdump($linear, 'Результат' . $from); |
|
149 | + } |
|
147 | 150 | foreach($linear as $index => &$eq) |
148 | 151 | { |
149 | 152 | pdump($eq[count($linear)], 'x' . $index); |
@@ -284,7 +284,7 @@ |
||
284 | 284 | $time_left = min(floor($time_left / PERIOD_DAY), $term_original); |
285 | 285 | $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0; |
286 | 286 | |
287 | - array_walk_recursive($result, function (&$value) use ($cost_left) { |
|
287 | + array_walk_recursive($result, function(&$value) use ($cost_left) { |
|
288 | 288 | $value -= $cost_left; |
289 | 289 | }); |
290 | 290 | } |
@@ -2,12 +2,10 @@ |
||
2 | 2 | |
3 | 3 | // Эти функции будут переписаны по добавлению инфы в БД |
4 | 4 | |
5 | -function pname_factory_production_field_name($factory_unit_id) |
|
6 | -{ |
|
5 | +function pname_factory_production_field_name($factory_unit_id) { |
|
7 | 6 | return get_unit_param($factory_unit_id, P_NAME) . '_porcent'; |
8 | 7 | } |
9 | 8 | |
10 | -function pname_resource_name($resource_id) |
|
11 | -{ |
|
9 | +function pname_resource_name($resource_id) { |
|
12 | 10 | return get_unit_param($resource_id, P_NAME); |
13 | 11 | } |
14 | 12 | \ No newline at end of file |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | |
272 | 272 | |
273 | 273 | if (($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) { |
274 | - if(!empty($render_user['user_birthday'])) { |
|
274 | + if (!empty($render_user['user_birthday'])) { |
|
275 | 275 | $result[NICK_BIRTHDAY] = ''; |
276 | 276 | } |
277 | 277 | } |
@@ -283,13 +283,13 @@ discard block |
||
283 | 283 | } |
284 | 284 | |
285 | 285 | if (($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
286 | - if(isset($render_user['vacation'])) { |
|
286 | + if (isset($render_user['vacation'])) { |
|
287 | 287 | $result[NICK_VACATION] = $render_user['vacation']; |
288 | 288 | } |
289 | 289 | } |
290 | 290 | |
291 | 291 | if ($options === true || !empty($options['icons']) || !empty($options['player_rank'])) { |
292 | - if(isset($render_user['total_points'])) { |
|
292 | + if (isset($render_user['total_points'])) { |
|
293 | 293 | $result[NICK_RANK] = SN::$gc->playerLevelHelper->getPointLevel($render_user['total_points'], $render_user['authlevel']); |
294 | 294 | } |
295 | 295 | } |
@@ -313,7 +313,7 @@ discard block |
||
313 | 313 | } |
314 | 314 | |
315 | 315 | if ($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
316 | - if(isset($render_user['ally_tag'])) { |
|
316 | + if (isset($render_user['ally_tag'])) { |
|
317 | 317 | $result[NICK_ALLY] = $render_user['ally_tag']; |
318 | 318 | } |
319 | 319 | } |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | $rexep = "#" . strtr(preg_quote($format), $masks) . "#"; |
113 | 113 | if (preg_match($rexep, $date, $out)) { |
114 | 114 | $ret = array( |
115 | - "tm_sec" => (int)$out['S'], |
|
116 | - "tm_min" => (int)$out['M'], |
|
117 | - "tm_hour" => (int)$out['H'], |
|
118 | - "tm_mday" => (int)$out['d'], |
|
115 | + "tm_sec" => (int) $out['S'], |
|
116 | + "tm_min" => (int) $out['M'], |
|
117 | + "tm_hour" => (int) $out['H'], |
|
118 | + "tm_mday" => (int) $out['d'], |
|
119 | 119 | "tm_mon" => $out['m'] ? $out['m'] - 1 : 0, |
120 | 120 | "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0, |
121 | 121 | ); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | * @return int |
151 | 151 | */ |
152 | 152 | function datePart($fullDate) { |
153 | - return (int)strtotime(date('Y-m-d', $fullDate)); |
|
153 | + return (int) strtotime(date('Y-m-d', $fullDate)); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @return bool |
179 | 179 | * @throws ErrorException |
180 | 180 | */ |
181 | - function ($errno, $errstr, $errfile, $errline) { |
|
181 | + function($errno, $errstr, $errfile, $errline) { |
|
182 | 182 | throw new ErrorException($errstr, 0, $errno, $errfile, $errline); |
183 | 183 | } |
184 | 184 | ); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | |
5 | 5 | require('../includes/init.' . substr(strrchr(__FILE__, '.'), 1)); |
6 | 6 | |
7 | -if($user['authlevel'] < 3) |
|
7 | +if ($user['authlevel'] < 3) |
|
8 | 8 | { |
9 | 9 | messageBox($lang['sys_noalloaw'], $lang['sys_noaccess']); |
10 | 10 | die(); |
@@ -19,9 +19,9 @@ discard block |
||
19 | 19 | |
20 | 20 | // [#] info_best_battles 1b0 |
21 | 21 | $best_reports = array(); |
22 | -if(defined('MODULE_INFO_BEST_BATTLES_QUERY')) { |
|
22 | +if (defined('MODULE_INFO_BEST_BATTLES_QUERY')) { |
|
23 | 23 | $query = doquery(MODULE_INFO_BEST_BATTLES_QUERY); |
24 | - while($row = db_fetch($query)) { |
|
24 | + while ($row = db_fetch($query)) { |
|
25 | 25 | $best_reports[] = $row['ube_report_id']; |
26 | 26 | } |
27 | 27 | } |
@@ -188,16 +188,16 @@ discard block |
||
188 | 188 | |
189 | 189 | function sn_maintenance_pack_user_list($user_list) { |
190 | 190 | $user_list = explode(',', $user_list); |
191 | - foreach($user_list as $key => $user_id) { |
|
192 | - if(!is_numeric($user_id)) { |
|
191 | + foreach ($user_list as $key => $user_id) { |
|
192 | + if (!is_numeric($user_id)) { |
|
193 | 193 | unset($user_list[$key]); |
194 | 194 | } |
195 | 195 | } |
196 | 196 | |
197 | 197 | $result = array(); |
198 | - if(!empty($user_list)) { |
|
198 | + if (!empty($user_list)) { |
|
199 | 199 | $query = doquery("SELECT `id` FROM `{{users}}` WHERE `id` in (" . implode(',', $user_list) . ")"); |
200 | - while($row = db_fetch($query)) { |
|
200 | + while ($row = db_fetch($query)) { |
|
201 | 201 | $result[] = $row['id']; |
202 | 202 | } |
203 | 203 | } |
@@ -212,11 +212,11 @@ discard block |
||
212 | 212 | $old_server_status == GAME_DISABLE_NONE ? SN::$config->db_saveItem('game_disable', GAME_DISABLE_MAINTENANCE) : false; |
213 | 213 | sn_db_transaction_commit(); |
214 | 214 | |
215 | -foreach($ques as $que_transaction) { |
|
215 | +foreach ($ques as $que_transaction) { |
|
216 | 216 | sn_db_transaction_start(); |
217 | 217 | |
218 | 218 | !is_array($que_transaction) ? $que_transaction = array($que_transaction) : false; |
219 | - foreach($que_transaction as $que) { |
|
219 | + foreach ($que_transaction as $que) { |
|
220 | 220 | set_time_limit(120); |
221 | 221 | $QryResult = doquery($que); |
222 | 222 | //$msg .= '<hr>' . $que . '<hr>'; |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | $this->secret_word = SN::$sn_secret_word; |
93 | 93 | |
94 | 94 | $snTableNames = $this->db->schema()->getSnTables(); |
95 | - foreach($this->table_check as $table_name) { |
|
96 | - if(empty($snTableNames[$table_name])) { |
|
95 | + foreach ($this->table_check as $table_name) { |
|
96 | + if (empty($snTableNames[$table_name])) { |
|
97 | 97 | die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br /> |
98 | 98 | В противном случае - сообщите Администрации сервера об ошибке.<br/> |
99 | 99 | Не хватает таблицы для работы системы авторизации: ' . $table_name); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | */ |
118 | 118 | // OK v4.6 |
119 | 119 | public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) { |
120 | - if(!$this->password_check($old_password_unsafe)) { |
|
120 | + if (!$this->password_check($old_password_unsafe)) { |
|
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | // OK v4.5 |
139 | 139 | public function assign_from_db_row($row) { |
140 | 140 | $this->reset(); |
141 | - if(empty($row) || !is_array($row)) { |
|
141 | + if (empty($row) || !is_array($row)) { |
|
142 | 142 | return false; |
143 | 143 | } |
144 | 144 | $this->account_id = $row['account_id']; |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | $this->reset(); |
204 | 204 | |
205 | 205 | $email_safe = $this->db->db_escape($email_unsafe); |
206 | - if($email_safe) { |
|
206 | + if ($email_safe) { |
|
207 | 207 | $account_row = $this->db->doquery("SELECT * FROM `{{account}}` WHERE LOWER(`account_email`) = LOWER('{$email_safe}') FOR UPDATE;", true); |
208 | 208 | |
209 | 209 | return $this->assign_from_db_row($account_row); |
@@ -276,11 +276,11 @@ discard block |
||
276 | 276 | `account_email` = LOWER('{$email_safe}'), |
277 | 277 | `account_language` = '{$language_safe}'" |
278 | 278 | ); |
279 | - if(!$result) { |
|
279 | + if (!$result) { |
|
280 | 280 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
281 | 281 | } |
282 | 282 | |
283 | - if(!($account_id = $this->db->db_insert_id())) { |
|
283 | + if (!($account_id = $this->db->db_insert_id())) { |
|
284 | 284 | throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR); |
285 | 285 | } |
286 | 286 | |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | WHERE `account_id` = '{$account_id_safe}'" |
311 | 311 | ) ? true : false; |
312 | 312 | |
313 | - if($result) { |
|
313 | + if ($result) { |
|
314 | 314 | $result = $this->db_get_by_id($this->account_id); |
315 | 315 | } |
316 | 316 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | public function metamatter_change($change_type, $metamatter, $comment = false, $already_changed = false) { |
400 | 400 | global $debug, $mm_change_legit, $config; |
401 | 401 | |
402 | - if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
402 | + if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) { |
|
403 | 403 | $debug->error('Ошибка при попытке манипуляции с ММ'); |
404 | 404 | return false; |
405 | 405 | } |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | |
409 | 409 | $mm_change_legit = true; |
410 | 410 | // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER); |
411 | - if($already_changed) { |
|
411 | + if ($already_changed) { |
|
412 | 412 | $metamatter_total_delta = 0; |
413 | 413 | $result = -1; |
414 | 414 | } else { |
@@ -421,7 +421,7 @@ discard block |
||
421 | 421 | ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$config->player_metamatter_immortal} AND `account_immortal` IS NULL, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') . |
422 | 422 | " WHERE `account_id` = {$account_id_safe}" |
423 | 423 | ); |
424 | - if(!$result) { |
|
424 | + if (!$result) { |
|
425 | 425 | $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
426 | 426 | } |
427 | 427 | $result = SN::$db->db_affected_rows(); |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | $this->awardImmortal($metamatter, $config); |
430 | 430 | } |
431 | 431 | |
432 | - if(empty(core_auth::$user['id'])) { |
|
432 | + if (empty(core_auth::$user['id'])) { |
|
433 | 433 | $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id); |
434 | 434 | reset($user_list); |
435 | 435 | $user_id_unsafe = key($user_list); |
@@ -438,30 +438,30 @@ discard block |
||
438 | 438 | } |
439 | 439 | $user_id_safe = $this->db->db_escape($user_id_unsafe); |
440 | 440 | |
441 | - if(!$result) { |
|
441 | + if (!$result) { |
|
442 | 442 | $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402); |
443 | 443 | } |
444 | 444 | |
445 | - if(!$already_changed) { |
|
445 | + if (!$already_changed) { |
|
446 | 446 | $this->account_metamatter += $metamatter; |
447 | 447 | $this->account_metamatter_total += $metamatter_total_delta; |
448 | 448 | } |
449 | 449 | |
450 | - if(is_array($comment)) { |
|
450 | + if (is_array($comment)) { |
|
451 | 451 | $comment = call_user_func_array('sprintf', $comment); |
452 | 452 | } |
453 | 453 | |
454 | 454 | $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe); |
455 | 455 | |
456 | - if($metamatter > 0 && !empty($user_id_safe)) { |
|
456 | + if ($metamatter > 0 && !empty($user_id_safe)) { |
|
457 | 457 | $old_referral = doquery("SELECT * FROM `{{referrals}}` WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", '', true); |
458 | - if($old_referral['id']) { |
|
458 | + if ($old_referral['id']) { |
|
459 | 459 | $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM; |
460 | 460 | doquery("UPDATE `{{referrals}}` SET dark_matter = dark_matter + '{$dark_matter_from_metamatter}' WHERE `id` = {$user_id_safe} LIMIT 1;"); |
461 | 461 | $new_referral = doquery("SELECT * FROM `{{referrals}}` WHERE `id` = {$user_id_safe} LIMIT 1;", '', true); |
462 | 462 | |
463 | 463 | $partner_bonus = floor($new_referral['dark_matter'] / $config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= $config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / $config->rpg_bonus_divisor) : 0); |
464 | - if($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) { |
|
464 | + if ($partner_bonus > 0 && $new_referral['dark_matter'] >= $config->rpg_bonus_minimum) { |
|
465 | 465 | rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}"); |
466 | 466 | } |
467 | 467 | } |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | * @throws Exception |
478 | 478 | */ |
479 | 479 | public function cookieSet($rememberMe = false, $domain = null) { |
480 | - if(!$this->is_exists) { |
|
480 | + if (!$this->is_exists) { |
|
481 | 481 | throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR); |
482 | 482 | } |
483 | 483 | |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | // OK v4.1 |
497 | 497 | public function cookieClear($domain = null) { |
498 | 498 | // Автоматически вообще-то - если установлена кука имперсонатора - то чистим обычную, а куку имперсонатора - копируем в неё |
499 | - if(!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
499 | + if (!empty($_COOKIE[$this->cookie_name_impersonate])) { |
|
500 | 500 | sn_setcookie($this->cookie_name, $_COOKIE[$this->cookie_name_impersonate], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $domain); |
501 | 501 | sn_setcookie($this->cookie_name_impersonate, '', SN_TIME_NOW - PERIOD_WEEK, $this->sn_root_path, $domain); |
502 | 502 | } else { |
@@ -506,14 +506,14 @@ discard block |
||
506 | 506 | |
507 | 507 | public function cookieLogin(&$rememberMe = false) { |
508 | 508 | // Пытаемся войти по куке |
509 | - if(!empty($_COOKIE[$this->cookie_name])) { |
|
510 | - if(count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
509 | + if (!empty($_COOKIE[$this->cookie_name])) { |
|
510 | + if (count(explode("/%/", $_COOKIE[$this->cookie_name])) < 4) { |
|
511 | 511 | list($account_id_unsafe, $cookie_password_hash_salted, $user_remember_me) = explode(AUTH_COOKIE_DELIMETER, $_COOKIE[$this->cookie_name]); |
512 | 512 | } else { |
513 | 513 | list($account_id_unsafe, $user_name, $cookie_password_hash_salted, $user_remember_me) = explode("/%/", $_COOKIE[$this->cookie_name]); |
514 | 514 | } |
515 | 515 | |
516 | - if( |
|
516 | + if ( |
|
517 | 517 | $this->db_get_by_id($account_id_unsafe) |
518 | 518 | && ($this->password_encode_for_cookie($this->account_password) == $cookie_password_hash_salted) |
519 | 519 | ) { |
@@ -538,10 +538,10 @@ discard block |
||
538 | 538 | * @param classConfig $config |
539 | 539 | */ |
540 | 540 | protected function awardImmortal($metamatter, $config) { |
541 | - if(!is_object($awardModule = moduleAward())) { |
|
541 | + if (!is_object($awardModule = moduleAward())) { |
|
542 | 542 | return; |
543 | 543 | } |
544 | - if ($this->account_metamatter + $metamatter >= $config->player_metamatter_immortal ) { |
|
544 | + if ($this->account_metamatter + $metamatter >= $config->player_metamatter_immortal) { |
|
545 | 545 | $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list(ACCOUNT_PROVIDER_LOCAL, $this->account_id); |
546 | 546 | if (!empty($account_translation)) { |
547 | 547 | reset($account_translation); |
@@ -563,10 +563,10 @@ discard block |
||
563 | 563 | * @return bool|mysqli_result|null |
564 | 564 | */ |
565 | 565 | public function getMetamatterSum($where = '', $group = '') { |
566 | - if(is_array($where) && !empty($where)) { |
|
566 | + if (is_array($where) && !empty($where)) { |
|
567 | 567 | $where = implode(' AND ', $where); |
568 | 568 | } |
569 | - if(is_array($group) && !empty($group)) { |
|
569 | + if (is_array($group) && !empty($group)) { |
|
570 | 570 | $group = implode(',', $group); |
571 | 571 | } |
572 | 572 |
@@ -91,99 +91,99 @@ |
||
91 | 91 | |
92 | 92 | // Services -------------------------------------------------------------------------------------------------------- |
93 | 93 | // Default db |
94 | - $gc->db = function (GlobalContainer $c) { |
|
94 | + $gc->db = function(GlobalContainer $c) { |
|
95 | 95 | SN::$db = new \DBAL\db_mysql($c); |
96 | 96 | |
97 | 97 | return SN::$db; |
98 | 98 | }; |
99 | 99 | |
100 | - $gc->debug = function (/** @noinspection PhpUnusedParameterInspection */ |
|
100 | + $gc->debug = function(/** @noinspection PhpUnusedParameterInspection */ |
|
101 | 101 | GlobalContainer $c) { |
102 | 102 | return new \debug(); |
103 | 103 | }; |
104 | 104 | |
105 | - $gc->cache = function (GlobalContainer $gc) { |
|
105 | + $gc->cache = function(GlobalContainer $gc) { |
|
106 | 106 | return new \classCache($gc->cachePrefix); |
107 | 107 | }; |
108 | 108 | |
109 | - $gc->config = function (GlobalContainer $gc) { |
|
109 | + $gc->config = function(GlobalContainer $gc) { |
|
110 | 110 | return new \classConfig($gc->cachePrefix); |
111 | 111 | }; |
112 | 112 | |
113 | 113 | |
114 | - $gc->repository = function (GlobalContainer $gc) { |
|
114 | + $gc->repository = function(GlobalContainer $gc) { |
|
115 | 115 | return new Repository($gc); |
116 | 116 | }; |
117 | 117 | |
118 | - $gc->storage = function (GlobalContainer $gc) { |
|
118 | + $gc->storage = function(GlobalContainer $gc) { |
|
119 | 119 | return new \Storage($gc); |
120 | 120 | }; |
121 | 121 | |
122 | - $gc->repoV2 = function (GlobalContainer $gc) { |
|
122 | + $gc->repoV2 = function(GlobalContainer $gc) { |
|
123 | 123 | return new RepoV2($gc); |
124 | 124 | }; |
125 | 125 | |
126 | - $gc->storageV2 = function (GlobalContainer $gc) { |
|
126 | + $gc->storageV2 = function(GlobalContainer $gc) { |
|
127 | 127 | return new StorageV2($gc); |
128 | 128 | }; |
129 | 129 | |
130 | - $gc->design = function (GlobalContainer $gc) { |
|
130 | + $gc->design = function(GlobalContainer $gc) { |
|
131 | 131 | return new \Design($gc); |
132 | 132 | }; |
133 | 133 | |
134 | - $gc->bbCodeParser = function (GlobalContainer $gc) { |
|
134 | + $gc->bbCodeParser = function(GlobalContainer $gc) { |
|
135 | 135 | return new \BBCodeParser($gc); |
136 | 136 | }; |
137 | 137 | |
138 | - $gc->fleetDispatcher = function (GlobalContainer $gc) { |
|
138 | + $gc->fleetDispatcher = function(GlobalContainer $gc) { |
|
139 | 139 | return new \Fleet\FleetDispatcher($gc); |
140 | 140 | }; |
141 | 141 | |
142 | - $gc->watchdog = function (GlobalContainer $gc) { |
|
142 | + $gc->watchdog = function(GlobalContainer $gc) { |
|
143 | 143 | return new Watchdog($gc); |
144 | 144 | }; |
145 | 145 | |
146 | - $gc->valueStorage = function (GlobalContainer $gc) { |
|
146 | + $gc->valueStorage = function(GlobalContainer $gc) { |
|
147 | 147 | return new ValueStorage([]); |
148 | 148 | }; |
149 | 149 | |
150 | - $gc->bonusCatalog = function (GlobalContainer $gc) { |
|
150 | + $gc->bonusCatalog = function(GlobalContainer $gc) { |
|
151 | 151 | return new BonusCatalog($gc); |
152 | 152 | }; |
153 | 153 | |
154 | - $gc->general = function (GlobalContainer $gc) { |
|
154 | + $gc->general = function(GlobalContainer $gc) { |
|
155 | 155 | return new General($gc); |
156 | 156 | }; |
157 | 157 | |
158 | - $gc->economicHelper = function (GlobalContainer $gc) { |
|
158 | + $gc->economicHelper = function(GlobalContainer $gc) { |
|
159 | 159 | return new EconomicHelper($gc); |
160 | 160 | }; |
161 | 161 | |
162 | - $gc->playerLevelHelper = function (GlobalContainer $gc) { |
|
162 | + $gc->playerLevelHelper = function(GlobalContainer $gc) { |
|
163 | 163 | return new PlayerLevelHelper($gc); |
164 | 164 | }; |
165 | 165 | |
166 | - $gc->pimp = function (GlobalContainer $gc) { |
|
166 | + $gc->pimp = function(GlobalContainer $gc) { |
|
167 | 167 | return new SnPimp($gc); |
168 | 168 | }; |
169 | 169 | |
170 | - $gc->modules = function (GlobalContainer $gc) { |
|
170 | + $gc->modules = function(GlobalContainer $gc) { |
|
171 | 171 | return new ModulesManager($gc); |
172 | 172 | }; |
173 | 173 | |
174 | 174 | // Dummy objects --------------------------------------------------------------------------------------------------- |
175 | - $gc->theUser = function (GlobalContainer $gc) { |
|
175 | + $gc->theUser = function(GlobalContainer $gc) { |
|
176 | 176 | return new \TheUser($gc); |
177 | 177 | }; |
178 | 178 | |
179 | 179 | |
180 | 180 | // Models ---------------------------------------------------------------------------------------------------------- |
181 | 181 | $gc->skinEntityClass = \SkinV2::class; |
182 | - $gc->skinModel = function (GlobalContainer $gc) { |
|
182 | + $gc->skinModel = function(GlobalContainer $gc) { |
|
183 | 183 | return new \SkinModel($gc); |
184 | 184 | }; |
185 | 185 | |
186 | - $gc->textModel = function (GlobalContainer $gc) { |
|
186 | + $gc->textModel = function(GlobalContainer $gc) { |
|
187 | 187 | return new \TextModel($gc); |
188 | 188 | }; |
189 | 189 |