Passed
Branch trunk (7dc288)
by SuperNova.WS
06:07
created
simulator.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 include('common.' . substr(strrchr(__FILE__, '.'), 1));
4 4
 
5
-if(sys_get_param_int('BE_DEBUG') && !defined('BE_DEBUG'))
5
+if (sys_get_param_int('BE_DEBUG') && !defined('BE_DEBUG'))
6 6
 {
7 7
   define('BE_DEBUG', true);
8 8
 }
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 $sym_defender = $_POST['defender'] ? $_POST['defender'] : array();
16 16
 $sym_attacker = $_POST['attacker'] ? $_POST['attacker'] : array();
17 17
 
18
-if($replay)
18
+if ($replay)
19 19
 {
20 20
   $unpacked = sn_ube_simulator_decode_replay($replay);
21 21
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
   $sym_attacker = array(1 => $sym_attacker);
29 29
 }
30 30
 
31
-if($_POST['submit'] || $execute)
31
+if ($_POST['submit'] || $execute)
32 32
 {
33 33
   $replay = sn_ube_simulator_encode_replay($sym_defender, 'D');
34 34
   $replay .= sn_ube_simulator_encode_replay($sym_attacker, 'A');
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
 //    sn_ube_report_save($combat_data);
43 43
 //  }
44 44
 
45
-  if(sys_get_param_str('reload'))
45
+  if (sys_get_param_str('reload'))
46 46
   {
47 47
     $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]);
48 48
   }
@@ -62,9 +62,9 @@  discard block
 block discarded – undo
62 62
   $template = gettemplate('simulator', true);
63 63
   $techs_and_officers = array(TECH_WEAPON, TECH_SHIELD, TECH_ARMOR, MRC_ADMIRAL);
64 64
 
65
-  foreach($techs_and_officers as $tech_id)
65
+  foreach ($techs_and_officers as $tech_id)
66 66
   {
67
-    if(!$sym_attacker[1][$tech_id])
67
+    if (!$sym_attacker[1][$tech_id])
68 68
     {
69 69
       $sym_attacker[1][$tech_id] = mrc_get_level($user, false, $tech_id);
70 70
     }
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
     UNIT_GOVERNORS => array(MRC_FORTIFIER),
79 79
     UNIT_DEFENCE => sn_get_groups('defense_active'),
80 80
   );
