@@ -89,15 +89,15 @@ discard block |
||
89 | 89 | // Инфа об устройстве и браузере - общая для всех |
90 | 90 | sn_db_transaction_start(); |
91 | 91 | $this->device_cypher = $_COOKIE[SN_COOKIE_D]; |
92 | - if($this->device_cypher) { |
|
92 | + if ($this->device_cypher) { |
|
93 | 93 | $cypher_safe = db_escape($this->device_cypher); |
94 | 94 | $device_id = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true); |
95 | - if(!empty($device_id['device_id'])) { |
|
95 | + if (!empty($device_id['device_id'])) { |
|
96 | 96 | $this->device_id = $device_id['device_id']; |
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
100 | - if($this->device_id <= 0) { |
|
100 | + if ($this->device_id <= 0) { |
|
101 | 101 | do { |
102 | 102 | $cypher_safe = db_escape($this->device_cypher = sys_random_string()); |
103 | 103 | $row = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true); |
@@ -118,10 +118,10 @@ discard block |
||
118 | 118 | $this->page_address_id = db_get_set_unique_id_value($this->page_address, 'url_id', 'security_url', 'url_string'); |
119 | 119 | sn_db_transaction_commit(); |
120 | 120 | |
121 | - if($this->write_full_url) { |
|
121 | + if ($this->write_full_url) { |
|
122 | 122 | sn_db_transaction_start(); |
123 | 123 | $this->page_url = substr($_SERVER['REQUEST_URI'], strlen(SN_ROOT_RELATIVE)); |
124 | - if(strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) { |
|
124 | + if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) { |
|
125 | 125 | $this->page_url = '/simulator.php'; |
126 | 126 | } |
127 | 127 | $this->page_url_id = db_get_set_unique_id_value($this->page_url, 'url_id', 'security_url', 'url_string'); |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function db_security_entry_insert($user_id_unsafe) { |
146 | 146 | // TODO $user_id = !empty(self::$user['id']) ? self::$user['id'] : 'NULL'; |
147 | - if(empty($user_id_unsafe)) { |
|
147 | + if (empty($user_id_unsafe)) { |
|
148 | 148 | // self::flog('Нет ИД пользователя'); |
149 | 149 | return true; |
150 | 150 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | public function db_counter_insert($user_id_unsafe) { |
168 | 168 | global $config, $sys_stop_log_hit, $is_watching; |
169 | 169 | |
170 | - if($sys_stop_log_hit || !$config->game_counter) { |
|
170 | + if ($sys_stop_log_hit || !$config->game_counter) { |
|
171 | 171 | return; |
172 | 172 | } |
173 | 173 | |
@@ -183,14 +183,14 @@ discard block |
||
183 | 183 | // $this->ip_v4_int . ", '{$proxy_safe}', " . $this->page_address_id . ", " . $this->page_url_id . ");"); |
184 | 184 | doquery( |
185 | 185 | "INSERT INTO {{counter}} SET |
186 | - `visit_time` = '" . SN_TIME_SQL. "', |
|
186 | + `visit_time` = '" . SN_TIME_SQL . "', |
|
187 | 187 | `user_id` = {$user_id_safe}, |
188 | 188 | `device_id` = {$this->device_id}, |
189 | 189 | `browser_id` = {$this->browser_id}, |
190 | 190 | `user_ip` = {$this->ip_v4_int}, |
191 | 191 | `user_proxy` = '{$proxy_safe}', |
192 | 192 | `page_url_id` = {$this->page_address_id}" . |
193 | - ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '' ). |
|
193 | + ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '') . |
|
194 | 194 | ";"); |
195 | 195 | |
196 | 196 | $is_watching = false; |
@@ -205,18 +205,18 @@ discard block |
||
205 | 205 | // TODO Хотя тут может получится вечный цикл - ПОДУМАТЬ |
206 | 206 | // TODO Тут же можно пробовать провести попытку слияния аккаунтов - хотя это и очень небезопасно |
207 | 207 | |
208 | - if(sys_get_param('login_player_register_logout')) { |
|
208 | + if (sys_get_param('login_player_register_logout')) { |
|
209 | 209 | $this->logout(); |
210 | 210 | } |
211 | 211 | |
212 | 212 | $original_suggest = ''; |
213 | 213 | // Смотрим - есть ли у нас данные от пользователя |
214 | - if(($player_name_submitted = sys_get_param('submit_player_name'))) { |
|
214 | + if (($player_name_submitted = sys_get_param('submit_player_name'))) { |
|
215 | 215 | // Попытка регистрации нового игрока из данных, введенных пользователем |
216 | 216 | $this->player_suggested_name = sys_get_param_str_unsafe('player_suggested_name'); |
217 | 217 | } else { |
218 | - foreach($this->providers_authorised as $provider) { |
|
219 | - if($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5 |
|
218 | + foreach ($this->providers_authorised as $provider) { |
|
219 | + if ($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5 |
|
220 | 220 | $original_suggest = $provider->player_name_suggest(); |
221 | 221 | break; |
222 | 222 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | } |
225 | 225 | |
226 | 226 | // Если у нас провайдеры не дают имени и пользователь не дал свой вариант - это у нас первый логин в игру |
227 | - if(!$this->player_suggested_name) { |
|
227 | + if (!$this->player_suggested_name) { |
|
228 | 228 | $max_user_id = db_player_get_max_id(); // 4.5 |
229 | 229 | // TODO - предлагать имя игрока по локали |
230 | 230 | |
@@ -233,15 +233,15 @@ discard block |
||
233 | 233 | sn_db_transaction_rollback(); |
234 | 234 | $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000); |
235 | 235 | sn_db_transaction_start(); |
236 | - } while(db_player_name_exists($this->player_suggested_name)); |
|
236 | + } while (db_player_name_exists($this->player_suggested_name)); |
|
237 | 237 | |
238 | 238 | } |
239 | 239 | |
240 | - if($player_name_submitted) { |
|
240 | + if ($player_name_submitted) { |
|
241 | 241 | $this->register_player_db_create($this->player_suggested_name); // OK 4.5 |
242 | - if($this->register_status == LOGIN_SUCCESS) { |
|
242 | + if ($this->register_status == LOGIN_SUCCESS) { |
|
243 | 243 | sys_redirect(SN_ROOT_VIRTUAL . 'overview.php'); |
244 | - } elseif($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
|
244 | + } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) { |
|
245 | 245 | // self::$player_suggested_name .= ' ' . $this->account->account_id; |
246 | 246 | } |
247 | 247 | // if(self::$login_status != LOGIN_SUCCESS) { |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | : false |
266 | 266 | ); |
267 | 267 | |
268 | - if($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
268 | + if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) { |
|
269 | 269 | $prohibited_characters = array_map(function($value) { |
270 | 270 | return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'"; |
271 | 271 | }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED)); |
@@ -297,27 +297,27 @@ discard block |
||
297 | 297 | global $sn_module_list, $lang; |
298 | 298 | |
299 | 299 | // !self::$is_init ? self::init() : false; |
300 | - if(empty($sn_module_list['auth'])) { |
|
300 | + if (empty($sn_module_list['auth'])) { |
|
301 | 301 | die('{Не обнаружено ни одного провайдера авторизации в core_auth::login()!}'); |
302 | 302 | } |
303 | 303 | |
304 | 304 | !empty($_POST) ? self::flog(dump($_POST, '$_POST')) : false; |
305 | 305 | !empty($_GET) ? self::flog(dump($_GET, '$_GET')) : false; |
306 | - !empty($_COOKIE) ? self::flog(dump($_COOKIE,'$_COOKIE')) : false; |
|
306 | + !empty($_COOKIE) ? self::flog(dump($_COOKIE, '$_COOKIE')) : false; |
|
307 | 307 | |
308 | 308 | $this->auth_reset(); // OK v4.5 |
309 | 309 | |
310 | 310 | $this->providers = array(); |
311 | - foreach($sn_module_list['auth'] as $module_name => $module) { |
|
311 | + foreach ($sn_module_list['auth'] as $module_name => $module) { |
|
312 | 312 | $this->providers[$module->provider_id] = $module; |
313 | 313 | } |
314 | 314 | |
315 | 315 | // $this->providers = array_reverse($this->providers, true); // НИНАДА! СН-аккаунт должен всегда авторизироваться первым! |
316 | 316 | //pdump($this->providers); |
317 | - foreach($this->providers as $provider_id => $provider) { |
|
317 | + foreach ($this->providers as $provider_id => $provider) { |
|
318 | 318 | $login_status = $provider->login(); // OK v4.5 |
319 | 319 | self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? $lang['sys_login_messages'][$provider->account_login_status] : dump($provider))); |
320 | - if($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
|
320 | + if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) { |
|
321 | 321 | $this->providers_authorised[$provider_id] = &$this->providers[$provider_id]; |
322 | 322 | |
323 | 323 | $this->user_id_to_provider = array_replace_recursive( |
@@ -325,20 +325,20 @@ discard block |
||
325 | 325 | // static::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5 |
326 | 326 | PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5 |
327 | 327 | ); |
328 | - } elseif($login_status != LOGIN_UNDEFINED) { |
|
328 | + } elseif ($login_status != LOGIN_UNDEFINED) { |
|
329 | 329 | $this->provider_error_list[$provider_id] = $login_status; |
330 | 330 | } |
331 | 331 | } |
332 | 332 | |
333 | - if(empty($this->providers_authorised)) { |
|
333 | + if (empty($this->providers_authorised)) { |
|
334 | 334 | // Ни один аккаунт не авторизирован |
335 | 335 | // Проверяем - есть ли у нас ошибки в аккаунтах? |
336 | - if(!empty($this->provider_error_list)) { |
|
336 | + if (!empty($this->provider_error_list)) { |
|
337 | 337 | // Если есть - выводим их |
338 | 338 | self::$login_status = reset($this->provider_error_list); |
339 | 339 | $providerError = $this->providers[key($this->provider_error_list)]->account_login_message; |
340 | 340 | |
341 | - if(!empty($providerError)) { |
|
341 | + if (!empty($providerError)) { |
|
342 | 342 | self::$login_message = $providerError; |
343 | 343 | } |
344 | 344 | } |
@@ -353,12 +353,12 @@ discard block |
||
353 | 353 | // В self::$accessible_user_row_list - список доступных игроков для данных аккаунтов с соответствующими записями из таблицы `users` |
354 | 354 | |
355 | 355 | // Остались ли у нас в списке доступные игроки? |
356 | - if(empty($this->accessible_user_row_list)) { |
|
356 | + if (empty($this->accessible_user_row_list)) { |
|
357 | 357 | // Нет ни одного игрока ни на одном авторизированном аккаунте |
358 | 358 | // Надо регать нового игрока |
359 | 359 | |
360 | 360 | // Сейчас происходит процесс регистрации игрока? |
361 | - if(!$this->is_player_register) { |
|
361 | + if (!$this->is_player_register) { |
|
362 | 362 | // Нет - отправляем на процесс регистрации |
363 | 363 | $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id')); |
364 | 364 | sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : '')); |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | // Да, есть доступные игроки, которые так же прописаны в базе |
368 | 368 | $this->get_active_user(); // 4.5 |
369 | 369 | |
370 | - if($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) { |
|
370 | + if ($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) { |
|
371 | 371 | $a_user = db_user_by_id($this->is_impersonating); |
372 | 372 | $this->impersonator_username = $a_user['username']; |
373 | 373 | } |
@@ -375,9 +375,9 @@ discard block |
||
375 | 375 | |
376 | 376 | //Прописываем текущего игрока на все авторизированные аккаунты |
377 | 377 | // TODO - ИЛИ ВСЕХ ИГРОКОВ?? |
378 | - if(empty($this->is_impersonating)) { |
|
379 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
380 | - if(empty($this->user_id_to_provider[self::$user['id']][$provider_id])) { |
|
378 | + if (empty($this->is_impersonating)) { |
|
379 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
380 | + if (empty($this->user_id_to_provider[self::$user['id']][$provider_id])) { |
|
381 | 381 | // self::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']); |
382 | 382 | PlayerToAccountTranslate::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']); |
383 | 383 | $this->user_id_to_provider[self::$user['id']][$provider_id][$provider->account->account_id] = true; |
@@ -387,9 +387,9 @@ discard block |
||
387 | 387 | } |
388 | 388 | } |
389 | 389 | |
390 | - if(empty(self::$user['id'])) { |
|
390 | + if (empty(self::$user['id'])) { |
|
391 | 391 | self::cookie_set(''); // OK 4.5 |
392 | - } elseif(self::$user['id'] != $_COOKIE[SN_COOKIE_U]) { |
|
392 | + } elseif (self::$user['id'] != $_COOKIE[SN_COOKIE_U]) { |
|
393 | 393 | self::cookie_set(self::$user['id']); // OK 4.5 |
394 | 394 | } |
395 | 395 | |
@@ -408,21 +408,21 @@ discard block |
||
408 | 408 | */ |
409 | 409 | // OK v4.7 |
410 | 410 | public function logout($redirect = true) { |
411 | - if(!empty($_COOKIE[SN_COOKIE_U_I])) { |
|
411 | + if (!empty($_COOKIE[SN_COOKIE_U_I])) { |
|
412 | 412 | self::cookie_set($_COOKIE[SN_COOKIE_U_I]); |
413 | 413 | self::cookie_set(0, true); |
414 | 414 | self::$main_provider->logout(); |
415 | 415 | } else { |
416 | - foreach($this->providers as $provider_name => $provider) { |
|
416 | + foreach ($this->providers as $provider_name => $provider) { |
|
417 | 417 | $provider->logout(); |
418 | 418 | } |
419 | 419 | |
420 | 420 | self::cookie_set(0); |
421 | 421 | } |
422 | 422 | |
423 | - if($redirect === true) { |
|
423 | + if ($redirect === true) { |
|
424 | 424 | sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php')); |
425 | - } elseif($redirect !== false) { |
|
425 | + } elseif ($redirect !== false) { |
|
426 | 426 | sys_redirect($redirect); |
427 | 427 | } |
428 | 428 | } |
@@ -433,15 +433,15 @@ discard block |
||
433 | 433 | * @param $user_selected |
434 | 434 | */ |
435 | 435 | public function impersonate($user_selected) { |
436 | - if($_COOKIE[SN_COOKIE_U_I]) { |
|
436 | + if ($_COOKIE[SN_COOKIE_U_I]) { |
|
437 | 437 | die('You already impersonating someone. Go back to living other\'s life! Or clear your cookies and try again'); // TODO: Log it |
438 | 438 | } |
439 | 439 | |
440 | - if($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) { |
|
440 | + if ($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) { |
|
441 | 441 | die('You can\'t impersonate - too low level'); // TODO: Log it |
442 | 442 | } |
443 | 443 | |
444 | - if($this->auth_level_max_local <= $user_selected['authlevel']) { |
|
444 | + if ($this->auth_level_max_local <= $user_selected['authlevel']) { |
|
445 | 445 | die('You can\'t impersonate this account - level is greater or equal to yours'); // TODO: Log it |
446 | 446 | } |
447 | 447 | |
@@ -449,7 +449,7 @@ discard block |
||
449 | 449 | $account_translate = reset($account_translate[$user_selected['id']][self::$main_provider->provider_id]); |
450 | 450 | $account_to_impersonate = new Account(self::$main_provider->db); |
451 | 451 | $account_to_impersonate->db_get_by_id($account_translate['provider_account_id']); |
452 | - if(!$account_to_impersonate->is_exists) { |
|
452 | + if (!$account_to_impersonate->is_exists) { |
|
453 | 453 | die('Какая-то ошибка - не могу найти аккаунт для имперсонации'); // TODO: Log it |
454 | 454 | } |
455 | 455 | self::$main_provider->impersonate($account_to_impersonate); |
@@ -475,12 +475,12 @@ discard block |
||
475 | 475 | public function password_check($password_unsafe) { |
476 | 476 | $result = false; |
477 | 477 | |
478 | - if(empty($this->providers_authorised)) { |
|
478 | + if (empty($this->providers_authorised)) { |
|
479 | 479 | // TODO - такого быть не может! |
480 | 480 | self::flog("password_check: Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true); |
481 | 481 | } else { |
482 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
483 | - if($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) { |
|
482 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
483 | + if ($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) { |
|
484 | 484 | $result = $result || $provider->password_check($password_unsafe); |
485 | 485 | } |
486 | 486 | } |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | public function password_change($old_password_unsafe, $new_password_unsafe) { |
502 | 502 | global $lang; |
503 | 503 | |
504 | - if(empty($this->providers_authorised)) { |
|
504 | + if (empty($this->providers_authorised)) { |
|
505 | 505 | // TODO - такого быть не может! |
506 | 506 | self::flog("Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true); |
507 | 507 | return false; |
@@ -514,8 +514,8 @@ discard block |
||
514 | 514 | $salt_unsafe = self::password_salt_generate(); |
515 | 515 | |
516 | 516 | $providers_changed_password = array(); |
517 | - foreach($this->providers_authorised as $provider_id => $provider) { |
|
518 | - if( |
|
517 | + foreach ($this->providers_authorised as $provider_id => $provider) { |
|
518 | + if ( |
|
519 | 519 | !$provider->is_feature_supported(AUTH_FEATURE_PASSWORD_CHANGE) |
520 | 520 | || !$provider->password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe) |
521 | 521 | ) { |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id); |
528 | 528 | |
529 | 529 | // Рассылаем уведомления о смене пароля в ЛС |
530 | - foreach($account_translation as $user_id => $provider_info) { |
|
530 | + foreach ($account_translation as $user_id => $provider_info) { |
|
531 | 531 | // TODO - УКазывать тип аккаунта, на котором сменён пароль |
532 | 532 | msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, |
533 | 533 | $lang['sys_administration'], $lang['sys_login_register_message_title'], |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | sn_db_transaction_start(); |
575 | 575 | // Проверить наличие такого имени в истории имён |
576 | 576 | |
577 | - if(db_player_name_exists($player_name_unsafe)) { |
|
577 | + if (db_player_name_exists($player_name_unsafe)) { |
|
578 | 578 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_EXISTS, ERR_ERROR); |
579 | 579 | } |
580 | 580 | |
@@ -582,11 +582,11 @@ discard block |
||
582 | 582 | $player_language = ''; |
583 | 583 | $player_email = ''; |
584 | 584 | // TODO - порнография - работа должна происходить над списком аккаунтов, а не только на одном аккаунте... |
585 | - foreach($this->providers_authorised as $provider) { |
|
586 | - if(!$player_language && $provider->account->account_language) { |
|
585 | + foreach ($this->providers_authorised as $provider) { |
|
586 | + if (!$player_language && $provider->account->account_language) { |
|
587 | 587 | $player_language = $provider->account->account_language; |
588 | 588 | } |
589 | - if(!$player_email && $provider->account->account_email) { |
|
589 | + if (!$player_email && $provider->account->account_email) { |
|
590 | 590 | $player_email = $provider->account->account_email; |
591 | 591 | } |
592 | 592 | } |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | )); |
603 | 603 | // Зарегестрировать на него аккаунты из self::$accounts_authorised |
604 | 604 | $a_user = self::$user; |
605 | - foreach($this->providers_authorised as $provider) { |
|
605 | + foreach ($this->providers_authorised as $provider) { |
|
606 | 606 | // TODO - порнография. Должен быть отдельный класс трансляторов - в т.ч. и кэширующий транслятор |
607 | 607 | // TODO - ну и работа должна происходить над списком аккаунтов, а не только на одном аккаунте... |
608 | 608 | // self::db_translate_register_user($provider->provider_id, $provider->account->account_id, $a_user['id']); |
@@ -614,7 +614,7 @@ discard block |
||
614 | 614 | |
615 | 615 | sn_db_transaction_commit(); |
616 | 616 | $this->register_status = LOGIN_SUCCESS; |
617 | - } catch(Exception $e) { |
|
617 | + } catch (Exception $e) { |
|
618 | 618 | sn_db_transaction_rollback(); |
619 | 619 | |
620 | 620 | // Если старое имя занято |
@@ -633,10 +633,10 @@ discard block |
||
633 | 633 | // Пробиваем все ИД игроков по базе - есть ли вообще такие записи |
634 | 634 | // Вообще-то это не особо нужно - у нас по определению стоят констраинты |
635 | 635 | // Зато так мы узнаем максимальный authlevel, проверим права имперсонейта и вытащим все записи юзеров |
636 | - foreach($this->user_id_to_provider as $user_id => $cork) { |
|
636 | + foreach ($this->user_id_to_provider as $user_id => $cork) { |
|
637 | 637 | $user = db_user_by_id($user_id); |
638 | 638 | // Если записи игрока в БД не существует? |
639 | - if(empty($user['id'])) { |
|
639 | + if (empty($user['id'])) { |
|
640 | 640 | // Удаляем этого и переходим к следующему |
641 | 641 | unset($this->user_id_to_provider[$user_id]); |
642 | 642 | // Де-регистрируем игрока из таблицы трансляции игроков |
@@ -657,7 +657,7 @@ discard block |
||
657 | 657 | // OK v4.5 |
658 | 658 | protected function get_active_user() { |
659 | 659 | // Проверяем куку "текущего игрока" из браузера |
660 | - if( |
|
660 | + if ( |
|
661 | 661 | // Кука не пустая |
662 | 662 | ($_COOKIE[SN_COOKIE_U] = trim($_COOKIE[SN_COOKIE_U])) && !empty($_COOKIE[SN_COOKIE_U]) |
663 | 663 | // И в куке находится ID |
@@ -682,7 +682,7 @@ discard block |
||
682 | 682 | } |
683 | 683 | |
684 | 684 | // В куке нет валидного ИД записи игрока, доступной с текущих аккаунтов |
685 | - if(empty(self::$user['id'])) { |
|
685 | + if (empty(self::$user['id'])) { |
|
686 | 686 | // Берем первого из доступных |
687 | 687 | // TODO - default_user |
688 | 688 | self::$user = reset($this->accessible_user_row_list); |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | |
707 | 707 | $result = array(); |
708 | 708 | |
709 | - if($user_id && empty($this->is_impersonating)) { |
|
709 | + if ($user_id && empty($this->is_impersonating)) { |
|
710 | 710 | // self::db_counter_insert(); |
711 | 711 | self::$device->db_counter_insert($user_id); |
712 | 712 | |
@@ -714,12 +714,12 @@ discard block |
||
714 | 714 | |
715 | 715 | sys_user_options_unpack($user); |
716 | 716 | |
717 | - if($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) { |
|
717 | + if ($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) { |
|
718 | 718 | $user['banaday'] = 0; |
719 | 719 | $user['vacation'] = SN_TIME_NOW; |
720 | 720 | } |
721 | 721 | |
722 | - $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip']; |
|
722 | + $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip']; |
|
723 | 723 | $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain']; |
724 | 724 | |
725 | 725 | $result[F_BANNED_STATUS] = $user['banaday']; |
@@ -733,13 +733,13 @@ discard block |
||
733 | 733 | ); |
734 | 734 | } |
735 | 735 | |
736 | - if($extra = $config->security_ban_extra) { |
|
736 | + if ($extra = $config->security_ban_extra) { |
|
737 | 737 | $extra = explode(',', $extra); |
738 | - array_walk($extra,'trim'); |
|
738 | + array_walk($extra, 'trim'); |
|
739 | 739 | in_array(self::$device->device_id, $extra) and die(); |
740 | 740 | } |
741 | 741 | |
742 | - if(self::$login_message) { |
|
742 | + if (self::$login_message) { |
|
743 | 743 | $result[F_LOGIN_MESSAGE] = self::$login_message; |
744 | 744 | } |
745 | 745 | |
@@ -775,21 +775,21 @@ discard block |
||
775 | 775 | protected function register_player_name_validate($player_name_unsafe) { |
776 | 776 | // TODO - переделать под RAW-строки |
777 | 777 | // Если имя игрока пустое - NO GO! |
778 | - if(trim($player_name_unsafe) == '') { |
|
778 | + if (trim($player_name_unsafe) == '') { |
|
779 | 779 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_EMPTY, ERR_ERROR); |
780 | 780 | } |
781 | 781 | // Проверяем, что бы в начале и конце не было пустых символов |
782 | - if($player_name_unsafe != trim($player_name_unsafe)) { |
|
782 | + if ($player_name_unsafe != trim($player_name_unsafe)) { |
|
783 | 783 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_TRIMMED, ERR_ERROR); |
784 | 784 | } |
785 | 785 | // Если логин имеет запрещенные символы - NO GO! |
786 | - if(strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
786 | + if (strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) { |
|
787 | 787 | // TODO - выдавать в сообщение об ошибке список запрещенных символов |
788 | 788 | // TODO - заранее извещать игрока, какие символы являются запрещенными |
789 | 789 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_RESTRICTED_CHARACTERS, ERR_ERROR); |
790 | 790 | } |
791 | 791 | // Если логин меньше минимальной длины - NO GO! |
792 | - if(strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) { |
|
792 | + if (strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) { |
|
793 | 793 | // TODO - выдавать в сообщение об ошибке минимальную длину имени игрока |
794 | 794 | // TODO - заранее извещать игрока, какая минимальная и максимальная длина имени |
795 | 795 | throw new Exception(REGISTER_ERROR_PLAYER_NAME_SHORT, ERR_ERROR); |
@@ -847,7 +847,7 @@ discard block |
||
847 | 847 | } |
848 | 848 | |
849 | 849 | protected static function flog($message, $die = false) { |
850 | - if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
850 | + if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) { |
|
851 | 851 | return; |
852 | 852 | } |
853 | 853 | list($called, $caller) = debug_backtrace(false); |
@@ -860,7 +860,7 @@ discard block |
||
860 | 860 | $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false; |
861 | 861 | |
862 | 862 | classSupernova::log_file("$message - $caller_name"); |
863 | - if($die) { |
|
863 | + if ($die) { |
|
864 | 864 | $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>"); |
865 | 865 | } |
866 | 866 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | |
104 | 104 | function db_unit_records_sum($unit_id, $user_skip_list_unit) |
105 | 105 | { |
106 | - return doquery ( |
|
106 | + return doquery( |
|
107 | 107 | "SELECT unit_player_id, username, sum(unit_level) as unit_level |
108 | 108 | FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id |
109 | 109 | WHERE unit_player_id != 0 AND unit_snid = {$unit_id} {$user_skip_list_unit} |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | function db_unit_records_plain($unit_id, $user_skip_list_unit) |
117 | 117 | { |
118 | - return doquery ( |
|
118 | + return doquery( |
|
119 | 119 | "SELECT unit_player_id, username, unit_level |
120 | 120 | FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id |
121 | 121 | WHERE unit_player_id != 0 AND unit_snid = {$unit_id} {$user_skip_list_unit} |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | } |
126 | 126 | |
127 | 127 | function db_stat_list_statistic($who, $is_common_stat, $Rank, $start, $source = false) { |
128 | - if(!$source) { |
|
128 | + if (!$source) { |
|
129 | 129 | $source = array( |
130 | 130 | 'statpoints' => 'statpoints', |
131 | 131 | 'users' => 'users', |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | ); |
147 | 147 | } |
148 | 148 | |
149 | - if($who == 1) { |
|
150 | - if($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
|
149 | + if ($who == 1) { |
|
150 | + if ($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
|
151 | 151 | $query_str = |
152 | 152 | "SELECT |
153 | 153 | @rownum:=@rownum+1 rownum, subject.{$source['id']} as `id`, sp.{$Rank}_rank as rank, sp.{$Rank}_old_rank as rank_old, sp.{$Rank}_points as points, subject.{$source['username']} as `name`, subject.* |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | ORDER BY |
162 | 162 | sp.`{$Rank}_rank`, subject.{$source['id']} |
163 | 163 | LIMIT |
164 | - ". $start .",100;"; |
|
164 | + " . $start . ",100;"; |
|
165 | 165 | } else { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday` |
166 | 166 | $query_str = |
167 | 167 | "SELECT |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | ORDER BY |
175 | 175 | subject.{$Rank} DESC, subject.{$source['id']} |
176 | 176 | LIMIT |
177 | - ". $start .",100;"; |
|
177 | + " . $start . ",100;"; |
|
178 | 178 | } |
179 | 179 | } else { |
180 | 180 | // TODO |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | ORDER BY |
192 | 192 | sp.`{$Rank}_rank`, subject.id |
193 | 193 | LIMIT |
194 | - ". $start .",100;"; |
|
194 | + " . $start . ",100;"; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | return doquery($query_str); |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) { |
278 | 278 | $current_value_safe = db_escape($current_value_unsafe); |
279 | 279 | $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true); |
280 | - if(!isset($value_id['id_field']) || !$value_id['id_field']) { |
|
280 | + if (!isset($value_id['id_field']) || !$value_id['id_field']) { |
|
281 | 281 | doquery("INSERT INTO {{{$db_table_name}}} (`{$db_value_field_name}`) VALUES ('{$current_value_safe}');"); |
282 | 282 | $variable_id = db_insert_id(); |
283 | 283 | } else { |
@@ -27,19 +27,19 @@ discard block |
||
27 | 27 | */ |
28 | 28 | function db_set_make_safe_string($set, $delta = false) { |
29 | 29 | $set_safe = array(); |
30 | - foreach($set as $field => $value) { |
|
31 | - if(empty($field)) { |
|
30 | + foreach ($set as $field => $value) { |
|
31 | + if (empty($field)) { |
|
32 | 32 | continue; |
33 | 33 | } |
34 | 34 | |
35 | 35 | $field = '`' . db_escape($field) . '`'; |
36 | 36 | $new_value = $value; |
37 | - if($value === null) { |
|
37 | + if ($value === null) { |
|
38 | 38 | $new_value = 'NULL'; |
39 | - } elseif(is_string($value) && (string)($new_value = floatval($value)) != (string)$value) { |
|
39 | + } elseif (is_string($value) && (string) ($new_value = floatval($value)) != (string) $value) { |
|
40 | 40 | // non-float |
41 | 41 | $new_value = '"' . db_escape($value) . '"'; |
42 | - } elseif($delta) { |
|
42 | + } elseif ($delta) { |
|
43 | 43 | // float and DELTA-set |
44 | 44 | $new_value = "{$field} + ({$new_value})"; |
45 | 45 | } |
@@ -59,8 +59,8 @@ discard block |
||
59 | 59 | */ |
60 | 60 | function missile_list_convert_to_fleet(&$missile_db_list, &$fleet_db_list) { |
61 | 61 | // Missile attack |
62 | - foreach($missile_db_list as $irak) { |
|
63 | - if($irak['fleet_end_time'] >= SN_TIME_NOW) { |
|
62 | + foreach ($missile_db_list as $irak) { |
|
63 | + if ($irak['fleet_end_time'] >= SN_TIME_NOW) { |
|
64 | 64 | $irak['fleet_start_type'] = PT_PLANET; |
65 | 65 | $planet_start = DBStaticPlanet::db_planet_by_vector($irak, 'fleet_start_', false, 'name'); |
66 | 66 | $irak['fleet_id'] = -$irak['id']; |
@@ -8,23 +8,23 @@ discard block |
||
8 | 8 | $fleet_events = array(); |
9 | 9 | $fleet_number = 0; |
10 | 10 | |
11 | - if(empty($fleet_list)) |
|
11 | + if (empty($fleet_list)) |
|
12 | 12 | { |
13 | 13 | return; |
14 | 14 | } |
15 | 15 | |
16 | - foreach($fleet_list as $fleet) |
|
16 | + foreach ($fleet_list as $fleet) |
|
17 | 17 | { |
18 | 18 | $planet_start_type = $fleet['fleet_start_type'] == PT_MOON ? PT_MOON : PT_PLANET; |
19 | 19 | $planet_start = DBStaticPlanet::db_planet_by_gspt($fleet['fleet_start_galaxy'], $fleet['fleet_start_system'], $fleet['fleet_start_planet'], $planet_start_type, false, 'name'); |
20 | 20 | $fleet['fleet_start_name'] = $planet_start['name']; |
21 | 21 | |
22 | 22 | $planet_end_type = $fleet['fleet_end_type'] == PT_MOON ? PT_MOON : PT_PLANET; |
23 | - if($fleet['fleet_end_planet'] > $config->game_maxPlanet) |
|
23 | + if ($fleet['fleet_end_planet'] > $config->game_maxPlanet) |
|
24 | 24 | { |
25 | 25 | $fleet['fleet_end_name'] = $lang['ov_fleet_exploration']; |
26 | 26 | } |
27 | - elseif($fleet['fleet_mission'] == MT_COLONIZE) |
|
27 | + elseif ($fleet['fleet_mission'] == MT_COLONIZE) |
|
28 | 28 | { |
29 | 29 | $fleet['fleet_end_name'] = $lang['ov_fleet_colonization']; |
30 | 30 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $fleet['fleet_end_name'] = $planet_end['name']; |
35 | 35 | } |
36 | 36 | |
37 | - if($fleet['fleet_start_time'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] != MT_MISSILE && |
|
37 | + if ($fleet['fleet_start_time'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $fleet['fleet_mission'] != MT_MISSILE && |
|
38 | 38 | ($planet_scanned === false |
39 | 39 | || |
40 | 40 | ( |
@@ -49,12 +49,12 @@ discard block |
||
49 | 49 | $fleet_events[] = flt_register_fleet_event($fleet, 0, $planet_end_type); |
50 | 50 | } |
51 | 51 | |
52 | - if($fleet['fleet_end_stay'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $planet_scanned === false && $fleet['fleet_mission'] != MT_MISSILE) |
|
52 | + if ($fleet['fleet_end_stay'] > SN_TIME_NOW && $fleet['fleet_mess'] == 0 && $planet_scanned === false && $fleet['fleet_mission'] != MT_MISSILE) |
|
53 | 53 | { |
54 | 54 | $fleet_events[] = flt_register_fleet_event($fleet, 1, $planet_end_type); |
55 | 55 | } |
56 | 56 | |
57 | - if( |
|
57 | + if ( |
|
58 | 58 | $fleet['fleet_end_time'] > SN_TIME_NOW && $fleet['fleet_mission'] != MT_MISSILE && ($fleet['fleet_mess'] == 1 || ($fleet['fleet_mission'] != MT_RELOCATE && $fleet['fleet_mission'] != MT_COLONIZE)) && |
59 | 59 | ( |
60 | 60 | ($planet_scanned === false && $fleet['fleet_owner'] == $user['id']) |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $fleet_events[] = flt_register_fleet_event($fleet, 2, $planet_end_type); |
72 | 72 | } |
73 | 73 | |
74 | - if($fleet['fleet_mission'] == MT_MISSILE) |
|
74 | + if ($fleet['fleet_mission'] == MT_MISSILE) |
|
75 | 75 | { |
76 | 76 | $fleet_events[] = flt_register_fleet_event($fleet, 3, $planet_end_type); |
77 | 77 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | { |
85 | 85 | global $user, $planetrow, $fleet_number; |
86 | 86 | |
87 | - switch($fleet['ov_label'] = $ov_label) |
|
87 | + switch ($fleet['ov_label'] = $ov_label) |
|
88 | 88 | { |
89 | 89 | case 0: |
90 | 90 | $fleet['event_time'] = $fleet['fleet_start_time']; |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | |
117 | 117 | } |
118 | 118 | |
119 | - $fleet['ov_this_planet'] = $is_this_planet;// || $planet_scanned != false; |
|
119 | + $fleet['ov_this_planet'] = $is_this_planet; // || $planet_scanned != false; |
|
120 | 120 | |
121 | - if($fleet['fleet_owner'] == $user['id']) |
|
121 | + if ($fleet['fleet_owner'] == $user['id']) |
|
122 | 122 | { |
123 | 123 | $user_data = $user; |
124 | 124 | } |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | |
8 | 8 | $possible_cores = array(); |
9 | 9 | $probability = 0; |
10 | - foreach($density_list as $possible_core_id => $core_data) { |
|
11 | - if(!$core_data[UNIT_PLANET_DENSITY_RARITY]) { |
|
10 | + foreach ($density_list as $possible_core_id => $core_data) { |
|
11 | + if (!$core_data[UNIT_PLANET_DENSITY_RARITY]) { |
|
12 | 12 | continue; |
13 | 13 | } |
14 | 14 | |
15 | - if( |
|
15 | + if ( |
|
16 | 16 | // Core type exists |
17 | 17 | in_array($possible_core_id, $position_data['core_types']) |
18 | 18 | // Limit core type with planet sector count |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | |
34 | 34 | $random = mt_rand(1, $probability); |
35 | 35 | $selected_core = null; |
36 | - foreach($possible_cores as $core_type => $core_info) { |
|
37 | - if($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) { |
|
36 | + foreach ($possible_cores as $core_type => $core_info) { |
|
37 | + if ($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) { |
|
38 | 38 | $selected_core = $core_info; |
39 | 39 | break; |
40 | 40 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | $Position = intval($Position); |
61 | 61 | |
62 | - if(!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
62 | + if (!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) { |
|
63 | 63 | return false; |
64 | 64 | } |
65 | 65 | |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | |
69 | 69 | $planet_generator = sn_get_groups('planet_generator'); |
70 | 70 | |
71 | - if($HomeWorld) { |
|
71 | + if ($HomeWorld) { |
|
72 | 72 | $position_data = $planet_generator[0]; |
73 | 73 | } else { |
74 | 74 | $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position]; |
75 | - if($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
75 | + if ($Position >= UNIVERSE_RANDOM_PLANET_START) { |
|
76 | 76 | // Корректируем температуру для планеты-странника |
77 | 77 | $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START); |
78 | 78 | } |
@@ -172,15 +172,15 @@ discard block |
||
172 | 172 | $moon_name = ''; |
173 | 173 | $moon_row = array(); |
174 | 174 | $moon = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id'); |
175 | - if(!$moon['id']) { |
|
175 | + if (!$moon['id']) { |
|
176 | 176 | $moon_planet = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_PLANET, true, '`id`, `temp_min`, `temp_max`, `name`, `debris_metal`, `debris_crystal`'); |
177 | 177 | |
178 | - if($moon_planet['id']) { |
|
178 | + if ($moon_planet['id']) { |
|
179 | 179 | $base_storage_size = BASE_STORAGE_SIZE; |
180 | 180 | |
181 | - if(!$moon_chance) { |
|
181 | + if (!$moon_chance) { |
|
182 | 182 | $size = mt_rand(1100, 8999); |
183 | - } elseif($moon_chance <= 100) { |
|
183 | + } elseif ($moon_chance <= 100) { |
|
184 | 184 | $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999); |
185 | 185 | } else { |
186 | 186 | $size = $moon_chance; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | |
197 | 197 | $field_max = ceil($size / 1000); |
198 | 198 | |
199 | - if(isset($options['image']) && $options['image']) { |
|
199 | + if (isset($options['image']) && $options['image']) { |
|
200 | 200 | $moon_image = $options['image']; |
201 | 201 | } else { |
202 | 202 | $moon_image = 'mond'; |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | `deuterium` = '0', `deuterium_perhour` = '0', `deuterium_max` = '{$base_storage_size}'" |
212 | 212 | ); |
213 | 213 | |
214 | - if($update_debris) { |
|
214 | + if ($update_debris) { |
|
215 | 215 | $debris_spent = $moon_chance * 1000000; |
216 | 216 | $metal_spent = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100)); |
217 | 217 | $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent); |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $planet_row['id'] = $user['current_planet']; |
248 | 248 | |
249 | 249 | // Пытаемся переключить на новую планету |
250 | - if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) |
|
250 | + if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet']) |
|
251 | 251 | { |
252 | 252 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id'); |
253 | 253 | } |
@@ -257,15 +257,15 @@ discard block |
||
257 | 257 | } |
258 | 258 | |
259 | 259 | // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету |
260 | - if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
260 | + if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet'] |
|
261 | 261 | { |
262 | 262 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id'); |
263 | 263 | // Если текущей планеты не существует - выставляем Столицу |
264 | - if(!isset($planet_row['id'])) |
|
264 | + if (!isset($planet_row['id'])) |
|
265 | 265 | { |
266 | 266 | $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id'); |
267 | 267 | // Если и столицы не существует - значит что-то очень не так с записью пользователя |
268 | - if(!isset($planet_row['id'])) |
|
268 | + if (!isset($planet_row['id'])) |
|
269 | 269 | { |
270 | 270 | global $debug; |
271 | 271 | $debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502); |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | } |
275 | 275 | |
276 | 276 | // Если производилось переключение планеты - делаем запись в юзере |
277 | - if($user['current_planet'] != $planet_row['id']) |
|
277 | + if ($user['current_planet'] != $planet_row['id']) |
|
278 | 278 | { |
279 | 279 | db_user_set_by_id($user['id'], "`current_planet` = '{$planet_row['id']}'"); |
280 | 280 | $user['current_planet'] = $planet_row['id']; |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | { |
299 | 299 | global $lang; |
300 | 300 | |
301 | - if(!$from['id']) |
|
301 | + if (!$from['id']) |
|
302 | 302 | { |
303 | 303 | $result = $lang['sys_planet_expedition']; |
304 | 304 | } |
@@ -337,7 +337,7 @@ discard block |
||
337 | 337 | function uni_calculate_moon_chance($FleetDebris) |
338 | 338 | { |
339 | 339 | $MoonChance = $FleetDebris / 1000000; |
340 | - return ($MoonChance < 1) ? 0 : ($MoonChance>30 ? 30 : $MoonChance); |
|
340 | + return ($MoonChance < 1) ? 0 : ($MoonChance > 30 ? 30 : $MoonChance); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | function uni_coordinates_valid($coordinates, $prefix = '') |
@@ -359,11 +359,11 @@ discard block |
||
359 | 359 | global $lang, $config; |
360 | 360 | |
361 | 361 | try { |
362 | - if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
362 | + if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) { |
|
363 | 363 | throw new exception($lang['ov_teleport_err_cooldown'], ERR_ERROR); |
364 | 364 | } |
365 | 365 | |
366 | - if(mrc_get_level($user, false, RES_DARK_MATTER) < $config->planet_teleport_cost) { |
|
366 | + if (mrc_get_level($user, false, RES_DARK_MATTER) < $config->planet_teleport_cost) { |
|
367 | 367 | throw new exception($lang['ov_teleport_err_no_dark_matter'], ERR_ERROR); |
368 | 368 | } |
369 | 369 | |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | // if(!empty($incoming['incoming'])) { |
376 | 376 | // throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR); |
377 | 377 | // } |
378 | - if(fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
378 | + if (fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) { |
|
379 | 379 | throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR); |
380 | 380 | } |
381 | 381 | |
@@ -384,10 +384,10 @@ discard block |
||
384 | 384 | // throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR); |
385 | 385 | //} |
386 | 386 | |
387 | - if(is_array($new_coordinates)) { |
|
387 | + if (is_array($new_coordinates)) { |
|
388 | 388 | $new_coordinates['planet_type'] = PT_PLANET; |
389 | 389 | $incoming = DBStaticPlanet::db_planet_by_vector($new_coordinates, '', true, 'id'); |
390 | - if($incoming['id']) { |
|
390 | + if ($incoming['id']) { |
|
391 | 391 | throw new exception($lang['ov_teleport_err_destination_busy'], ERR_ERROR); |
392 | 392 | } |
393 | 393 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | 'result' => ERR_NONE, |
397 | 397 | 'message' => '', |
398 | 398 | ); |
399 | - } catch(exception $e) { |
|
399 | + } catch (exception $e) { |
|
400 | 400 | $response = array( |
401 | 401 | 'result' => $e->getCode(), |
402 | 402 | 'message' => $e->getMessage(), |
@@ -2,7 +2,7 @@ |
||
2 | 2 | |
3 | 3 | function flt_mission_hold(&$mission_data) |
4 | 4 | { |
5 | - if($mission_data['fleet']['fleet_end_stay'] < SN_TIME_NOW) |
|
5 | + if ($mission_data['fleet']['fleet_end_stay'] < SN_TIME_NOW) |
|
6 | 6 | { |
7 | 7 | fleet_send_back($mission_data['fleet']); |
8 | 8 | // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = '{$fleet_row['fleet_id']}' LIMIT 1;"); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | $fleet_row = &$mission_data['fleet']; |
14 | 14 | $destination_planet = &$mission_data['dst_planet']; |
15 | 15 | |
16 | - if(!$destination_planet || !is_array($destination_planet) || $fleet_row['fleet_owner'] != $destination_planet['id_owner']) |
|
16 | + if (!$destination_planet || !is_array($destination_planet) || $fleet_row['fleet_owner'] != $destination_planet['id_owner']) |
|
17 | 17 | { |
18 | 18 | // doquery("UPDATE {{fleets}} SET `fleet_mess` = 1 WHERE `fleet_id` = {$fleet_row['fleet_id']} LIMIT 1;"); |
19 | 19 | fleet_send_back($mission_data['fleet']); |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $mission_data['src_planet']['name'], uni_render_coordinates_href($fleet_row, 'fleet_start_', 3, ''), $destination_planet['name'], uni_render_coordinates_href($fleet_row, 'fleet_end_', 3, ''), |
27 | 27 | $fleet_row['fleet_resource_metal'], $lang['Metal'], $fleet_row['fleet_resource_crystal'], $lang['Crystal'], $fleet_row['fleet_resource_deuterium'], $lang['Deuterium']) . |
28 | 28 | '<br />' . $lang['sys_relocate_mess_user']; |
29 | - foreach(sys_unit_str2arr($fleet_row['fleet_array']) as $ship_id => $ship_count) |
|
29 | + foreach (sys_unit_str2arr($fleet_row['fleet_array']) as $ship_id => $ship_count) |
|
30 | 30 | { |
31 | 31 | $Message .= $lang['tech'][$ship_id] . ' - ' . $ship_count . '<br />'; |
32 | 32 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | function flt_mission_destroy($mission_data) { |
9 | 9 | $fleet_row = $mission_data['fleet']; |
10 | 10 | $destination_planet = $mission_data['dst_planet']; |
11 | - if(!$destination_planet || !is_array($destination_planet) || $destination_planet['planet_type'] != PT_MOON) { |
|
11 | + if (!$destination_planet || !is_array($destination_planet) || $destination_planet['planet_type'] != PT_MOON) { |
|
12 | 12 | fleet_send_back($fleet_row); |
13 | 13 | |
14 | 14 | return CACHE_FLEET; |