@@ -18,17 +18,17 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | $sensorLevel = mrc_get_level($user, $planetrow, STRUC_MOON_PHALANX); |
| 20 | 20 | if (!intval($sensorLevel)) { |
| 21 | - message (classLocale::$lang['phalanx_nosensoravailable'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
| 21 | + message(classLocale::$lang['phalanx_nosensoravailable'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | if ($planetrow['planet_type'] != PT_MOON) { |
| 25 | - message (classLocale::$lang['phalanx_onlyformoons'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
| 25 | + message(classLocale::$lang['phalanx_onlyformoons'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | $scan_galaxy = sys_get_param_int('galaxy'); |
| 29 | 29 | $scan_system = sys_get_param_int('system'); |
| 30 | 30 | $scan_planet = sys_get_param_int('planet'); |
| 31 | -$scan_planet_type = 1; // sys_get_param_int('planettype'); |
|
| 31 | +$scan_planet_type = 1; // sys_get_param_int('planettype'); |
|
| 32 | 32 | $id = sys_get_param_id('id'); |
| 33 | 33 | |
| 34 | 34 | $source_galaxy = $planetrow['galaxy']; |
@@ -38,9 +38,9 @@ discard block |
||
| 38 | 38 | $sensorRange = GetPhalanxRange($sensorLevel); |
| 39 | 39 | |
| 40 | 40 | $system_distance = abs($source_system - $scan_system); |
| 41 | -if($system_distance > $sensorRange || $scan_galaxy != $source_galaxy) |
|
| 41 | +if ($system_distance > $sensorRange || $scan_galaxy != $source_galaxy) |
|
| 42 | 42 | { |
| 43 | - message (classLocale::$lang['phalanx_rangeerror'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
| 43 | + message(classLocale::$lang['phalanx_rangeerror'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | $cost = $sensorLevel * 1000; |
@@ -51,14 +51,14 @@ discard block |
||
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | $planet_scanned = db_planet_by_gspt($scan_galaxy, $scan_system, $scan_planet, $scan_planet_type); |
| 54 | -if(!$planet_scanned['id']) |
|
| 54 | +if (!$planet_scanned['id']) |
|
| 55 | 55 | { |
| 56 | 56 | message(classLocale::$lang['phalanx_planet_not_exists'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | -if($planet_scanned['destruyed']) |
|
| 59 | +if ($planet_scanned['destruyed']) |
|
| 60 | 60 | { |
| 61 | - message (classLocale::$lang['phalanx_planet_destroyed'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
| 61 | + message(classLocale::$lang['phalanx_planet_destroyed'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | db_planet_set_by_id($user['current_planet'], "deuterium = deuterium - {$cost}"); |
@@ -450,7 +450,7 @@ discard block |
||
| 450 | 450 | public function compile_request($request) { |
| 451 | 451 | global $config, $user; |
| 452 | 452 | |
| 453 | - if(!(classSupernova::$auth->account instanceof Account)) { |
|
| 453 | + if (!(classSupernova::$auth->account instanceof Account)) { |
|
| 454 | 454 | // TODO - throw new Exception($lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT); |
| 455 | 455 | } |
| 456 | 456 | $this->account = classSupernova::$auth->account; |
@@ -471,15 +471,15 @@ discard block |
||
| 471 | 471 | $this->payment_currency = $config->payment_currency_default; |
| 472 | 472 | $this->payment_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_currency); |
| 473 | 473 | |
| 474 | - if(empty($this->payment_external_currency) && !empty($this->config['currency'])) { |
|
| 474 | + if (empty($this->payment_external_currency) && !empty($this->config['currency'])) { |
|
| 475 | 475 | $this->payment_external_currency = $this->config['currency']; |
| 476 | 476 | } |
| 477 | - if(empty($this->payment_external_currency)) { |
|
| 477 | + if (empty($this->payment_external_currency)) { |
|
| 478 | 478 | throw new Exception(classLocale::$lang['pay_error_internal_no_external_currency_set'], SN_PAYMENT_ERROR_INTERNAL_NO_EXTERNAL_CURRENCY_SET); |
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | $this->payment_external_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_external_currency); |
| 482 | - if($this->payment_external_amount < 0.01) { |
|
| 482 | + if ($this->payment_external_amount < 0.01) { |
|
| 483 | 483 | throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT); |
| 484 | 484 | } |
| 485 | 485 | |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | $this->generate_description(); |
| 489 | 489 | |
| 490 | 490 | $this->db_insert(); |
| 491 | - if(!$this->is_exists) { |
|
| 491 | + if (!$this->is_exists) { |
|
| 492 | 492 | throw new Exception(classLocale::$lang['pay_msg_request_error_db_payment_create'], SN_PAYMENT_REQUEST_DB_ERROR_PAYMENT_CREATE); |
| 493 | 493 | } |
| 494 | 494 | } |
@@ -503,24 +503,24 @@ discard block |
||
| 503 | 503 | protected function payment_request_process($options = array()) { |
| 504 | 504 | global $lang, $config; |
| 505 | 505 | |
| 506 | - if(!$this->manifest['active']) { |
|
| 506 | + if (!$this->manifest['active']) { |
|
| 507 | 507 | throw new Exception(classLocale::$lang['pay_msg_module_disabled'], SN_MODULE_DISABLED); |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | 510 | // Если есть payment_id - загружаем под него данные |
| 511 | - if(!empty($this->payment_params['payment_id'])) { |
|
| 511 | + if (!empty($this->payment_params['payment_id'])) { |
|
| 512 | 512 | $this->request_payment_id = sys_get_param_id($this->payment_params['payment_id']); |
| 513 | - if(!$this->request_payment_id) { |
|
| 513 | + if (!$this->request_payment_id) { |
|
| 514 | 514 | throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG); |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - if(!$this->db_get_by_id($this->request_payment_id)) { |
|
| 517 | + if (!$this->db_get_by_id($this->request_payment_id)) { |
|
| 518 | 518 | throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG); |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | // Проверяем - был ли этот платеж обработан? |
| 522 | 522 | // TODO - Статусы бывают разные. Нужен спецфлаг payment_processed |
| 523 | - if($this->payment_status != PAYMENT_STATUS_NONE) { |
|
| 523 | + if ($this->payment_status != PAYMENT_STATUS_NONE) { |
|
| 524 | 524 | sn_db_transaction_rollback(); |
| 525 | 525 | sys_redirect(SN_ROOT_VIRTUAL . 'metamatter.php?payment_id=' . $this->payment_id); |
| 526 | 526 | die(); |
@@ -530,89 +530,89 @@ discard block |
||
| 530 | 530 | // Пытаемся получить из запроса ИД аккаунта |
| 531 | 531 | $request_account_id = !empty($this->payment_params['account_id']) ? sys_get_param_id($this->payment_params['account_id']) : 0; |
| 532 | 532 | // Если в запросе нет ИД аккаунта - пытаемся использовать payment_account_id |
| 533 | - if(empty($request_account_id) && !empty($this->payment_account_id)) { |
|
| 533 | + if (empty($request_account_id) && !empty($this->payment_account_id)) { |
|
| 534 | 534 | $request_account_id = $this->payment_account_id; |
| 535 | 535 | } |
| 536 | 536 | // Если теперь у нас нету ИД аккаунта ни в запросе, ни в записи таблицы - можно паниковать |
| 537 | - if(empty($request_account_id)) { |
|
| 537 | + if (empty($request_account_id)) { |
|
| 538 | 538 | // TODO - аккаунт |
| 539 | 539 | throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
| 540 | 540 | } |
| 541 | 541 | // Если нет записи в таблице - тогда берем payment_account_id из запроса |
| 542 | - if(empty($this->payment_account_id)) { |
|
| 542 | + if (empty($this->payment_account_id)) { |
|
| 543 | 543 | $this->payment_account_id = $request_account_id; |
| 544 | 544 | } |
| 545 | 545 | // Если у нас отличаются ИД аккаунта в запросе и ИД аккаунта в записи - тоже можно паниковать |
| 546 | - if($this->payment_account_id != $request_account_id) { |
|
| 546 | + if ($this->payment_account_id != $request_account_id) { |
|
| 547 | 547 | // TODO - Поменять сообщение об ошибке |
| 548 | 548 | throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
| 549 | 549 | } |
| 550 | 550 | // Проверяем существование аккаунта с данным ИД |
| 551 | - if(!$this->account->db_get_by_id($this->payment_account_id)) { |
|
| 551 | + if (!$this->account->db_get_by_id($this->payment_account_id)) { |
|
| 552 | 552 | throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'] . ' ID ' . $this->payment_account_id, $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options)); |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | // TODO Проверка на сервер_ид - как бы и не нужна, наверное? |
| 556 | - if(!empty($this->payment_params['server_id'])) { |
|
| 556 | + if (!empty($this->payment_params['server_id'])) { |
|
| 557 | 557 | $this->request_server_id = sys_get_param_str($this->payment_params['server_id']); |
| 558 | - if(SN_ROOT_VIRTUAL != $this->request_server_id) { |
|
| 558 | + if (SN_ROOT_VIRTUAL != $this->request_server_id) { |
|
| 559 | 559 | throw new Exception(classLocale::$lang['pay_msg_request_server_wrong'] . " {$this->request_server_id} вместо " . SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG); |
| 560 | 560 | } |
| 561 | 561 | } |
| 562 | 562 | |
| 563 | 563 | // Сверка количества оплаченной ММ с учётом бонусов |
| 564 | - if(!empty($this->payment_params['payment_dark_matter_gained'])) { |
|
| 564 | + if (!empty($this->payment_params['payment_dark_matter_gained'])) { |
|
| 565 | 565 | $request_mm_amount = sys_get_param_id($this->payment_params['payment_dark_matter_gained']); |
| 566 | - if($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) { |
|
| 566 | + if ($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) { |
|
| 567 | 567 | throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'] . " пришло {$request_mm_amount} ММ вместо {$this->payment_dark_matter_gained} ММ", SN_PAYMENT_REQUEST_MM_AMOUNT_INVALID); |
| 568 | 568 | } |
| 569 | 569 | empty($this->payment_dark_matter_gained) ? $this->payment_dark_matter_gained = $request_mm_amount : false; |
| 570 | 570 | } |
| 571 | - if(empty($this->payment_dark_matter_paid)) { |
|
| 571 | + if (empty($this->payment_dark_matter_paid)) { |
|
| 572 | 572 | // TODO - обратный расчёт из gained |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | // Проверка наличия внешнего ИД платежа |
| 576 | - if(!empty($this->payment_params['payment_external_id'])) { |
|
| 576 | + if (!empty($this->payment_params['payment_external_id'])) { |
|
| 577 | 577 | $request_payment_external_id = sys_get_param_id($this->payment_params['payment_external_id']); |
| 578 | - if(empty($request_payment_external_id)) { |
|
| 578 | + if (empty($request_payment_external_id)) { |
|
| 579 | 579 | throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG); |
| 580 | - } elseif(!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) { |
|
| 580 | + } elseif (!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) { |
|
| 581 | 581 | // TODO - Может быть поменять сообщение |
| 582 | 582 | throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG); |
| 583 | 583 | } |
| 584 | 584 | $this->payment_external_id = $request_payment_external_id; |
| 585 | 585 | } |
| 586 | 586 | // Сверка суммы, запрошенной СН к оплате |
| 587 | - if(!empty($this->payment_params['payment_external_money'])) { |
|
| 587 | + if (!empty($this->payment_params['payment_external_money'])) { |
|
| 588 | 588 | $request_money_out = sys_get_param_float($this->payment_params['payment_external_money']); |
| 589 | - if($request_money_out != $this->payment_external_amount && $this->is_loaded) { |
|
| 589 | + if ($request_money_out != $this->payment_external_amount && $this->is_loaded) { |
|
| 590 | 590 | throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " пришло {$request_money_out} денег вместо {$this->payment_external_amount} денег", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
| 591 | 591 | } |
| 592 | 592 | empty($this->payment_external_amount) ? $this->payment_external_amount = $request_money_out : false; |
| 593 | 593 | } |
| 594 | 594 | // Заполняем поле валюты платёжной системы |
| 595 | - if(!empty($this->payment_params['payment_external_currency'])) { |
|
| 595 | + if (!empty($this->payment_params['payment_external_currency'])) { |
|
| 596 | 596 | $this->payment_external_currency = sys_get_param_str($this->payment_params['payment_external_currency']); |
| 597 | - if(empty($this->payment_external_currency)) { |
|
| 597 | + if (empty($this->payment_external_currency)) { |
|
| 598 | 598 | // TODO - поменять сообщение |
| 599 | 599 | throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID); |
| 600 | 600 | } |
| 601 | 601 | } |
| 602 | - if(empty($this->payment_external_currency)) { |
|
| 602 | + if (empty($this->payment_external_currency)) { |
|
| 603 | 603 | $this->payment_external_currency = $this->config['currency']; |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | 606 | // Заполнение внутренней суммы и валюты из внешних данных |
| 607 | - if(empty($this->payment_currency)) { |
|
| 607 | + if (empty($this->payment_currency)) { |
|
| 608 | 608 | $this->payment_currency = $config->payment_currency_default; |
| 609 | 609 | } |
| 610 | - if(empty($this->payment_amount) && !empty($this->payment_external_currency)) { |
|
| 610 | + if (empty($this->payment_amount) && !empty($this->payment_external_currency)) { |
|
| 611 | 611 | $this->payment_amount = self::currency_convert($this->payment_external_amount, $this->payment_external_currency, $this->payment_currency); |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | // TODO - Тестовый режим |
| 615 | - if(!empty($this->payment_params['test'])) { |
|
| 615 | + if (!empty($this->payment_params['test'])) { |
|
| 616 | 616 | $this->payment_test = $this->config['test'] || sys_get_param_int($this->payment_params['test']); |
| 617 | 617 | } |
| 618 | 618 | |
@@ -641,12 +641,12 @@ discard block |
||
| 641 | 641 | sn_db_transaction_start(); |
| 642 | 642 | try { |
| 643 | 643 | $response = $this->payment_request_process(); |
| 644 | - } catch(Exception $e) { |
|
| 644 | + } catch (Exception $e) { |
|
| 645 | 645 | $response['result'] = $e->getCode(); |
| 646 | 646 | $response['message'] = $e->getMessage(); |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | - if($response['result'] == SN_PAYMENT_REQUEST_OK) { |
|
| 649 | + if ($response['result'] == SN_PAYMENT_REQUEST_OK) { |
|
| 650 | 650 | sn_db_transaction_commit(); |
| 651 | 651 | $debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Успешный платёж', LOG_INFO_PAYMENT); |
| 652 | 652 | } else { |
@@ -655,7 +655,7 @@ discard block |
||
| 655 | 655 | } |
| 656 | 656 | |
| 657 | 657 | // Переводим код результата из СН в код платежной системы |
| 658 | - if(is_array($this->result_translations) && !empty($this->result_translations)) { |
|
| 658 | + if (is_array($this->result_translations) && !empty($this->result_translations)) { |
|
| 659 | 659 | $response['result'] = isset($this->result_translations[$response['result']]) ? $this->result_translations[$response['result']] : $this->result_translations[SN_PAYMENT_REQUEST_UNDEFINED_ERROR]; |
| 660 | 660 | } |
| 661 | 661 | |
@@ -680,7 +680,7 @@ discard block |
||
| 680 | 680 | $currency_from = strtolower($currency_from); |
| 681 | 681 | $currency_to = strtolower($currency_to); |
| 682 | 682 | |
| 683 | - if($currency_from != $currency_to) { |
|
| 683 | + if ($currency_from != $currency_to) { |
|
| 684 | 684 | // $config_currency_from_name = 'payment_currency_exchange_' . $currency_from; |
| 685 | 685 | // $config_currency_to_name = 'payment_currency_exchange_' . $currency_to; |
| 686 | 686 | |
@@ -710,10 +710,10 @@ discard block |
||
| 710 | 710 | public static function bonus_calculate($dark_matter, $direct = true, $return_bonus = false) { |
| 711 | 711 | $bonus = 0; |
| 712 | 712 | $dark_matter_new = $dark_matter; |
| 713 | - if(!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) { |
|
| 714 | - if($direct) { |
|
| 715 | - foreach(self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
| 716 | - if($dm_for_bonus <= $dark_matter) { |
|
| 713 | + if (!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) { |
|
| 714 | + if ($direct) { |
|
| 715 | + foreach (self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
| 716 | + if ($dm_for_bonus <= $dark_matter) { |
|
| 717 | 717 | $dark_matter_new = $dark_matter * (1 + $multiplier); |
| 718 | 718 | $bonus = $multiplier; |
| 719 | 719 | } else { |
@@ -721,9 +721,9 @@ discard block |
||
| 721 | 721 | } |
| 722 | 722 | } |
| 723 | 723 | } else { |
| 724 | - foreach(self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
| 724 | + foreach (self::$bonus_table as $dm_for_bonus => $multiplier) { |
|
| 725 | 725 | $temp = $dm_for_bonus * (1 + $multiplier); |
| 726 | - if($dark_matter >= $temp) { |
|
| 726 | + if ($dark_matter >= $temp) { |
|
| 727 | 727 | $dark_matter_new = round($dark_matter / (1 + $multiplier)); |
| 728 | 728 | $bonus = $multiplier; |
| 729 | 729 | } else { |
@@ -779,13 +779,13 @@ discard block |
||
| 779 | 779 | ); |
| 780 | 780 | |
| 781 | 781 | $replace = false; |
| 782 | - if($this->payment_id) { |
|
| 782 | + if ($this->payment_id) { |
|
| 783 | 783 | $payment['payment_id'] = $this->payment_id; |
| 784 | 784 | $replace = true; |
| 785 | 785 | } |
| 786 | 786 | |
| 787 | 787 | $query = array(); |
| 788 | - foreach($payment as $key => $value) { |
|
| 788 | + foreach ($payment as $key => $value) { |
|
| 789 | 789 | $value = is_string($value) ? '"' . db_escape($value) . '"' : $value; |
| 790 | 790 | $query[] = "`{$key}` = {$value}"; |
| 791 | 791 | } |
@@ -797,12 +797,12 @@ discard block |
||
| 797 | 797 | |
| 798 | 798 | |
| 799 | 799 | function payment_adjust_mm_new() { |
| 800 | - if(!$this->payment_test) { |
|
| 800 | + if (!$this->payment_test) { |
|
| 801 | 801 | // Not a test payment. Adding DM to account |
| 802 | 802 | $this->account = new Account($this->db); |
| 803 | 803 | $this->account->db_get_by_id($this->payment_account_id); |
| 804 | 804 | $result = $this->account->metamatter_change(RPG_PURCHASE, $this->payment_dark_matter_gained, $this->payment_comment); |
| 805 | - if(!$result) { |
|
| 805 | + if (!$result) { |
|
| 806 | 806 | throw new Exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST); |
| 807 | 807 | } |
| 808 | 808 | } |
@@ -812,25 +812,25 @@ discard block |
||
| 812 | 812 | die('{НЕ РАБОТАЕТ! СООБЩИТЕ АДМИНИСТРАЦИИ!}'); |
| 813 | 813 | global $lang; |
| 814 | 814 | |
| 815 | - if(!isset($payment['payment_status'])) { |
|
| 815 | + if (!isset($payment['payment_status'])) { |
|
| 816 | 816 | throw new exception(classLocale::$lang['pay_msg_request_payment_not_found'], SN_PAYMENT_REQUEST_ORDER_NOT_FOUND); |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | - if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
| 820 | - $safe_comment = db_escape($payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] .' ' . $payment['payment_comment']); |
|
| 819 | + if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) { |
|
| 820 | + $safe_comment = db_escape($payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] . ' ' . $payment['payment_comment']); |
|
| 821 | 821 | |
| 822 | - if(!$payment['payment_test']) { |
|
| 822 | + if (!$payment['payment_test']) { |
|
| 823 | 823 | $result = $this->account->metamatter_change(RPG_PURCHASE_CANCEL, -$payment['payment_dark_matter_gained'], $payment['payment_comment']); |
| 824 | - if(!$result) { |
|
| 824 | + if (!$result) { |
|
| 825 | 825 | throw new exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST); |
| 826 | 826 | } |
| 827 | 827 | } |
| 828 | 828 | $payment['payment_status'] = PAYMENT_STATUS_CANCELED; |
| 829 | 829 | db_payment_update($payment, $safe_comment); |
| 830 | 830 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_complete'], SN_PAYMENT_REQUEST_OK); |
| 831 | - } elseif($payment['payment_status'] == PAYMENT_STATUS_CANCELED) { |
|
| 831 | + } elseif ($payment['payment_status'] == PAYMENT_STATUS_CANCELED) { |
|
| 832 | 832 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancelled_already'], SN_PAYMENT_REQUEST_OK); |
| 833 | - } elseif($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
| 833 | + } elseif ($payment['payment_status'] == PAYMENT_STATUS_NONE) { |
|
| 834 | 834 | throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_not_complete'], SN_PAYMENT_REQUEST_PAYMENT_NOT_COMPLETE); |
| 835 | 835 | } |
| 836 | 836 | } |
@@ -844,8 +844,8 @@ discard block |
||
| 844 | 844 | |
| 845 | 845 | protected function db_complete_payment() { |
| 846 | 846 | // TODO - поле payment_processed |
| 847 | - if($this->payment_status == PAYMENT_STATUS_NONE) { |
|
| 848 | - if(!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) { |
|
| 847 | + if ($this->payment_status == PAYMENT_STATUS_NONE) { |
|
| 848 | + if (!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) { |
|
| 849 | 849 | $this->payment_adjust_mm_new(); |
| 850 | 850 | $this->payment_status = PAYMENT_STATUS_COMPLETE; |
| 851 | 851 | } else { |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | protected function db_assign_payment($payment = null) { |
| 893 | 893 | $this->payment_reset(); |
| 894 | 894 | |
| 895 | - if(is_array($payment) && isset($payment['payment_id'])) { |
|
| 895 | + if (is_array($payment) && isset($payment['payment_id'])) { |
|
| 896 | 896 | $this->payment_id = $payment['payment_id']; |
| 897 | 897 | $this->payment_status = $payment['payment_status']; |
| 898 | 898 | $this->payment_date = $payment['payment_date']; |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | |
| 203 | 203 | |
| 204 | 204 | public static function log_file($message, $spaces = 0) { |
| 205 | - if(self::$debug) { |
|
| 205 | + if (self::$debug) { |
|
| 206 | 206 | self::$debug->log_file($message, $spaces); |
| 207 | 207 | } |
| 208 | 208 | } |
@@ -214,16 +214,16 @@ discard block |
||
| 214 | 214 | // Перепаковывает массив на заданную глубину, убирая поля с null |
| 215 | 215 | public static function array_repack(&$array, $level = 0) { |
| 216 | 216 | // TODO $lock_table не нужна тут |
| 217 | - if(!is_array($array)) { |
|
| 217 | + if (!is_array($array)) { |
|
| 218 | 218 | return; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | - foreach($array as $key => &$value) { |
|
| 222 | - if($value === null) { |
|
| 221 | + foreach ($array as $key => &$value) { |
|
| 222 | + if ($value === null) { |
|
| 223 | 223 | unset($array[$key]); |
| 224 | - } elseif($level > 0 && is_array($value)) { |
|
| 224 | + } elseif ($level > 0 && is_array($value)) { |
|
| 225 | 225 | static::array_repack($value, $level - 1); |
| 226 | - if(empty($value)) { |
|
| 226 | + if (empty($value)) { |
|
| 227 | 227 | unset($array[$key]); |
| 228 | 228 | } |
| 229 | 229 | } |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | // TODO Вынести в отдельный объект |
| 235 | 235 | public static function cache_repack($location_type, $record_id = 0) { |
| 236 | 236 | // Если есть $user_id - проверяем, а надо ли перепаковывать? |
| 237 | - if($record_id && isset(static::$data[$location_type][$record_id]) && static::$data[$location_type][$record_id] !== null) { |
|
| 237 | + if ($record_id && isset(static::$data[$location_type][$record_id]) && static::$data[$location_type][$record_id] !== null) { |
|
| 238 | 238 | return; |
| 239 | 239 | } |
| 240 | 240 | |
@@ -245,9 +245,9 @@ discard block |
||
| 245 | 245 | |
| 246 | 246 | public static function cache_clear($location_type, $hard = true) { |
| 247 | 247 | //print("<br />CACHE CLEAR {$cache_id} " . ($hard ? 'HARD' : 'SOFT') . "<br />"); |
| 248 | - if($hard && !empty(static::$data[$location_type])) { |
|
| 248 | + if ($hard && !empty(static::$data[$location_type])) { |
|
| 249 | 249 | // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях |
| 250 | - array_walk(static::$data[$location_type], function (&$item) { $item = null; }); |
|
| 250 | + array_walk(static::$data[$location_type], function(&$item) { $item = null; }); |
|
| 251 | 251 | } |
| 252 | 252 | static::$locator[$location_type] = array(); |
| 253 | 253 | static::$queries[$location_type] = array(); |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | |
| 257 | 257 | public static function cache_clear_all($hard = true) { |
| 258 | 258 | //print('<br />CACHE CLEAR ALL<br />'); |
| 259 | - if($hard) { |
|
| 259 | + if ($hard) { |
|
| 260 | 260 | static::$data = array(); |
| 261 | 261 | static::cache_lock_unset_all(); |
| 262 | 262 | } |
@@ -285,12 +285,12 @@ discard block |
||
| 285 | 285 | */ |
| 286 | 286 | public static function cache_set($location_type, $record_id, $record, $force_overwrite = false, $skip_lock = false) { |
| 287 | 287 | // нет идентификатора - выход |
| 288 | - if(!($record_id = $record[static::$location_info[$location_type][P_ID]])) { |
|
| 288 | + if (!($record_id = $record[static::$location_info[$location_type][P_ID]])) { |
|
| 289 | 289 | return; |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | $in_transaction = static::db_transaction_check(false); |
| 293 | - if( |
|
| 293 | + if ( |
|
| 294 | 294 | $force_overwrite |
| 295 | 295 | || |
| 296 | 296 | // Не заменяются заблокированные записи во время транзакции |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | !static::cache_isset($location_type, $record_id) |
| 301 | 301 | ) { |
| 302 | 302 | static::$data[$location_type][$record_id] = $record; |
| 303 | - if($in_transaction && !$skip_lock) { |
|
| 303 | + if ($in_transaction && !$skip_lock) { |
|
| 304 | 304 | static::cache_lock_set($location_type, $record_id); |
| 305 | 305 | } |
| 306 | 306 | } |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | |
| 309 | 309 | public static function cache_unset($cache_id, $safe_record_id) { |
| 310 | 310 | // $record_id должен быть проверен заранее ! |
| 311 | - if(isset(static::$data[$cache_id][$safe_record_id]) && static::$data[$cache_id][$safe_record_id] !== null) { |
|
| 311 | + if (isset(static::$data[$cache_id][$safe_record_id]) && static::$data[$cache_id][$safe_record_id] !== null) { |
|
| 312 | 312 | // Выставляем запись в null |
| 313 | 313 | static::$data[$cache_id][$safe_record_id] = null; |
| 314 | 314 | // Очищаем кэш мягко - что бы удалить очистить связанные данные - кэш локаций и кэш запоросов и всё, что потребуется впредь |
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | public static function cache_lock_unset($location_type, $record_id) { |
| 328 | - if(isset(static::$locks[$location_type][$record_id])) { |
|
| 328 | + if (isset(static::$locks[$location_type][$record_id])) { |
|
| 329 | 329 | unset(static::$locks[$location_type][$record_id]); |
| 330 | 330 | } |
| 331 | 331 | |
@@ -359,13 +359,13 @@ discard block |
||
| 359 | 359 | */ |
| 360 | 360 | public static function db_transaction_check($status = null) { |
| 361 | 361 | $error_msg = false; |
| 362 | - if($status && !static::$db_in_transaction) { |
|
| 362 | + if ($status && !static::$db_in_transaction) { |
|
| 363 | 363 | $error_msg = 'No transaction started for current operation'; |
| 364 | - } elseif($status === null && static::$db_in_transaction) { |
|
| 364 | + } elseif ($status === null && static::$db_in_transaction) { |
|
| 365 | 365 | $error_msg = 'Transaction is already started'; |
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - if($error_msg) { |
|
| 368 | + if ($error_msg) { |
|
| 369 | 369 | // TODO - Убрать позже |
| 370 | 370 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_transaction_check() - ' . $error_msg . '</h1>'); |
| 371 | 371 | $backtrace = debug_backtrace(); |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | static::$transaction_id++; |
| 388 | 388 | doquery('START TRANSACTION'); |
| 389 | 389 | |
| 390 | - if($config->db_manual_lock_enabled) { |
|
| 390 | + if ($config->db_manual_lock_enabled) { |
|
| 391 | 391 | $config->db_loadItem('var_db_manually_locked'); |
| 392 | 392 | $config->db_saveItem('var_db_manually_locked', SN_TIME_SQL); |
| 393 | 393 | } |
@@ -404,7 +404,7 @@ discard block |
||
| 404 | 404 | public static function db_transaction_commit() { |
| 405 | 405 | static::db_transaction_check(true); |
| 406 | 406 | |
| 407 | - if(!empty(static::$delayed_changset)) { |
|
| 407 | + if (!empty(static::$delayed_changset)) { |
|
| 408 | 408 | static::db_changeset_apply(static::$delayed_changset, true); |
| 409 | 409 | // pdump(static::$delayed_changset); |
| 410 | 410 | } |
@@ -420,7 +420,7 @@ discard block |
||
| 420 | 420 | |
| 421 | 421 | public static function db_transaction_rollback() { |
| 422 | 422 | // static::db_transaction_check(true); // TODO - вообще-то тут тоже надо проверять есть ли транзакция |
| 423 | - if(!empty(static::$delayed_changset)) { |
|
| 423 | + if (!empty(static::$delayed_changset)) { |
|
| 424 | 424 | static::db_changeset_revert(); |
| 425 | 425 | } |
| 426 | 426 | static::$delayed_changset = array(); |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | */ |
| 444 | 444 | public static function db_lock_tables($tables) { |
| 445 | 445 | $tables = is_array($tables) ? $tables : array($tables => ''); |
| 446 | - foreach($tables as $table_name => $condition) { |
|
| 446 | + foreach ($tables as $table_name => $condition) { |
|
| 447 | 447 | self::$db->doquery("SELECT 1 FROM {{{$table_name}}}" . ($condition ? ' WHERE ' . $condition : '')); |
| 448 | 448 | } |
| 449 | 449 | } |
@@ -486,17 +486,17 @@ discard block |
||
| 486 | 486 | //pdump($filter, 'Выбираем ' . $location_type); |
| 487 | 487 | $query_cache = &static::$queries[$location_type][$filter]; |
| 488 | 488 | |
| 489 | - if(!isset($query_cache) || $query_cache === null) { |
|
| 489 | + if (!isset($query_cache) || $query_cache === null) { |
|
| 490 | 490 | // pdump($filter, 'Кэш пустой, начинаем возню'); |
| 491 | 491 | $location_info = &static::$location_info[$location_type]; |
| 492 | 492 | $id_field = $location_info[P_ID]; |
| 493 | 493 | $query_cache = array(); |
| 494 | 494 | |
| 495 | - if(static::db_transaction_check(false)) { |
|
| 495 | + if (static::db_transaction_check(false)) { |
|
| 496 | 496 | //pdump($filter, 'Транзакция - блокируем ' . $location_type); |
| 497 | 497 | // Проходим по всем родителям данной записи |
| 498 | 498 | // foreach($location_info[P_OWNER_INFO] as $owner_location_type => $owner_data) |
| 499 | - foreach($location_info[P_OWNER_INFO] as $owner_data) { |
|
| 499 | + foreach ($location_info[P_OWNER_INFO] as $owner_data) { |
|
| 500 | 500 | $owner_location_type = $owner_data[P_LOCATION]; |
| 501 | 501 | //pdump($filter, 'Транзакция - блокируем родителя ' . $owner_location_type); |
| 502 | 502 | $parent_id_list = array(); |
@@ -509,15 +509,15 @@ discard block |
||
| 509 | 509 | ($fetch ? ' LIMIT 1' : ''), false, true); |
| 510 | 510 | |
| 511 | 511 | //pdump($q, 'Запрос блокировки'); |
| 512 | - while($row = db_fetch($query)) { |
|
| 512 | + while ($row = db_fetch($query)) { |
|
| 513 | 513 | // Исключаем из списка родительских ИД уже заблокированные записи |
| 514 | - if(!static::cache_lock_get($owner_location_type, $row['parent_id'])) { |
|
| 514 | + if (!static::cache_lock_get($owner_location_type, $row['parent_id'])) { |
|
| 515 | 515 | $parent_id_list[$row['parent_id']] = $row['parent_id']; |
| 516 | 516 | } |
| 517 | 517 | } |
| 518 | 518 | //pdump($parent_id_list, 'Выбраны родители'); |
| 519 | 519 | // Если все-таки какие-то записи еще не заблокированы - вынимаем текущие версии из базы |
| 520 | - if($indexes_str = implode(',', $parent_id_list)) { |
|
| 520 | + if ($indexes_str = implode(',', $parent_id_list)) { |
|
| 521 | 521 | //pdump($indexes_str, '$indexes_str'); |
| 522 | 522 | $parent_id_field = static::$location_info[$owner_location_type][P_ID]; |
| 523 | 523 | static::db_get_record_list($owner_location_type, |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | "SELECT * FROM {{{$location_info[P_TABLE_NAME]}}}" . |
| 533 | 533 | (($filter = trim($filter)) ? " WHERE {$filter}" : '') |
| 534 | 534 | ); |
| 535 | - while($row = db_fetch($query)) { |
|
| 535 | + while ($row = db_fetch($query)) { |
|
| 536 | 536 | // static::db_get_record_by_id($location_type, $row[$id_field]); |
| 537 | 537 | static::cache_set($location_type, $row[$id_field], $row); |
| 538 | 538 | $query_cache[$row[$id_field]] = &static::$data[$location_type][$row[$id_field]]; |
@@ -540,14 +540,14 @@ discard block |
||
| 540 | 540 | } |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | - if($no_return) { |
|
| 543 | + if ($no_return) { |
|
| 544 | 544 | return true; |
| 545 | 545 | } else { |
| 546 | 546 | $result = false; |
| 547 | - if(is_array($query_cache)) { |
|
| 548 | - foreach($query_cache as $key => $value) { |
|
| 547 | + if (is_array($query_cache)) { |
|
| 548 | + foreach ($query_cache as $key => $value) { |
|
| 549 | 549 | $result[$key] = $value; |
| 550 | - if($fetch) { |
|
| 550 | + if ($fetch) { |
|
| 551 | 551 | break; |
| 552 | 552 | } |
| 553 | 553 | } |
@@ -566,16 +566,16 @@ discard block |
||
| 566 | 566 | */ |
| 567 | 567 | public static function db_upd_record_by_id($location_type, $record_id, $set) { |
| 568 | 568 | //if(!($record_id = intval($record_id)) || !($set = trim($set))) return false; |
| 569 | - if(!($record_id = idval($record_id)) || !($set = trim($set))) { |
|
| 569 | + if (!($record_id = idval($record_id)) || !($set = trim($set))) { |
|
| 570 | 570 | return false; |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | $location_info = &static::$location_info[$location_type]; |
| 574 | 574 | $id_field = $location_info[P_ID]; |
| 575 | 575 | $table_name = $location_info[P_TABLE_NAME]; |
| 576 | - if($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ? |
|
| 576 | + if ($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ? |
|
| 577 | 577 | { |
| 578 | - if(static::$db->db_affected_rows()) { |
|
| 578 | + if (static::$db->db_affected_rows()) { |
|
| 579 | 579 | // Обновляем данные только если ряд был затронут |
| 580 | 580 | // TODO - переделать под работу со структурированными $set |
| 581 | 581 | |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | public static function db_upd_record_list($location_type, $condition, $set) { |
| 594 | - if(!($set = trim($set))) { |
|
| 594 | + if (!($set = trim($set))) { |
|
| 595 | 595 | return false; |
| 596 | 596 | } |
| 597 | 597 | |
@@ -600,9 +600,9 @@ discard block |
||
| 600 | 600 | |
| 601 | 601 | //static::db_get_record_list($location_type, $condition, false, true); |
| 602 | 602 | |
| 603 | - if($result = static::db_query("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) { |
|
| 603 | + if ($result = static::db_query("UPDATE {{{$table_name}}} SET " . $set . ($condition ? ' WHERE ' . $condition : ''))) { |
|
| 604 | 604 | |
| 605 | - if(static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут |
|
| 605 | + if (static::$db->db_affected_rows()) { // Обновляем данные только если ряд был затронут |
|
| 606 | 606 | // Поскольку нам неизвестно, что и как обновилось - сбрасываем кэш этого типа полностью |
| 607 | 607 | // TODO - когда будет структурированный $condition и $set - перепаковывать данные |
| 608 | 608 | static::cache_clear($location_type, true); |
@@ -621,8 +621,8 @@ discard block |
||
| 621 | 621 | public static function db_ins_record($location_type, $set) { |
| 622 | 622 | $set = trim($set); |
| 623 | 623 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
| 624 | - if($result = static::db_query("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
|
| 625 | - if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 624 | + if ($result = static::db_query("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
|
| 625 | + if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 626 | 626 | { |
| 627 | 627 | $record_id = db_insert_id(); |
| 628 | 628 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
@@ -644,8 +644,8 @@ discard block |
||
| 644 | 644 | $fields = implode(',', array_keys($field_set)); |
| 645 | 645 | |
| 646 | 646 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
| 647 | - if($result = static::db_query("INSERT INTO `{{{$table_name}}}` ($fields) VALUES ($values);")) { |
|
| 648 | - if(static::$db->db_affected_rows()) { |
|
| 647 | + if ($result = static::db_query("INSERT INTO `{{{$table_name}}}` ($fields) VALUES ($values);")) { |
|
| 648 | + if (static::$db->db_affected_rows()) { |
|
| 649 | 649 | // Обновляем данные только если ряд был затронут |
| 650 | 650 | $record_id = db_insert_id(); |
| 651 | 651 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
@@ -661,15 +661,15 @@ discard block |
||
| 661 | 661 | |
| 662 | 662 | public static function db_del_record_by_id($location_type, $safe_record_id) { |
| 663 | 663 | // if(!($safe_record_id = intval($safe_record_id))) return false; |
| 664 | - if(!($safe_record_id = idval($safe_record_id))) { |
|
| 664 | + if (!($safe_record_id = idval($safe_record_id))) { |
|
| 665 | 665 | return false; |
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | $location_info = &static::$location_info[$location_type]; |
| 669 | 669 | $id_field = $location_info[P_ID]; |
| 670 | 670 | $table_name = $location_info[P_TABLE_NAME]; |
| 671 | - if($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) { |
|
| 672 | - if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 671 | + if ($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) { |
|
| 672 | + if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 673 | 673 | { |
| 674 | 674 | static::cache_unset($location_type, $safe_record_id); |
| 675 | 675 | } |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | public static function db_del_record_list($location_type, $condition) { |
| 682 | - if(!($condition = trim($condition))) { |
|
| 682 | + if (!($condition = trim($condition))) { |
|
| 683 | 683 | return false; |
| 684 | 684 | } |
| 685 | 685 | |
@@ -688,8 +688,8 @@ discard block |
||
| 688 | 688 | |
| 689 | 689 | //static::db_get_record_list($location_type, $condition, false, true); |
| 690 | 690 | |
| 691 | - if($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) { |
|
| 692 | - if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 691 | + if ($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) { |
|
| 692 | + if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 693 | 693 | { |
| 694 | 694 | // Обнуление кэша, потому что непонятно, что поменялось |
| 695 | 695 | // TODO - когда будет структурированный $condition можно будет делать только cache_unset по нужным записям |
@@ -736,20 +736,20 @@ discard block |
||
| 736 | 736 | |
| 737 | 737 | public static function db_get_user_by_username($username_unsafe, $for_update = false, $fields = '*', $player = null, $like = false) { |
| 738 | 738 | // TODO Проверить, кстати - а везде ли нужно выбирать юзеров или где-то все-таки ищутся Альянсы ? |
| 739 | - if(!($username_unsafe = trim($username_unsafe))) { |
|
| 739 | + if (!($username_unsafe = trim($username_unsafe))) { |
|
| 740 | 740 | return false; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | $user = null; |
| 744 | - if(is_array(static::$data[LOC_USER])) { |
|
| 745 | - foreach(static::$data[LOC_USER] as $user_id => $user_data) { |
|
| 746 | - if(is_array($user_data) && isset($user_data['username'])) { |
|
| 744 | + if (is_array(static::$data[LOC_USER])) { |
|
| 745 | + foreach (static::$data[LOC_USER] as $user_id => $user_data) { |
|
| 746 | + if (is_array($user_data) && isset($user_data['username'])) { |
|
| 747 | 747 | // проверяем поле |
| 748 | 748 | // TODO Возможно есть смысл всегда искать по strtolower - но может игрок захочет переименоваться с другим регистром? Проверить! |
| 749 | - if((!$like && $user_data['username'] == $username_unsafe) || ($like && strtolower($user_data['username']) == strtolower($username_unsafe))) { |
|
| 749 | + if ((!$like && $user_data['username'] == $username_unsafe) || ($like && strtolower($user_data['username']) == strtolower($username_unsafe))) { |
|
| 750 | 750 | // $user_as_ally = intval($user_data['user_as_ally']); |
| 751 | 751 | $user_as_ally = idval($user_data['user_as_ally']); |
| 752 | - if($player === null || ($player === true && !$user_as_ally) || ($player === false && $user_as_ally)) { |
|
| 752 | + if ($player === null || ($player === true && !$user_as_ally) || ($player === false && $user_as_ally)) { |
|
| 753 | 753 | $user = $user_data; |
| 754 | 754 | break; |
| 755 | 755 | } |
@@ -758,7 +758,7 @@ discard block |
||
| 758 | 758 | } |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | - if($user === null) { |
|
| 761 | + if ($user === null) { |
|
| 762 | 762 | // Вытаскиваем запись |
| 763 | 763 | $username_safe = db_escape($like ? strtolower($username_unsafe) : $username_unsafe); // тут на самом деле strtolower() лишняя, но пусть будет |
| 764 | 764 | |
@@ -776,17 +776,17 @@ discard block |
||
| 776 | 776 | |
| 777 | 777 | // UNUSED |
| 778 | 778 | public static function db_get_user_by_email($email_unsafe, $use_both = false, $for_update = false, $fields = '*') { |
| 779 | - if(!($email_unsafe = strtolower(trim($email_unsafe)))) { |
|
| 779 | + if (!($email_unsafe = strtolower(trim($email_unsafe)))) { |
|
| 780 | 780 | return false; |
| 781 | 781 | } |
| 782 | 782 | |
| 783 | 783 | $user = null; |
| 784 | 784 | // TODO переделать на индексы |
| 785 | - if(is_array(static::$data[LOC_USER])) { |
|
| 786 | - foreach(static::$data[LOC_USER] as $user_id => $user_data) { |
|
| 787 | - if(is_array($user_data) && isset($user_data['email_2'])) { |
|
| 785 | + if (is_array(static::$data[LOC_USER])) { |
|
| 786 | + foreach (static::$data[LOC_USER] as $user_id => $user_data) { |
|
| 787 | + if (is_array($user_data) && isset($user_data['email_2'])) { |
|
| 788 | 788 | // проверяем поле |
| 789 | - if(strtolower($user_data['email_2']) == $email_unsafe || ($use_both && strtolower($user_data['email']) == $email_unsafe)) { |
|
| 789 | + if (strtolower($user_data['email_2']) == $email_unsafe || ($use_both && strtolower($user_data['email']) == $email_unsafe)) { |
|
| 790 | 790 | $user = $user_data; |
| 791 | 791 | break; |
| 792 | 792 | } |
@@ -794,7 +794,7 @@ discard block |
||
| 794 | 794 | } |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | - if($user === null) { |
|
| 797 | + if ($user === null) { |
|
| 798 | 798 | // Вытаскиваем запись |
| 799 | 799 | $email_safe = db_escape($email_unsafe); |
| 800 | 800 | $user = static::db_query( |
@@ -813,7 +813,7 @@ discard block |
||
| 813 | 813 | $user = null; |
| 814 | 814 | // TODO переделать на индексы |
| 815 | 815 | |
| 816 | - if($user === null && !empty($where_safe)) { |
|
| 816 | + if ($user === null && !empty($where_safe)) { |
|
| 817 | 817 | // Вытаскиваем запись |
| 818 | 818 | $user = static::db_query("SELECT * FROM {{users}} WHERE {$where_safe}", true); |
| 819 | 819 | |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | public static function db_get_unit_by_id($unit_id, $for_update = false, $fields = '*') { |
| 836 | 836 | // TODO запихивать в $data[LOC_LOCATION][$location_type][$location_id] |
| 837 | 837 | $unit = static::db_get_record_by_id(LOC_UNIT, $unit_id, $for_update, $fields); |
| 838 | - if(is_array($unit)) { |
|
| 838 | + if (is_array($unit)) { |
|
| 839 | 839 | static::$locator[LOC_UNIT][$unit['unit_location_type']][$unit['unit_location_id']][$unit['unit_snid']] = &static::$data[LOC_UNIT][$unit_id]; |
| 840 | 840 | } |
| 841 | 841 | |
@@ -851,15 +851,15 @@ discard block |
||
| 851 | 851 | */ |
| 852 | 852 | public static function db_get_unit_list_by_location($user_id = 0, $location_type, $location_id) { |
| 853 | 853 | //if(!($location_type = intval($location_type)) || !($location_id = intval($location_id))) return false; |
| 854 | - if(!($location_type = idval($location_type)) || !($location_id = idval($location_id))) { |
|
| 854 | + if (!($location_type = idval($location_type)) || !($location_id = idval($location_id))) { |
|
| 855 | 855 | return false; |
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | $query_cache = &static::$locator[LOC_UNIT][$location_type][$location_id]; |
| 859 | - if(!isset($query_cache)) { |
|
| 859 | + if (!isset($query_cache)) { |
|
| 860 | 860 | $got_data = static::db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . static::db_unit_time_restrictions()); |
| 861 | - if(is_array($got_data)) { |
|
| 862 | - foreach($got_data as $unit_id => $unit_data) { |
|
| 861 | + if (is_array($got_data)) { |
|
| 862 | + foreach ($got_data as $unit_id => $unit_data) { |
|
| 863 | 863 | // static::$data[LOC_LOCATION][$location_type][$location_id][$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id]; |
| 864 | 864 | $query_cache[$unit_data['unit_snid']] = &static::$data[LOC_UNIT][$unit_id]; |
| 865 | 865 | } |
@@ -867,8 +867,8 @@ discard block |
||
| 867 | 867 | } |
| 868 | 868 | |
| 869 | 869 | $result = false; |
| 870 | - if(is_array($query_cache)) { |
|
| 871 | - foreach($query_cache as $key => $value) { |
|
| 870 | + if (is_array($query_cache)) { |
|
| 871 | + foreach ($query_cache as $key => $value) { |
|
| 872 | 872 | $result[$key] = $value; |
| 873 | 873 | } |
| 874 | 874 | } |
@@ -903,7 +903,7 @@ discard block |
||
| 903 | 903 | * |
| 904 | 904 | */ |
| 905 | 905 | public static function db_que_list_by_type_location($user_id, $planet_id = null, $que_type = false, $for_update = false) { |
| 906 | - if(!$user_id) { |
|
| 906 | + if (!$user_id) { |
|
| 907 | 907 | pdump(debug_backtrace()); |
| 908 | 908 | die('No user_id for que_get_que()'); |
| 909 | 909 | } |
@@ -913,16 +913,16 @@ discard block |
||
| 913 | 913 | $query = array(); |
| 914 | 914 | |
| 915 | 915 | // if($user_id = intval($user_id)) |
| 916 | - if($user_id = idval($user_id)) { |
|
| 916 | + if ($user_id = idval($user_id)) { |
|
| 917 | 917 | $query[] = "`que_player_id` = {$user_id}"; |
| 918 | 918 | } |
| 919 | 919 | |
| 920 | - if($que_type == QUE_RESEARCH || $planet_id === null) { |
|
| 920 | + if ($que_type == QUE_RESEARCH || $planet_id === null) { |
|
| 921 | 921 | $query[] = "`que_planet_id` IS NULL"; |
| 922 | - } elseif($planet_id) { |
|
| 922 | + } elseif ($planet_id) { |
|
| 923 | 923 | $query[] = "(`que_planet_id` = {$planet_id}" . ($que_type ? '' : ' OR que_planet_id IS NULL') . ")"; |
| 924 | 924 | } |
| 925 | - if($que_type) { |
|
| 925 | + if ($que_type) { |
|
| 926 | 926 | $query[] = "`que_type` = {$que_type}"; |
| 927 | 927 | } |
| 928 | 928 | |
@@ -955,13 +955,13 @@ discard block |
||
| 955 | 955 | |
| 956 | 956 | |
| 957 | 957 | public static function db_changeset_prepare_unit($unit_id, $unit_value, $user, $planet_id = null) { |
| 958 | - if(!is_array($user)) { |
|
| 958 | + if (!is_array($user)) { |
|
| 959 | 959 | // TODO - remove later |
| 960 | 960 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER is not ARRAY</h1>'); |
| 961 | 961 | pdump(debug_backtrace()); |
| 962 | 962 | die('USER is not ARRAY'); |
| 963 | 963 | } |
| 964 | - if(!isset($user['id']) || !$user['id']) { |
|
| 964 | + if (!isset($user['id']) || !$user['id']) { |
|
| 965 | 965 | // TODO - remove later |
| 966 | 966 | print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER[id] пустой</h1>'); |
| 967 | 967 | pdump($user); |
@@ -976,7 +976,7 @@ discard block |
||
| 976 | 976 | |
| 977 | 977 | $db_changeset = array(); |
| 978 | 978 | $temp = db_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id'); |
| 979 | - if($temp['unit_id']) { |
|
| 979 | + if ($temp['unit_id']) { |
|
| 980 | 980 | $db_changeset = array( |
| 981 | 981 | 'action' => SQL_OP_UPDATE, |
| 982 | 982 | P_VERSION => 1, |
@@ -1045,9 +1045,9 @@ discard block |
||
| 1045 | 1045 | } |
| 1046 | 1046 | |
| 1047 | 1047 | public function db_changeset_condition_compile(&$conditions, &$table_name = '') { |
| 1048 | - if(!$conditions[P_LOCATION] || $conditions[P_LOCATION] == LOC_NONE) { |
|
| 1048 | + if (!$conditions[P_LOCATION] || $conditions[P_LOCATION] == LOC_NONE) { |
|
| 1049 | 1049 | $conditions[P_LOCATION] = LOC_NONE; |
| 1050 | - switch($table_name) { |
|
| 1050 | + switch ($table_name) { |
|
| 1051 | 1051 | case 'users': |
| 1052 | 1052 | case LOC_USER: |
| 1053 | 1053 | $conditions[P_TABLE_NAME] = $table_name = 'users'; |
@@ -1069,18 +1069,18 @@ discard block |
||
| 1069 | 1069 | } |
| 1070 | 1070 | |
| 1071 | 1071 | $conditions[P_FIELDS_STR] = ''; |
| 1072 | - if($conditions['fields']) { |
|
| 1072 | + if ($conditions['fields']) { |
|
| 1073 | 1073 | $fields = array(); |
| 1074 | - foreach($conditions['fields'] as $field_name => $field_data) { |
|
| 1074 | + foreach ($conditions['fields'] as $field_name => $field_data) { |
|
| 1075 | 1075 | $condition = "`{$field_name}` = "; |
| 1076 | 1076 | $value = ''; |
| 1077 | - if($field_data['delta']) { |
|
| 1077 | + if ($field_data['delta']) { |
|
| 1078 | 1078 | $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta']; |
| 1079 | - } elseif($field_data['set']) { |
|
| 1079 | + } elseif ($field_data['set']) { |
|
| 1080 | 1080 | $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']); |
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | - if($value) { |
|
| 1083 | + if ($value) { |
|
| 1084 | 1084 | $fields[] = $condition . $value; |
| 1085 | 1085 | } |
| 1086 | 1086 | } |
@@ -1088,16 +1088,14 @@ discard block |
||
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | 1090 | $conditions[P_WHERE_STR] = ''; |
| 1091 | - if(!empty($conditions['where'])) { |
|
| 1092 | - if($conditions[P_VERSION] == 1) { |
|
| 1091 | + if (!empty($conditions['where'])) { |
|
| 1092 | + if ($conditions[P_VERSION] == 1) { |
|
| 1093 | 1093 | $the_conditions = array(); |
| 1094 | - foreach($conditions['where'] as $field_id => $field_value) { |
|
| 1094 | + foreach ($conditions['where'] as $field_id => $field_value) { |
|
| 1095 | 1095 | // Простое условие - $field_id = $field_value |
| 1096 | - if(is_string($field_id)) { |
|
| 1096 | + if (is_string($field_id)) { |
|
| 1097 | 1097 | $field_value = |
| 1098 | - $field_value === null ? 'NULL' : |
|
| 1099 | - (is_string($field_value) ? "'" . db_escape($field_value) . "'" : |
|
| 1100 | - (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
| 1098 | + $field_value === null ? 'NULL' : (is_string($field_value) ? "'" . db_escape($field_value) . "'" : (is_bool($field_value) ? intval($field_value) : $field_value)); |
|
| 1101 | 1099 | $the_conditions[] = "`{$field_id}` = {$field_value}"; |
| 1102 | 1100 | } else { |
| 1103 | 1101 | die('Неподдерживаемый тип условия'); |
@@ -1114,7 +1112,7 @@ discard block |
||
| 1114 | 1112 | $conditions[P_WHERE_STR] = implode(' AND ', $the_conditions); |
| 1115 | 1113 | } |
| 1116 | 1114 | |
| 1117 | - switch($conditions['action']) { |
|
| 1115 | + switch ($conditions['action']) { |
|
| 1118 | 1116 | case SQL_OP_DELETE: |
| 1119 | 1117 | $conditions[P_ACTION_STR] = ("DELETE FROM {{{$table_name}}}"); |
| 1120 | 1118 | break; |
@@ -1134,11 +1132,11 @@ discard block |
||
| 1134 | 1132 | |
| 1135 | 1133 | public static function db_changeset_apply($db_changeset, $flush_delayed = false) { |
| 1136 | 1134 | $result = true; |
| 1137 | - if(!is_array($db_changeset) || empty($db_changeset)) { |
|
| 1135 | + if (!is_array($db_changeset) || empty($db_changeset)) { |
|
| 1138 | 1136 | return $result; |
| 1139 | 1137 | } |
| 1140 | 1138 | |
| 1141 | - foreach($db_changeset as $table_name => &$table_data) { |
|
| 1139 | + foreach ($db_changeset as $table_name => &$table_data) { |
|
| 1142 | 1140 | // TODO - delayed changeset |
| 1143 | 1141 | /* |
| 1144 | 1142 | if(static::db_transaction_check(false) && !$flush_delayed && ($table_name == 'users' || $table_name == 'planets' || $table_name == 'unit')) |
@@ -1147,19 +1145,19 @@ discard block |
||
| 1147 | 1145 | continue; |
| 1148 | 1146 | } |
| 1149 | 1147 | */ |
| 1150 | - foreach($table_data as $record_id => &$conditions) { |
|
| 1148 | + foreach ($table_data as $record_id => &$conditions) { |
|
| 1151 | 1149 | static::db_changeset_condition_compile($conditions, $table_name); |
| 1152 | 1150 | |
| 1153 | - if($conditions['action'] != SQL_OP_DELETE && !$conditions[P_FIELDS_STR]) { |
|
| 1151 | + if ($conditions['action'] != SQL_OP_DELETE && !$conditions[P_FIELDS_STR]) { |
|
| 1154 | 1152 | continue; |
| 1155 | 1153 | } |
| 1156 | - if($conditions['action'] == SQL_OP_DELETE && !$conditions[P_WHERE_STR]) { |
|
| 1154 | + if ($conditions['action'] == SQL_OP_DELETE && !$conditions[P_WHERE_STR]) { |
|
| 1157 | 1155 | continue; |
| 1158 | 1156 | } // Защита от случайного удаления всех данных в таблице |
| 1159 | 1157 | |
| 1160 | - if($conditions[P_LOCATION] != LOC_NONE) { |
|
| 1158 | + if ($conditions[P_LOCATION] != LOC_NONE) { |
|
| 1161 | 1159 | //die('spec ops supernova.php line 928 Добавить работу с кэшем юнитов итд'); |
| 1162 | - switch($conditions['action']) { |
|
| 1160 | + switch ($conditions['action']) { |
|
| 1163 | 1161 | case SQL_OP_DELETE: |
| 1164 | 1162 | $result = self::db_del_record_list($conditions[P_LOCATION], $conditions[P_WHERE_STR]) && $result; |
| 1165 | 1163 | break; |
@@ -1241,13 +1239,13 @@ discard block |
||
| 1241 | 1239 | public static function init_0_prepare() { |
| 1242 | 1240 | // Отключаем magic_quotes |
| 1243 | 1241 | ini_get('magic_quotes_sybase') ? die('SN is incompatible with \'magic_quotes_sybase\' turned on. Disable it in php.ini or .htaccess...') : false; |
| 1244 | - if(@get_magic_quotes_gpc()) { |
|
| 1242 | + if (@get_magic_quotes_gpc()) { |
|
| 1245 | 1243 | $gpcr = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST); |
| 1246 | - array_walk_recursive($gpcr, function (&$value, $key) { |
|
| 1244 | + array_walk_recursive($gpcr, function(&$value, $key) { |
|
| 1247 | 1245 | $value = stripslashes($value); |
| 1248 | 1246 | }); |
| 1249 | 1247 | } |
| 1250 | - if(function_exists('set_magic_quotes_runtime')) { |
|
| 1248 | + if (function_exists('set_magic_quotes_runtime')) { |
|
| 1251 | 1249 | @set_magic_quotes_runtime(0); |
| 1252 | 1250 | @ini_set('magic_quotes_runtime', 0); |
| 1253 | 1251 | @ini_set('magic_quotes_sybase', 0); |
@@ -1325,7 +1323,7 @@ discard block |
||
| 1325 | 1323 | } |
| 1326 | 1324 | |
| 1327 | 1325 | public static function init_debug_state() { |
| 1328 | - if($_SERVER['SERVER_NAME'] == 'localhost' && !defined('BE_DEBUG')) { |
|
| 1326 | + if ($_SERVER['SERVER_NAME'] == 'localhost' && !defined('BE_DEBUG')) { |
|
| 1329 | 1327 | define('BE_DEBUG', true); |
| 1330 | 1328 | } |
| 1331 | 1329 | // define('DEBUG_SQL_ONLINE', true); // Полный дамп запросов в рил-тайме. Подойдет любое значение |
@@ -1337,7 +1335,7 @@ discard block |
||
| 1337 | 1335 | defined('DEBUG_SQL_ERROR') && !defined('DEBUG_SQL_COMMENT') ? define('DEBUG_SQL_COMMENT', true) : false; |
| 1338 | 1336 | defined('DEBUG_SQL_COMMENT_LONG') && !defined('DEBUG_SQL_COMMENT') ? define('DEBUG_SQL_COMMENT', true) : false; |
| 1339 | 1337 | |
| 1340 | - if(defined('BE_DEBUG') || static::$config->debug) { |
|
| 1338 | + if (defined('BE_DEBUG') || static::$config->debug) { |
|
| 1341 | 1339 | @define('BE_DEBUG', true); |
| 1342 | 1340 | @ini_set('display_errors', 1); |
| 1343 | 1341 | @error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED); |
@@ -573,7 +573,8 @@ discard block |
||
| 573 | 573 | $location_info = &static::$location_info[$location_type]; |
| 574 | 574 | $id_field = $location_info[P_ID]; |
| 575 | 575 | $table_name = $location_info[P_TABLE_NAME]; |
| 576 | - if($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ? |
|
| 576 | + if($result = static::db_query($q = "UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) { |
|
| 577 | + // TODO Как-то вернуть может быть LIMIT 1 ? |
|
| 577 | 578 | { |
| 578 | 579 | if(static::$db->db_affected_rows()) { |
| 579 | 580 | // Обновляем данные только если ряд был затронут |
@@ -581,6 +582,7 @@ discard block |
||
| 581 | 582 | |
| 582 | 583 | // Тут именно так, а не cache_unset - что бы в кэшах автоматически обновилась запись. Будет нужно на будущее |
| 583 | 584 | static::$data[$location_type][$record_id] = null; |
| 585 | + } |
|
| 584 | 586 | // Вытаскиваем обновленную запись |
| 585 | 587 | static::db_get_record_by_id($location_type, $record_id); |
| 586 | 588 | static::cache_clear($location_type, false); // Мягкий сброс - только $queries |
@@ -622,9 +624,11 @@ discard block |
||
| 622 | 624 | $set = trim($set); |
| 623 | 625 | $table_name = static::$location_info[$location_type][P_TABLE_NAME]; |
| 624 | 626 | if($result = static::db_query("INSERT INTO `{{{$table_name}}}` SET {$set}")) { |
| 625 | - if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 627 | + if(static::$db->db_affected_rows()) { |
|
| 628 | + // Обновляем данные только если ряд был затронут |
|
| 626 | 629 | { |
| 627 | 630 | $record_id = db_insert_id(); |
| 631 | + } |
|
| 628 | 632 | // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию" |
| 629 | 633 | $result = static::db_get_record_by_id($location_type, $record_id); |
| 630 | 634 | // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего |
@@ -669,10 +673,12 @@ discard block |
||
| 669 | 673 | $id_field = $location_info[P_ID]; |
| 670 | 674 | $table_name = $location_info[P_TABLE_NAME]; |
| 671 | 675 | if($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) { |
| 672 | - if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 676 | + if(static::$db->db_affected_rows()) { |
|
| 677 | + // Обновляем данные только если ряд был затронут |
|
| 673 | 678 | { |
| 674 | 679 | static::cache_unset($location_type, $safe_record_id); |
| 675 | 680 | } |
| 681 | + } |
|
| 676 | 682 | } |
| 677 | 683 | |
| 678 | 684 | return $result; |
@@ -689,12 +695,14 @@ discard block |
||
| 689 | 695 | //static::db_get_record_list($location_type, $condition, false, true); |
| 690 | 696 | |
| 691 | 697 | if($result = static::db_query("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) { |
| 692 | - if(static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут |
|
| 698 | + if(static::$db->db_affected_rows()) { |
|
| 699 | + // Обновляем данные только если ряд был затронут |
|
| 693 | 700 | { |
| 694 | 701 | // Обнуление кэша, потому что непонятно, что поменялось |
| 695 | 702 | // TODO - когда будет структурированный $condition можно будет делать только cache_unset по нужным записям |
| 696 | 703 | static::cache_clear($location_type); |
| 697 | 704 | } |
| 705 | + } |
|
| 698 | 706 | } |
| 699 | 707 | |
| 700 | 708 | return $result; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
| 3 | +if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) |
|
| 4 | 4 | { |
| 5 | 5 | $debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403); |
| 6 | 6 | } |
@@ -10,11 +10,11 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | // Changing rank for single user |
| 12 | 12 | $id_user = sys_get_param_id('id_user'); |
| 13 | -if(isset($_GET['id_rank'])) |
|
| 13 | +if (isset($_GET['id_rank'])) |
|
| 14 | 14 | { |
| 15 | 15 | $id_rank = sys_get_param_int('id_rank'); |
| 16 | 16 | } |
| 17 | -if($id_user && isset($id_rank) && $user_admin){ |
|
| 17 | +if ($id_user && isset($id_rank) && $user_admin) { |
|
| 18 | 18 | db_user_set_by_id($id_user, "`ally_rank_id` = {$id_rank}"); |
| 19 | 19 | } |
| 20 | 20 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | $sort1 = sys_get_param_int('sort1'); |
| 46 | -if($sort1>5 || $sort1<0) $sort1 = 0; |
|
| 46 | +if ($sort1 > 5 || $sort1 < 0) $sort1 = 0; |
|
| 47 | 47 | $sort1s = array( |
| 48 | 48 | 0 => '`ally_rank_id` %1$s;', |
| 49 | 49 | 1 => '`username` %1$s;', |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | 'id, username, galaxy, system, planet, onlinetime, ally_rank_id, ally_register_time, total_points'); |
| 60 | 60 | |
| 61 | 61 | // while ($userRow = db_fetch($userList)) |
| 62 | -foreach($userList as $userRow) |
|
| 62 | +foreach ($userList as $userRow) |
|
| 63 | 63 | { |
| 64 | 64 | $i++; |
| 65 | 65 | if (!isset($ranks[$userRow['ally_rank_id']])) |
@@ -69,17 +69,17 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | if ($ally['ally_owner'] == $userRow['id']) |
| 71 | 71 | { |
| 72 | - $ally_range = ($ally['ally_owner_range'])?$ally['ally_owner_range']:classLocale::$lang['Founder']; |
|
| 72 | + $ally_range = ($ally['ally_owner_range']) ? $ally['ally_owner_range'] : classLocale::$lang['Founder']; |
|
| 73 | 73 | } |
| 74 | 74 | else |
| 75 | 75 | { |
| 76 | - if($user_admin) |
|
| 76 | + if ($user_admin) |
|
| 77 | 77 | { |
| 78 | 78 | $ally_range = '<select onchange="window.location=\'alliance.php?mode=admin&edit=members&id_user=' . $userRow['id'] . '&id_rank=\' + this.value">'; |
| 79 | 79 | |
| 80 | - foreach($ranks as $rankID => $rankArray){ |
|
| 80 | + foreach ($ranks as $rankID => $rankArray) { |
|
| 81 | 81 | $ally_range .= '<option value="' . $rankID . '"'; |
| 82 | - if($rankID == $userRow['ally_rank_id']) |
|
| 82 | + if ($rankID == $userRow['ally_rank_id']) |
|
| 83 | 83 | $ally_range .= " selected"; |
| 84 | 84 | $ally_range .= '>' . $rankArray['name']; |
| 85 | 85 | $ally_range .= '</option>'; |
@@ -93,9 +93,9 @@ discard block |
||
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $last_active = time() - $userRow["onlinetime"]; |
| 96 | - if($user_admin) |
|
| 96 | + if ($user_admin) |
|
| 97 | 97 | { |
| 98 | - if ( $last_active < 60 ) |
|
| 98 | + if ($last_active < 60) |
|
| 99 | 99 | { |
| 100 | 100 | $tmp = "lime>{$lang['On']}"; |
| 101 | 101 | } |
@@ -106,12 +106,12 @@ discard block |
||
| 106 | 106 | } |
| 107 | 107 | elseif ($last_active < 60 * 60 * 24) |
| 108 | 108 | { |
| 109 | - $last_active = round( $last_active / (60 * 60)); |
|
| 109 | + $last_active = round($last_active / (60 * 60)); |
|
| 110 | 110 | $tmp = "green>{$last_active} {$lang['sys_hrs_short']}"; |
| 111 | 111 | } |
| 112 | 112 | else |
| 113 | 113 | { |
| 114 | - $last_active = round( $last_active / (60 * 60 * 24)); |
|
| 114 | + $last_active = round($last_active / (60 * 60 * 24)); |
|
| 115 | 115 | if ($last_active < 7) |
| 116 | 116 | { |
| 117 | 117 | $tmp = "yellow"; |
@@ -129,9 +129,9 @@ discard block |
||
| 129 | 129 | } |
| 130 | 130 | else |
| 131 | 131 | { |
| 132 | - if($user_onlinestatus) |
|
| 132 | + if ($user_onlinestatus) |
|
| 133 | 133 | { |
| 134 | - if ( $last_active < 60 * 5 ) |
|
| 134 | + if ($last_active < 60 * 5) |
|
| 135 | 135 | { |
| 136 | 136 | $tmp = "lime>{$lang['On']}"; |
| 137 | 137 | } |
@@ -14,24 +14,24 @@ discard block |
||
| 14 | 14 | function sn_function_call($func_name, $func_arg = array()) { |
| 15 | 15 | // All data in classSupernova::$functions should be normalized to valid 'callable' state: '<function_name>'|array('<object_name>', '<method_name>') |
| 16 | 16 | |
| 17 | - if(is_array(classSupernova::$functions[$func_name]) && !is_callable(classSupernova::$functions[$func_name])) { |
|
| 17 | + if (is_array(classSupernova::$functions[$func_name]) && !is_callable(classSupernova::$functions[$func_name])) { |
|
| 18 | 18 | // Chain-callable functions should be made as following: |
| 19 | 19 | // 1. Never use incomplete calls with parameters "by default" |
| 20 | 20 | // 2. Reserve last parameter for cumulative result |
| 21 | 21 | // 3. Use same format for original value and cumulative result (if there is original value) |
| 22 | 22 | // 4. Honor cumulative result |
| 23 | 23 | // 5. Return cumulative result |
| 24 | - foreach(classSupernova::$functions[$func_name] as $func_chain_name) { |
|
| 24 | + foreach (classSupernova::$functions[$func_name] as $func_chain_name) { |
|
| 25 | 25 | // По идее - это уже тут не нужно, потому что оно все должно быть callable к этому моменту |
| 26 | 26 | // Но для старых модулей... |
| 27 | - if(is_callable($func_chain_name)) { |
|
| 27 | + if (is_callable($func_chain_name)) { |
|
| 28 | 28 | $result = call_user_func_array($func_chain_name, $func_arg); |
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | } else { |
| 32 | 32 | // TODO: This is left for backward compatibility. Appropriate code should be rewrote! |
| 33 | 33 | $func_name = isset(classSupernova::$functions[$func_name]) && is_callable(classSupernova::$functions[$func_name]) ? classSupernova::$functions[$func_name] : ('sn_' . $func_name); |
| 34 | - if(is_callable($func_name)) { |
|
| 34 | + if (is_callable($func_name)) { |
|
| 35 | 35 | $result = call_user_func_array($func_name, $func_arg); |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | * @param string $page_name - имя страницы, для которого должен был быть выполнен хук |
| 47 | 47 | */ |
| 48 | 48 | function execute_hooks(&$hook_list, &$template, $hook_type = null, $page_name = null) { |
| 49 | - if(!empty($hook_list)) { |
|
| 50 | - foreach($hook_list as $hook) { |
|
| 51 | - if(is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) { |
|
| 49 | + if (!empty($hook_list)) { |
|
| 50 | + foreach ($hook_list as $hook) { |
|
| 51 | + if (is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) { |
|
| 52 | 52 | $template = call_user_func($hook_call, $template, $hook_type, $page_name); |
| 53 | 53 | } |
| 54 | 54 | } |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | function pretty_number($n, $floor = true, $color = false, $limit = false, $style = null) { |
| 150 | 150 | $n = floatval($n); |
| 151 | - if(is_int($floor)) { |
|
| 151 | + if (is_int($floor)) { |
|
| 152 | 152 | $n = round($n, $floor); // , PHP_ROUND_HALF_DOWN |
| 153 | - } elseif($floor === true) { |
|
| 153 | + } elseif ($floor === true) { |
|
| 154 | 154 | $n = floor($n); |
| 155 | 155 | $floor = 0; |
| 156 | 156 | } else { |
@@ -160,14 +160,14 @@ discard block |
||
| 160 | 160 | $ret = $n; |
| 161 | 161 | |
| 162 | 162 | $suffix = ''; |
| 163 | - if($limit) { |
|
| 164 | - if($ret > 0) { |
|
| 165 | - while($ret > $limit) { |
|
| 163 | + if ($limit) { |
|
| 164 | + if ($ret > 0) { |
|
| 165 | + while ($ret > $limit) { |
|
| 166 | 166 | $suffix .= 'k'; |
| 167 | 167 | $ret = round($ret / 1000); |
| 168 | 168 | } |
| 169 | 169 | } else { |
| 170 | - while($ret < -$limit) { |
|
| 170 | + while ($ret < -$limit) { |
|
| 171 | 171 | $suffix .= 'k'; |
| 172 | 172 | $ret = round($ret / 1000); |
| 173 | 173 | } |
@@ -177,16 +177,16 @@ discard block |
||
| 177 | 177 | $ret = number_format($ret, $floor, ',', '.'); |
| 178 | 178 | $ret .= $suffix; |
| 179 | 179 | |
| 180 | - if($color !== false) { |
|
| 181 | - if($color === true) { |
|
| 180 | + if ($color !== false) { |
|
| 181 | + if ($color === true) { |
|
| 182 | 182 | $class = $n == 0 ? 'zero' : ($n > 0 ? 'positive' : 'negative'); |
| 183 | - } elseif($color >= 0) { |
|
| 183 | + } elseif ($color >= 0) { |
|
| 184 | 184 | $class = $n == $color ? 'zero' : ($n < $color ? 'positive' : 'negative'); |
| 185 | 185 | } else { |
| 186 | 186 | $class = ($n == -$color) ? 'zero' : ($n < -$color ? 'negative' : 'positive'); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - if(!isset($style)) { |
|
| 189 | + if (!isset($style)) { |
|
| 190 | 190 | $ret = "<span class='{$class}'>{$ret}</span>"; |
| 191 | 191 | } else { |
| 192 | 192 | $ret = $style ? $ret = $class : $ret = array('text' => $ret, 'class' => $class); |
@@ -311,11 +311,11 @@ discard block |
||
| 311 | 311 | |
| 312 | 312 | function sys_get_param_phone($param_name, $default = '') { |
| 313 | 313 | $phone_raw = sys_get_param_str_unsafe($param_name, $default = ''); |
| 314 | - if($phone_raw) { |
|
| 314 | + if ($phone_raw) { |
|
| 315 | 315 | $phone = $phone_raw[0] == '+' ? '+' : ''; |
| 316 | - for($i = 0; $i < strlen($phone_raw); $i++) { |
|
| 316 | + for ($i = 0; $i < strlen($phone_raw); $i++) { |
|
| 317 | 317 | $ord = ord($phone_raw[$i]); |
| 318 | - if($ord >= 48 && $ord <= 57) { |
|
| 318 | + if ($ord >= 48 && $ord <= 57) { |
|
| 319 | 319 | $phone .= $phone_raw[$i]; |
| 320 | 320 | } |
| 321 | 321 | } |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | function CheckAbandonPlanetState(&$planet) { |
| 335 | - if($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) { |
|
| 335 | + if ($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) { |
|
| 336 | 336 | db_planet_delete_by_id($planet['id']); |
| 337 | 337 | } |
| 338 | 338 | } |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | global $config; |
| 342 | 342 | |
| 343 | 343 | static $rate, $sn_group_resources_all, $sn_group_resources_loot; |
| 344 | - if(!$rate) { |
|
| 344 | + if (!$rate) { |
|
| 345 | 345 | $sn_group_resources_all = sn_get_groups('resources_all'); |
| 346 | 346 | $sn_group_resources_loot = sn_get_groups('resources_loot'); |
| 347 | 347 | |
@@ -351,19 +351,19 @@ discard block |
||
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | $unit_cost_data = get_unit_param($unit_id, 'cost'); |
| 354 | - if(!is_array($unit_cost_data)) { |
|
| 354 | + if (!is_array($unit_cost_data)) { |
|
| 355 | 355 | return array('total' => 0); |
| 356 | 356 | } |
| 357 | 357 | $factor = isset($unit_cost_data['factor']) ? $unit_cost_data['factor'] : 1; |
| 358 | 358 | $cost_array = array(BUILD_CREATE => array(), 'total' => 0); |
| 359 | 359 | $unit_level = $unit_level > 0 ? $unit_level : 0; |
| 360 | - foreach($unit_cost_data as $resource_id => $resource_amount) { |
|
| 361 | - if(!in_array($resource_id, $sn_group_resources_all)) { |
|
| 360 | + foreach ($unit_cost_data as $resource_id => $resource_amount) { |
|
| 361 | + if (!in_array($resource_id, $sn_group_resources_all)) { |
|
| 362 | 362 | continue; |
| 363 | 363 | } |
| 364 | 364 | // $cost_array[BUILD_CREATE][$resource_id] = $resource_amount * ($factor == 1 ? $unit_level : ((pow($factor, $unit_level) - $factor) / ($factor - 1))); |
| 365 | 365 | $cost_array[BUILD_CREATE][$resource_id] = round($resource_amount * ($factor == 1 ? $unit_level : ((1 - pow($factor, $unit_level)) / (1 - $factor)))); |
| 366 | - if(in_array($resource_id, $sn_group_resources_loot)) { |
|
| 366 | + if (in_array($resource_id, $sn_group_resources_loot)) { |
|
| 367 | 367 | $cost_array['total'] += $cost_array[BUILD_CREATE][$resource_id] * $rate[$resource_id]; |
| 368 | 368 | } |
| 369 | 369 | } |
@@ -438,19 +438,19 @@ discard block |
||
| 438 | 438 | $mercenary_level = 0; |
| 439 | 439 | $unit_db_name = pname_resource_name($unit_id); |
| 440 | 440 | |
| 441 | - if(in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { |
|
| 441 | + if (in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) { |
|
| 442 | 442 | $unit = classSupernova::db_get_unit_by_location($user['id'], LOC_USER, $user['id'], $unit_id); |
| 443 | 443 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0; |
| 444 | - } elseif(in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { |
|
| 444 | + } elseif (in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) { |
|
| 445 | 445 | $unit = classSupernova::db_get_unit_by_location(is_array($user) ? $user['id'] : $planet['id_owner'], LOC_PLANET, $planet['id'], $unit_id); |
| 446 | 446 | $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0; |
| 447 | - } elseif(in_array($unit_id, sn_get_groups('governors'))) { |
|
| 447 | + } elseif (in_array($unit_id, sn_get_groups('governors'))) { |
|
| 448 | 448 | $mercenary_level = $unit_id == $planet['PLANET_GOVERNOR_ID'] ? $planet['PLANET_GOVERNOR_LEVEL'] : 0; |
| 449 | - } elseif($unit_id == RES_DARK_MATTER) { |
|
| 449 | + } elseif ($unit_id == RES_DARK_MATTER) { |
|
| 450 | 450 | $mercenary_level = $user[$unit_db_name] + ($plain || $user['user_as_ally'] ? 0 : classSupernova::$auth->account->account_metamatter); |
| 451 | - } elseif($unit_id == RES_METAMATTER) { |
|
| 451 | + } elseif ($unit_id == RES_METAMATTER) { |
|
| 452 | 452 | $mercenary_level = classSupernova::$auth->account->account_metamatter; //$user[$unit_db_name]; |
| 453 | - } elseif(in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { |
|
| 453 | + } elseif (in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) { |
|
| 454 | 454 | $mercenary_level = !empty($planet) ? $planet[$unit_db_name] : $user[$unit_db_name]; |
| 455 | 455 | } |
| 456 | 456 | |
@@ -460,19 +460,19 @@ discard block |
||
| 460 | 460 | function mrc_modify_value(&$user, $planet = array(), $mercenaries, $value) { return sn_function_call(__FUNCTION__, array(&$user, $planet, $mercenaries, $value)); } |
| 461 | 461 | |
| 462 | 462 | function sn_mrc_modify_value(&$user, $planet = array(), $mercenaries, $value, $base_value = null) { |
| 463 | - if(!is_array($mercenaries)) { |
|
| 463 | + if (!is_array($mercenaries)) { |
|
| 464 | 464 | $mercenaries = array($mercenaries); |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | $base_value = isset($base_value) ? $base_value : $value; |
| 468 | 468 | |
| 469 | - foreach($mercenaries as $mercenary_id) { |
|
| 469 | + foreach ($mercenaries as $mercenary_id) { |
|
| 470 | 470 | $mercenary_level = mrc_get_level($user, $planet, $mercenary_id); |
| 471 | 471 | |
| 472 | 472 | $mercenary = get_unit_param($mercenary_id); |
| 473 | 473 | $mercenary_bonus = $mercenary['bonus']; |
| 474 | 474 | |
| 475 | - switch($mercenary['bonus_type']) { |
|
| 475 | + switch ($mercenary['bonus_type']) { |
|
| 476 | 476 | case BONUS_PERCENT_CUMULATIVE: |
| 477 | 477 | $value *= 1 + $mercenary_level * $mercenary_bonus / 100; |
| 478 | 478 | break; |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | $allowed_length = strlen($allowed_chars); |
| 504 | 504 | |
| 505 | 505 | $random_string = ''; |
| 506 | - for($i = 0; $i < $length; $i++) { |
|
| 506 | + for ($i = 0; $i < $length; $i++) { |
|
| 507 | 507 | $random_string .= $allowed_chars[mt_rand(0, $allowed_length - 1)]; |
| 508 | 508 | } |
| 509 | 509 | |
@@ -523,12 +523,12 @@ discard block |
||
| 523 | 523 | |
| 524 | 524 | $options = ''; |
| 525 | 525 | $option_list = array(); |
| 526 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
| 526 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
| 527 | 527 | $option_list[$option_group_id] = array(); |
| 528 | - foreach($option_group as $option_name => $option_value) { |
|
| 529 | - if(!isset($user[$option_name])) { |
|
| 528 | + foreach ($option_group as $option_name => $option_value) { |
|
| 529 | + if (!isset($user[$option_name])) { |
|
| 530 | 530 | $user[$option_name] = $option_value; |
| 531 | - } elseif($user[$option_name] == '') { |
|
| 531 | + } elseif ($user[$option_name] == '') { |
|
| 532 | 532 | $user[$option_name] = 0; |
| 533 | 533 | } |
| 534 | 534 | $options .= "{$option_name}^{$user[$option_name]}|"; |
@@ -548,16 +548,16 @@ discard block |
||
| 548 | 548 | $option_list = array(); |
| 549 | 549 | $option_string_list = explode('|', $user['options']); |
| 550 | 550 | |
| 551 | - foreach($option_string_list as $option_string) { |
|
| 551 | + foreach ($option_string_list as $option_string) { |
|
| 552 | 552 | list($option_name, $option_value) = explode('^', $option_string); |
| 553 | 553 | $option_list[$option_name] = $option_value; |
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | $final_list = array(); |
| 557 | - foreach($user_option_list as $option_group_id => $option_group) { |
|
| 557 | + foreach ($user_option_list as $option_group_id => $option_group) { |
|
| 558 | 558 | $final_list[$option_group_id] = array(); |
| 559 | - foreach($option_group as $option_name => $option_value) { |
|
| 560 | - if(!isset($option_list[$option_name])) { |
|
| 559 | + foreach ($option_group as $option_name => $option_value) { |
|
| 560 | + if (!isset($option_list[$option_name])) { |
|
| 561 | 561 | $option_list[$option_name] = $option_value; |
| 562 | 562 | } |
| 563 | 563 | $user[$option_name] = $final_list[$option_group_id][$option_name] = $option_list[$option_name]; |
@@ -571,12 +571,12 @@ discard block |
||
| 571 | 571 | |
| 572 | 572 | function sys_unit_str2arr($fleet_string) { |
| 573 | 573 | $fleet_array = array(); |
| 574 | - if(!empty($fleet_string)) { |
|
| 574 | + if (!empty($fleet_string)) { |
|
| 575 | 575 | $arrTemp = explode(';', $fleet_string); |
| 576 | - foreach($arrTemp as $temp) { |
|
| 577 | - if($temp) { |
|
| 576 | + foreach ($arrTemp as $temp) { |
|
| 577 | + if ($temp) { |
|
| 578 | 578 | $temp = explode(',', $temp); |
| 579 | - if(!empty($temp[0]) && !empty($temp[1])) { |
|
| 579 | + if (!empty($temp[0]) && !empty($temp[1])) { |
|
| 580 | 580 | $fleet_array[$temp[0]] += $temp[1]; |
| 581 | 581 | } |
| 582 | 582 | } |
@@ -588,13 +588,13 @@ discard block |
||
| 588 | 588 | |
| 589 | 589 | function sys_unit_arr2str($unit_list) { |
| 590 | 590 | $fleet_string = array(); |
| 591 | - if(isset($unit_list)) { |
|
| 592 | - if(!is_array($unit_list)) { |
|
| 591 | + if (isset($unit_list)) { |
|
| 592 | + if (!is_array($unit_list)) { |
|
| 593 | 593 | $unit_list = array($unit_list => 1); |
| 594 | 594 | } |
| 595 | 595 | |
| 596 | - foreach($unit_list as $unit_id => $unit_count) { |
|
| 597 | - if($unit_id && $unit_count) { |
|
| 596 | + foreach ($unit_list as $unit_id => $unit_count) { |
|
| 597 | + if ($unit_id && $unit_count) { |
|
| 598 | 598 | $fleet_string[] = "{$unit_id},{$unit_count}"; |
| 599 | 599 | } |
| 600 | 600 | } |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | $body = str_replace("\r\n", "\n", $body); |
| 622 | 622 | $body = str_replace("\n", "\r\n", $body); |
| 623 | 623 | |
| 624 | - if($html) { |
|
| 624 | + if ($html) { |
|
| 625 | 625 | $body = '<html><head><base href="' . SN_ROOT_VIRTUAL . '"></head><body>' . nl2br($body) . '</body></html>'; |
| 626 | 626 | } |
| 627 | 627 | |
@@ -665,21 +665,21 @@ discard block |
||
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | function sn_ali_fill_user_ally(&$user) { |
| 668 | - if(!$user['ally_id']) { |
|
| 668 | + if (!$user['ally_id']) { |
|
| 669 | 669 | return; |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | - if(!isset($user['ally'])) { |
|
| 672 | + if (!isset($user['ally'])) { |
|
| 673 | 673 | $user['ally'] = db_ally_get_by_id($user['ally_id']); |
| 674 | 674 | } |
| 675 | 675 | |
| 676 | - if(!isset($user['ally']['player'])) { |
|
| 676 | + if (!isset($user['ally']['player'])) { |
|
| 677 | 677 | $user['ally']['player'] = db_user_by_id($user['ally']['ally_user_id'], true, '*', false); |
| 678 | 678 | } |
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | function sn_get_url_contents($url) { |
| 682 | - if(function_exists('curl_init')) { |
|
| 682 | + if (function_exists('curl_init')) { |
|
| 683 | 683 | $crl = curl_init(); |
| 684 | 684 | $timeout = 5; |
| 685 | 685 | curl_setopt($crl, CURLOPT_URL, $url); |
@@ -714,10 +714,10 @@ discard block |
||
| 714 | 714 | |
| 715 | 715 | function get_ship_data($ship_id, $user) { |
| 716 | 716 | $ship_data = array(); |
| 717 | - if(in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { |
|
| 718 | - foreach(get_unit_param($ship_id, 'engine') as $engine_info) { |
|
| 717 | + if (in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) { |
|
| 718 | + foreach (get_unit_param($ship_id, 'engine') as $engine_info) { |
|
| 719 | 719 | $tech_level = intval(mrc_get_level($user, false, $engine_info['tech'])); |
| 720 | - if(empty($ship_data) || $tech_level >= $engine_info['min_level']) { |
|
| 720 | + if (empty($ship_data) || $tech_level >= $engine_info['min_level']) { |
|
| 721 | 721 | $ship_data = $engine_info; |
| 722 | 722 | $ship_data['tech_level'] = $tech_level; |
| 723 | 723 | } |
@@ -729,7 +729,7 @@ discard block |
||
| 729 | 729 | return $ship_data; |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | -if(!function_exists('strptime')) { |
|
| 732 | +if (!function_exists('strptime')) { |
|
| 733 | 733 | function strptime($date, $format) { |
| 734 | 734 | $masks = array( |
| 735 | 735 | '%d' => '(?P<d>[0-9]{2})', |
@@ -742,12 +742,12 @@ discard block |
||
| 742 | 742 | ); |
| 743 | 743 | |
| 744 | 744 | $rexep = "#" . strtr(preg_quote($format), $masks) . "#"; |
| 745 | - if(preg_match($rexep, $date, $out)) { |
|
| 745 | + if (preg_match($rexep, $date, $out)) { |
|
| 746 | 746 | $ret = array( |
| 747 | - "tm_sec" => (int)$out['S'], |
|
| 748 | - "tm_min" => (int)$out['M'], |
|
| 749 | - "tm_hour" => (int)$out['H'], |
|
| 750 | - "tm_mday" => (int)$out['d'], |
|
| 747 | + "tm_sec" => (int) $out['S'], |
|
| 748 | + "tm_min" => (int) $out['M'], |
|
| 749 | + "tm_hour" => (int) $out['H'], |
|
| 750 | + "tm_mday" => (int) $out['d'], |
|
| 751 | 751 | "tm_mon" => $out['m'] ? $out['m'] - 1 : 0, |
| 752 | 752 | "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0, |
| 753 | 753 | ); |
@@ -762,7 +762,7 @@ discard block |
||
| 762 | 762 | function sn_sys_sector_buy($redirect = 'overview.php') { |
| 763 | 763 | global $user, $planetrow; |
| 764 | 764 | |
| 765 | - if(!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { |
|
| 765 | + if (!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) { |
|
| 766 | 766 | return; |
| 767 | 767 | } |
| 768 | 768 | |
@@ -775,9 +775,9 @@ discard block |
||
| 775 | 775 | // $planetrow = $planetrow['planet']; |
| 776 | 776 | $sector_cost = eco_get_build_data($user, $planetrow, UNIT_SECTOR, mrc_get_level($user, $planetrow, UNIT_SECTOR), true); |
| 777 | 777 | $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER]; |
| 778 | - if($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { |
|
| 778 | + if ($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) { |
|
| 779 | 779 | $planet_name_text = uni_render_planet($planetrow); |
| 780 | - if(rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf(classLocale::$lang['sys_sector_purchase_log'], |
|
| 780 | + if (rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf(classLocale::$lang['sys_sector_purchase_log'], |
|
| 781 | 781 | $user['username'], $user['id'], $planet_name_text, classLocale::$lang['sys_planet_type'][$planetrow['planet_type']], $planetrow['id'], $sector_cost) |
| 782 | 782 | )) { |
| 783 | 783 | $sector_db_name = pname_resource_name(UNIT_SECTOR); |
@@ -792,30 +792,30 @@ discard block |
||
| 792 | 792 | } |
| 793 | 793 | |
| 794 | 794 | function sn_sys_handler_add(&$functions, $handler_list, $class_module_name = '', $sub_type = '') { |
| 795 | - if(isset($handler_list) && is_array($handler_list) && !empty($handler_list)) { |
|
| 796 | - foreach($handler_list as $function_name => $function_data) { |
|
| 797 | - if(is_string($function_data)) { |
|
| 795 | + if (isset($handler_list) && is_array($handler_list) && !empty($handler_list)) { |
|
| 796 | + foreach ($handler_list as $function_name => $function_data) { |
|
| 797 | + if (is_string($function_data)) { |
|
| 798 | 798 | $override_with = &$function_data; |
| 799 | - } elseif(isset($function_data['callable'])) { |
|
| 799 | + } elseif (isset($function_data['callable'])) { |
|
| 800 | 800 | $override_with = &$function_data['callable']; |
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | $overwrite = $override_with[0] == '*'; |
| 804 | - if($overwrite) { |
|
| 804 | + if ($overwrite) { |
|
| 805 | 805 | $override_with = substr($override_with, 1); |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | - if(($point_position = strpos($override_with, '.')) === false && $class_module_name) { |
|
| 808 | + if (($point_position = strpos($override_with, '.')) === false && $class_module_name) { |
|
| 809 | 809 | $override_with = array($class_module_name, $override_with); |
| 810 | - } elseif($point_position == 0) { |
|
| 810 | + } elseif ($point_position == 0) { |
|
| 811 | 811 | $override_with = substr($override_with, 1); |
| 812 | - } elseif($point_position > 0) { |
|
| 812 | + } elseif ($point_position > 0) { |
|
| 813 | 813 | $override_with = array(substr($override_with, 0, $point_position), substr($override_with, $point_position + 1)); |
| 814 | 814 | } |
| 815 | 815 | |
| 816 | - if($overwrite) { |
|
| 816 | + if ($overwrite) { |
|
| 817 | 817 | $functions[$function_name] = array(); |
| 818 | - } elseif(!isset($functions[$function_name])) { |
|
| 818 | + } elseif (!isset($functions[$function_name])) { |
|
| 819 | 819 | $functions[$function_name] = array(); |
| 820 | 820 | $sn_function_name = 'sn_' . $function_name . ($sub_type ? '_' . $sub_type : ''); |
| 821 | 821 | $functions[$function_name][] = $sn_function_name; |
@@ -831,15 +831,15 @@ discard block |
||
| 831 | 831 | function player_nick_render_to_html($result, $options = false) { |
| 832 | 832 | // TODO - обрабатывать разные случаи: $user, $render_nick_array, $string |
| 833 | 833 | |
| 834 | - if(is_string($result) && strpos($result, ':{i:')) { |
|
| 834 | + if (is_string($result) && strpos($result, ':{i:')) { |
|
| 835 | 835 | $result = player_nick_uncompact($result); |
| 836 | 836 | } |
| 837 | 837 | |
| 838 | - if(is_array($result)) { |
|
| 839 | - if(isset($result['id'])) { |
|
| 838 | + if (is_array($result)) { |
|
| 839 | + if (isset($result['id'])) { |
|
| 840 | 840 | $result = player_nick_render_current_to_array($result, $options); |
| 841 | 841 | } |
| 842 | - if(!isset($result[NICK_HTML])) { |
|
| 842 | + if (!isset($result[NICK_HTML])) { |
|
| 843 | 843 | $result = player_nick_render_array_to_html($result); |
| 844 | 844 | } |
| 845 | 845 | unset($result[NICK_HTML]); |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | try { |
| 863 | 863 | $result = unserialize($nick_string); |
| 864 | 864 | // ksort($result); // Всегда ksort-ый в player_nick_compact() |
| 865 | - } catch(exception $e) { |
|
| 865 | + } catch (exception $e) { |
|
| 866 | 866 | $result = strpos($nick_string, ':{i:') ? null : $nick_string; // fallback if it is already string - for old chat strings, for example |
| 867 | 867 | } |
| 868 | 868 | |
@@ -875,20 +875,20 @@ discard block |
||
| 875 | 875 | global $config, $user; |
| 876 | 876 | |
| 877 | 877 | // ALL STRING ARE UNSAFE!!! |
| 878 | - if(isset($nick_array[NICK_BIRTHSDAY])) { |
|
| 878 | + if (isset($nick_array[NICK_BIRTHSDAY])) { |
|
| 879 | 879 | $result[NICK_BIRTHSDAY] = '<img src="design/images/birthday.png" />'; |
| 880 | 880 | } |
| 881 | 881 | |
| 882 | - if(isset($nick_array[NICK_VACATION])) { |
|
| 882 | + if (isset($nick_array[NICK_VACATION])) { |
|
| 883 | 883 | $result[NICK_VACATION] = '<img src="design/images/icon_vacation.png" />'; |
| 884 | 884 | } |
| 885 | 885 | |
| 886 | - if(isset($nick_array[NICK_GENDER])) { |
|
| 886 | + if (isset($nick_array[NICK_GENDER])) { |
|
| 887 | 887 | $result[NICK_GENDER] = '<img src="' . ($user['dpath'] ? $user['dpath'] : DEFAULT_SKINPATH) . 'images/gender_' . $nick_array[NICK_GENDER] . '.png" />'; |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | - if(isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { |
|
| 891 | - switch($nick_array[NICK_AUTH_LEVEL]) { |
|
| 890 | + if (isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) { |
|
| 891 | + switch ($nick_array[NICK_AUTH_LEVEL]) { |
|
| 892 | 892 | case 4: |
| 893 | 893 | $highlight = $config->chat_highlight_developer; |
| 894 | 894 | break; |
@@ -909,20 +909,20 @@ discard block |
||
| 909 | 909 | $highlight = isset($nick_array[NICK_PREMIUM]) ? $config->chat_highlight_premium : ''; |
| 910 | 910 | } |
| 911 | 911 | |
| 912 | - if($highlight) { |
|
| 912 | + if ($highlight) { |
|
| 913 | 913 | list($result[NICK_HIGHLIGHT], $result[NICK_HIGHLIGHT_END]) = explode('$1', $highlight); |
| 914 | 914 | } |
| 915 | 915 | // $result = preg_replace("#(.+)#", $highlight, $result); |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | - if(isset($nick_array[NICK_CLASS])) { |
|
| 918 | + if (isset($nick_array[NICK_CLASS])) { |
|
| 919 | 919 | $result[NICK_CLASS] = '<span ' . $nick_array[NICK_CLASS] . '>'; |
| 920 | 920 | $result[NICK_CLASS_END] = '</span>'; |
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | $result[NICK_NICK] = sys_safe_output($nick_array[NICK_NICK]); |
| 924 | 924 | |
| 925 | - if(isset($nick_array[NICK_ALLY])) { |
|
| 925 | + if (isset($nick_array[NICK_ALLY])) { |
|
| 926 | 926 | $result[NICK_ALLY] = '[' . sys_safe_output($nick_array[NICK_ALLY]) . ']'; |
| 927 | 927 | } |
| 928 | 928 | |
@@ -946,32 +946,32 @@ discard block |
||
| 946 | 946 | */ |
| 947 | 947 | |
| 948 | 948 | |
| 949 | - if($render_user['user_birthday'] && ($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) { |
|
| 949 | + if ($render_user['user_birthday'] && ($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) { |
|
| 950 | 950 | $result[NICK_BIRTHSDAY] = ''; |
| 951 | 951 | } |
| 952 | 952 | |
| 953 | - if($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { |
|
| 953 | + if ($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) { |
|
| 954 | 954 | $result[NICK_GENDER] = $render_user['gender'] == GENDER_UNKNOWN ? 'unknown' : ($render_user['gender'] == GENDER_FEMALE ? 'female' : 'male'); |
| 955 | 955 | } |
| 956 | 956 | |
| 957 | - if(($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
|
| 957 | + if (($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) { |
|
| 958 | 958 | $result[NICK_VACATION] = $render_user['vacation']; |
| 959 | 959 | } |
| 960 | 960 | |
| 961 | - if($options === true || (isset($options['color']) && $options['color'])) { |
|
| 962 | - if($user_auth_level = $render_user['authlevel']) { |
|
| 961 | + if ($options === true || (isset($options['color']) && $options['color'])) { |
|
| 962 | + if ($user_auth_level = $render_user['authlevel']) { |
|
| 963 | 963 | $result[NICK_AUTH_LEVEL] = $user_auth_level; |
| 964 | 964 | } |
| 965 | - if($user_premium = mrc_get_level($render_user, false, UNIT_PREMIUM)) { |
|
| 965 | + if ($user_premium = mrc_get_level($render_user, false, UNIT_PREMIUM)) { |
|
| 966 | 966 | $result[NICK_PREMIUM] = $user_premium; |
| 967 | 967 | } |
| 968 | 968 | } |
| 969 | 969 | |
| 970 | - if((isset($options['class']) && $options['class'])) { |
|
| 970 | + if ((isset($options['class']) && $options['class'])) { |
|
| 971 | 971 | $result[NICK_CLASS] = (isset($result_options[NICK_CLASS]) ? ' ' . $result_options[NICK_CLASS] : '') . $options['class']; |
| 972 | 972 | } |
| 973 | 973 | |
| 974 | - if($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
|
| 974 | + if ($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) { |
|
| 975 | 975 | $result[NICK_ALLY] = $render_user['ally_tag']; |
| 976 | 976 | } |
| 977 | 977 | |
@@ -989,25 +989,25 @@ discard block |
||
| 989 | 989 | |
| 990 | 990 | $user_skip_list = array(); |
| 991 | 991 | |
| 992 | - if($config->stats_hide_admins) { |
|
| 992 | + if ($config->stats_hide_admins) { |
|
| 993 | 993 | $user_skip_list[] = '`authlevel` > 0'; |
| 994 | 994 | } |
| 995 | 995 | |
| 996 | - if($config->stats_hide_player_list) { |
|
| 996 | + if ($config->stats_hide_player_list) { |
|
| 997 | 997 | $temp = explode(',', $config->stats_hide_player_list); |
| 998 | - foreach($temp as $user_id) { |
|
| 998 | + foreach ($temp as $user_id) { |
|
| 999 | 999 | $user_id = floatval($user_id); |
| 1000 | - if($user_id) { |
|
| 1000 | + if ($user_id) { |
|
| 1001 | 1001 | $user_skip_list[] = '`id` = ' . $user_id; |
| 1002 | 1002 | } |
| 1003 | 1003 | } |
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | - if(!empty($user_skip_list)) { |
|
| 1006 | + if (!empty($user_skip_list)) { |
|
| 1007 | 1007 | $user_skip_list = implode(' OR ', $user_skip_list); |
| 1008 | 1008 | $user_skip_query = db_user_list($user_skip_list); |
| 1009 | - if(!empty($user_skip_query)) { |
|
| 1010 | - foreach($user_skip_query as $user_skip_row) { |
|
| 1009 | + if (!empty($user_skip_query)) { |
|
| 1010 | + foreach ($user_skip_query as $user_skip_row) { |
|
| 1011 | 1011 | $result[$user_skip_row['id']] = $user_skip_row['id']; |
| 1012 | 1012 | } |
| 1013 | 1013 | } |
@@ -1038,7 +1038,7 @@ discard block |
||
| 1038 | 1038 | |
| 1039 | 1039 | function sn_sn_get_groups($groups, &$result) { |
| 1040 | 1040 | $result = is_array($result) ? $result : array(); |
| 1041 | - foreach($groups = is_array($groups) ? $groups : array($groups) as $group_name) { |
|
| 1041 | + foreach ($groups = is_array($groups) ? $groups : array($groups) as $group_name) { |
|
| 1042 | 1042 | $result += is_array($a_group = get_unit_param(UNIT_GROUP, $group_name)) ? $a_group : array(); |
| 1043 | 1043 | } |
| 1044 | 1044 | |
@@ -1066,8 +1066,8 @@ discard block |
||
| 1066 | 1066 | $sn_data_unit = get_unit_param($unit_id); |
| 1067 | 1067 | |
| 1068 | 1068 | $result = is_array($result) ? $result : array(); |
| 1069 | - if($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && $config->empire_mercenary_temporary)) { |
|
| 1070 | - foreach($sn_data_unit[$field] as $require_id => $require_level) { |
|
| 1069 | + if ($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && $config->empire_mercenary_temporary)) { |
|
| 1070 | + foreach ($sn_data_unit[$field] as $require_id => $require_level) { |
|
| 1071 | 1071 | $level_got = mrc_get_level($user, $planetrow, $require_id); |
| 1072 | 1072 | $level_basic = mrc_get_level($user, $planetrow, $require_id, false, true); |
| 1073 | 1073 | $result[] = array( |
@@ -1091,16 +1091,16 @@ discard block |
||
| 1091 | 1091 | |
| 1092 | 1092 | $ranks = array(); |
| 1093 | 1093 | |
| 1094 | - if($ally['ranklist']) { |
|
| 1094 | + if ($ally['ranklist']) { |
|
| 1095 | 1095 | $str_ranks = explode(';', $ally['ranklist']); |
| 1096 | - foreach($str_ranks as $str_rank) { |
|
| 1097 | - if(!$str_rank) { |
|
| 1096 | + foreach ($str_ranks as $str_rank) { |
|
| 1097 | + if (!$str_rank) { |
|
| 1098 | 1098 | continue; |
| 1099 | 1099 | } |
| 1100 | 1100 | |
| 1101 | 1101 | $tmp = explode(',', $str_rank); |
| 1102 | 1102 | $rank_id = count($ranks); |
| 1103 | - foreach($ally_rights as $key => $value) { |
|
| 1103 | + foreach ($ally_rights as $key => $value) { |
|
| 1104 | 1104 | $ranks[$rank_id][$value] = $tmp[$key]; |
| 1105 | 1105 | } |
| 1106 | 1106 | } |
@@ -1116,8 +1116,8 @@ discard block |
||
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | 1118 | function array_merge_recursive_numeric($array1, $array2) { |
| 1119 | - if(!empty($array2) && is_array($array2)) { |
|
| 1120 | - foreach($array2 as $key => $value) { |
|
| 1119 | + if (!empty($array2) && is_array($array2)) { |
|
| 1120 | + foreach ($array2 as $key => $value) { |
|
| 1121 | 1121 | // if(!isset($array1[$key]) || !is_array($array1[$key])) { |
| 1122 | 1122 | // $array1[$key] = $value; |
| 1123 | 1123 | // } else { |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | |
| 1133 | 1133 | function sn_sys_array_cumulative_sum(&$array) { |
| 1134 | 1134 | $accum = 0; |
| 1135 | - foreach($array as &$value) { |
|
| 1135 | + foreach ($array as &$value) { |
|
| 1136 | 1136 | $accum += $value; |
| 1137 | 1137 | $value = $accum; |
| 1138 | 1138 | } |
@@ -1142,7 +1142,7 @@ discard block |
||
| 1142 | 1142 | $sn_data_density = sn_get_groups('planet_density'); |
| 1143 | 1143 | $density_price_chart = array(); |
| 1144 | 1144 | |
| 1145 | - foreach($sn_data_density as $density_id => $density_data) { |
|
| 1145 | + foreach ($sn_data_density as $density_id => $density_data) { |
|
| 1146 | 1146 | // Отсекаем записи с RARITY = 0 - служебные записи и супер-ядра |
| 1147 | 1147 | $density_data[UNIT_PLANET_DENSITY_RARITY] ? $density_price_chart[$density_id] = $density_data[UNIT_PLANET_DENSITY_RARITY] : false; |
| 1148 | 1148 | } |
@@ -1150,7 +1150,7 @@ discard block |
||
| 1150 | 1150 | |
| 1151 | 1151 | $total_rarity = array_sum($density_price_chart); |
| 1152 | 1152 | |
| 1153 | - foreach($density_price_chart as &$density_data) { |
|
| 1153 | + foreach ($density_price_chart as &$density_data) { |
|
| 1154 | 1154 | $density_data = ceil($total_rarity / $density_data * $planet_row['field_max'] * PLANET_DENSITY_TO_DARK_MATTER_RATE); |
| 1155 | 1155 | } |
| 1156 | 1156 | |
@@ -1158,18 +1158,18 @@ discard block |
||
| 1158 | 1158 | } |
| 1159 | 1159 | |
| 1160 | 1160 | function sn_sys_planet_core_transmute(&$user, &$planetrow) { |
| 1161 | - if(!sys_get_param_str('transmute')) { |
|
| 1161 | + if (!sys_get_param_str('transmute')) { |
|
| 1162 | 1162 | return array(); |
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | 1165 | global $lang; |
| 1166 | 1166 | |
| 1167 | 1167 | try { |
| 1168 | - if($planetrow['planet_type'] != PT_PLANET) { |
|
| 1168 | + if ($planetrow['planet_type'] != PT_PLANET) { |
|
| 1169 | 1169 | throw new exception(classLocale::$lang['ov_core_err_not_a_planet'], ERR_ERROR); |
| 1170 | 1170 | } |
| 1171 | 1171 | |
| 1172 | - if($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { |
|
| 1172 | + if ($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) { |
|
| 1173 | 1173 | throw new exception(classLocale::$lang['ov_core_err_same_density'], ERR_WARNING); |
| 1174 | 1174 | } |
| 1175 | 1175 | |
@@ -1183,7 +1183,7 @@ discard block |
||
| 1183 | 1183 | $planet_density_index = $planetrow['density_index']; |
| 1184 | 1184 | |
| 1185 | 1185 | $density_price_chart = planet_density_price_chart($planetrow); |
| 1186 | - if(!isset($density_price_chart[$new_density_index])) { |
|
| 1186 | + if (!isset($density_price_chart[$new_density_index])) { |
|
| 1187 | 1187 | // Hack attempt |
| 1188 | 1188 | throw new exception(classLocale::$lang['ov_core_err_denisty_type_wrong'], ERR_ERROR); |
| 1189 | 1189 | } |
@@ -1192,13 +1192,13 @@ discard block |
||
| 1192 | 1192 | // $transmute_cost = get_unit_param(UNIT_PLANET_DENSITY, 'cost'); |
| 1193 | 1193 | // $transmute_cost = $transmute_cost[RES_DARK_MATTER] * $density_price_chart[$new_density_index]; |
| 1194 | 1194 | $transmute_cost = $density_price_chart[$new_density_index]; |
| 1195 | - if($user_dark_matter < $transmute_cost) { |
|
| 1195 | + if ($user_dark_matter < $transmute_cost) { |
|
| 1196 | 1196 | throw new exception(classLocale::$lang['ov_core_err_no_dark_matter'], ERR_ERROR); |
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | 1199 | $sn_data_planet_density = sn_get_groups('planet_density'); |
| 1200 | - foreach($sn_data_planet_density as $key => $value) { |
|
| 1201 | - if($key == $new_density_index) { |
|
| 1200 | + foreach ($sn_data_planet_density as $key => $value) { |
|
| 1201 | + if ($key == $new_density_index) { |
|
| 1202 | 1202 | break; |
| 1203 | 1203 | } |
| 1204 | 1204 | $prev_density_index = $key; |
@@ -1229,7 +1229,7 @@ discard block |
||
| 1229 | 1229 | 'STATUS' => ERR_NONE, |
| 1230 | 1230 | 'MESSAGE' => sprintf(classLocale::$lang['ov_core_err_none'], classLocale::$lang['uni_planet_density_types'][$planet_density_index], classLocale::$lang['uni_planet_density_types'][$new_density_index], $new_density), |
| 1231 | 1231 | ); |
| 1232 | - } catch(exception $e) { |
|
| 1232 | + } catch (exception $e) { |
|
| 1233 | 1233 | sn_db_transaction_rollback(); |
| 1234 | 1234 | $result = array( |
| 1235 | 1235 | 'STATUS' => $e->getCode(), |
@@ -1242,8 +1242,8 @@ discard block |
||
| 1242 | 1242 | |
| 1243 | 1243 | function sn_module_get_active_count($group = '*') { |
| 1244 | 1244 | $active_modules = 0; |
| 1245 | - if(isset(sn_module::$sn_module_list[$group]) && is_array(sn_module::$sn_module_list[$group])) { |
|
| 1246 | - foreach(sn_module::$sn_module_list[$group] as $payment_module) { |
|
| 1245 | + if (isset(sn_module::$sn_module_list[$group]) && is_array(sn_module::$sn_module_list[$group])) { |
|
| 1246 | + foreach (sn_module::$sn_module_list[$group] as $payment_module) { |
|
| 1247 | 1247 | $active_modules += $payment_module->manifest['active']; |
| 1248 | 1248 | } |
| 1249 | 1249 | } |
@@ -1254,7 +1254,7 @@ discard block |
||
| 1254 | 1254 | function get_resource_exchange() { |
| 1255 | 1255 | static $rates; |
| 1256 | 1256 | |
| 1257 | - if(!$rates) { |
|
| 1257 | + if (!$rates) { |
|
| 1258 | 1258 | global $config; |
| 1259 | 1259 | |
| 1260 | 1260 | $rates = array( |
@@ -1264,7 +1264,7 @@ discard block |
||
| 1264 | 1264 | RES_DARK_MATTER => 'rpg_exchange_darkMatter', |
| 1265 | 1265 | ); |
| 1266 | 1266 | |
| 1267 | - foreach($rates as &$rate) { |
|
| 1267 | + foreach ($rates as &$rate) { |
|
| 1268 | 1268 | $rate = $config->$rate; |
| 1269 | 1269 | } |
| 1270 | 1270 | } |
@@ -1275,12 +1275,12 @@ discard block |
||
| 1275 | 1275 | function get_unit_cost_in(&$cost, $in_resource = RES_METAL) { |
| 1276 | 1276 | static $rates; |
| 1277 | 1277 | |
| 1278 | - if(!$rates) { |
|
| 1278 | + if (!$rates) { |
|
| 1279 | 1279 | $rates = get_resource_exchange(); |
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | 1282 | $metal_cost = 0; |
| 1283 | - foreach($cost as $resource_id => $resource_value) { |
|
| 1283 | + foreach ($cost as $resource_id => $resource_value) { |
|
| 1284 | 1284 | $metal_cost += $rates[$resource_id] * $resource_value; |
| 1285 | 1285 | } |
| 1286 | 1286 | |
@@ -1290,8 +1290,8 @@ discard block |
||
| 1290 | 1290 | function get_player_max_expeditons(&$user, $astrotech = -1) { return sn_function_call(__FUNCTION__, array(&$user, $astrotech, &$result)); } |
| 1291 | 1291 | |
| 1292 | 1292 | function sn_get_player_max_expeditons(&$user, $astrotech = -1, &$result = 0) { |
| 1293 | - if($astrotech == -1) { |
|
| 1294 | - if(!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) { |
|
| 1293 | + if ($astrotech == -1) { |
|
| 1294 | + if (!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) { |
|
| 1295 | 1295 | $astrotech = mrc_get_level($user, false, TECH_ASTROTECH); |
| 1296 | 1296 | $user[UNIT_PLAYER_EXPEDITIONS_MAX] = $astrotech >= 1 ? floor(sqrt($astrotech - 1)) : 0; |
| 1297 | 1297 | } |
@@ -1309,8 +1309,8 @@ discard block |
||
| 1309 | 1309 | function get_player_max_colonies(&$user, $astrotech = -1) { |
| 1310 | 1310 | global $config; |
| 1311 | 1311 | |
| 1312 | - if($astrotech == -1) { |
|
| 1313 | - if(!isset($user[UNIT_PLAYER_COLONIES_MAX])) { |
|
| 1312 | + if ($astrotech == -1) { |
|
| 1313 | + if (!isset($user[UNIT_PLAYER_COLONIES_MAX])) { |
|
| 1314 | 1314 | |
| 1315 | 1315 | $expeditions = get_player_max_expeditons($user); |
| 1316 | 1316 | $astrotech = mrc_get_level($user, false, TECH_ASTROTECH); |
@@ -1355,10 +1355,10 @@ discard block |
||
| 1355 | 1355 | |
| 1356 | 1356 | // pdump($powerup_unit, '$powerup_unit'); |
| 1357 | 1357 | $level_current = $term_original = $time_left = 0; |
| 1358 | - if($is_upgrade) { |
|
| 1358 | + if ($is_upgrade) { |
|
| 1359 | 1359 | $time_finish = strtotime($powerup_unit['unit_time_finish']); |
| 1360 | 1360 | $time_left = max(0, $time_finish - SN_TIME_NOW); |
| 1361 | - if($time_left > 0) { |
|
| 1361 | + if ($time_left > 0) { |
|
| 1362 | 1362 | $term_original = $time_finish - strtotime($powerup_unit['unit_time_start']); |
| 1363 | 1363 | $level_current = $powerup_unit['unit_level']; |
| 1364 | 1364 | } |
@@ -1366,22 +1366,22 @@ discard block |
||
| 1366 | 1366 | |
| 1367 | 1367 | $level_max = $level_max > $powerup_data[P_MAX_STACK] ? $level_max : $powerup_data[P_MAX_STACK]; |
| 1368 | 1368 | $original_cost = 0; |
| 1369 | - for($i = 1; $i <= $level_max; $i++) { |
|
| 1369 | + for ($i = 1; $i <= $level_max; $i++) { |
|
| 1370 | 1370 | $base_cost = eco_get_total_cost($powerup_id, $i); |
| 1371 | 1371 | $base_cost = $base_cost[BUILD_CREATE][RES_DARK_MATTER]; |
| 1372 | - foreach($sn_powerup_buy_discounts as $period => $discount) { |
|
| 1372 | + foreach ($sn_powerup_buy_discounts as $period => $discount) { |
|
| 1373 | 1373 | $upgrade_price = floor($base_cost * $discount * $period / PERIOD_MONTH); |
| 1374 | 1374 | $result[$i][$period] = $upgrade_price; |
| 1375 | 1375 | $original_cost = $is_upgrade && $i == $level_current && $period <= $term_original ? $upgrade_price : $original_cost; |
| 1376 | 1376 | } |
| 1377 | 1377 | } |
| 1378 | 1378 | |
| 1379 | - if($is_upgrade && $time_left) { |
|
| 1379 | + if ($is_upgrade && $time_left) { |
|
| 1380 | 1380 | $term_original = round($term_original / PERIOD_DAY); |
| 1381 | 1381 | $time_left = min(floor($time_left / PERIOD_DAY), $term_original); |
| 1382 | 1382 | $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0; |
| 1383 | 1383 | |
| 1384 | - array_walk_recursive($result, function (&$value) use ($cost_left) { |
|
| 1384 | + array_walk_recursive($result, function(&$value) use ($cost_left) { |
|
| 1385 | 1385 | $value -= $cost_left; |
| 1386 | 1386 | }); |
| 1387 | 1387 | } |
@@ -1439,7 +1439,7 @@ discard block |
||
| 1439 | 1439 | |
| 1440 | 1440 | function print_rr($var, $capture = false) { |
| 1441 | 1441 | $print = '<pre>' . htmlspecialchars(print_r($var, true)) . '</pre>'; |
| 1442 | - if($capture) { |
|
| 1442 | + if ($capture) { |
|
| 1443 | 1443 | return $print; |
| 1444 | 1444 | } else { |
| 1445 | 1445 | print($print); |
@@ -92,9 +92,9 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | for ($Option = 10; $Option >= 0; $Option--) |
| 94 | 94 | { |
| 95 | - $template->assign_block_vars('option', array( |
|
| 96 | - 'VALUE' => $Option * 10, |
|
| 97 | - )); |
|
| 95 | + $template->assign_block_vars('option', array( |
|
| 96 | + 'VALUE' => $Option * 10, |
|
| 97 | + )); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | $caps_real = eco_get_planet_caps($user, $planetrow, 3600); |
@@ -163,14 +163,14 @@ discard block |
||
| 163 | 163 | int_calc_storage_bar(RES_DEUTERIUM); |
| 164 | 164 | |
| 165 | 165 | $template->assign_vars(array( |
| 166 | - 'PLANET_NAME' => $planetrow['name'], |
|
| 167 | - 'PLANET_TYPE' => $planetrow['planet_type'], |
|
| 168 | - 'PLANET_DENSITY_INDEX' => $planet_density_index, |
|
| 169 | - 'PLANET_CORE_TEXT' => classLocale::$lang['uni_planet_density_types'][$planet_density_index], |
|
| 166 | + 'PLANET_NAME' => $planetrow['name'], |
|
| 167 | + 'PLANET_TYPE' => $planetrow['planet_type'], |
|
| 168 | + 'PLANET_DENSITY_INDEX' => $planet_density_index, |
|
| 169 | + 'PLANET_CORE_TEXT' => classLocale::$lang['uni_planet_density_types'][$planet_density_index], |
|
| 170 | 170 | |
| 171 | - 'PRODUCTION_LEVEL' => floor($caps_real['efficiency'] * 100), |
|
| 171 | + 'PRODUCTION_LEVEL' => floor($caps_real['efficiency'] * 100), |
|
| 172 | 172 | |
| 173 | - 'PAGE_HINT' => classLocale::$lang['res_hint'], |
|
| 173 | + 'PAGE_HINT' => classLocale::$lang['res_hint'], |
|
| 174 | 174 | )); |
| 175 | 175 | |
| 176 | 176 | display($template, classLocale::$lang['res_planet_production']); |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -define('INSIDE' , true); |
|
| 3 | -define('INSTALL' , false); |
|
| 2 | +define('INSIDE', true); |
|
| 3 | +define('INSTALL', false); |
|
| 4 | 4 | define('IN_ADMIN', true); |
| 5 | 5 | |
| 6 | 6 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 7 | 7 | |
| 8 | -if($user['authlevel'] < 3) |
|
| 8 | +if ($user['authlevel'] < 3) |
|
| 9 | 9 | { |
| 10 | 10 | AdminMessage(classLocale::$lang['adm_err_denied']); |
| 11 | 11 | } |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | $username_unsafe = sys_get_param_str_unsafe('username'); |
| 26 | 26 | $username = sys_get_param_escaped('username'); |
| 27 | 27 | |
| 28 | -if($galaxy_src) |
|
| 28 | +if ($galaxy_src) |
|
| 29 | 29 | { |
| 30 | 30 | sn_db_transaction_start(); |
| 31 | 31 | $errors = array(); |
@@ -35,41 +35,41 @@ discard block |
||
| 35 | 35 | $planet = sys_o_get_updated($owner, array('galaxy' => $galaxy_src, 'system' => $system_src, 'planet' => $planet_src, 'planet_type' => 1), SN_TIME_NOW); |
| 36 | 36 | $que = $planet['que']; |
| 37 | 37 | $planet = $planet['planet']; |
| 38 | - if(!$planet) |
|
| 38 | + if (!$planet) |
|
| 39 | 39 | { |
| 40 | 40 | $errors[] = classLocale::$lang['adm_pl_comp_err_0']; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - if($planet['destruyed']) |
|
| 43 | + if ($planet['destruyed']) |
|
| 44 | 44 | { |
| 45 | 45 | $errors[] = classLocale::$lang['adm_pl_comp_err_1']; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if($planet['id_owner'] != $owner['id'] || !$username) |
|
| 48 | + if ($planet['id_owner'] != $owner['id'] || !$username) |
|
| 49 | 49 | { |
| 50 | 50 | $errors[] = classLocale::$lang['adm_pl_comp_err_4']; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | $destination = sys_o_get_updated($owner, array('galaxy' => $galaxy_dst, 'system' => $system_dst, 'planet' => $planet_dst, 'planet_type' => 1), SN_TIME_NOW); |
| 54 | 54 | $destination = $destination['planet']; |
| 55 | - if(!$destination) |
|
| 55 | + if (!$destination) |
|
| 56 | 56 | { |
| 57 | 57 | $errors[] = classLocale::$lang['adm_pl_comp_err_2']; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - if($planet['id'] == $destination['id']) |
|
| 60 | + if ($planet['id'] == $destination['id']) |
|
| 61 | 61 | { |
| 62 | 62 | $errors[] = classLocale::$lang['adm_pl_comp_err_5']; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if($planet['id_owner'] != $destination['id_owner']) |
|
| 65 | + if ($planet['id_owner'] != $destination['id_owner']) |
|
| 66 | 66 | { |
| 67 | 67 | $errors[] = classLocale::$lang['adm_pl_comp_err_3']; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - if(!empty($errors)) |
|
| 70 | + if (!empty($errors)) |
|
| 71 | 71 | { |
| 72 | - foreach($errors as $error) |
|
| 72 | + foreach ($errors as $error) |
|
| 73 | 73 | { |
| 74 | 74 | $template->assign_block_vars('error', array( |
| 75 | 75 | 'TEXT' => $error, |
@@ -83,14 +83,14 @@ discard block |
||
| 83 | 83 | killer_add_planet($planet); |
| 84 | 84 | |
| 85 | 85 | $moon = db_planet_by_gspt($galaxy_src, $system_src, $planet_src, PT_MOON, true); |
| 86 | - if($moon) |
|
| 86 | + if ($moon) |
|
| 87 | 87 | { |
| 88 | 88 | $moon = sys_o_get_updated($owner, $moon, SN_TIME_NOW); |
| 89 | 89 | $moon = $moon['planet']; |
| 90 | 90 | killer_add_planet($moon); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - foreach(sn_get_groups('resources_loot') as $resource_id) |
|
| 93 | + foreach (sn_get_groups('resources_loot') as $resource_id) |
|
| 94 | 94 | { |
| 95 | 95 | $resource_name = pname_resource_name($resource_id); |
| 96 | 96 | $template->assign_var("{$resource_name}_cost", $final_cost[$resource_id]); |
@@ -98,13 +98,13 @@ discard block |
||
| 98 | 98 | $template->assign_var("{$resource_name}_bonus", $final_cost[$resource_id]); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - if($_GET['btn_confirm']) |
|
| 101 | + if ($_GET['btn_confirm']) |
|
| 102 | 102 | { |
| 103 | 103 | $time = SN_TIME_NOW + PERIOD_DAY; |
| 104 | 104 | |
| 105 | 105 | db_unit_list_delete($planet['id_owner'], LOC_PLANET, $planet['id']); |
| 106 | 106 | db_planet_set_by_id($planet['id'], "id_owner = 0, destruyed = {$time}"); |
| 107 | - if($moon) |
|
| 107 | + if ($moon) |
|
| 108 | 108 | { |
| 109 | 109 | db_unit_list_delete($planet['id_owner'], LOC_PLANET, $moon['id']); |
| 110 | 110 | db_planet_set_by_id($moon['id'], "id_owner = 0, destruyed = {$time}"); |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | 'username' => $username, |
| 132 | 132 | )); |
| 133 | 133 | |
| 134 | -display(parsetemplate($template, $parse), classLocale::$lang['adm_pl_comp_title'], false, '', true ); |
|
| 134 | +display(parsetemplate($template, $parse), classLocale::$lang['adm_pl_comp_title'], false, '', true); |
|
| 135 | 135 | |
| 136 | 136 | function killer_add_planet($planet) |
| 137 | 137 | { |
@@ -146,34 +146,34 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | */ |
| 148 | 148 | |
| 149 | - foreach(sn_get_groups('structures') as $unit_id) |
|
| 149 | + foreach (sn_get_groups('structures') as $unit_id) |
|
| 150 | 150 | { |
| 151 | 151 | $build_level = mrc_get_level($user, $planet, $unit_id, true, true); |
| 152 | - if($build_level > 0) |
|
| 152 | + if ($build_level > 0) |
|
| 153 | 153 | { |
| 154 | 154 | $unit_cost = get_unit_param($unit_id, 'cost'); |
| 155 | 155 | $build_factor = $unit_cost['factor'] != 1 ? (1 - pow($unit_cost['factor'], $build_level)) / (1 - $unit_cost['factor']) : $unit_cost['factor']; |
| 156 | - foreach($sn_group_resources_loot as $resource_id) |
|
| 156 | + foreach ($sn_group_resources_loot as $resource_id) |
|
| 157 | 157 | { |
| 158 | 158 | $final_cost[$resource_id] += isset($unit_cost[$resource_id]) && $unit_cost[$resource_id] > 0 ? floor($unit_cost[$resource_id] * $build_factor) : 0; |
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - foreach(sn_get_groups(array('defense', 'fleet')) as $unit_id) |
|
| 163 | + foreach (sn_get_groups(array('defense', 'fleet')) as $unit_id) |
|
| 164 | 164 | { |
| 165 | 165 | $unit_count = mrc_get_level($user, $planet, $unit_id, true, true); |
| 166 | - if($unit_count > 0) |
|
| 166 | + if ($unit_count > 0) |
|
| 167 | 167 | { |
| 168 | 168 | $unit_cost = get_unit_param($unit_id, 'cost'); |
| 169 | - foreach($sn_group_resources_loot as $resource_id) |
|
| 169 | + foreach ($sn_group_resources_loot as $resource_id) |
|
| 170 | 170 | { |
| 171 | 171 | $final_cost[$resource_id] += isset($unit_cost[$resource_id]) && $unit_cost[$resource_id] > 0 ? floor($unit_cost[$resource_id] * $unit_count) : 0; |
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - foreach($sn_group_resources_loot as $resource_id) |
|
| 176 | + foreach ($sn_group_resources_loot as $resource_id) |
|
| 177 | 177 | { |
| 178 | 178 | $final_cost[$resource_id] += floor(mrc_get_level($user, $planet, $resource_id, true, true)); |
| 179 | 179 | } |
@@ -8,13 +8,13 @@ discard block |
||
| 8 | 8 | * @copyright 2008 by ??????? for XNova |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -define('INSIDE' , true); |
|
| 12 | -define('INSTALL' , false); |
|
| 11 | +define('INSIDE', true); |
|
| 12 | +define('INSTALL', false); |
|
| 13 | 13 | define('IN_ADMIN', true); |
| 14 | 14 | |
| 15 | 15 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 16 | 16 | |
| 17 | -if($user['authlevel'] < 3) |
|
| 17 | +if ($user['authlevel'] < 3) |
|
| 18 | 18 | { |
| 19 | 19 | AdminMessage(classLocale::$lang['adm_err_denied']); |
| 20 | 20 | } |
@@ -34,9 +34,9 @@ discard block |
||
| 34 | 34 | |
| 35 | 35 | // Afficher les templates |
| 36 | 36 | if (isset($GET_result)) { |
| 37 | - switch ($GET_result){ |
|
| 37 | + switch ($GET_result) { |
|
| 38 | 38 | case 'usr_search': |
| 39 | - $SelUser = db_user_by_username('%'. $Pattern .'%', false, '*', true, true); |
|
| 39 | + $SelUser = db_user_by_username('%' . $Pattern . '%', false, '*', true, true); |
|
| 40 | 40 | $UsrMain = db_planet_by_id($SelUser['id_planet'], false, 'name'); |
| 41 | 41 | |
| 42 | 42 | $bloc = classLocale::$lang; |
@@ -44,14 +44,14 @@ discard block |
||
| 44 | 44 | $bloc['answer2'] = $SelUser['username']; |
| 45 | 45 | $bloc['answer3'] = $SelUser['user_lastip']; |
| 46 | 46 | $bloc['answer4'] = $SelUser['email']; |
| 47 | - $bloc['answer5'] = classLocale::$lang['adm_usr_level'][ $SelUser['authlevel'] ]; |
|
| 48 | - $bloc['answer6'] = classLocale::$lang['adm_usr_genre'][ $SelUser['gender'] ]; |
|
| 49 | - $bloc['answer7'] = "[".$SelUser['id_planet']."] ".$UsrMain['name']; |
|
| 50 | - $bloc['answer8'] = "[".$SelUser['galaxy'].":".$SelUser['system'].":".$SelUser['planet']."] "; |
|
| 47 | + $bloc['answer5'] = classLocale::$lang['adm_usr_level'][$SelUser['authlevel']]; |
|
| 48 | + $bloc['answer6'] = classLocale::$lang['adm_usr_genre'][$SelUser['gender']]; |
|
| 49 | + $bloc['answer7'] = "[" . $SelUser['id_planet'] . "] " . $UsrMain['name']; |
|
| 50 | + $bloc['answer8'] = "[" . $SelUser['galaxy'] . ":" . $SelUser['system'] . ":" . $SelUser['planet'] . "] "; |
|
| 51 | 51 | $bloc['qst_quest_complete'] = get_quest_amount_complete($SelUser['id']); |
| 52 | 52 | $bloc['user_id'] = $SelUser['id']; |
| 53 | 53 | $SubPanelTPL = gettemplate('admin/admin_panel_asw1'); |
| 54 | - $parse['adm_sub_form2'] = parsetemplate( $SubPanelTPL, $bloc ); |
|
| 54 | + $parse['adm_sub_form2'] = parsetemplate($SubPanelTPL, $bloc); |
|
| 55 | 55 | break; |
| 56 | 56 | |
| 57 | 57 | case 'usr_data': |
@@ -69,10 +69,10 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | $selected_user = db_user_by_username($Pattern, false, 'id'); |
| 71 | 71 | $QryUpdate = db_user_set_by_id($selected_user['id'], "`authlevel` = '{$NewLvl}'"); |
| 72 | - $Message = classLocale::$lang['adm_mess_lvl1']. " ". $Pattern ." ".classLocale::$lang['adm_mess_lvl2']; |
|
| 73 | - $Message .= "<font color=\"red\">".classLocale::$lang['adm_usr_level'][ $NewLvl ]."</font>!"; |
|
| 72 | + $Message = classLocale::$lang['adm_mess_lvl1'] . " " . $Pattern . " " . classLocale::$lang['adm_mess_lvl2']; |
|
| 73 | + $Message .= "<font color=\"red\">" . classLocale::$lang['adm_usr_level'][$NewLvl] . "</font>!"; |
|
| 74 | 74 | |
| 75 | - AdminMessage ( $Message, classLocale::$lang['adm_mod_level'] ); |
|
| 75 | + AdminMessage($Message, classLocale::$lang['adm_mod_level']); |
|
| 76 | 76 | break; |
| 77 | 77 | |
| 78 | 78 | case 'ip_search': |
@@ -81,12 +81,12 @@ discard block |
||
| 81 | 81 | $bloc['adm_this_ip'] = $ip; |
| 82 | 82 | $SelUser = db_user_list("`user_lastip` = '{$ip}'"); |
| 83 | 83 | //while ( $Usr = db_fetch($SelUser) ) { |
| 84 | - foreach($SelUser as $Usr) { |
|
| 84 | + foreach ($SelUser as $Usr) { |
|
| 85 | 85 | $UsrMain = db_planet_by_id($Usr['id_planet'], false, 'name'); |
| 86 | - $bloc['adm_plyer_lst'] .= "<tr><th>".$Usr['username']."</th><th>[".$Usr['galaxy'].":".$Usr['system'].":".$Usr['planet']."] ".$UsrMain['name']."</th></tr>"; |
|
| 86 | + $bloc['adm_plyer_lst'] .= "<tr><th>" . $Usr['username'] . "</th><th>[" . $Usr['galaxy'] . ":" . $Usr['system'] . ":" . $Usr['planet'] . "] " . $UsrMain['name'] . "</th></tr>"; |
|
| 87 | 87 | } |
| 88 | 88 | $SubPanelTPL = gettemplate('admin/admin_panel_asw2'); |
| 89 | - $parse['adm_sub_form2'] = parsetemplate( $SubPanelTPL, $bloc ); |
|
| 89 | + $parse['adm_sub_form2'] = parsetemplate($SubPanelTPL, $bloc); |
|
| 90 | 90 | break; |
| 91 | 91 | default: |
| 92 | 92 | break; |
@@ -95,14 +95,14 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | // Traiter les reponses aux formulaires |
| 97 | 97 | if (isset($GET_action)) { |
| 98 | - $bloc = classLocale::$lang; |
|
| 99 | - switch ($GET_action){ |
|
| 98 | + $bloc = classLocale::$lang; |
|
| 99 | + switch ($GET_action) { |
|
| 100 | 100 | case 'usr_search': |
| 101 | - $SubPanelTPL = gettemplate('admin/admin_panel_frm1'); |
|
| 101 | + $SubPanelTPL = gettemplate('admin/admin_panel_frm1'); |
|
| 102 | 102 | break; |
| 103 | 103 | |
| 104 | 104 | case 'usr_data': |
| 105 | - $SubPanelTPL = gettemplate('admin/admin_panel_frm4'); |
|
| 105 | + $SubPanelTPL = gettemplate('admin/admin_panel_frm4'); |
|
| 106 | 106 | break; |
| 107 | 107 | |
| 108 | 108 | case 'usr_level': |
@@ -115,21 +115,21 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 | for ($Lvl = 0; $Lvl < 4; $Lvl++) { |
| 118 | - $bloc['adm_level_lst'] .= '<option value="'. $Lvl .'">'. classLocale::$lang['adm_usr_level'][ $Lvl ] ."</option>"; |
|
| 118 | + $bloc['adm_level_lst'] .= '<option value="' . $Lvl . '">' . classLocale::$lang['adm_usr_level'][$Lvl] . "</option>"; |
|
| 119 | 119 | } |
| 120 | - $SubPanelTPL = gettemplate('admin/admin_panel_frm3'); |
|
| 120 | + $SubPanelTPL = gettemplate('admin/admin_panel_frm3'); |
|
| 121 | 121 | break; |
| 122 | 122 | |
| 123 | 123 | case 'ip_search': |
| 124 | - $SubPanelTPL = gettemplate('admin/admin_panel_frm2'); |
|
| 124 | + $SubPanelTPL = gettemplate('admin/admin_panel_frm2'); |
|
| 125 | 125 | break; |
| 126 | 126 | |
| 127 | 127 | default: |
| 128 | 128 | break; |
| 129 | 129 | } |
| 130 | - $parse['adm_sub_form2'] = parsetemplate( $SubPanelTPL, $bloc ); |
|
| 130 | + $parse['adm_sub_form2'] = parsetemplate($SubPanelTPL, $bloc); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | -$page = parsetemplate( $PanelMainTPL, $parse ); |
|
| 134 | -display( $page, classLocale::$lang['panel_mainttl'], false, '', true ); |
|
| 133 | +$page = parsetemplate($PanelMainTPL, $parse); |
|
| 134 | +display($page, classLocale::$lang['panel_mainttl'], false, '', true); |
|
| 135 | 135 | ?> |
@@ -8,18 +8,18 @@ discard block |
||
| 8 | 8 | * @copyright 2008 by ??????? for XNova |
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | -define('INSIDE' , true); |
|
| 12 | -define('INSTALL' , false); |
|
| 11 | +define('INSIDE', true); |
|
| 12 | +define('INSTALL', false); |
|
| 13 | 13 | define('IN_ADMIN', true); |
| 14 | 14 | require('../common.' . substr(strrchr(__FILE__, '.'), 1)); |
| 15 | 15 | |
| 16 | -if($user['authlevel'] < 3) { |
|
| 16 | +if ($user['authlevel'] < 3) { |
|
| 17 | 17 | AdminMessage(classLocale::$lang['adm_err_denied']); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | $template = gettemplate('admin/settings', true); |
| 21 | 21 | |
| 22 | -if(sys_get_param('save')) { |
|
| 22 | +if (sys_get_param('save')) { |
|
| 23 | 23 | $config->game_name = sys_get_param_str_unsafe('game_name'); |
| 24 | 24 | $config->game_mode = sys_get_param_int('game_mode'); |
| 25 | 25 | $config->game_speed = sys_get_param_float('game_speed', 1); |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | $config->url_faq = sys_get_param_str_unsafe('url_faq'); |
| 30 | 30 | $config->url_forum = sys_get_param_str_unsafe('url_forum'); |
| 31 | 31 | $config->url_rules = sys_get_param_str_unsafe('url_rules'); |
| 32 | - $config->url_purchase_metamatter = sys_get_param_str_unsafe('url_purchase_metamatter'); |
|
| 32 | + $config->url_purchase_metamatter = sys_get_param_str_unsafe('url_purchase_metamatter'); |
|
| 33 | 33 | $config->game_disable = sys_get_param_int('game_disable'); |
| 34 | 34 | $config->game_disable_reason = sys_get_param_str_unsafe('game_disable_reason'); |
| 35 | 35 | $config->server_updater_check_auto = sys_get_param_int('server_updater_check_auto'); |
@@ -96,8 +96,8 @@ discard block |
||
| 96 | 96 | $config->stats_schedule = sys_get_param_str('stats_schedule'); |
| 97 | 97 | |
| 98 | 98 | $config->empire_mercenary_base_period = sys_get_param_int('empire_mercenary_base_period'); |
| 99 | - if($config->empire_mercenary_temporary != sys_get_param_int('empire_mercenary_temporary')) { |
|
| 100 | - if($config->empire_mercenary_temporary) { |
|
| 99 | + if ($config->empire_mercenary_temporary != sys_get_param_int('empire_mercenary_temporary')) { |
|
| 100 | + if ($config->empire_mercenary_temporary) { |
|
| 101 | 101 | db_unit_list_admin_delete_mercenaries_finished(); |
| 102 | 102 | } else { |
| 103 | 103 | db_unit_list_admin_set_mercenaries_expire_time($config->empire_mercenary_base_period); |
@@ -140,21 +140,21 @@ discard block |
||
| 140 | 140 | // 'STATS_SCHEDULE' => $config->stats_hide_player_list, |
| 141 | 141 | )); |
| 142 | 142 | |
| 143 | -foreach(classLocale::$lang['sys_game_disable_reason'] as $id => $name) { |
|
| 143 | +foreach (classLocale::$lang['sys_game_disable_reason'] as $id => $name) { |
|
| 144 | 144 | $template->assign_block_vars('sys_game_disable_reason', array( |
| 145 | 145 | 'ID' => $id, |
| 146 | 146 | 'NAME' => $name, |
| 147 | 147 | )); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | -foreach(classLocale::$lang['sys_game_mode'] as $mode_id => $mode_name) { |
|
| 150 | +foreach (classLocale::$lang['sys_game_mode'] as $mode_id => $mode_name) { |
|
| 151 | 151 | $template->assign_block_vars('game_modes', array( |
| 152 | 152 | 'ID' => $mode_id, |
| 153 | 153 | 'NAME' => $mode_name, |
| 154 | 154 | )); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | -foreach(classLocale::$lang['adm_opt_ver_response'] as $ver_id => $ver_response) { |
|
| 157 | +foreach (classLocale::$lang['adm_opt_ver_response'] as $ver_id => $ver_response) { |
|
| 158 | 158 | $template->assign_block_vars('ver_response', array( |
| 159 | 159 | 'ID' => $ver_id, |
| 160 | 160 | 'NAME' => js_safe_string($ver_response), |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | $lang_list = lng_get_list(); |
| 165 | -foreach($lang_list as $lang_id => $lang_data) { |
|
| 165 | +foreach ($lang_list as $lang_id => $lang_data) { |
|
| 166 | 166 | $template->assign_block_vars('game_languages', array( |
| 167 | 167 | 'ID' => $lang_id, |
| 168 | 168 | 'NAME' => "{$lang_data['LANG_NAME_NATIVE']} ({$lang_data['LANG_NAME_ENGLISH']})", |