81
-  foreach($show_groups as $unit_group_id => $unit_group)
81
+  foreach ($show_groups as $unit_group_id => $unit_group)
82 82
   {
83 83
     $template->assign_block_vars('simulator', array(
84 84
       'GROUP' => $unit_group_id,
85 85
       'NAME' => $lang['tech'][$unit_group_id],
86 86
     ));
87 87
 
88
-    foreach($unit_group as $unit_id)
88
+    foreach ($unit_group as $unit_id)
89 89
     {
90 90
       $tab++;
91 91
 
Please login to merge, or discard this patch.
login.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@
 block discarded – undo
15 15
 
16 16
 include('includes/init.' . substr(strrchr(__FILE__, '.'), 1));
17 17
 // die();
18
-if($template_result[F_USER_IS_AUTHORIZED]) {
18
+if ($template_result[F_USER_IS_AUTHORIZED]) {
19 19
   sys_redirect('index' . DOT_PHP_EX);
20 20
 }
21 21
 lng_include('login');
Please login to merge, or discard this patch.
market.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 $newstock = $stock;
27 27
 $intError = MARKET_DEAL;
28 28
 
29
-switch($mode)
29
+switch ($mode)
30 30
 {
31 31
   case MARKET_RESOURCES: // Resource trader
32 32
     require('includes/includes/market_trader.inc');
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
 }
83 83
 
84 84
 $message_id = sys_get_param_int('message');
85
-if($message_id != MARKET_NOTHING)
85
+if ($message_id != MARKET_NOTHING)
86 86
 {
87 87
   $template->assign_block_vars('result', array('MESSAGE' => $lang['eco_mrk_errors'][$message_id]));
88 88
 }
89 89
 
90
-if($message)
90
+if ($message)
91 91
 {
92 92
   $template->assign_block_vars('result', array('MESSAGE' => $message));
93 93
 }
Please login to merge, or discard this patch.
classes/auth_abstract.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
    */
36 36
   // OK 4.9
37 37
   public function __construct($filename = __FILE__) {
38
-    if($this->provider_id == ACCOUNT_PROVIDER_NONE) {
38
+    if ($this->provider_id == ACCOUNT_PROVIDER_NONE) {
39 39
       die('У всех провайдеров должен быть $provider_id!');
40 40
     }
41 41
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
   // OK 4.6
134 134
   public function player_name_suggest() {
135 135
     $name = '';
136
-    if(is_object($this->account) && !empty($this->account->account_email)) {
136
+    if (is_object($this->account) && !empty($this->account->account_email)) {
137 137
       list($name) = explode('@', $this->account->account_email);
138 138
     }
139 139
 
Please login to merge, or discard this patch.
classes/Confirmation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
       // $query = static::$db->doquery("SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' AND `type` = {$confirmation_type_safe} FOR UPDATE", true);
42 42
       // Тип не нужен для проверки - код подтверждения должен быть уникален от слова "совсем"
43 43
       $query = $this->db->doquery("SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' FOR UPDATE", true);
44
-    } while($query);
44
+    } while ($query);
45 45
 
46 46
     $this->db->doquery(
47 47
       "REPLACE INTO {{confirmations}}
Please login to merge, or discard this patch.
classes/Pimple/Container.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -239,7 +239,7 @@
 block discarded – undo
239 239
 
240 240
         $factory = $this->values[$id];
241 241
 
242
-        $extended = function ($c) use ($callable, $factory) {
242
+        $extended = function($c) use ($callable, $factory) {
243 243
             return $callable($factory($c), $c);
244 244
         };
245 245
 
Please login to merge, or discard this patch.
classes/PlayerToAccountTranslate.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
   protected static $is_init = false;
20 20
 
21 21
   protected static function init() {
22
-    if(!empty(static::$db)) {
22
+    if (!empty(static::$db)) {
23 23
       return;
24 24
     }
25 25
     static::$db = classSupernova::$db;
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
     $provider_id_safe = intval($provider_id_unsafe);
67 67
     !is_array($account_list) ? $account_list = array($account_list) : false;
68 68
 
69
-    foreach($account_list as $provider_account_id_unsafe) {
69
+    foreach ($account_list as $provider_account_id_unsafe) {
70 70
       $provider_account_id_safe = intval($provider_account_id_unsafe);
71 71
 
72 72
       // TODO - Здесь могут отсутствовать аккаунты - проверять провайдером
73 73
       $query = static::$db->doquery("SELECT `user_id` FROM {{account_translate}} WHERE `provider_id` = {$provider_id_safe} AND `provider_account_id` = {$provider_account_id_safe} FOR UPDATE");
74
-      while($row = static::$db->db_fetch($query)) {
74
+      while ($row = static::$db->db_fetch($query)) {
75 75
         $account_translation[$row['user_id']][$provider_id_unsafe][$provider_account_id_unsafe] = true;
76 76
       }
77 77
     }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
       "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} " .
92 92
       ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '') .
93 93
       "ORDER BY `timestamp` FOR UPDATE");
94
-    while($row = static::$db->db_fetch($query)) {
94
+    while ($row = static::$db->db_fetch($query)) {
95 95
       $account_translation[$row['user_id']][$row['provider_id']][$row['provider_account_id']] = $row;
96 96
     }
97 97
 
Please login to merge, or discard this patch.
classes/oldArrayAccessNd.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 {
Please login to merge, or discard this patch.
classes/sn_module_payment.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'];
Please login to merge, or discard this patch.