Completed
Push — trunk ( 0e7a2e...6a6c5e )
by SuperNova.WS
07:28
created
classes/userOptions.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 
135 135
     $update_cache = false;
136 136
 
137
-    if(!empty($this->to_write)) {
138
-      foreach($this->to_write as $key => $cork) {
137
+    if (!empty($this->to_write)) {
138
+      foreach ($this->to_write as $key => $cork) {
139 139
         $value = is_array($this->data[$key]) ? serialize($this->data[$key]) : $this->data[$key]; // Сериализация для массивов при сохранении в БД
140 140
         $this->to_write[$key] = "({$this->user_id}, '" . db_escape($key) . "', '" . db_escape($value) . "')";
141 141
       }
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
       $update_cache = true;
147 147
     }
148 148
 
149
-    if(!empty($this->to_delete)) {
150
-      foreach($this->to_delete as $key => &$value) {
151
-        $value = is_string($key) ? "'". db_escape($key) . "'" : $key;
149
+    if (!empty($this->to_delete)) {
150
+      foreach ($this->to_delete as $key => &$value) {
151
+        $value = is_string($key) ? "'" . db_escape($key) . "'" : $key;
152 152
       }
153 153
 
154
-      doquery("DELETE FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} AND `option_id` IN (". implode(',', $this->to_delete) . ") ");
154
+      doquery("DELETE FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} AND `option_id` IN (" . implode(',', $this->to_delete) . ") ");
155 155
 
156 156
       $this->to_delete = array();
157 157
       $update_cache = true;
158 158
     }
159 159
 
160
-    if($update_cache) {
160
+    if ($update_cache) {
161 161
       global $sn_cache;
162 162
 
163 163
       $field_name = $this->cached_name();
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
   protected function load($forceLoad = false) {
185 185
     global $sn_cache;
186 186
 
187
-    if($this->loaded) {
187
+    if ($this->loaded) {
188 188
       return;
189 189
     }
190 190
 
@@ -192,23 +192,23 @@  discard block
 block discarded – undo
192 192
     $this->to_write = array();
193 193
     $this->to_delete = array();
194 194
 
195
-    if(!$this->user_id) {
195
+    if (!$this->user_id) {
196 196
       $this->loaded = true;
197 197
       return;
198 198
     }
199 199
 
200 200
     $field_name = $this->cached_name();
201
-    if(!$forceLoad) {
201
+    if (!$forceLoad) {
202 202
       $a_data = $sn_cache->$field_name;
203 203
 
204
-      if(!empty($a_data)) {
204
+      if (!empty($a_data)) {
205 205
         $this->data = array_replace_recursive($this->data, $a_data);
206 206
         return;
207 207
       }
208 208
     }
209 209
 
210 210
     $query = doquery("SELECT * FROM `{{player_options}}` WHERE `player_id` = {$this->user_id} FOR UPDATE");
211
-    while($row = db_fetch($query)) {
211
+    while ($row = db_fetch($query)) {
212 212
       // $this->data[$row['option_id']] = $row['value'];
213 213
       $this->data[$row['option_id']] = is_string($row['value']) && ($temp = unserialize($row['value'])) !== false ? $temp : $row['value']; // Десериализация
214 214
     }
Please login to merge, or discard this patch.
language/ru/buildings.mo.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,9 @@
 block discarded – undo
24 24
 * DO NOT CHANGE
25 25
 */
26 26
 
27
-if (!defined('INSIDE')) die();
27
+if (!defined('INSIDE')) {
28
+  die();
29
+}
28 30
 
29 31
 $a_lang_array = array(
30 32
   'built' => 'Построено',
Please login to merge, or discard this patch.
language/en/buildings.mo.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,9 @@
 block discarded – undo
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(
Please login to merge, or discard this patch.
time_probe.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,11 +10,11 @@  discard block
 block discarded – undo
10 10
 $time_server = $time_local  - $time_diff
11 11
 */
12 12
 
13
-if($font_size = sys_get_param_str('font_size')) {
14
-  if(strpos($font_size, '%') !== false) {
13
+if ($font_size = sys_get_param_str('font_size')) {
14
+  if (strpos($font_size, '%') !== false) {
15 15
     // Размер шрифта в процентах
16 16
     $font_size = min(max(floatval($font_size), FONT_SIZE_PERCENT_MIN), FONT_SIZE_PERCENT_MAX) . '%';
17
-  } elseif(strpos($font_size, 'px') !== false) {
17
+  } elseif (strpos($font_size, 'px') !== false) {
18 18
     // Размер шрифта в пикселях
19 19
     $font_size = min(max(floatval($font_size), FONT_SIZE_PIXELS_MIN), FONT_SIZE_PIXELS_MAX) . 'px';
20 20
   } else {
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
   SN::$user_options[PLAYER_OPTION_BASE_FONT_SIZE] = $font_size;
27 27
 } else {
28 28
   $user_time_diff = playerTimeDiff::user_time_diff_get();
29
-  if($user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) {
29
+  if ($user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) {
30 30
     $time_diff = intval($user_time_diff[PLAYER_OPTION_TIME_DIFF]);
31 31
   } else {
32 32
     $user_time_diff = playerTimeDiff::user_time_diff_probe();
Please login to merge, or discard this patch.
admin/ajax_maintenance.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 
5 5
 require('../includes/init.' . substr(strrchr(__FILE__, '.'), 1));
6 6
 
7
-if($user['authlevel'] < 3)
7
+if ($user['authlevel'] < 3)
8 8
 {
9 9
   messageBox($lang['sys_noalloaw'], $lang['sys_noaccess']);
10 10
   die();
@@ -19,9 +19,9 @@  discard block
 block discarded – undo
19 19
 
20 20
 // [#] info_best_battles 1b0
21 21
 $best_reports = array();
22
-if(defined('MODULE_INFO_BEST_BATTLES_QUERY')) {
22
+if (defined('MODULE_INFO_BEST_BATTLES_QUERY')) {
23 23
   $query = doquery(MODULE_INFO_BEST_BATTLES_QUERY);
24
-  while($row = db_fetch($query)) {
24
+  while ($row = db_fetch($query)) {
25 25
     $best_reports[] = $row['ube_report_id'];
26 26
   }
27 27
 }
@@ -188,16 +188,16 @@  discard block
 block discarded – undo
188 188
 
189 189
 function sn_maintenance_pack_user_list($user_list) {
190 190
   $user_list = explode(',', $user_list);
191
-  foreach($user_list as $key => $user_id) {
192
-    if(!ceil(floatval($user_id))) {
191
+  foreach ($user_list as $key => $user_id) {
192
+    if (!ceil(floatval($user_id))) {
193 193
       unset($user_list[$key]);
194 194
     }
195 195
   }
196 196
 
197 197
   $result = array();
198
-  if(!empty($user_list)) {
198
+  if (!empty($user_list)) {
199 199
     $query = doquery("SELECT `id` FROM {{users}} WHERE `id` in (" . implode(',', $user_list) . ")");
200
-    while($row = db_fetch($query)) {
200
+    while ($row = db_fetch($query)) {
201 201
       $result[] = $row['id'];
202 202
     }
203 203
   }
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
 $old_server_status == GAME_DISABLE_NONE ? SN::$config->db_saveItem('game_disable', GAME_DISABLE_MAINTENANCE) : false;
213 213
 sn_db_transaction_commit();
214 214
 
215
-foreach($ques as $que_transaction) {
215
+foreach ($ques as $que_transaction) {
216 216
   sn_db_transaction_start();
217 217
 
218 218
   !is_array($que_transaction) ? $que_transaction = array($que_transaction) : false;
219
-  foreach($que_transaction as $que) {
219
+  foreach ($que_transaction as $que) {
220 220
     set_time_limit(120);
221 221
     $QryResult = doquery($que);
222 222
     //$msg .= '<hr>' . $que . '<hr>';
Please login to merge, or discard this patch.
admin/admin_analyze_matter.php 1 patch
Spacing   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 
16 16
 $constants = get_defined_constants(true);
17 17
 $rpgConstants = array();
18
-foreach($constants['user'] as $constantName => $constantValue) {
19
-  if(substr($constantName, 0, 4) == 'RPG_') {
18
+foreach ($constants['user'] as $constantName => $constantValue) {
19
+  if (substr($constantName, 0, 4) == 'RPG_') {
20 20
     $rpgConstants[$constantValue] = $constantName;
21 21
   }
22 22
 }
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 GROUP BY log_dark_matter_reason, IF(sign((log_dark_matter_amount)) > 0, 1, -1) ORDER BY sum(log_dark_matter_amount) DESC;
34 34
 ");
35 35
 
36
-while($row = SN::$db->db_fetch($result)) {
36
+while ($row = SN::$db->db_fetch($result)) {
37 37
   $row['CONSTANT'] = $rpgConstants[$row['REASON']];
38 38
 
39 39
   $row['DM_AMOUNT_TEXT'] = HelperString::numberFloorAndFormat($row['DM_AMOUNT']);
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 GROUP BY reason, if(sign((amount)) > 0, 1, -1) ORDER BY sum(amount) DESC;
56 56
 ");
57 57
 
58
-while($row = SN::$db->db_fetch($result)) {
59
-  if(empty($spent[$row['BALANCE']])) {
58
+while ($row = SN::$db->db_fetch($result)) {
59
+  if (empty($spent[$row['BALANCE']])) {
60 60
     $spent[$row['BALANCE']] = array();
61 61
   }
62 62
 
@@ -66,16 +66,15 @@  discard block
 block discarded – undo
66 66
   $spent[$row['BALANCE']] = array_merge_recursive_numeric($spent[$row['BALANCE']], $row);
67 67
 }
68 68
 
69
-foreach($spent as &$row) {
69
+foreach ($spent as &$row) {
70 70
   @$row['TOTAL_COUNT'] = $row['MM_COUNT'] + $row['DM_COUNT'];
71 71
   @$row['TOTAL_AMOUNT'] = $row['MM_AMOUNT'] + $row['DM_AMOUNT'];
72 72
   @$row['TOTAL_AMOUNT_TEXT'] = HelperString::numberFloorAndFormat($row['TOTAL_AMOUNT']);
73 73
   @$row['TOTAL_COUNT_TEXT'] = HelperString::numberFloorAndFormat($row['TOTAL_COUNT']);
74 74
 }
75 75
 
76
-usort($spent, function ($a, $b) {
77
-  return $a['TOTAL_AMOUNT'] < $b['TOTAL_AMOUNT'] ? -1 :
78
-    ($a['TOTAL_AMOUNT'] > $b['TOTAL_AMOUNT'] ? 1 : 0);
76
+usort($spent, function($a, $b) {
77
+  return $a['TOTAL_AMOUNT'] < $b['TOTAL_AMOUNT'] ? -1 : ($a['TOTAL_AMOUNT'] > $b['TOTAL_AMOUNT'] ? 1 : 0);
79 78
 });
80 79
 
81 80
 
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(!(SN::$auth->account instanceof Account)) {
453
+    if (!(SN::$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 = SN::$auth->account;
@@ -470,15 +470,15 @@  discard block
 block discarded – undo
470 470
     $this->payment_currency = $config->payment_currency_default;
471 471
     $this->payment_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_currency);
472 472
 
473
-    if(empty($this->payment_external_currency) && !empty($this->config['currency'])) {
473
+    if (empty($this->payment_external_currency) && !empty($this->config['currency'])) {
474 474
       $this->payment_external_currency = $this->config['currency'];
475 475
     }
476
-    if(empty($this->payment_external_currency)) {
476
+    if (empty($this->payment_external_currency)) {
477 477
       throw new Exception($lang['pay_error_internal_no_external_currency_set'], SN_PAYMENT_ERROR_INTERNAL_NO_EXTERNAL_CURRENCY_SET);
478 478
     }
479 479
 
480 480
     $this->payment_external_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_external_currency);
481
-    if($this->payment_external_amount < 0.01) {
481
+    if ($this->payment_external_amount < 0.01) {
482 482
       throw new Exception($lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT);
483 483
     }
484 484
 
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
     $this->generate_description();
488 488
 
489 489
     $this->db_insert();
490
-    if(!$this->is_exists) {
490
+    if (!$this->is_exists) {
491 491
       throw new Exception($lang['pay_msg_request_error_db_payment_create'], SN_PAYMENT_REQUEST_DB_ERROR_PAYMENT_CREATE);
492 492
     }
493 493
   }
@@ -502,24 +502,24 @@  discard block
 block discarded – undo
502 502
   protected function payment_request_process($options = array()) {
503 503
     global $lang, $config;
504 504
 
505
-    if(!$this->manifest['active']) {
505
+    if (!$this->manifest['active']) {
506 506
       throw new Exception($lang['pay_msg_module_disabled'], SN_MODULE_DISABLED);
507 507
     }
508 508
 
509 509
     // Если есть payment_id - загружаем под него данные
510
-    if(!empty($this->payment_params['payment_id'])) {
510
+    if (!empty($this->payment_params['payment_id'])) {
511 511
       $this->request_payment_id = sys_get_param_id($this->payment_params['payment_id']);
512
-      if(!$this->request_payment_id) {
512
+      if (!$this->request_payment_id) {
513 513
         throw new Exception($lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG);
514 514
       }
515 515
 
516
-      if(!$this->db_get_by_id($this->request_payment_id)) {
516
+      if (!$this->db_get_by_id($this->request_payment_id)) {
517 517
         throw new Exception($lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG);
518 518
       }
519 519
 
520 520
       // Проверяем - был ли этот платеж обработан?
521 521
       // TODO - Статусы бывают разные. Нужен спецфлаг payment_processed
522
-      if($this->payment_status != PAYMENT_STATUS_NONE) {
522
+      if ($this->payment_status != PAYMENT_STATUS_NONE) {
523 523
         sn_db_transaction_rollback();
524 524
         sys_redirect(SN_ROOT_VIRTUAL . 'metamatter.php?payment_id=' . $this->payment_id);
525 525
         die();
@@ -529,89 +529,89 @@  discard block
 block discarded – undo
529 529
     // Пытаемся получить из запроса ИД аккаунта
530 530
     $request_account_id = !empty($this->payment_params['account_id']) ? sys_get_param_id($this->payment_params['account_id']) : 0;
531 531
     // Если в запросе нет ИД аккаунта - пытаемся использовать payment_account_id
532
-    if(empty($request_account_id) && !empty($this->payment_account_id)) {
532
+    if (empty($request_account_id) && !empty($this->payment_account_id)) {
533 533
       $request_account_id = $this->payment_account_id;
534 534
     }
535 535
     // Если теперь у нас нету ИД аккаунта ни в запросе, ни в записи таблицы - можно паниковать
536
-    if(empty($request_account_id)) {
536
+    if (empty($request_account_id)) {
537 537
       // TODO - аккаунт
538 538
       throw new Exception($lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
539 539
     }
540 540
     // Если нет записи в таблице - тогда берем payment_account_id из запроса
541
-    if(empty($this->payment_account_id)) {
541
+    if (empty($this->payment_account_id)) {
542 542
       $this->payment_account_id = $request_account_id;
543 543
     }
544 544
     // Если у нас отличаются ИД аккаунта в запросе и ИД аккаунта в записи - тоже можно паниковать
545
-    if($this->payment_account_id != $request_account_id) {
545
+    if ($this->payment_account_id != $request_account_id) {
546 546
       // TODO - Поменять сообщение об ошибке
547 547
       throw new Exception($lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
548 548
     }
549 549
     // Проверяем существование аккаунта с данным ИД
550
-    if(!$this->account->db_get_by_id($this->payment_account_id)) {
550
+    if (!$this->account->db_get_by_id($this->payment_account_id)) {
551 551
       throw new Exception($lang['pay_msg_request_user_invalid'] . ' ID ' . $this->payment_account_id, $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
552 552
     }
553 553
 
554 554
     // TODO Проверка на сервер_ид - как бы и не нужна, наверное?
555
-    if(!empty($this->payment_params['server_id'])) {
555
+    if (!empty($this->payment_params['server_id'])) {
556 556
       $this->request_server_id = sys_get_param_str($this->payment_params['server_id']);
557
-      if(SN_ROOT_VIRTUAL != $this->request_server_id) {
557
+      if (SN_ROOT_VIRTUAL != $this->request_server_id) {
558 558
         throw new Exception($lang['pay_msg_request_server_wrong'] . " {$this->request_server_id} вместо " . SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG);
559 559
       }
560 560
     }
561 561
 
562 562
     // Сверка количества оплаченной ММ с учётом бонусов
563
-    if(!empty($this->payment_params['payment_dark_matter_gained'])) {
563
+    if (!empty($this->payment_params['payment_dark_matter_gained'])) {
564 564
       $request_mm_amount = sys_get_param_id($this->payment_params['payment_dark_matter_gained']);
565
-      if($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) {
565
+      if ($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) {
566 566
         throw new Exception($lang['pay_msg_mm_request_amount_invalid'] . " пришло {$request_mm_amount} ММ вместо {$this->payment_dark_matter_gained} ММ", SN_PAYMENT_REQUEST_MM_AMOUNT_INVALID);
567 567
       }
568 568
       empty($this->payment_dark_matter_gained) ? $this->payment_dark_matter_gained = $request_mm_amount : false;
569 569
     }
570
-    if(empty($this->payment_dark_matter_paid)) {
570
+    if (empty($this->payment_dark_matter_paid)) {
571 571
       // TODO - обратный расчёт из gained
572 572
     }
573 573
 
574 574
     // Проверка наличия внешнего ИД платежа
575
-    if(!empty($this->payment_params['payment_external_id'])) {
575
+    if (!empty($this->payment_params['payment_external_id'])) {
576 576
       $request_payment_external_id = sys_get_param_id($this->payment_params['payment_external_id']);
577
-      if(empty($request_payment_external_id)) {
577
+      if (empty($request_payment_external_id)) {
578 578
         throw new exception($lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG);
579
-      } elseif(!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) {
579
+      } elseif (!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) {
580 580
         // TODO - Может быть поменять сообщение
581 581
         throw new exception($lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG);
582 582
       }
583 583
       $this->payment_external_id = $request_payment_external_id;
584 584
     }
585 585
     // Сверка суммы, запрошенной СН к оплате
586
-    if(!empty($this->payment_params['payment_external_money'])) {
586
+    if (!empty($this->payment_params['payment_external_money'])) {
587 587
       $request_money_out = sys_get_param_float($this->payment_params['payment_external_money']);
588
-      if($request_money_out != $this->payment_external_amount && $this->is_loaded) {
588
+      if ($request_money_out != $this->payment_external_amount && $this->is_loaded) {
589 589
         throw new Exception($lang['pay_msg_request_payment_amount_invalid'] . " пришло {$request_money_out} денег вместо {$this->payment_external_amount} денег", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID);
590 590
       }
591 591
       empty($this->payment_external_amount) ? $this->payment_external_amount = $request_money_out : false;
592 592
     }
593 593
     // Заполняем поле валюты платёжной системы
594
-    if(!empty($this->payment_params['payment_external_currency'])) {
594
+    if (!empty($this->payment_params['payment_external_currency'])) {
595 595
       $this->payment_external_currency = sys_get_param_str($this->payment_params['payment_external_currency']);
596
-      if(empty($this->payment_external_currency)) {
596
+      if (empty($this->payment_external_currency)) {
597 597
         // TODO - поменять сообщение
598 598
         throw new Exception($lang['pay_msg_request_payment_amount_invalid'] . " {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID);
599 599
       }
600 600
     }
601
-    if(empty($this->payment_external_currency)) {
601
+    if (empty($this->payment_external_currency)) {
602 602
       $this->payment_external_currency = $this->config['currency'];
603 603
     }
604 604
 
605 605
     // Заполнение внутренней суммы и валюты из внешних данных
606
-    if(empty($this->payment_currency)) {
606
+    if (empty($this->payment_currency)) {
607 607
       $this->payment_currency = $config->payment_currency_default;
608 608
     }
609
-    if(empty($this->payment_amount) && !empty($this->payment_external_currency)) {
609
+    if (empty($this->payment_amount) && !empty($this->payment_external_currency)) {
610 610
       $this->payment_amount = self::currency_convert($this->payment_external_amount, $this->payment_external_currency, $this->payment_currency);
611 611
     }
612 612
 
613 613
     // TODO - Тестовый режим
614
-    if(!empty($this->payment_params['test'])) {
614
+    if (!empty($this->payment_params['test'])) {
615 615
       $this->payment_test = $this->config['test'] || sys_get_param_int($this->payment_params['test']);
616 616
     }
617 617
 
@@ -640,12 +640,12 @@  discard block
 block discarded – undo
640 640
     sn_db_transaction_start();
641 641
     try {
642 642
       $response = $this->payment_request_process();
643
-    } catch(Exception $e) {
643
+    } catch (Exception $e) {
644 644
       $response['result'] = $e->getCode();
645 645
       $response['message'] = $e->getMessage();
646 646
     }
647 647
 
648
-    if($response['result'] == SN_PAYMENT_REQUEST_OK) {
648
+    if ($response['result'] == SN_PAYMENT_REQUEST_OK) {
649 649
       sn_db_transaction_commit();
650 650
       $debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Успешный платёж', LOG_INFO_PAYMENT);
651 651
     } else {
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
     }
655 655
 
656 656
     // Переводим код результата из СН в код платежной системы
657
-    if(is_array($this->result_translations) && !empty($this->result_translations)) {
657
+    if (is_array($this->result_translations) && !empty($this->result_translations)) {
658 658
       $response['result'] = isset($this->result_translations[$response['result']]) ? $this->result_translations[$response['result']] : $this->result_translations[SN_PAYMENT_REQUEST_UNDEFINED_ERROR];
659 659
     }
660 660
 
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
     $currency_from = strtolower($currency_from);
680 680
     $currency_to = strtolower($currency_to);
681 681
 
682
-    if($currency_from != $currency_to) {
682
+    if ($currency_from != $currency_to) {
683 683
 //      $config_currency_from_name = 'payment_currency_exchange_' . $currency_from;
684 684
 //      $config_currency_to_name = 'payment_currency_exchange_' . $currency_to;
685 685
 
@@ -709,10 +709,10 @@  discard block
 block discarded – undo
709 709
   public static function bonus_calculate($dark_matter, $direct = true, $return_bonus = false) {
710 710
     $bonus = 0;
711 711
     $dark_matter_new = $dark_matter;
712
-    if(!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) {
713
-      if($direct) {
714
-        foreach(self::$bonus_table as $dm_for_bonus => $multiplier) {
715
-          if($dm_for_bonus <= $dark_matter) {
712
+    if (!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) {
713
+      if ($direct) {
714
+        foreach (self::$bonus_table as $dm_for_bonus => $multiplier) {
715
+          if ($dm_for_bonus <= $dark_matter) {
716 716
             $dark_matter_new = $dark_matter * (1 + $multiplier);
717 717
             $bonus = $multiplier;
718 718
           } else {
@@ -720,9 +720,9 @@  discard block
 block discarded – undo
720 720
           }
721 721
         }
722 722
       } else {
723
-        foreach(self::$bonus_table as $dm_for_bonus => $multiplier) {
723
+        foreach (self::$bonus_table as $dm_for_bonus => $multiplier) {
724 724
           $temp = $dm_for_bonus * (1 + $multiplier);
725
-          if($dark_matter >= $temp) {
725
+          if ($dark_matter >= $temp) {
726 726
             $dark_matter_new = round($dark_matter / (1 + $multiplier));
727 727
             $bonus = $multiplier;
728 728
           } else {
@@ -778,13 +778,13 @@  discard block
 block discarded – undo
778 778
     );
779 779
 
780 780
     $replace = false;
781
-    if($this->payment_id) {
781
+    if ($this->payment_id) {
782 782
       $payment['payment_id'] = $this->payment_id;
783 783
       $replace = true;
784 784
     }
785 785
 
786 786
     $query = array();
787
-    foreach($payment as $key => $value) {
787
+    foreach ($payment as $key => $value) {
788 788
       $value = is_string($value) ? '"' . db_escape($value) . '"' : $value;
789 789
       $query[] = "`{$key}` = {$value}";
790 790
     }
@@ -796,12 +796,12 @@  discard block
 block discarded – undo
796 796
 
797 797
 
798 798
   function payment_adjust_mm_new() {
799
-    if(!$this->payment_test) {
799
+    if (!$this->payment_test) {
800 800
       // Not a test payment. Adding DM to account
801 801
       $this->account = new Account($this->db);
802 802
       $this->account->db_get_by_id($this->payment_account_id);
803 803
       $result = $this->account->metamatter_change(RPG_PURCHASE, $this->payment_dark_matter_gained, $this->payment_comment);
804
-      if(!$result) {
804
+      if (!$result) {
805 805
         throw new Exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST);
806 806
       }
807 807
     }
@@ -811,25 +811,25 @@  discard block
 block discarded – undo
811 811
     die('{НЕ РАБОТАЕТ! СООБЩИТЕ АДМИНИСТРАЦИИ!}');
812 812
     global $lang;
813 813
 
814
-    if(!isset($payment['payment_status'])) {
814
+    if (!isset($payment['payment_status'])) {
815 815
       throw new exception($lang['pay_msg_request_payment_not_found'], SN_PAYMENT_REQUEST_ORDER_NOT_FOUND);
816 816
     }
817 817
 
818
-    if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
819
-      $safe_comment = db_escape($payment['payment_comment'] = $lang['pay_msg_request_payment_cancelled'] .' ' . $payment['payment_comment']);
818
+    if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
819
+      $safe_comment = db_escape($payment['payment_comment'] = $lang['pay_msg_request_payment_cancelled'] . ' ' . $payment['payment_comment']);
820 820
 
821
-      if(!$payment['payment_test']) {
821
+      if (!$payment['payment_test']) {
822 822
         $result = $this->account->metamatter_change(RPG_PURCHASE_CANCEL, -$payment['payment_dark_matter_gained'], $payment['payment_comment']);
823
-        if(!$result) {
823
+        if (!$result) {
824 824
           throw new exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST);
825 825
         }
826 826
       }
827 827
       $payment['payment_status'] = PAYMENT_STATUS_CANCELED;
828 828
       doquery("UPDATE {{payment}} SET payment_status = {$payment['payment_status']}, payment_comment = '{$safe_comment}' WHERE payment_id = {$payment['payment_id']};");
829 829
       throw new exception($lang['pay_msg_request_payment_cancel_complete'], SN_PAYMENT_REQUEST_OK);
830
-    } elseif($payment['payment_status'] == PAYMENT_STATUS_CANCELED) {
830
+    } elseif ($payment['payment_status'] == PAYMENT_STATUS_CANCELED) {
831 831
       throw new exception($lang['pay_msg_request_payment_cancelled_already'], SN_PAYMENT_REQUEST_OK);
832
-    } elseif($payment['payment_status'] == PAYMENT_STATUS_NONE) {
832
+    } elseif ($payment['payment_status'] == PAYMENT_STATUS_NONE) {
833 833
       throw new exception($lang['pay_msg_request_payment_cancel_not_complete'], SN_PAYMENT_REQUEST_PAYMENT_NOT_COMPLETE);
834 834
     }
835 835
   }
@@ -843,8 +843,8 @@  discard block
 block discarded – undo
843 843
 
844 844
   protected function db_complete_payment() {
845 845
     // TODO - поле payment_processed
846
-    if($this->payment_status == PAYMENT_STATUS_NONE) {
847
-      if(!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) {
846
+    if ($this->payment_status == PAYMENT_STATUS_NONE) {
847
+      if (!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) {
848 848
         $this->payment_adjust_mm_new();
849 849
         $this->payment_status = PAYMENT_STATUS_COMPLETE;
850 850
       } else {
@@ -891,7 +891,7 @@  discard block
 block discarded – undo
891 891
   protected function db_assign_payment($payment = null) {
892 892
     $this->payment_reset();
893 893
 
894
-    if(is_array($payment) && isset($payment['payment_id'])) {
894
+    if (is_array($payment) && isset($payment['payment_id'])) {
895 895
       $this->payment_id = $payment['payment_id'];
896 896
       $this->payment_status = $payment['payment_status'];
897 897
       $this->payment_date = $payment['payment_date'];
Please login to merge, or discard this patch.
classes/auth_local.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
     $this->prepare();
97 97
 
98 98
     $this->manifest['active'] = false;
99
-    if(!empty($this->config) && is_array($this->config['db'])) {
99
+    if (!empty($this->config) && is_array($this->config['db'])) {
100 100
       // БД, отличная от стандартной
101 101
       $this->db = new db_mysql();
102 102
 
103 103
       $this->db->sn_db_connect($this->config['db']);
104
-      if($this->manifest['active'] = $this->db->connected) {
104
+      if ($this->manifest['active'] = $this->db->connected) {
105 105
         $this->provider_id = ACCOUNT_PROVIDER_CENTRAL;
106 106
 
107 107
         $this->domain = $this->config['domain'];
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     }
116 116
 
117 117
     // Fallback to local DB
118
-    if(!$this->manifest['active']) {
118
+    if (!$this->manifest['active']) {
119 119
       $this->db = SN::$db;
120 120
 
121 121
       $this->provider_id = ACCOUNT_PROVIDER_LOCAL;
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
    */
170 170
   public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) {
171 171
     $result = parent::password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe);
172
-    if($result) {
172
+    if ($result) {
173 173
       $this->cookie_set();
174 174
     }
175 175
 
@@ -198,12 +198,12 @@  discard block
 block discarded – undo
198 198
   protected function password_reset_send_code() {
199 199
     global $lang, $config;
200 200
 
201
-    if(!$this->is_password_reset) {
201
+    if (!$this->is_password_reset) {
202 202
       return $this->account_login_status;
203 203
     }
204 204
 
205 205
     // Проверяем поддержку сброса пароля
206
-    if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
206
+    if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
207 207
       return $this->account_login_status;
208 208
     }
209 209
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
       unset($this->account);
214 214
       $this->account = new Account($this->db);
215 215
 
216
-      if(!$this->account->db_get_by_email($email_unsafe)) {
216
+      if (!$this->account->db_get_by_email($email_unsafe)) {
217 217
         throw new Exception(PASSWORD_RESTORE_ERROR_EMAIL_NOT_EXISTS, ERR_ERROR);
218 218
         // return $this->account_login_status;
219 219
       }
@@ -223,14 +223,14 @@  discard block
 block discarded – undo
223 223
 
224 224
       // TODO - Проверять уровень доступа аккаунта!
225 225
       // Аккаунты с АУТЛЕВЕЛ больше 0 - НЕ СБРАСЫВАЮТ ПАРОЛИ!
226
-      foreach($user_list as $user_id => $user_data) {
227
-        if($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) {
226
+      foreach ($user_list as $user_id => $user_data) {
227
+        if ($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) {
228 228
           throw new Exception(PASSWORD_RESTORE_ERROR_ADMIN_ACCOUNT, ERR_ERROR);
229 229
         }
230 230
       }
231 231
 
232 232
       $confirmation = $this->confirmation->db_confirmation_get_latest_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5
233
-      if(isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) {
233
+      if (isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) {
234 234
         throw new Exception(PASSWORD_RESTORE_ERROR_TOO_OFTEN, ERR_ERROR);
235 235
       }
236 236
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
       $confirm_code_unsafe = $this->confirmation->db_confirmation_get_unique_code_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5
242 242
       sn_db_transaction_commit();
243 243
 
244
-      if(!is_email($email_unsafe)) {
244
+      if (!is_email($email_unsafe)) {
245 245
         SN::$debug->error("Email is invalid: '{$email_unsafe}'", 'Invalid email for password restoration');
246 246
       }
247 247
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
       );
252 252
 
253 253
       $result = $result ? PASSWORD_RESTORE_SUCCESS_CODE_SENT : PASSWORD_RESTORE_ERROR_SENDING;
254
-    } catch(Exception $e) {
254
+    } catch (Exception $e) {
255 255
       sn_db_transaction_rollback();
256 256
       $result = $e->getMessage();
257 257
     }
@@ -266,46 +266,46 @@  discard block
 block discarded – undo
266 266
   protected function password_reset_confirm() {
267 267
     global $lang, $config;
268 268
 
269
-    if(!$this->is_password_reset_confirm) {
269
+    if (!$this->is_password_reset_confirm) {
270 270
       return $this->account_login_status;
271 271
     }
272 272
 
273
-    if($this->account_login_status != LOGIN_UNDEFINED) {
273
+    if ($this->account_login_status != LOGIN_UNDEFINED) {
274 274
       return $this->account_login_status;
275 275
     }
276 276
 
277 277
     // Проверяем поддержку сброса пароля
278
-    if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
278
+    if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
279 279
       return $this->account_login_status;
280 280
     }
281 281
 
282 282
     try {
283 283
       $code_unsafe = sys_get_param_str_unsafe('password_reset_code');
284
-      if(empty($code_unsafe)) {
284
+      if (empty($code_unsafe)) {
285 285
         throw new Exception(PASSWORD_RESTORE_ERROR_CODE_EMPTY, ERR_ERROR);
286 286
       }
287 287
 
288 288
       sn_db_transaction_start();
289 289
       $confirmation = $this->confirmation->db_confirmation_get_by_type_and_code(CONFIRM_PASSWORD_RESET, $code_unsafe); // OK 4.5
290 290
 
291
-      if(empty($confirmation)) {
291
+      if (empty($confirmation)) {
292 292
         throw new Exception(PASSWORD_RESTORE_ERROR_CODE_WRONG, ERR_ERROR);
293 293
       }
294 294
 
295
-      if(SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) {
295
+      if (SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) {
296 296
         throw new Exception(PASSWORD_RESTORE_ERROR_CODE_TOO_OLD, ERR_ERROR);
297 297
       }
298 298
 
299 299
       unset($this->account);
300 300
       $this->account = new Account($this->db);
301 301
 
302
-      if(!$this->account->db_get_by_email($confirmation['email'])) {
302
+      if (!$this->account->db_get_by_email($confirmation['email'])) {
303 303
         throw new Exception(PASSWORD_RESTORE_ERROR_CODE_OK_BUT_NO_ACCOUNT_FOR_EMAIL, ERR_ERROR);
304 304
       }
305 305
 
306 306
       $new_password_unsafe = $this->make_random_password();
307 307
       $salt_unsafe = $this->password_salt_generate();
308
-      if(!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) {
308
+      if (!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) {
309 309
         // Ошибка смены пароля
310 310
         throw new Exception(AUTH_ERROR_INTERNAL_PASSWORD_CHANGE_ON_RESTORE, ERR_ERROR);
311 311
       }
@@ -315,14 +315,14 @@  discard block
 block discarded – undo
315 315
       $this->cookie_set();
316 316
       $this->login_cookie();
317 317
 
318
-      if($this->account_login_status == LOGIN_SUCCESS) {
318
+      if ($this->account_login_status == LOGIN_SUCCESS) {
319 319
         // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!!
320 320
         $message_header = sprintf($lang['log_lost_email_title'], $config->game_name);
321 321
         $message = sprintf($lang['log_lost_email_pass'], $config->game_name, $this->account->account_name, $new_password_unsafe);
322 322
         @$operation_result = mymail($confirmation['email'], $message_header, htmlspecialchars($message));
323 323
 
324 324
         $users_translated = PlayerToAccountTranslate::db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5
325
-        if(!empty($users_translated)) {
325
+        if (!empty($users_translated)) {
326 326
           // Отправляем в лички письмо о сбросе пароля
327 327
 
328 328
           // ПО ОПРЕДЕЛЕНИЮ в $users_translated только
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
           $message = HelperString::nl2br($message) . '<br><br>';
335 335
           // msg_send_simple_message($found_provider->data[F_USER_ID], 0, SN_TIME_NOW, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['sys_login_register_message_title'], $message);
336 336
 
337
-          foreach($users_translated as $user_id => $providers_list) {
337
+          foreach ($users_translated as $user_id => $providers_list) {
338 338
             msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['sys_login_register_message_title'], $message);
339 339
           }
340 340
         } else {
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
     $this->flog('Регистрация: начинаем. Провайдер ' . $this->provider_id);
388 388
 
389 389
     try {
390
-      if(!$this->is_register) {
390
+      if (!$this->is_register) {
391 391
         $this->flog('Регистрация: не выставлен флаг регистрации - пропускаем');
392 392
         throw new Exception(LOGIN_UNDEFINED, ERR_ERROR);
393 393
       }
@@ -399,8 +399,8 @@  discard block
 block discarded – undo
399 399
       // $this->account_check_duplicate_name_or_email($this->input_login_unsafe, $this->input_email_unsafe);
400 400
 
401 401
       $this->account->db_get_by_name_or_email($this->input_login_unsafe, $this->input_email_unsafe);
402
-      if($this->account->is_exists) {
403
-        if($this->account->account_email == $this->input_email_unsafe) {
402
+      if ($this->account->is_exists) {
403
+        if ($this->account->account_email == $this->input_email_unsafe) {
404 404
           throw new Exception(REGISTER_ERROR_EMAIL_EXISTS, ERR_ERROR);
405 405
         } else {
406 406
           throw new Exception(REGISTER_ERROR_ACCOUNT_NAME_EXISTS, ERR_ERROR);
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
       // А вот это пока не нужно. Трансляцией аккаунтов в юзеров и созданием новых юзеров для новозашедших аккаунтов занимается Auth
440 440
       // $this->register_account();
441 441
       sn_db_transaction_commit();
442
-    } catch(Exception $e) {
442
+    } catch (Exception $e) {
443 443
       sn_db_transaction_rollback();
444 444
       $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false;
445 445
     }
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
    * @return int Результат попытки
455 455
    */
456 456
   protected function login_cookie() {
457
-    if($this->account_login_status != LOGIN_UNDEFINED) {
457
+    if ($this->account_login_status != LOGIN_UNDEFINED) {
458 458
       return $this->account_login_status;
459 459
     }
460 460
 
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 //      $this->cookie_clear();
481 481
 //    }
482 482
 
483
-    if($this->account->cookieLogin($rememberMe)) {
483
+    if ($this->account->cookieLogin($rememberMe)) {
484 484
         $this->account_login_status = LOGIN_SUCCESS;
485 485
         $this->remember_me = intval($rememberMe);
486 486
     }
@@ -497,13 +497,13 @@  discard block
 block discarded – undo
497 497
   protected function login_username() {
498 498
     // TODO - Логин по старым именам
499 499
     try {
500
-      if(!$this->is_login) {
500
+      if (!$this->is_login) {
501 501
         $this->flog('Логин: не выставлен флаг входа в игру - это не логин');
502 502
         throw new Exception(LOGIN_UNDEFINED, ERR_ERROR);
503 503
       }
504 504
 
505 505
       // TODO Пустое имя аккаунта
506
-      if(!$this->input_login_unsafe) {
506
+      if (!$this->input_login_unsafe) {
507 507
         throw new Exception(LOGIN_UNDEFINED, ERR_ERROR);
508 508
       }
509 509
 
@@ -513,11 +513,11 @@  discard block
 block discarded – undo
513 513
 //      if(empty($account)) {
514 514
 //        throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR);
515 515
 //      }
516
-      if(!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) {
516
+      if (!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) {
517 517
         throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR);
518 518
       }
519 519
 
520
-      if(!$this->account->password_check($this->input_login_password_raw)) {
520
+      if (!$this->account->password_check($this->input_login_password_raw)) {
521 521
         throw new Exception(LOGIN_ERROR_PASSWORD, ERR_ERROR);
522 522
       }
523 523
 
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 
526 526
       $this->cookie_set();
527 527
       $this->account_login_status = LOGIN_SUCCESS;
528
-    } catch(Exception $e) {
528
+    } catch (Exception $e) {
529 529
       $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false;
530 530
     }
531 531
 
@@ -546,11 +546,11 @@  discard block
 block discarded – undo
546 546
   protected function cookie_set($account_to_impersonate = null) {
547 547
     $this_account = is_object($account_to_impersonate) ? $account_to_impersonate : $this->account;
548 548
 
549
-    if(!is_object($this_account) || !$this_account->is_exists) {
549
+    if (!is_object($this_account) || !$this_account->is_exists) {
550 550
       throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR);
551 551
     }
552 552
 
553
-    if(is_object($account_to_impersonate) && $account_to_impersonate->is_exists) {
553
+    if (is_object($account_to_impersonate) && $account_to_impersonate->is_exists) {
554 554
       sn_setcookie($this->cookie_name_impersonate, $_COOKIE[$this->cookie_name], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain);
555 555
     }
556 556
 
@@ -587,10 +587,10 @@  discard block
 block discarded – undo
587 587
   protected function login_validate_input() {
588 588
     // Проверяем, что бы в начале и конце не было пустых символов
589 589
     // TODO - при копировании Эксель -> Опера - в конце образуются пустые места. Это не должно быть проблемой! Вынести проверку пароля в регистрацию!
590
-    if($this->input_login_password_raw != trim($this->input_login_password_raw)) {
590
+    if ($this->input_login_password_raw != trim($this->input_login_password_raw)) {
591 591
       throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR);
592 592
     }
593
-    if(!$this->input_login_password_raw) {
593
+    if (!$this->input_login_password_raw) {
594 594
       throw new Exception(LOGIN_ERROR_PASSWORD_EMPTY, ERR_ERROR);
595 595
     }
596 596
   }
@@ -605,37 +605,37 @@  discard block
 block discarded – undo
605 605
     $this->login_validate_input();
606 606
 
607 607
     // Если нет имени пользователя - NO GO!
608
-    if(!$this->input_login_unsafe) {
608
+    if (!$this->input_login_unsafe) {
609 609
       throw new Exception(LOGIN_ERROR_USERNAME_EMPTY, ERR_ERROR);
610 610
     }
611 611
     // Если логин имеет запрещенные символы - NO GO!
612
-    if(strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
612
+    if (strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
613 613
       throw new Exception(LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS, ERR_ERROR);
614 614
     }
615 615
     // Если логин меньше минимальной длины - NO GO!
616
-    if(strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) {
616
+    if (strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) {
617 617
       throw new Exception(REGISTER_ERROR_USERNAME_SHORT, ERR_ERROR);
618 618
     }
619 619
     // Если пароль меньше минимальной длины - NO GO!
620
-    if(strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) {
620
+    if (strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) {
621 621
       throw new Exception(REGISTER_ERROR_PASSWORD_INSECURE, ERR_ERROR);
622 622
     }
623 623
     // Если пароль имеет пробельные символы в начале или конце - NO GO!
624
-    if($this->input_login_password_raw != trim($this->input_login_password_raw)) {
624
+    if ($this->input_login_password_raw != trim($this->input_login_password_raw)) {
625 625
       throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR);
626 626
     }
627 627
     // Если пароль не совпадает с подтверждением - NO GO! То, что у пароля нет пробельных символов в начале/конце - мы уже проверили выше
628 628
     //Если они есть у повтора - значит пароль и повтор не совпадут
629
-    if($this->input_login_password_raw <> $this->input_login_password_raw_repeat) {
629
+    if ($this->input_login_password_raw <> $this->input_login_password_raw_repeat) {
630 630
       throw new Exception(REGISTER_ERROR_PASSWORD_DIFFERENT, ERR_ERROR);
631 631
     }
632 632
     // Если нет емейла - NO GO!
633 633
     // TODO - регистрация без емейла
634
-    if(!$this->input_email_unsafe) {
634
+    if (!$this->input_email_unsafe) {
635 635
       throw new Exception(REGISTER_ERROR_EMAIL_EMPTY, ERR_ERROR);
636 636
     }
637 637
     // Если емейл не является емейлом - NO GO!
638
-    if(!is_email($this->input_email_unsafe)) {
638
+    if (!is_email($this->input_email_unsafe)) {
639 639
       throw new Exception(REGISTER_ERROR_EMAIL_WRONG, ERR_ERROR);
640 640
     }
641 641
   }
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
     return core_auth::make_random_password();
667 667
   }
668 668
   protected function flog($message, $die = false) {
669
-    if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
669
+    if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
670 670
       return;
671 671
     }
672 672
     list($called, $caller) = debug_backtrace(false);
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
     $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false;
681 681
 
682 682
     SN::log_file("$message - $caller_name");
683
-    if($die) {
683
+    if ($die) {
684 684
       $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
685 685
     }
686 686
   }
Please login to merge, or discard this patch.
classes/SN.php 1 patch
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -419,7 +419,8 @@  discard block
 block discarded – undo
419 419
     $location_info = &static::$location_info[$location_type];
420 420
     $id_field = $location_info[P_ID];
421 421
     $table_name = $location_info[P_TABLE_NAME];
422
-    if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) // TODO Как-то вернуть может быть LIMIT 1 ?
422
+    if ($result = static::db_query_update("UPDATE {{{$table_name}}} SET {$set} WHERE `{$id_field}` = {$record_id}")) {
423
+      // TODO Как-то вернуть может быть LIMIT 1 ?
423 424
     {
424 425
       if (static::$db->db_affected_rows()) {
425 426
         // Обновляем данные только если ряд был затронут
@@ -427,6 +428,7 @@  discard block
 block discarded – undo
427 428
 
428 429
         // Тут именно так, а не cache_unset - что бы в кэшах автоматически обновилась запись. Будет нужно на будущее
429 430
         _SnCacheInternal::$data[$location_type][$record_id] = null;
431
+    }
430 432
         // Вытаскиваем обновленную запись
431 433
         static::db_get_record_by_id($location_type, $record_id);
432 434
         _SnCacheInternal::cache_clear($location_type, false); // Мягкий сброс - только $queries
@@ -460,9 +462,11 @@  discard block
 block discarded – undo
460 462
     $set = trim($set);
461 463
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
462 464
     if ($result = static::db_query_insert("INSERT INTO `{{{$table_name}}}` SET {$set}")) {
463
-      if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
465
+      if (static::$db->db_affected_rows()) {
466
+        // Обновляем данные только если ряд был затронут
464 467
       {
465 468
         $record_id = db_insert_id();
469
+      }
466 470
         // Вытаскиваем запись целиком, потому что в $set могли быть "данные по умолчанию"
467 471
         $result = static::db_get_record_by_id($location_type, $record_id);
468 472
         // Очищаем второстепенные кэши - потому что вставленная запись могла повлиять на результаты запросов или локация или еще чего
@@ -483,10 +487,12 @@  discard block
 block discarded – undo
483 487
     $id_field = $location_info[P_ID];
484 488
     $table_name = $location_info[P_TABLE_NAME];
485 489
     if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE `{$id_field}` = {$safe_record_id}")) {
486
-      if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
490
+      if (static::$db->db_affected_rows()) {
491
+        // Обновляем данные только если ряд был затронут
487 492
       {
488 493
         _SnCacheInternal::cache_unset($location_type, $safe_record_id);
489 494
       }
495
+      }
490 496
     }
491 497
 
492 498
     return $result;
@@ -500,11 +506,13 @@  discard block
 block discarded – undo
500 506
     $table_name = static::$location_info[$location_type][P_TABLE_NAME];
501 507
 
502 508
     if ($result = static::db_query_delete("DELETE FROM `{{{$table_name}}}` WHERE {$condition}")) {
503
-      if (static::$db->db_affected_rows()) // Обновляем данные только если ряд был затронут
509
+      if (static::$db->db_affected_rows()) {
510
+        // Обновляем данные только если ряд был затронут
504 511
       {
505 512
         // Обнуление кэша, потому что непонятно, что поменялось
506 513
         _SnCacheInternal::cache_clear($location_type);
507 514
       }
515
+      }
508 516
     }
509 517
 
510 518
     return $result;
Please login to merge, or discard this patch.