@@ -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 | } |
@@ -76,7 +76,7 @@ |
||
| 76 | 76 | |
| 77 | 77 | $result = array(); |
| 78 | 78 | $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++; |
| 79 | - $result[] = "tID {$transaction_id}"; |
|
| 79 | + $result[] = "tid {$transaction_id}"; |
|
| 80 | 80 | foreach($backtrace as $a_trace) { |
| 81 | 81 | if(in_array($a_trace['function'], $exclude_functions)) { |
| 82 | 82 | continue; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * que esperabas!!! soy newbie!!! D':< |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | -if(!defined('INSIDE')) { |
|
| 27 | +if (!defined('INSIDE')) { |
|
| 28 | 28 | die("attemp hacking"); |
| 29 | 29 | } |
| 30 | 30 | |
@@ -37,16 +37,16 @@ discard block |
||
| 37 | 37 | function log_file($message, $ident_change = 0) { |
| 38 | 38 | static $ident = 0; |
| 39 | 39 | |
| 40 | - if(!defined('SN_DEBUG_LOG')) { |
|
| 40 | + if (!defined('SN_DEBUG_LOG')) { |
|
| 41 | 41 | return; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - if($this->log_file_handler === null) { |
|
| 44 | + if ($this->log_file_handler === null) { |
|
| 45 | 45 | $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+'); |
| 46 | 46 | @fwrite($this->log_file_handler, "\r\n\r\n"); |
| 47 | 47 | } |
| 48 | 48 | $ident_change < 0 ? $ident += $ident_change * 2 : false; |
| 49 | - if($this->log_file_handler) { |
|
| 49 | + if ($this->log_file_handler) { |
|
| 50 | 50 | @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n"); |
| 51 | 51 | } |
| 52 | 52 | $ident_change > 0 ? $ident += $ident_change * 2 : false; |
@@ -81,8 +81,8 @@ discard block |
||
| 81 | 81 | $result = array(); |
| 82 | 82 | $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++; |
| 83 | 83 | $result[] = "tID {$transaction_id}"; |
| 84 | - foreach($backtrace as $a_trace) { |
|
| 85 | - if(in_array($a_trace['function'], $exclude_functions)) { |
|
| 84 | + foreach ($backtrace as $a_trace) { |
|
| 85 | + if (in_array($a_trace['function'], $exclude_functions)) { |
|
| 86 | 86 | continue; |
| 87 | 87 | } |
| 88 | 88 | $function = |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $result[] = "{$function} - '{$file}' Line {$a_trace['line']}"; |
| 100 | 100 | |
| 101 | - if(!$long_comment) { |
|
| 101 | + if (!$long_comment) { |
|
| 102 | 102 | break; |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -107,26 +107,26 @@ discard block |
||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | function dump($dump = false, $force_base = false, $deadlock = false) { |
| 110 | - if($dump === false) { |
|
| 110 | + if ($dump === false) { |
|
| 111 | 111 | return; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | $error_backtrace = array(); |
| 115 | 115 | $base_dump = false; |
| 116 | 116 | |
| 117 | - if($force_base === true) { |
|
| 117 | + if ($force_base === true) { |
|
| 118 | 118 | $base_dump = true; |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - if($dump === true) { |
|
| 121 | + if ($dump === true) { |
|
| 122 | 122 | $base_dump = true; |
| 123 | 123 | } else { |
| 124 | - if(!is_array($dump)) { |
|
| 124 | + if (!is_array($dump)) { |
|
| 125 | 125 | $dump = array('var' => $dump); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - foreach($dump as $dump_var_name => $dump_var) { |
|
| 129 | - if($dump_var_name == 'base_dump') { |
|
| 128 | + foreach ($dump as $dump_var_name => $dump_var) { |
|
| 129 | + if ($dump_var_name == 'base_dump') { |
|
| 130 | 130 | $base_dump = $dump_var; |
| 131 | 131 | } else { |
| 132 | 132 | $error_backtrace[$dump_var_name] = $dump_var; |
@@ -134,24 +134,23 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
| 137 | + if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) { |
|
| 138 | 138 | $error_backtrace['deadlock'] = explode("\n", $q['Status']); |
| 139 | 139 | $error_backtrace['locks'] = _SnCacheInternal::$locks; |
| 140 | 140 | $error_backtrace['cSN_data'] = _SnCacheInternal::$data; |
| 141 | - foreach($error_backtrace['cSN_data'] as &$location) { |
|
| 142 | - foreach($location as $location_id => &$location_data) // $location_data = $location_id; |
|
| 141 | + foreach ($error_backtrace['cSN_data'] as &$location) { |
|
| 142 | + foreach ($location as $location_id => &$location_data) // $location_data = $location_id; |
|
| 143 | 143 | { |
| 144 | - $location_data = isset($location_data['username']) ? $location_data['username'] : |
|
| 145 | - (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
| 144 | + $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id); |
|
| 146 | 145 | } |
| 147 | 146 | } |
| 148 | 147 | } |
| 149 | 148 | |
| 150 | - if($base_dump) { |
|
| 151 | - if(!is_array($this->log_array) || empty($this->log_array)) { |
|
| 149 | + if ($base_dump) { |
|
| 150 | + if (!is_array($this->log_array) || empty($this->log_array)) { |
|
| 152 | 151 | $this->log_array = []; |
| 153 | 152 | } else { |
| 154 | - foreach($this->log_array as $log) { |
|
| 153 | + foreach ($this->log_array as $log) { |
|
| 155 | 154 | $error_backtrace['queries'][] = $log; |
| 156 | 155 | } |
| 157 | 156 | } |
@@ -163,17 +162,17 @@ discard block |
||
| 163 | 162 | // Converting object instances to object names |
| 164 | 163 | |
| 165 | 164 | foreach ($error_backtrace['backtrace'] as &$backtrace) { |
| 166 | - if(is_object($backtrace['object'])) { |
|
| 165 | + if (is_object($backtrace['object'])) { |
|
| 167 | 166 | $backtrace['object'] = get_class($backtrace['object']); |
| 168 | 167 | } |
| 169 | 168 | |
| 170 | - if(empty($backtrace['args'])) { |
|
| 169 | + if (empty($backtrace['args'])) { |
|
| 171 | 170 | continue; |
| 172 | 171 | } |
| 173 | 172 | |
| 174 | 173 | // Doing same conversion for backtrace params |
| 175 | - foreach($backtrace['args'] as &$arg) { |
|
| 176 | - if(is_object($arg)) { |
|
| 174 | + foreach ($backtrace['args'] as &$arg) { |
|
| 175 | + if (is_object($arg)) { |
|
| 177 | 176 | $arg = 'object::' . get_class($arg); |
| 178 | 177 | } |
| 179 | 178 | } |
@@ -202,14 +201,14 @@ discard block |
||
| 202 | 201 | function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) { |
| 203 | 202 | global $config, $sys_stop_log_hit, $lang, $sys_log_disabled, $user; |
| 204 | 203 | |
| 205 | - if(empty(classSupernova::$db->connected)) { |
|
| 204 | + if (empty(classSupernova::$db->connected)) { |
|
| 206 | 205 | // TODO - писать ошибку в файл |
| 207 | 206 | die('SQL server currently unavailable. Please contact Administration...'); |
| 208 | 207 | } |
| 209 | 208 | |
| 210 | 209 | sn_db_transaction_rollback(); |
| 211 | 210 | |
| 212 | - if(classSupernova::$config->debug == 1) { |
|
| 211 | + if (classSupernova::$config->debug == 1) { |
|
| 213 | 212 | echo "<h2>{$title}</h2><br><font color=red>" . htmlspecialchars($message) . "</font><br><hr>"; |
| 214 | 213 | echo "<table>{$this->log}</table>"; |
| 215 | 214 | } |
@@ -219,7 +218,7 @@ discard block |
||
| 219 | 218 | $error_text = db_escape($message); |
| 220 | 219 | $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false); |
| 221 | 220 | |
| 222 | - if(!$sys_log_disabled) { |
|
| 221 | + if (!$sys_log_disabled) { |
|
| 223 | 222 | $query = "INSERT INTO `{{logs}}` SET |
| 224 | 223 | `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "', |
| 225 | 224 | `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
@@ -237,7 +236,7 @@ discard block |
||
| 237 | 236 | ob_start(); |
| 238 | 237 | print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}"); |
| 239 | 238 | |
| 240 | - foreach($error_backtrace as $name => $value) { |
|
| 239 | + foreach ($error_backtrace as $name => $value) { |
|
| 241 | 240 | print('<hr>'); |
| 242 | 241 | pdump($value, $name); |
| 243 | 242 | } |
@@ -249,14 +248,14 @@ discard block |
||
| 249 | 248 | function warning($message, $title = 'System Message', $log_code = 300, $dump = false) { |
| 250 | 249 | global $user, $lang, $sys_log_disabled; |
| 251 | 250 | |
| 252 | - if(empty(classSupernova::$db->connected)) { |
|
| 251 | + if (empty(classSupernova::$db->connected)) { |
|
| 253 | 252 | // TODO - писать ошибку в файл |
| 254 | 253 | die('SQL server currently unavailable. Please contact Administration...'); |
| 255 | 254 | } |
| 256 | 255 | |
| 257 | 256 | $error_backtrace = $this->dump($dump, false); |
| 258 | 257 | |
| 259 | - if(!$sys_log_disabled) { |
|
| 258 | + if (!$sys_log_disabled) { |
|
| 260 | 259 | $query = "INSERT INTO `{{logs}}` SET |
| 261 | 260 | `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "', |
| 262 | 261 | `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "', `log_text` = '" . db_escape($message) . "', |
@@ -274,11 +273,11 @@ discard block |
||
| 274 | 273 | // Dump variables nicer then var_dump() |
| 275 | 274 | |
| 276 | 275 | function dump($value, $varname = null, $level = 0, $dumper = '') { |
| 277 | - if(isset($varname)) { |
|
| 276 | + if (isset($varname)) { |
|
| 278 | 277 | $varname .= " = "; |
| 279 | 278 | } |
| 280 | 279 | |
| 281 | - if($level == -1) { |
|
| 280 | + if ($level == -1) { |
|
| 282 | 281 | $trans[' '] = '∴'; |
| 283 | 282 | $trans["\t"] = '⇒'; |
| 284 | 283 | $trans["\n"] = '¶;'; |
@@ -287,7 +286,7 @@ discard block |
||
| 287 | 286 | |
| 288 | 287 | return strtr(htmlspecialchars($value), $trans); |
| 289 | 288 | } |
| 290 | - if($level == 0) { |
|
| 289 | + if ($level == 0) { |
|
| 291 | 290 | // $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname; |
| 292 | 291 | $dumper = mt_rand(10, 99) . '|' . $varname; |
| 293 | 292 | } |
@@ -295,22 +294,22 @@ discard block |
||
| 295 | 294 | $type = gettype($value); |
| 296 | 295 | $dumper .= $type; |
| 297 | 296 | |
| 298 | - if($type == 'string') { |
|
| 297 | + if ($type == 'string') { |
|
| 299 | 298 | $dumper .= '(' . strlen($value) . ')'; |
| 300 | 299 | $value = dump($value, '', -1); |
| 301 | - } elseif($type == 'boolean') { |
|
| 300 | + } elseif ($type == 'boolean') { |
|
| 302 | 301 | $value = ($value ? 'true' : 'false'); |
| 303 | - } elseif($type == 'object') { |
|
| 302 | + } elseif ($type == 'object') { |
|
| 304 | 303 | $props = get_class_vars(get_class($value)); |
| 305 | 304 | $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>'; |
| 306 | - foreach($props as $key => $val) { |
|
| 305 | + foreach ($props as $key => $val) { |
|
| 307 | 306 | $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => '; |
| 308 | 307 | $dumper .= dump($value->$key, '', $level + 1); |
| 309 | 308 | } |
| 310 | 309 | $value = ''; |
| 311 | - } elseif($type == 'array') { |
|
| 310 | + } elseif ($type == 'array') { |
|
| 312 | 311 | $dumper .= '(' . count($value) . ')'; |
| 313 | - foreach($value as $key => $val) { |
|
| 312 | + foreach ($value as $key => $val) { |
|
| 314 | 313 | $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => '; |
| 315 | 314 | $dumper .= dump($val, '', $level + 1); |
| 316 | 315 | } |
@@ -330,7 +329,7 @@ discard block |
||
| 330 | 329 | // $backtrace = $backtrace[1]; |
| 331 | 330 | |
| 332 | 331 | $caller = ''; |
| 333 | - if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
| 332 | + if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) { |
|
| 334 | 333 | $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') . |
| 335 | 334 | (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') . |
| 336 | 335 | $backtrace[1]['function'] . |
@@ -357,7 +356,7 @@ discard block |
||
| 357 | 356 | } |
| 358 | 357 | |
| 359 | 358 | function pr($prePrint = false) { |
| 360 | - if($prePrint) { |
|
| 359 | + if ($prePrint) { |
|
| 361 | 360 | print("<br>"); |
| 362 | 361 | } |
| 363 | 362 | print(mt_rand() . "<br>"); |
@@ -367,7 +366,7 @@ discard block |
||
| 367 | 366 | global $_PRINT_COUNT_VALUE; |
| 368 | 367 | $_PRINT_COUNT_VALUE++; |
| 369 | 368 | |
| 370 | - if($prePrint) { |
|
| 369 | + if ($prePrint) { |
|
| 371 | 370 | print("<br>"); |
| 372 | 371 | } |
| 373 | 372 | print($_PRINT_COUNT_VALUE . "<br>"); |
@@ -139,11 +139,13 @@ |
||
| 139 | 139 | $error_backtrace['locks'] = _SnCacheInternal::$locks; |
| 140 | 140 | $error_backtrace['cSN_data'] = _SnCacheInternal::$data; |
| 141 | 141 | foreach($error_backtrace['cSN_data'] as &$location) { |
| 142 | - foreach($location as $location_id => &$location_data) // $location_data = $location_id; |
|
| 142 | + foreach($location as $location_id => &$location_data) { |
|
| 143 | + // $location_data = $location_id; |
|
| 143 | 144 | { |
| 144 | 145 | $location_data = isset($location_data['username']) ? $location_data['username'] : |
| 145 | 146 | (isset($location_data['name']) ? $location_data['name'] : $location_id); |
| 146 | 147 | } |
| 148 | + } |
|
| 147 | 149 | } |
| 148 | 150 | } |
| 149 | 151 | |
@@ -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 { |
@@ -6,8 +6,7 @@ discard block |
||
| 6 | 6 | require_once('db_queries_fleet.php'); |
| 7 | 7 | |
| 8 | 8 | |
| 9 | -function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) |
|
| 10 | -{ |
|
| 9 | +function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) { |
|
| 11 | 10 | return doquery( |
| 12 | 11 | "SELECT p.*, u.username" . ($table_parent_columns ? ', p1.name AS parent_name' : '') . |
| 13 | 12 | " FROM {{planets}} AS p |
@@ -16,8 +15,7 @@ discard block |
||
| 16 | 15 | " WHERE " . ($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}")); |
| 17 | 16 | } |
| 18 | 17 | |
| 19 | -function db_planet_list_search($searchtext) |
|
| 20 | -{ |
|
| 18 | +function db_planet_list_search($searchtext) { |
|
| 21 | 19 | return doquery( |
| 22 | 20 | "SELECT |
| 23 | 21 | p.galaxy, p.system, p.planet, p.planet_type, p.name as planet_name, |
@@ -37,8 +35,7 @@ discard block |
||
| 37 | 35 | |
| 38 | 36 | |
| 39 | 37 | |
| 40 | -function db_user_list_search($searchtext) |
|
| 41 | -{ |
|
| 38 | +function db_user_list_search($searchtext) { |
|
| 42 | 39 | return doquery( |
| 43 | 40 | "SELECT |
| 44 | 41 | pn.player_name, u.id as uid, u.username, u.ally_id, u.id_planet, u.total_points, u.total_rank, |
@@ -56,8 +53,7 @@ discard block |
||
| 56 | 53 | ); |
| 57 | 54 | } |
| 58 | 55 | |
| 59 | -function db_buddy_list_by_user($user_id) |
|
| 60 | -{ |
|
| 56 | +function db_buddy_list_by_user($user_id) { |
|
| 61 | 57 | // return ($user_id = intval($user_id)) ? doquery( |
| 62 | 58 | return ($user_id = idval($user_id)) ? doquery( |
| 63 | 59 | "SELECT |
@@ -87,8 +83,7 @@ discard block |
||
| 87 | 83 | |
| 88 | 84 | |
| 89 | 85 | |
| 90 | -function db_unit_records_sum($unit_id, $user_skip_list_unit) |
|
| 91 | -{ |
|
| 86 | +function db_unit_records_sum($unit_id, $user_skip_list_unit) { |
|
| 92 | 87 | return doquery ( |
| 93 | 88 | "SELECT unit_player_id, username, sum(unit_level) as unit_level |
| 94 | 89 | FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id |
@@ -99,8 +94,7 @@ discard block |
||
| 99 | 94 | , true); |
| 100 | 95 | } |
| 101 | 96 | |
| 102 | -function db_unit_records_plain($unit_id, $user_skip_list_unit) |
|
| 103 | -{ |
|
| 97 | +function db_unit_records_plain($unit_id, $user_skip_list_unit) { |
|
| 104 | 98 | return doquery ( |
| 105 | 99 | "SELECT unit_player_id, username, unit_level |
| 106 | 100 | FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id |
@@ -184,15 +178,13 @@ discard block |
||
| 184 | 178 | } |
| 185 | 179 | |
| 186 | 180 | |
| 187 | -function db_stat_list_delete_ally_player() |
|
| 188 | -{ |
|
| 181 | +function db_stat_list_delete_ally_player() { |
|
| 189 | 182 | return doquery('DELETE s FROM `{{statpoints}}` AS s JOIN `{{users}}` AS u ON u.id = s.id_owner WHERE s.id_ally IS NULL AND u.user_as_ally IS NOT NULL'); |
| 190 | 183 | } |
| 191 | 184 | |
| 192 | 185 | |
| 193 | 186 | |
| 194 | -function db_chat_player_list_online($chat_refresh_rate, $ally_add) |
|
| 195 | -{ |
|
| 187 | +function db_chat_player_list_online($chat_refresh_rate, $ally_add) { |
|
| 196 | 188 | $sql_date = SN_TIME_NOW - $chat_refresh_rate * 2; |
| 197 | 189 | |
| 198 | 190 | return doquery( |
@@ -206,13 +198,11 @@ discard block |
||
| 206 | 198 | ORDER BY authlevel DESC, `username`"); |
| 207 | 199 | } |
| 208 | 200 | |
| 209 | -function db_referrals_list_by_id($user_id) |
|
| 210 | -{ |
|
| 201 | +function db_referrals_list_by_id($user_id) { |
|
| 211 | 202 | return doquery("SELECT r.*, u.username, u.register_time FROM {{referrals}} AS r LEFT JOIN {{users}} AS u ON u.id = r.id WHERE id_partner = {$user_id}"); |
| 212 | 203 | } |
| 213 | 204 | |
| 214 | -function db_message_list_admin_by_type($int_type_selected, $StartRec) |
|
| 215 | -{ |
|
| 205 | +function db_message_list_admin_by_type($int_type_selected, $StartRec) { |
|
| 216 | 206 | return doquery("SELECT |
| 217 | 207 | message_id as `ID`, |
| 218 | 208 | message_from as `FROM`, |
@@ -231,8 +221,7 @@ discard block |
||
| 231 | 221 | } |
| 232 | 222 | |
| 233 | 223 | |
| 234 | -function db_message_insert_all($message_type, $from, $subject, $text) |
|
| 235 | -{ |
|
| 224 | +function db_message_insert_all($message_type, $from, $subject, $text) { |
|
| 236 | 225 | return doquery($QryInsertMessage = 'INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' . |
| 237 | 226 | "SELECT `id`, 0, unix_timestamp(now()), {$message_type}, '{$from}', '{$subject}', '{$text}' FROM {{users}}"); |
| 238 | 227 | } |
@@ -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']; |
@@ -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 |
@@ -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 | } |
@@ -89,18 +89,18 @@ discard block |
||
| 89 | 89 | case 0: |
| 90 | 90 | $fleet['event_time'] = $fleet['fleet_start_time']; |
| 91 | 91 | $is_this_planet = ( |
| 92 | - ($planetrow['galaxy'] == $fleet['fleet_end_galaxy']) AND |
|
| 93 | - ($planetrow['system'] == $fleet['fleet_end_system']) AND |
|
| 94 | - ($planetrow['planet'] == $fleet['fleet_end_planet']) AND |
|
| 92 | + ($planetrow['galaxy'] == $fleet['fleet_end_galaxy']) and |
|
| 93 | + ($planetrow['system'] == $fleet['fleet_end_system']) and |
|
| 94 | + ($planetrow['planet'] == $fleet['fleet_end_planet']) and |
|
| 95 | 95 | ($planetrow['planet_type'] == $planet_end_type)); |
| 96 | 96 | break; |
| 97 | 97 | |
| 98 | 98 | case 1: |
| 99 | 99 | $fleet['event_time'] = $fleet['fleet_end_stay']; |
| 100 | 100 | $is_this_planet = ( |
| 101 | - ($planetrow['galaxy'] == $fleet['fleet_end_galaxy']) AND |
|
| 102 | - ($planetrow['system'] == $fleet['fleet_end_system']) AND |
|
| 103 | - ($planetrow['planet'] == $fleet['fleet_end_planet']) AND |
|
| 101 | + ($planetrow['galaxy'] == $fleet['fleet_end_galaxy']) and |
|
| 102 | + ($planetrow['system'] == $fleet['fleet_end_system']) and |
|
| 103 | + ($planetrow['planet'] == $fleet['fleet_end_planet']) and |
|
| 104 | 104 | ($planetrow['planet_type'] == $planet_end_type)); |
| 105 | 105 | break; |
| 106 | 106 | |
@@ -108,9 +108,9 @@ discard block |
||
| 108 | 108 | case 3: |
| 109 | 109 | $fleet['event_time'] = $fleet['fleet_end_time']; |
| 110 | 110 | $is_this_planet = ( |
| 111 | - ($planetrow['galaxy'] == $fleet['fleet_start_galaxy']) AND |
|
| 112 | - ($planetrow['system'] == $fleet['fleet_start_system']) AND |
|
| 113 | - ($planetrow['planet'] == $fleet['fleet_start_planet']) AND |
|
| 111 | + ($planetrow['galaxy'] == $fleet['fleet_start_galaxy']) and |
|
| 112 | + ($planetrow['system'] == $fleet['fleet_start_system']) and |
|
| 113 | + ($planetrow['planet'] == $fleet['fleet_start_planet']) and |
|
| 114 | 114 | ($planetrow['planet_type'] == $fleet['fleet_start_type'])); |
| 115 | 115 | break; |
| 116 | 116 | |
@@ -1,8 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -function flt_parse_fleets_to_events($fleet_list, $planet_scanned = false) |
|
| 5 | -{ |
|
| 4 | +function flt_parse_fleets_to_events($fleet_list, $planet_scanned = false) { |
|
| 6 | 5 | global $config, $user, $fleet_number, $lang; |
| 7 | 6 | |
| 8 | 7 | $fleet_events = array(); |
@@ -23,12 +22,10 @@ discard block |
||
| 23 | 22 | if($fleet['fleet_end_planet'] > $config->game_maxPlanet) |
| 24 | 23 | { |
| 25 | 24 | $fleet['fleet_end_name'] = $lang['ov_fleet_exploration']; |
| 26 | - } |
|
| 27 | - elseif($fleet['fleet_mission'] == MT_COLONIZE) |
|
| 25 | + } elseif($fleet['fleet_mission'] == MT_COLONIZE) |
|
| 28 | 26 | { |
| 29 | 27 | $fleet['fleet_end_name'] = $lang['ov_fleet_colonization']; |
| 30 | - } |
|
| 31 | - else |
|
| 28 | + } else |
|
| 32 | 29 | { |
| 33 | 30 | $planet_end = DBStaticPlanet::db_planet_by_gspt($fleet['fleet_end_galaxy'], $fleet['fleet_end_system'], $fleet['fleet_end_planet'], $planet_end_type, false, 'name'); |
| 34 | 31 | $fleet['fleet_end_name'] = $planet_end['name']; |
@@ -80,8 +77,7 @@ discard block |
||
| 80 | 77 | return $fleet_events; |
| 81 | 78 | } |
| 82 | 79 | |
| 83 | -function flt_register_fleet_event($fleet, $ov_label, $planet_end_type) |
|
| 84 | -{ |
|
| 80 | +function flt_register_fleet_event($fleet, $ov_label, $planet_end_type) { |
|
| 85 | 81 | global $user, $planetrow, $fleet_number; |
| 86 | 82 | |
| 87 | 83 | switch($fleet['ov_label'] = $ov_label) |
@@ -121,8 +117,7 @@ discard block |
||
| 121 | 117 | if($fleet['fleet_owner'] == $user['id']) |
| 122 | 118 | { |
| 123 | 119 | $user_data = $user; |
| 124 | - } |
|
| 125 | - else |
|
| 120 | + } else |
|
| 126 | 121 | { |
| 127 | 122 | $user_data = db_user_by_id($fleet['fleet_owner']); |
| 128 | 123 | } |
@@ -134,8 +129,7 @@ discard block |
||
| 134 | 129 | * @param array $planetrow |
| 135 | 130 | * @param template $template |
| 136 | 131 | */ |
| 137 | -function int_planet_pretemplate($planetrow, &$template) |
|
| 138 | -{ |
|
| 132 | +function int_planet_pretemplate($planetrow, &$template) { |
|
| 139 | 133 | global $lang, $user; |
| 140 | 134 | |
| 141 | 135 | $governor_id = $planetrow['PLANET_GOVERNOR_ID']; |
@@ -4,8 +4,7 @@ discard block |
||
| 4 | 4 | // Open Source |
| 5 | 5 | // V1 |
| 6 | 6 | // |
| 7 | -function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0') |
|
| 8 | -{ |
|
| 7 | +function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0') { |
|
| 9 | 8 | // Here we select which part of defense should take damage: structure or shield |
| 10 | 9 | // $damageTo = P_SHIELD; |
| 11 | 10 | // $damageTo = P_STRUCTURE; |
@@ -34,8 +33,7 @@ discard block |
||
| 34 | 33 | $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] ); |
| 35 | 34 | $structures[$targetedStructure][0] -= $structsDestroyed; |
| 36 | 35 | $MIPDamage -= $structsDestroyed*$damageDone; |
| 37 | - } |
|
| 38 | - else |
|
| 36 | + } else |
|
| 39 | 37 | { |
| 40 | 38 | // REALLY random attack |
| 41 | 39 | $can_be_damaged = sn_get_groups('defense_active'); |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | $mip_data = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET); |
| 15 | 15 | $MIPDamage = floor(mrc_modify_value($attackerTech, false, TECH_WEAPON, $MIPs * $mip_data[P_ATTACK] * mt_rand(80, 120) / 100)); |
| 16 | - foreach($structures as $key => $structure) |
|
| 16 | + foreach ($structures as $key => $structure) |
|
| 17 | 17 | { |
| 18 | 18 | $unit_info = get_unit_param($key); |
| 19 | 19 | $amplify = isset($mip_data[P_AMPLIFY][$key]) ? $mip_data[P_AMPLIFY][$key] : 1; |
@@ -31,9 +31,9 @@ discard block |
||
| 31 | 31 | { |
| 32 | 32 | //attacking only selected structure |
| 33 | 33 | $damageDone = $structures[$targetedStructure][$damageTo]; |
| 34 | - $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] ); |
|
| 34 | + $structsDestroyed = min(floor($MIPDamage / $damageDone), $structures[$targetedStructure][0]); |
|
| 35 | 35 | $structures[$targetedStructure][0] -= $structsDestroyed; |
| 36 | - $MIPDamage -= $structsDestroyed*$damageDone; |
|
| 36 | + $MIPDamage -= $structsDestroyed * $damageDone; |
|
| 37 | 37 | } |
| 38 | 38 | else |
| 39 | 39 | { |
@@ -44,16 +44,16 @@ discard block |
||
| 44 | 44 | do |
| 45 | 45 | { |
| 46 | 46 | // finding is there any structure that can be damaged with leftovers of $MIPDamage |
| 47 | - foreach($can_be_damaged as $key => $unit_id) |
|
| 47 | + foreach ($can_be_damaged as $key => $unit_id) |
|
| 48 | 48 | { |
| 49 | 49 | //debug($structures[$unit_id][0]); |
| 50 | 50 | //debug($structures[$unit_id][$damageTo], $MIPDamage); |
| 51 | - if($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage) |
|
| 51 | + if ($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage) |
|
| 52 | 52 | { |
| 53 | 53 | unset($can_be_damaged[$key]); |
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | - if(empty($can_be_damaged)) |
|
| 56 | + if (empty($can_be_damaged)) |
|
| 57 | 57 | { |
| 58 | 58 | break; |
| 59 | 59 | } |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | //debug($destroyed, 'Actually destroyed'); |
| 73 | 73 | |
| 74 | 74 | //print('<hr>'); |
| 75 | - } while($MIPDamage > 0 && !empty($can_be_damaged)); |
|
| 75 | + } while ($MIPDamage > 0 && !empty($can_be_damaged)); |
|
| 76 | 76 | //debug($MIPDamage, 'MIPDamage left'); |
| 77 | 77 | } |
| 78 | 78 | //debug($structures);//die(); |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | $crystal += $destroyed * $unit_info[P_COST][RES_CRYSTAL] / 4; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - $return['structures'] = $structures; // Structures left after attack |
|
| 91 | - $return['metal'] = floor($metal); // Metal scraps |
|
| 90 | + $return['structures'] = $structures; // Structures left after attack |
|
| 91 | + $return['metal'] = floor($metal); // Metal scraps |
|
| 92 | 92 | $return['crystal'] = floor($crystal); // Crystal scraps |
| 93 | 93 | |
| 94 | 94 | return $return; |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | $iraks = doquery("SELECT * FROM {{iraks}} WHERE `fleet_end_time` <= " . SN_TIME_NOW . " FOR UPDATE;"); |
| 114 | 114 | |
| 115 | - while($fleetRow = db_fetch($iraks)) { |
|
| 115 | + while ($fleetRow = db_fetch($iraks)) { |
|
| 116 | 116 | set_time_limit(15); |
| 117 | 117 | $db_changeset = array(); |
| 118 | 118 | |
@@ -128,9 +128,9 @@ discard block |
||
| 128 | 128 | |
| 129 | 129 | $rowAttacker = db_user_by_id($fleetRow['fleet_owner'], true); |
| 130 | 130 | |
| 131 | - if($target_planet_row['id']) { |
|
| 131 | + if ($target_planet_row['id']) { |
|
| 132 | 132 | $planetDefense = array(); |
| 133 | - foreach(sn_get_groups('defense_active') as $unit_id) { |
|
| 133 | + foreach (sn_get_groups('defense_active') as $unit_id) { |
|
| 134 | 134 | $planetDefense[$unit_id] = array(mrc_get_level($targetUser, $target_planet_row, $unit_id, true, true)); |
| 135 | 135 | } |
| 136 | 136 | |
@@ -141,23 +141,23 @@ discard block |
||
| 141 | 141 | $message = $lang['mip_all_destroyed']; |
| 142 | 142 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit(UNIT_DEF_MISSILE_INTERCEPTOR, -$missiles, $targetUser, $target_planet_row['id']); |
| 143 | 143 | } else { |
| 144 | - if($interceptors) { |
|
| 144 | + if ($interceptors) { |
|
| 145 | 145 | $message = sprintf($lang['mip_destroyed'], $interceptors); |
| 146 | 146 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit(UNIT_DEF_MISSILE_INTERCEPTOR, -$interceptors, $targetUser, $target_planet_row['id']); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | $attackResult = COE_missileAttack($targetUser, $rowAttacker, $missiles - $interceptors, $planetDefense, $fleetRow['primaer']); |
| 150 | 150 | |
| 151 | - foreach($attackResult['structures'] as $key => $structure) { |
|
| 151 | + foreach ($attackResult['structures'] as $key => $structure) { |
|
| 152 | 152 | $destroyed = $planetDefense[$key][0] - $structure[0]; |
| 153 | - if($destroyed) { |
|
| 153 | + if ($destroyed) { |
|
| 154 | 154 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($key, -$destroyed, $targetUser, $target_planet_row['id']); |
| 155 | 155 | |
| 156 | 156 | $message .= " {$lang['tech'][$key]} - {$destroyed} {$lang['quantity']}<br>"; |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - if(!empty($message)) { |
|
| 160 | + if (!empty($message)) { |
|
| 161 | 161 | $message = $lang['mip_defense_destroyed'] . $message . "{$lang['mip_recycled']}{$lang['Metal']}: {$attackResult['metal']}, {$lang['Crystal']}: {$attackResult['crystal']}<br>"; |
| 162 | 162 | |
| 163 | 163 | DBStaticPlanet::db_planet_set_by_id($target_planet_row['id'], "`metal` = `metal` + {$attackResult['metal']}, `crystal` = `crystal` + {$attackResult['crystal']}"); |
@@ -174,8 +174,8 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | empty($message) ? $message = $lang['mip_no_defense'] : false; |
| 176 | 176 | |
| 177 | - msg_send_simple_message ( $fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message ); |
|
| 178 | - msg_send_simple_message ( $fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message ); |
|
| 177 | + msg_send_simple_message($fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message); |
|
| 178 | + msg_send_simple_message($fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message); |
|
| 179 | 179 | } |
| 180 | 180 | doquery("DELETE FROM {{iraks}} WHERE id = '{$fleetRow['id']}';"); |
| 181 | 181 | } |
@@ -458,8 +458,7 @@ |
||
| 458 | 458 | |
| 459 | 459 | if(is_numeric($planet['id'])) { |
| 460 | 460 | DBStaticPlanet::db_planet_set_by_id($planet['id'], "`que_processed` = UNIX_TIMESTAMP(NOW())"); |
| 461 | - } |
|
| 462 | - elseif(is_numeric($user['id'])) { |
|
| 461 | + } elseif(is_numeric($user['id'])) { |
|
| 463 | 462 | db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())'); |
| 464 | 463 | } |
| 465 | 464 | |
@@ -2,8 +2,8 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | function que_get_unit_que($unit_id) { |
| 4 | 4 | $que_type = false; |
| 5 | - foreach(sn_get_groups('ques') as $que_id => $que_data) { |
|
| 6 | - if(in_array($unit_id, $que_data['unit_list'])) { |
|
| 5 | + foreach (sn_get_groups('ques') as $que_id => $que_data) { |
|
| 6 | + if (in_array($unit_id, $que_data['unit_list'])) { |
|
| 7 | 7 | $que_type = $que_id; |
| 8 | 8 | break; |
| 9 | 9 | } |
@@ -16,14 +16,14 @@ discard block |
||
| 16 | 16 | function que_get_max_que_length($user, $planet, $que_id, $que_data = null) { |
| 17 | 17 | global $config; |
| 18 | 18 | |
| 19 | - if(empty($que_data)) { |
|
| 19 | + if (empty($que_data)) { |
|
| 20 | 20 | $que_data = sn_get_groups('ques'); |
| 21 | 21 | $que_data = $que_data[$que_id]; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | $que_length = 1; |
| 26 | - switch($que_id) { |
|
| 26 | + switch ($que_id) { |
|
| 27 | 27 | case QUE_RESEARCH: |
| 28 | 28 | $que_length = $config->server_que_length_research + mrc_get_level($user, '', UNIT_PREMIUM); // TODO - вынести в модуль |
| 29 | 29 | break; |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | function eco_que_str2arr($que_str) { |
| 39 | 39 | $que_arr = explode(';', $que_str); |
| 40 | - foreach($que_arr as $que_index => &$que_item) { |
|
| 41 | - if($que_item) { |
|
| 40 | + foreach ($que_arr as $que_index => &$que_item) { |
|
| 41 | + if ($que_item) { |
|
| 42 | 42 | $que_item = explode(',', $que_item); |
| 43 | 43 | } else { |
| 44 | 44 | unset($que_arr[$que_index]); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | function eco_que_arr2str($que_arr) { |
| 51 | - foreach($que_arr as &$que_item) { |
|
| 51 | + foreach ($que_arr as &$que_item) { |
|
| 52 | 52 | $que_item = implode(',', $que_item); |
| 53 | 53 | } |
| 54 | 54 | return implode(';', $que_arr); |
@@ -59,14 +59,14 @@ discard block |
||
| 59 | 59 | global $lang, $config; |
| 60 | 60 | |
| 61 | 61 | $is_autoconvert = false; |
| 62 | - if($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) { |
|
| 62 | + if ($build_mode == BUILD_AUTOCONVERT || sys_get_param_int('auto_convert')) { |
|
| 63 | 63 | $build_mode = BUILD_CREATE; |
| 64 | 64 | $is_autoconvert = true; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $unit_amount_qued = 0; |
| 68 | 68 | try { |
| 69 | - if(!$user['id']) { |
|
| 69 | + if (!$user['id']) { |
|
| 70 | 70 | throw new exception('{Нет идентификатора пользователя - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
| 71 | 71 | } |
| 72 | 72 | |
@@ -77,16 +77,16 @@ discard block |
||
| 77 | 77 | foreach($unit_list as $unit_id => $unit_amount) if($unit_amount) break; |
| 78 | 78 | } |
| 79 | 79 | */ |
| 80 | - if(!$unit_id) { |
|
| 80 | + if (!$unit_id) { |
|
| 81 | 81 | throw new exception('{Нет идентификатора юнита - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | $que_id = que_get_unit_que($unit_id); |
| 85 | - if(!$que_id) { |
|
| 85 | + if (!$que_id) { |
|
| 86 | 86 | throw new exception('{Неправильный тип очереди - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - if($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { |
|
| 89 | + if ($build_mode == BUILD_DESTROY && $que_id != QUE_STRUCTURES) { |
|
| 90 | 90 | throw new exception('{Уничтожать можно только здания на планете}', ERR_ERROR); // TODO EXCEPTION |
| 91 | 91 | } |
| 92 | 92 | |
@@ -94,11 +94,11 @@ discard block |
||
| 94 | 94 | $que_data = $que_data[$que_id]; |
| 95 | 95 | |
| 96 | 96 | // TODO Переделать под подочереди |
| 97 | - if($que_id == QUE_STRUCTURES) { |
|
| 97 | + if ($que_id == QUE_STRUCTURES) { |
|
| 98 | 98 | $sn_groups_build_allow = sn_get_groups('build_allow'); |
| 99 | 99 | $que_data['unit_list'] = $sn_groups_build_allow[$planet['planet_type']]; |
| 100 | 100 | |
| 101 | - if(!isset($que_data['unit_list'][$unit_id])) { |
|
| 101 | + if (!isset($que_data['unit_list'][$unit_id])) { |
|
| 102 | 102 | throw new exception('{Это здание нельзя строить на ' . ($planet['planet_type'] == PT_PLANET ? 'планете' : 'луне'), ERR_ERROR); // TODO EXCEPTION |
| 103 | 103 | } |
| 104 | 104 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | // Это нужно, что бы заблокировать пользователя и работу с очередями |
| 120 | 120 | $user = db_user_by_id($user['id']); |
| 121 | 121 | // Это нужно, что бы заблокировать планету от списания ресурсов |
| 122 | - if(isset($planet['id']) && $planet['id']) { |
|
| 122 | + if (isset($planet['id']) && $planet['id']) { |
|
| 123 | 123 | $planet = DBStaticPlanet::db_planet_by_id($planet['id'], true); |
| 124 | 124 | } else { |
| 125 | 125 | $planet['id'] = 0; |
@@ -131,17 +131,17 @@ discard block |
||
| 131 | 131 | $in_que = &$que['in_que'][$que_id][$user['id']][$planet_id]; |
| 132 | 132 | $que_max_length = que_get_max_que_length($user, $planet, $que_id, $que_data); |
| 133 | 133 | // TODO Добавить вызовы функций проверок текущей и максимальной длин очередей |
| 134 | - if(count($in_que) >= $que_max_length) { |
|
| 134 | + if (count($in_que) >= $que_max_length) { |
|
| 135 | 135 | throw new exception('{Все слоты очереди заняты}', ERR_ERROR); // TODO EXCEPTION |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // TODO Отдельно посмотреть на уничтожение зданий - что бы можно было уничтожать их без планов |
| 139 | - switch(eco_can_build_unit($user, $planet, $unit_id)) { |
|
| 139 | + switch (eco_can_build_unit($user, $planet, $unit_id)) { |
|
| 140 | 140 | case BUILD_ALLOWED: break; |
| 141 | 141 | case BUILD_UNIT_BUSY: throw new exception('{Строение занято}', ERR_ERROR); break; // TODO EXCEPTION eco_bld_msg_err_laboratory_upgrading |
| 142 | 142 | // case BUILD_REQUIRE_NOT_MEET: |
| 143 | 143 | default: |
| 144 | - if($build_mode == BUILD_CREATE) { |
|
| 144 | + if ($build_mode == BUILD_CREATE) { |
|
| 145 | 145 | throw new exception('{Требования не удовлетворены}', ERR_ERROR); |
| 146 | 146 | } |
| 147 | 147 | break; // TODO EXCEPTION eco_bld_msg_err_requirements_not_meet |
@@ -151,14 +151,14 @@ discard block |
||
| 151 | 151 | $unit_amount_qued = $unit_amount; |
| 152 | 152 | $units_qued = isset($in_que[$unit_id]) ? $in_que[$unit_id] : 0; |
| 153 | 153 | $unit_level = mrc_get_level($user, $planet, $unit_id, true, true) + $units_qued; |
| 154 | - if($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { |
|
| 155 | - if($unit_level >= $unit_max) { |
|
| 154 | + if ($unit_max = get_unit_param($unit_id, P_MAX_STACK)) { |
|
| 155 | + if ($unit_level >= $unit_max) { |
|
| 156 | 156 | throw new exception('{Максимальное количество юнитов данного типа уже достигнуто или будет достигнуто по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION |
| 157 | 157 | } |
| 158 | 158 | $unit_amount = max(0, min($unit_amount, $unit_max - $unit_level)); |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - if($unit_amount < 1) { |
|
| 161 | + if ($unit_amount < 1) { |
|
| 162 | 162 | throw new exception('{Неправильное количество юнитов - сообщите Администрации}', ERR_ERROR); // TODO EXCEPTION |
| 163 | 163 | } |
| 164 | 164 | |
@@ -174,21 +174,21 @@ discard block |
||
| 174 | 174 | // { |
| 175 | 175 | // die('Unit busy'); // TODO EXCEPTION |
| 176 | 176 | // } |
| 177 | - if(get_unit_param($unit_id, P_STACKABLE)) { |
|
| 177 | + if (get_unit_param($unit_id, P_STACKABLE)) { |
|
| 178 | 178 | // TODO Поле 'max_Lot_size' для ограничения размера стэка в очереди - то ли в юниты, то ли в очередь |
| 179 | - if(in_array($unit_id, $group_missile = sn_get_groups('missile'))) { |
|
| 179 | + if (in_array($unit_id, $group_missile = sn_get_groups('missile'))) { |
|
| 180 | 180 | // TODO Поле 'container' - указывает на родительску структуру, в которой хранится данный юнит и по вместительности которой нужно применять размер юнита |
| 181 | 181 | $used_silo = 0; |
| 182 | - foreach($group_missile as $missile_id) { |
|
| 182 | + foreach ($group_missile as $missile_id) { |
|
| 183 | 183 | $missile_qued = isset($in_que[$missile_id]) ? $in_que[$missile_id] : 0; |
| 184 | 184 | $used_silo += (mrc_get_level($user, $planet, $missile_id, true, true) + $missile_qued) * get_unit_param($missile_id, P_UNIT_SIZE); |
| 185 | 185 | } |
| 186 | 186 | $free_silo = mrc_get_level($user, $planet, STRUC_SILO) * get_unit_param(STRUC_SILO, P_CAPACITY) - $used_silo; |
| 187 | - if($free_silo <= 0) { |
|
| 187 | + if ($free_silo <= 0) { |
|
| 188 | 188 | throw new exception('{Ракетная шахта уже заполнена или будет заполнена по окончанию очереди}', ERR_ERROR); // TODO EXCEPTION |
| 189 | 189 | } |
| 190 | 190 | $unit_size = get_unit_param($unit_id, P_UNIT_SIZE); |
| 191 | - if($free_silo < $unit_size) { |
|
| 191 | + if ($free_silo < $unit_size) { |
|
| 192 | 192 | throw new exception("{В ракетной шахте нет места для {$lang['tech'][$unit_id]}}", ERR_ERROR); // TODO EXCEPTION |
| 193 | 193 | } |
| 194 | 194 | $unit_amount = max(0, min($unit_amount, floor($free_silo / $unit_size))); |
@@ -196,10 +196,10 @@ discard block |
||
| 196 | 196 | $unit_level = $new_unit_level = 0; |
| 197 | 197 | } else { |
| 198 | 198 | $unit_amount = 1; |
| 199 | - if($que_id == QUE_STRUCTURES) { |
|
| 199 | + if ($que_id == QUE_STRUCTURES) { |
|
| 200 | 200 | // if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $que['sectors'][$planet['id']] <= 0) |
| 201 | 201 | $sectors_qued = is_array($in_que) ? array_sum($in_que) : 0; |
| 202 | - if($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) |
|
| 202 | + if ($build_mode == BUILD_CREATE && eco_planet_fields_max($planet) - $planet['field_current'] - $sectors_qued <= 0) |
|
| 203 | 203 | { |
| 204 | 204 | throw new exception('{Не хватает секторов на планете}', ERR_ERROR); // TODO EXCEPTION |
| 205 | 205 | } |
@@ -217,9 +217,9 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | $exchange = array(); |
| 219 | 219 | $market_get_autoconvert_cost = market_get_autoconvert_cost(); |
| 220 | - if($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) { |
|
| 220 | + if ($is_autoconvert && $build_data[BUILD_AUTOCONVERT]) { |
|
| 221 | 221 | $dark_matter = mrc_get_level($user, null, RES_DARK_MATTER); |
| 222 | - if(mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) { |
|
| 222 | + if (mrc_get_level($user, null, RES_DARK_MATTER) < $market_get_autoconvert_cost) { |
|
| 223 | 223 | throw new exception("{Нет хватает " . ($market_get_autoconvert_cost - $dark_matter) . "ТМ на постройки с автоконвертацией ресурсов}", ERR_ERROR); // TODO EXCEPTION |
| 224 | 224 | } |
| 225 | 225 | |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | $resource_exchange_rates = array(); |
| 230 | 230 | $resource_diff = array(); |
| 231 | 231 | $all_positive = true; |
| 232 | - foreach($resources_loot as $resource_id) { |
|
| 232 | + foreach ($resources_loot as $resource_id) { |
|
| 233 | 233 | $resource_db_name = pname_resource_name($resource_id); |
| 234 | 234 | $resource_got[$resource_id] = floor(mrc_get_level($user, $planet, $resource_id)); |
| 235 | 235 | $resource_exchange_rates[$resource_id] = $config->__get("rpg_exchange_{$resource_db_name}"); |
@@ -237,15 +237,15 @@ discard block |
||
| 237 | 237 | $all_positive = $all_positive && ($resource_diff[$resource_id] > 0); |
| 238 | 238 | } |
| 239 | 239 | // Нужна автоконвертация |
| 240 | - if($all_positive) { |
|
| 240 | + if ($all_positive) { |
|
| 241 | 241 | $is_autoconvert = false; |
| 242 | 242 | } else { |
| 243 | - foreach($resource_diff as $resource_diff_id => &$resource_diff_amount) { |
|
| 244 | - if($resource_diff_amount >= 0) { |
|
| 243 | + foreach ($resource_diff as $resource_diff_id => &$resource_diff_amount) { |
|
| 244 | + if ($resource_diff_amount >= 0) { |
|
| 245 | 245 | continue; |
| 246 | 246 | } |
| 247 | - foreach($resource_diff as $resource_got_id => &$resource_got_amount) { |
|
| 248 | - if($resource_got_amount <= 0) { |
|
| 247 | + foreach ($resource_diff as $resource_got_id => &$resource_got_amount) { |
|
| 248 | + if ($resource_got_amount <= 0) { |
|
| 249 | 249 | continue; |
| 250 | 250 | } |
| 251 | 251 | $current_exchange = $resource_exchange_rates[$resource_got_id] / $resource_exchange_rates[$resource_diff_id]; |
@@ -261,14 +261,14 @@ discard block |
||
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | $is_autoconvert_ok = true; |
| 264 | - foreach($resource_diff as $resource_diff_amount2) { |
|
| 265 | - if($resource_diff_amount2 < 0) { |
|
| 264 | + foreach ($resource_diff as $resource_diff_amount2) { |
|
| 265 | + if ($resource_diff_amount2 < 0) { |
|
| 266 | 266 | $is_autoconvert_ok = false; |
| 267 | 267 | break; |
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - if($is_autoconvert_ok) { |
|
| 271 | + if ($is_autoconvert_ok) { |
|
| 272 | 272 | $build_data['RESULT'][$build_mode] = BUILD_ALLOWED; |
| 273 | 273 | $build_data['CAN'][$build_mode] = $unit_amount; |
| 274 | 274 | } else { |
@@ -277,19 +277,19 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | $unit_amount = min($build_data['CAN'][$build_mode], $unit_amount); |
| 280 | - if($unit_amount <= 0) { |
|
| 280 | + if ($unit_amount <= 0) { |
|
| 281 | 281 | throw new exception('{Не хватает ресурсов}', ERR_ERROR); // TODO EXCEPTION |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | - if($new_unit_level < 0) { |
|
| 284 | + if ($new_unit_level < 0) { |
|
| 285 | 285 | throw new exception('{Нельзя уничтожить больше юнитов, чем есть}', ERR_ERROR); // TODO EXCEPTION |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - if($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { |
|
| 288 | + if ($build_data['RESULT'][$build_mode] != BUILD_ALLOWED) { |
|
| 289 | 289 | throw new exception('{Строительство блокировано}', ERR_ERROR); // TODO EXCEPTION |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - if($is_autoconvert) { |
|
| 292 | + if ($is_autoconvert) { |
|
| 293 | 293 | ksort($exchange); |
| 294 | 294 | ksort($resource_got); |
| 295 | 295 | db_change_units($user, $planet, array( |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | $unit_amount_qued = 0; |
| 307 | - while($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) { |
|
| 307 | + while ($unit_amount > 0 && count($que['ques'][$que_id][$user['id']][$planet_id]) < $que_max_length) { |
|
| 308 | 308 | $place = min($unit_amount, MAX_FLEET_OR_DEFS_PER_ROW); |
| 309 | 309 | que_add_unit($unit_id, $user, $planet, $build_data, $new_unit_level, $place, $build_mode); |
| 310 | 310 | $unit_amount -= $place; |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | |
| 315 | 315 | sn_db_transaction_commit(); |
| 316 | 316 | |
| 317 | - if($redirect) { |
|
| 317 | + if ($redirect) { |
|
| 318 | 318 | sys_redirect("{$_SERVER['PHP_SELF']}?mode=" . sys_get_param_str('mode') . "&ally_id=" . sys_get_param_id('ally_id')); |
| 319 | 319 | } |
| 320 | 320 | |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | 'STATUS' => ERR_NONE, |
| 323 | 323 | 'MESSAGE' => '{Строительство начато}', |
| 324 | 324 | ); |
| 325 | - } catch(exception $e) { |
|
| 325 | + } catch (exception $e) { |
|
| 326 | 326 | sn_db_transaction_rollback(); |
| 327 | 327 | $operation_result = array( |
| 328 | 328 | 'STATUS' => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR, |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | ); |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | - if(!empty($operation_result['MESSAGE'])) { |
|
| 333 | + if (!empty($operation_result['MESSAGE'])) { |
|
| 334 | 334 | $operation_result['MESSAGE'] .= ' ' . ($unit_amount_qued ? $unit_amount_qued : $unit_amount) . 'x[' . $lang['tech'][$unit_id] . ']'; |
| 335 | 335 | } |
| 336 | 336 | |
@@ -344,11 +344,11 @@ discard block |
||
| 344 | 344 | function que_recalculate($old_que) { |
| 345 | 345 | $new_que = array(); |
| 346 | 346 | |
| 347 | - if(!is_array($old_que['items'])) { |
|
| 347 | + if (!is_array($old_que['items'])) { |
|
| 348 | 348 | return $new_que; |
| 349 | 349 | } |
| 350 | - foreach($old_que['items'] as $row) { |
|
| 351 | - if(!isset($row) || !$row || $row['que_unit_amount'] <= 0) { |
|
| 350 | + foreach ($old_que['items'] as $row) { |
|
| 351 | + if (!isset($row) || !$row || $row['que_unit_amount'] <= 0) { |
|
| 352 | 352 | continue; |
| 353 | 353 | } |
| 354 | 354 | |
@@ -359,9 +359,9 @@ discard block |
||
| 359 | 359 | |
| 360 | 360 | $last_id = count($new_que['items']) - 1; |
| 361 | 361 | |
| 362 | - if($row['que_planet_id']) { |
|
| 362 | + if ($row['que_planet_id']) { |
|
| 363 | 363 | $new_que['planets'][$row['que_planet_id']][$row['que_type']][] = &$new_que['items'][$last_id]; |
| 364 | - } elseif($row['que_type'] == QUE_RESEARCH) { |
|
| 364 | + } elseif ($row['que_type'] == QUE_RESEARCH) { |
|
| 365 | 365 | $new_que['players'][$row['que_player_id']][$row['que_type']][] = &$new_que['items'][$last_id]; |
| 366 | 366 | } |
| 367 | 367 | $new_que['ques'][$row['que_type']][$row['que_player_id']][intval($row['que_planet_id'])][] = &$new_que['items'][$last_id]; |
@@ -396,9 +396,9 @@ discard block |
||
| 396 | 396 | $que_type = que_get_unit_que($unit_id); |
| 397 | 397 | $planet_id_origin = $planet['id'] ? $planet['id'] : 'NULL'; |
| 398 | 398 | $planet_id = $que_type == QUE_RESEARCH ? 'NULL' : $planet_id_origin; |
| 399 | - if(is_numeric($planet_id)) { |
|
| 399 | + if (is_numeric($planet_id)) { |
|
| 400 | 400 | DBStaticPlanet::db_planet_set_by_id($planet_id, "`que_processed` = UNIX_TIMESTAMP(NOW())"); |
| 401 | - } elseif(is_numeric($user['id'])) { |
|
| 401 | + } elseif (is_numeric($user['id'])) { |
|
| 402 | 402 | db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())'); |
| 403 | 403 | } |
| 404 | 404 | |
@@ -428,17 +428,17 @@ discard block |
||
| 428 | 428 | $planet['id'] = $planet['id'] && $que_type !== QUE_RESEARCH ? $planet['id'] : 0; |
| 429 | 429 | $global_que = que_get($user['id'], $planet['id'], $que_type, true); |
| 430 | 430 | |
| 431 | - if(!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) { |
|
| 431 | + if (!empty($global_que['ques'][$que_type][$user['id']][$planet['id']])) { |
|
| 432 | 432 | $que = array_reverse($global_que['ques'][$que_type][$user['id']][$planet['id']]); |
| 433 | 433 | |
| 434 | - foreach($que as $que_item) { |
|
| 434 | + foreach ($que as $que_item) { |
|
| 435 | 435 | DBStaticQue::db_que_delete_by_id($que_item['que_id']); |
| 436 | 436 | |
| 437 | - if($que_item['que_planet_id_origin']) { |
|
| 437 | + if ($que_item['que_planet_id_origin']) { |
|
| 438 | 438 | $planet['id'] = $que_item['que_planet_id_origin']; |
| 439 | 439 | } |
| 440 | 440 | |
| 441 | - if(!isset($planets_locked[$planet['id']])) { |
|
| 441 | + if (!isset($planets_locked[$planet['id']])) { |
|
| 442 | 442 | $planets_locked[$planet['id']] = $planet['id'] ? DBStaticPlanet::db_planet_by_id($planet['id'], true) : $planet; |
| 443 | 443 | } |
| 444 | 444 | |
@@ -450,15 +450,15 @@ discard block |
||
| 450 | 450 | RES_DEUTERIUM => $build_data[RES_DEUTERIUM] * $que_item['que_unit_amount'], |
| 451 | 451 | )); |
| 452 | 452 | |
| 453 | - if(!$clear) { |
|
| 453 | + if (!$clear) { |
|
| 454 | 454 | break; |
| 455 | 455 | } |
| 456 | 456 | } |
| 457 | 457 | |
| 458 | - if(is_numeric($planet['id'])) { |
|
| 458 | + if (is_numeric($planet['id'])) { |
|
| 459 | 459 | DBStaticPlanet::db_planet_set_by_id($planet['id'], "`que_processed` = UNIX_TIMESTAMP(NOW())"); |
| 460 | 460 | } |
| 461 | - elseif(is_numeric($user['id'])) { |
|
| 461 | + elseif (is_numeric($user['id'])) { |
|
| 462 | 462 | db_user_set_by_id($user['id'], '`que_processed` = UNIX_TIMESTAMP(NOW())'); |
| 463 | 463 | } |
| 464 | 464 | |
@@ -503,21 +503,21 @@ discard block |
||
| 503 | 503 | // TODO: Переделать для $que_type === false |
| 504 | 504 | $planet['id'] = $planet['id'] ? $planet['id'] : 0; |
| 505 | 505 | |
| 506 | - if(!is_array($que)) { |
|
| 506 | + if (!is_array($que)) { |
|
| 507 | 507 | $que = que_get($user['id'], $planet['id'], $que_type); |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - if(is_array($que) && isset($que['items'])) { |
|
| 510 | + if (is_array($que) && isset($que['items'])) { |
|
| 511 | 511 | $que = $que['ques'][$que_type][$user['id']][$planet['id']]; |
| 512 | 512 | } |
| 513 | 513 | |
| 514 | - if($que) { |
|
| 515 | - foreach($que as $que_element) { |
|
| 514 | + if ($que) { |
|
| 515 | + foreach ($que as $que_element) { |
|
| 516 | 516 | $template->assign_block_vars('que', que_tpl_parse_element($que_element, $short_names)); |
| 517 | 517 | } |
| 518 | 518 | } |
| 519 | 519 | |
| 520 | - if($que_type == QUE_RESEARCH) { |
|
| 520 | + if ($que_type == QUE_RESEARCH) { |
|
| 521 | 521 | // TODO Исправить |
| 522 | 522 | // $template->assign_var('RESEARCH_ONGOING', count($global_que[QUE_RESEARCH][0]) >= $config->server_que_length_research); |
| 523 | 523 | } |
@@ -545,7 +545,7 @@ discard block |
||
| 545 | 545 | $user = db_user_by_id($user['id'], true); |
| 546 | 546 | |
| 547 | 547 | $time_left[$user['id']][0] = max(0, $on_time - $user['que_processed']); |
| 548 | - if($planet === null && !$time_left[$user['id']][0]) { |
|
| 548 | + if ($planet === null && !$time_left[$user['id']][0]) { |
|
| 549 | 549 | // TODO |
| 550 | 550 | return $que; |
| 551 | 551 | } |
@@ -554,12 +554,12 @@ discard block |
||
| 554 | 554 | $que_type_id = $planet === null ? QUE_RESEARCH : false; |
| 555 | 555 | $planet = intval(is_array($planet) ? $planet['id'] : $planet); // В $planet у нас теперь только её ID или шаблон null/0/false |
| 556 | 556 | $que = que_get($user['id'], $planet, $que_type_id, true); |
| 557 | - if(empty($que['items'])) { |
|
| 557 | + if (empty($que['items'])) { |
|
| 558 | 558 | return $que; |
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | $planet_list = array(); |
| 562 | - if($planet !== null) { |
|
| 562 | + if ($planet !== null) { |
|
| 563 | 563 | // Если нужно изменять данные на планетах - блокируем планеты и получаем данные о них |
| 564 | 564 | // TODO - от них не надо ничего, кроме ID и que_processed |
| 565 | 565 | $planet_row = DBStaticPlanet::db_planet_list_by_user_or_planet($user['id'], $planet); |
@@ -568,21 +568,21 @@ discard block |
||
| 568 | 568 | } |
| 569 | 569 | |
| 570 | 570 | // Теперь в $time_left лежит время обсчета всех очередей по каждой из планеты |
| 571 | - if(array_sum($time_left[$user['id']]) == 0) { |
|
| 571 | + if (array_sum($time_left[$user['id']]) == 0) { |
|
| 572 | 572 | return $que; |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | $db_changeset = array(); |
| 576 | 576 | $unit_changes = array(); |
| 577 | - foreach($que['items'] as &$que_item) { |
|
| 577 | + foreach ($que['items'] as &$que_item) { |
|
| 578 | 578 | $que_player_id = &$que_item['que_player_id']; |
| 579 | 579 | $que_planet_id = intval($que_item['que_planet_id']); |
| 580 | 580 | |
| 581 | 581 | $que_time_left = &$que['time_left'][$que_player_id][$que_planet_id][$que_item['que_type']]; |
| 582 | - if(!isset($que_time_left)) { |
|
| 582 | + if (!isset($que_time_left)) { |
|
| 583 | 583 | $que_time_left = $time_left[$que_player_id][$que_planet_id]; |
| 584 | 584 | } |
| 585 | - if($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
| 585 | + if ($que_time_left <= 0 || $que_item['que_unit_amount'] <= 0) { |
|
| 586 | 586 | continue; |
| 587 | 587 | } |
| 588 | 588 | // Дальше мы идем, если только осталось время в очереди И юниты к постройке |
@@ -595,7 +595,7 @@ discard block |
||
| 595 | 595 | // Теперь работаем с остатком времени на юните. Оно не может быть равно или меньше нуля |
| 596 | 596 | |
| 597 | 597 | // Если времени в очереди осталось не меньше, чем время текущего юнита - значит мы достроили юнит |
| 598 | - if($que_time_left >= $que_item['que_time_left']) { |
|
| 598 | + if ($que_time_left >= $que_item['que_time_left']) { |
|
| 599 | 599 | // Увеличиваем количество отстроенных юнитов |
| 600 | 600 | $unit_processed++; |
| 601 | 601 | // Вычитаем из времени очереди потраченное на постройку время |
@@ -608,12 +608,12 @@ discard block |
||
| 608 | 608 | $que_item['que_unit_amount'] -= $unit_processed; |
| 609 | 609 | |
| 610 | 610 | // Если еще остались юниты - значит ВСЁ оставшееся время приходится на достройку следующего юнита |
| 611 | - if($que_item['que_unit_amount'] > 0) { |
|
| 611 | + if ($que_item['que_unit_amount'] > 0) { |
|
| 612 | 612 | $que_item['que_time_left'] = $que_item['que_time_left'] - $que_time_left; |
| 613 | 613 | $que_time_left = 0; |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | - if($que_item['que_unit_amount'] <= 0) { |
|
| 616 | + if ($que_item['que_unit_amount'] <= 0) { |
|
| 617 | 617 | $db_changeset['que'][] = array( |
| 618 | 618 | 'action' => SQL_OP_DELETE, |
| 619 | 619 | P_VERSION => 1, |
@@ -639,14 +639,14 @@ discard block |
||
| 639 | 639 | ); |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - if($unit_processed) { |
|
| 642 | + if ($unit_processed) { |
|
| 643 | 643 | $unit_processed_delta = $unit_processed * ($que_item['que_unit_mode'] == BUILD_CREATE ? 1 : -1); |
| 644 | 644 | $unit_changes[$que_player_id][$que_planet_id][$que_item['que_unit_id']] += $unit_processed_delta; |
| 645 | 645 | } |
| 646 | 646 | } |
| 647 | 647 | |
| 648 | - foreach($time_left as $player_id => $planet_data) { |
|
| 649 | - foreach($planet_data as $planet_id => $time_on_planet) { |
|
| 648 | + foreach ($time_left as $player_id => $planet_data) { |
|
| 649 | + foreach ($planet_data as $planet_id => $time_on_planet) { |
|
| 650 | 650 | $table = $planet_id ? 'planets' : 'users'; |
| 651 | 651 | $id = $planet_id ? $planet_id : $player_id; |
| 652 | 652 | $db_changeset[$table][] = array( |
@@ -662,8 +662,8 @@ discard block |
||
| 662 | 662 | ), |
| 663 | 663 | ); |
| 664 | 664 | |
| 665 | - if(is_array($unit_changes[$player_id][$planet_id])) { |
|
| 666 | - foreach($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
| 665 | + if (is_array($unit_changes[$player_id][$planet_id])) { |
|
| 666 | + foreach ($unit_changes[$player_id][$planet_id] as $unit_id => $unit_amount) { |
|
| 667 | 667 | $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($unit_id, $unit_amount, $user, $planet_id ? $planet_id : null); |
| 668 | 668 | } |
| 669 | 669 | } |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | $que = que_recalculate($que); |
| 674 | 674 | |
| 675 | 675 | // TODO: Re-enable quests for Alliances |
| 676 | - if(!empty($unit_changes) && !$user['user_as_ally']) { |
|
| 676 | + if (!empty($unit_changes) && !$user['user_as_ally']) { |
|
| 677 | 677 | $quest_list = qst_get_quests($user['id'], QUEST_STATUS_ALL); |
| 678 | 678 | $quest_triggers = qst_active_triggers($quest_list); |
| 679 | 679 | $quest_rewards = array(); |
@@ -681,26 +681,26 @@ discard block |
||
| 681 | 681 | |
| 682 | 682 | |
| 683 | 683 | $xp_incoming = array(); |
| 684 | - foreach($unit_changes as $user_id => $planet_changes) { |
|
| 685 | - foreach($planet_changes as $planet_id => $changes) { |
|
| 684 | + foreach ($unit_changes as $user_id => $planet_changes) { |
|
| 685 | + foreach ($planet_changes as $planet_id => $changes) { |
|
| 686 | 686 | $planet_this = $planet_id ? classSupernova::db_get_record_by_id(LOC_PLANET, $planet_id) : array(); |
| 687 | - foreach($changes as $unit_id => $unit_value) { |
|
| 687 | + foreach ($changes as $unit_id => $unit_value) { |
|
| 688 | 688 | $que_id = que_get_unit_que($unit_id); |
| 689 | 689 | $unit_level_new = mrc_get_level($user, $planet_this, $unit_id, false, true) + $unit_value; |
| 690 | - if($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
| 690 | + if ($que_id == QUE_STRUCTURES || $que_id == QUE_RESEARCH) { |
|
| 691 | 691 | $build_data = eco_get_build_data($user, $planet_this, $unit_id, $unit_level_new - 1); |
| 692 | 692 | $build_data = $build_data[BUILD_CREATE]; |
| 693 | - foreach(sn_get_groups('resources_loot') as $resource_id) { |
|
| 693 | + foreach (sn_get_groups('resources_loot') as $resource_id) { |
|
| 694 | 694 | $xp_incoming[$que_id] += $build_data[$resource_id]; // TODO - добавить конверсию рейтов обмена |
| 695 | 695 | } |
| 696 | 696 | } |
| 697 | 697 | |
| 698 | - if(is_array($quest_triggers)) { |
|
| 698 | + if (is_array($quest_triggers)) { |
|
| 699 | 699 | // TODO: Check mutiply condition quests |
| 700 | 700 | $quest_trigger_list = array_keys($quest_triggers, $unit_id); |
| 701 | 701 | |
| 702 | - if(is_array($quest_trigger_list)) { |
|
| 703 | - foreach($quest_trigger_list as $quest_id) { |
|
| 702 | + if (is_array($quest_trigger_list)) { |
|
| 703 | + foreach ($quest_trigger_list as $quest_id) { |
|
| 704 | 704 | if ($quest_list[$quest_id]['quest_status_status'] != QUEST_STATUS_COMPLETE) { |
| 705 | 705 | if ($quest_list[$quest_id]['quest_unit_amount'] <= $unit_level_new) { |
| 706 | 706 | $quest_rewards[$quest_id][$user_id][$planet_id] = $quest_list[$quest_id]['quest_rewards_list']; |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | // TODO: Изменить начисление награды за квесты на ту планету, на которой происходил ресеч |
| 719 | 719 | qst_reward($user, $quest_rewards, $quest_list, $quest_statuses); |
| 720 | 720 | |
| 721 | - foreach($xp_incoming as $que_id => $xp) { |
|
| 721 | + foreach ($xp_incoming as $que_id => $xp) { |
|
| 722 | 722 | rpg_level_up($user, $que_id == QUE_RESEARCH ? RPG_TECH : RPG_STRUCTURE, $xp / 1000); |
| 723 | 723 | } |
| 724 | 724 | } |
@@ -1,7 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -function sys_maintenance() |
|
| 4 | -{ |
|
| 3 | +function sys_maintenance() { |
|
| 5 | 4 | global $config; |
| 6 | 5 | |
| 7 | 6 | $bashing_time_limit = SN_TIME_NOW - $config->fleet_bashing_scope; |
@@ -42,8 +41,7 @@ discard block |
||
| 42 | 41 | * TODO: 2. [<m|w|d|h|m|s>@]<time> |
| 43 | 42 | */ |
| 44 | 43 | |
| 45 | -function sys_schedule_get_prev_run($scheduleList, $recorded_run = SN_TIME_NOW, $return_next_run = false) |
|
| 46 | -{ |
|
| 44 | +function sys_schedule_get_prev_run($scheduleList, $recorded_run = SN_TIME_NOW, $return_next_run = false) { |
|
| 47 | 45 | static $date_part_names_reverse = array('seconds', 'minutes', 'hours', 'days', 'months', 'years',); |
| 48 | 46 | |
| 49 | 47 | $possible_schedules = array(); |
@@ -17,11 +17,11 @@ discard block |
||
| 17 | 17 | array('query' => "DELETE FROM `{{planets}}` WHERE `id_owner` = 0 AND `destruyed` < UNIX_TIMESTAMP();", 'result' => false, 'error' => '', 'affected_rows' => 0), |
| 18 | 18 | ); |
| 19 | 19 | |
| 20 | - foreach($queries as &$query) |
|
| 20 | + foreach ($queries as &$query) |
|
| 21 | 21 | { |
| 22 | 22 | $query['result'] = doquery($query['query']); |
| 23 | 23 | $query['error'] = classSupernova::$db->db_error(); |
| 24 | - $query['affected_rows'] = classSupernova::$db->db_affected_rows(); |
|
| 24 | + $query['affected_rows'] = classSupernova::$db->db_affected_rows(); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | return $queries; |
@@ -53,30 +53,30 @@ discard block |
||
| 53 | 53 | $recorded_run = strtotime($recorded_run); |
| 54 | 54 | |
| 55 | 55 | $prev_run_array = getdate($recorded_run); |
| 56 | - $prev_run_array = array($prev_run_array['seconds'],$prev_run_array['minutes'],$prev_run_array['hours'],$prev_run_array['mday'],$prev_run_array['mon'],$prev_run_array['year']); |
|
| 56 | + $prev_run_array = array($prev_run_array['seconds'], $prev_run_array['minutes'], $prev_run_array['hours'], $prev_run_array['mday'], $prev_run_array['mon'], $prev_run_array['year']); |
|
| 57 | 57 | $today_array = getdate(SN_TIME_NOW); |
| 58 | - $today_array = array($today_array['seconds'],$today_array['minutes'],$today_array['hours'],$today_array['mday'],$today_array['mon'],$today_array['year']); |
|
| 58 | + $today_array = array($today_array['seconds'], $today_array['minutes'], $today_array['hours'], $today_array['mday'], $today_array['mon'], $today_array['year']); |
|
| 59 | 59 | $scheduleList = explode(',', $scheduleList); |
| 60 | 60 | array_walk($scheduleList, function(&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) { |
| 61 | 61 | $schedule = array('schedule_array' => array_reverse(explode(':', trim($schedule)))); |
| 62 | 62 | |
| 63 | 63 | $interval = $date_part_names_reverse[count($schedule['schedule_array'])]; |
| 64 | 64 | |
| 65 | - foreach($prev_run_array as $index => $date_part) { |
|
| 65 | + foreach ($prev_run_array as $index => $date_part) { |
|
| 66 | 66 | $schedule['array']['recorded'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $date_part; |
| 67 | 67 | $schedule['array']['now'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $today_array[$index]; |
| 68 | 68 | } |
| 69 | - if($schedule['array']['recorded'] == $schedule['array']['now']) { |
|
| 69 | + if ($schedule['array']['recorded'] == $schedule['array']['now']) { |
|
| 70 | 70 | unset($schedule['array']['now']); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - foreach($schedule['array'] as $name => $array) { |
|
| 73 | + foreach ($schedule['array'] as $name => $array) { |
|
| 74 | 74 | $schedule['string'][$name] = "{$array[5]}-{$array[4]}-{$array[3]} {$array[2]}:{$array[1]}:{$array[0]}"; |
| 75 | 75 | $schedule['string'][$name . '_next'] = $schedule['string'][$name] . ' +1 ' . $interval; |
| 76 | 76 | $schedule['string'][$name . '_prev'] = $schedule['string'][$name] . ' -1 ' . $interval; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - foreach($schedule['string'] as $string) { |
|
| 79 | + foreach ($schedule['string'] as $string) { |
|
| 80 | 80 | $timestamp = strtotime($string); |
| 81 | 81 | $schedule['timestamp'][$timestamp] = $possible_schedules[$timestamp] = date(FMT_DATE_TIME_SQL, strtotime($string)); |
| 82 | 82 | } |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | |
| 87 | 87 | $prev_run = 0; |
| 88 | 88 | $next_run = 0; |
| 89 | - foreach($possible_schedules as $timestamp => $string_date) { |
|
| 89 | + foreach ($possible_schedules as $timestamp => $string_date) { |
|
| 90 | 90 | $prev_run = SN_TIME_NOW >= $timestamp ? $timestamp : $prev_run; |
| 91 | 91 | $next_run = SN_TIME_NOW < $timestamp && !$next_run ? $timestamp : $next_run; |
| 92 | 92 | } |