@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | |
32 | 34 | $a_lang_array = (array( |
@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | |
32 | 34 | $a_lang_array = (array( |
@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | |
32 | 34 | $a_lang_array = (array( |
@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | global $config; |
32 | 34 |
@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | |
32 | 34 | $a_lang_array = (array( |
@@ -23,7 +23,9 @@ |
||
23 | 23 | * DO NOT CHANGE |
24 | 24 | */ |
25 | 25 | |
26 | -if (!defined('INSIDE')) die(); |
|
26 | +if (!defined('INSIDE')) { |
|
27 | + die(); |
|
28 | +} |
|
27 | 29 | |
28 | 30 | $a_lang_array = (array( |
29 | 31 | // Metamatter |
@@ -26,7 +26,9 @@ |
||
26 | 26 | * DO NOT CHANGE |
27 | 27 | */ |
28 | 28 | |
29 | -if (!defined('INSIDE')) die(); |
|
29 | +if (!defined('INSIDE')) { |
|
30 | + die(); |
|
31 | +} |
|
30 | 32 | |
31 | 33 | |
32 | 34 | $a_lang_array = (array( |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | !is_array($offset) ? $offset = array($offset) : false; |
39 | 39 | |
40 | 40 | $current_leaf = $this->__get(reset($offset)); |
41 | - while(($leaf_index = next($offset)) !== false) { |
|
42 | - if(!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) { |
|
41 | + while (($leaf_index = next($offset)) !== false) { |
|
42 | + if (!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) { |
|
43 | 43 | unset($current_leaf); |
44 | 44 | break; |
45 | 45 | } |
@@ -64,9 +64,9 @@ discard block |
||
64 | 64 | |
65 | 65 | !is_array($offset) ? $offset = array($offset) : false; |
66 | 66 | |
67 | - if($this->offsetExists($offset)) { |
|
67 | + if ($this->offsetExists($offset)) { |
|
68 | 68 | $result = $this->__get(reset($offset)); |
69 | - while(($leaf_index = next($offset)) !== false) { |
|
69 | + while (($leaf_index = next($offset)) !== false) { |
|
70 | 70 | $result = $result[$leaf_index]; |
71 | 71 | } |
72 | 72 | } |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function offsetSet($offset, $value = null) { |
93 | 93 | // Если нет никакого индекса - значит нечего записывать |
94 | - if(!isset($offset) || (is_array($offset) && empty($offset))) { |
|
94 | + if (!isset($offset) || (is_array($offset) && empty($offset))) { |
|
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
98 | 98 | // Если в массиве индекса только один элемент - значит это просто индекс |
99 | - if(is_array($offset) && count($offset) == 1) { |
|
99 | + if (is_array($offset) && count($offset) == 1) { |
|
100 | 100 | // Разворачиваем его в индекс |
101 | 101 | $offset = array(reset($offset) => $value); |
102 | 102 | unset($value); |
@@ -104,16 +104,16 @@ discard block |
||
104 | 104 | } |
105 | 105 | |
106 | 106 | // Адресация многомерного массива через массив индексов в $option |
107 | - if(is_array($offset) && isset($value)) { |
|
107 | + if (is_array($offset) && isset($value)) { |
|
108 | 108 | // TODO - а не переделать ли это всё на __isset() ?? |
109 | 109 | // Вытаскиваем корневой элемент |
110 | 110 | $root = $this->__get(reset($offset)); |
111 | 111 | $current_leaf = &$root; |
112 | - while(($leaf_index = next($offset)) !== false) { |
|
112 | + while (($leaf_index = next($offset)) !== false) { |
|
113 | 113 | !is_array($current_leaf[$leaf_index]) ? $current_leaf[$leaf_index] = array() : false; |
114 | 114 | $current_leaf = &$current_leaf[$leaf_index]; |
115 | 115 | } |
116 | - if($current_leaf != $value) { |
|
116 | + if ($current_leaf != $value) { |
|
117 | 117 | $current_leaf = $value; |
118 | 118 | // Сохраняем данные с корня |
119 | 119 | $this->__set(reset($offset), $root); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | // Пакетная запись из массива ключ -> значение |
123 | 123 | !is_array($offset) ? $offset = array($offset => $value) : false; |
124 | 124 | |
125 | - foreach($offset as $key => $value) { |
|
125 | + foreach ($offset as $key => $value) { |
|
126 | 126 | $this->__get($key) !== $value ? $this->__set($key, $value) : false; |
127 | 127 | } |
128 | 128 | } |
@@ -143,18 +143,18 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function offsetUnset($offset) { |
145 | 145 | // Если нет никакого индекса - значит нечего записывать |
146 | - if(!isset($offset) || (is_array($offset) && empty($offset))) { |
|
146 | + if (!isset($offset) || (is_array($offset) && empty($offset))) { |
|
147 | 147 | return; |
148 | 148 | } |
149 | 149 | |
150 | 150 | !is_array($offset) ? $offset = array($offset) : false; |
151 | 151 | |
152 | - if($this->offsetExists($offset)) { |
|
152 | + if ($this->offsetExists($offset)) { |
|
153 | 153 | // Перематываем массив в конец |
154 | 154 | $key_to_delete = end($offset); |
155 | 155 | $parent_offset = $offset; |
156 | 156 | array_pop($parent_offset); |
157 | - if(!count($parent_offset)) { |
|
157 | + if (!count($parent_offset)) { |
|
158 | 158 | // В массиве был один элемент - мы удаляем в корне. Просто удаляем элемент |
159 | 159 | $this->__unset($key_to_delete); |
160 | 160 | } else { |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | public function compile_request($request) { |
451 | 451 | global $config, $lang, $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($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($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($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($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($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($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($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($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($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($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($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($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($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($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($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($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'] = $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'] = $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 | doquery("UPDATE {{payment}} SET payment_status = {$payment['payment_status']}, payment_comment = '{$safe_comment}' WHERE payment_id = {$payment['payment_id']};"); |
830 | 830 | throw new exception($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($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($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']; |