Passed
Branch trunk (7dc288)
by SuperNova.WS
06:07
created
language/ru/buddy.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.
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.
classes/template_compile.php 3 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
 
143 143
     preg_match_all('#<!-- INCLUDE (\{\$?[A-Z0-9\-_]+\}|[a-zA-Z0-9\_\-\+\./]+) -->#', $code, $matches);
144 144
     $include_blocks = $matches[1];
145
-    if($include_blocks)
145
+    if ($include_blocks)
146 146
     {
147
-      foreach($include_blocks as &$included_file)
147
+      foreach ($include_blocks as &$included_file)
148 148
       {
149 149
         $included_file .= '.tpl.html';
150 150
       }
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 
454 454
     $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){';
455 455
 //    $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;';
456
-    $tag_template_php .= '$_'. $tag_args . '_val = &' . $varref . '[$_'. $tag_args. '_i];';
457
-    $tag_template_php .= '$this->_block_value["'. $tag_args . '"] = &' . $varref . '[$_'. $tag_args. '_i];';
456
+    $tag_template_php .= '$_' . $tag_args . '_val = &' . $varref . '[$_' . $tag_args . '_i];';
457
+    $tag_template_php .= '$this->_block_value["' . $tag_args . '"] = &' . $varref . '[$_' . $tag_args . '_i];';
458 458
 
459 459
     return $tag_template_php;
460 460
   }
@@ -558,10 +558,10 @@  discard block
 block discarded – undo
558 558
         break;
559 559
 
560 560
         case 'is':
561
-          $is_arg_start = ($tokens[$i-1] == ')') ? array_pop($is_arg_stack) : $i-1;
561
+          $is_arg_start = ($tokens[$i - 1] == ')') ? array_pop($is_arg_stack) : $i - 1;
562 562
           $is_arg = implode(' ', array_slice($tokens, $is_arg_start, $i - $is_arg_start));
563 563
 
564
-          $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i+1));
564
+          $new_tokens = $this->_parse_is_expr($is_arg, array_slice($tokens, $i + 1));
565 565
 
566 566
           array_splice($tokens, $is_arg_start, sizeof($tokens), $new_tokens);
567 567
 
@@ -821,11 +821,11 @@  discard block
 block discarded – undo
821 821
     }
822 822
     else if ($include_last_iterator)
823 823
     {
824
-      return '$_'. $blocks[$blockcount] . '_val';
824
+      return '$_' . $blocks[$blockcount] . '_val';
825 825
     }
826 826
     else
827 827
     {
828
-      return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']';
828
+      return '$_' . $blocks[$blockcount - 1] . '_val[\'' . $blocks[$blockcount] . '\']';
829 829
     }
830 830
   }
831 831
 
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
     if ($fp = @fopen($filename, 'wb'))
843 843
     {
844 844
       @flock($fp, LOCK_EX);
845
-      @fwrite ($fp, $data);
845
+      @fwrite($fp, $data);
846 846
       @flock($fp, LOCK_UN);
847 847
       @fclose($fp);
848 848
 
@@ -862,7 +862,7 @@  discard block
 block discarded – undo
862 862
   {
863 863
     global $config;
864 864
 
865
-    if(!$config->tpl_minifier)
865
+    if (!$config->tpl_minifier)
866 866
     {
867 867
       return $html;
868 868
     }
@@ -874,14 +874,14 @@  discard block
 block discarded – undo
874 874
     //$html = preg_replace('/[\r\n\t]+/', ' ', $html);
875 875
     $html = preg_replace('/>[\s]*</', '><', $html); // Strip spacechars between tags
876 876
     $html = preg_replace('/[\s]+/', ' ', $html); // Replace several spacechars with one space
877
-    if(!empty($pre[0]))
877
+    if (!empty($pre[0]))
878 878
     {
879
-      foreach($pre[0] as $tag)
879
+      foreach ($pre[0] as $tag)
880 880
       {
881 881
         $tag = preg_replace('/^\ *\/\/[^\<]*?$/m', ' ', $tag); // Strips comments - except those that contains HTML comment inside
882 882
         $tag = preg_replace('/[\ \t]{2,}/', ' ', $tag); // Replace several spaces by one
883 883
         $tag = preg_replace('/\s{2,}/', "\r\n", $tag); // Replace several linefeeds by one
884
-        $html = preg_replace('/#pre#/', $tag, $html,1);
884
+        $html = preg_replace('/#pre#/', $tag, $html, 1);
885 885
       }
886 886
     }
887 887
 
Please login to merge, or discard this patch.
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
   }
56 56
 
57 57
   /**
58
-  * Load template source from file
59
-  * @access private
60
-  */
58
+   * Load template source from file
59
+   * @access private
60
+   */
61 61
   function _tpl_load_file($handle, $store_in_db = false)
62 62
   {
63 63
     // Try and open template for read
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
   }
101 101
 
102 102
   /**
103
-  * Remove any PHP tags that do not belong, these regular expressions are derived from
104
-  * the ones that exist in zend_language_scanner.l
105
-  * @access private
106
-  */
103
+   * Remove any PHP tags that do not belong, these regular expressions are derived from
104
+   * the ones that exist in zend_language_scanner.l
105
+   * @access private
106
+   */
107 107
   function remove_php_tags(&$code)
108 108
   {
109 109
     // This matches the information gathered from the internal PHP lexer
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
   }
118 118
 
119 119
   /**
120
-  * The all seeing all doing compile method. Parts are inspired by or directly from Smarty
121
-  * @access private
122
-  */
120
+   * The all seeing all doing compile method. Parts are inspired by or directly from Smarty
121
+   * @access private
122
+   */
123 123
   function compile($code, $no_echo = false, $echo_var = '')
124 124
   {
125 125
     global $config;
@@ -290,9 +290,9 @@  discard block
 block discarded – undo
290 290
   }
291 291
 
292 292
   /**
293
-  * Compile variables
294
-  * @access private
295
-  */
293
+   * Compile variables
294
+   * @access private
295
+   */
296 296
   function compile_var_tags(&$text_blocks)
297 297
   {
298 298
     // including $lang variable
@@ -359,9 +359,9 @@  discard block
 block discarded – undo
359 359
   }
360 360
 
361 361
   /**
362
-  * Compile blocks
363
-  * @access private
364
-  */
362
+   * Compile blocks
363
+   * @access private
364
+   */
365 365
   function compile_tag_block($tag_args)
366 366
   {
367 367
     $no_nesting = false;
@@ -447,14 +447,14 @@  discard block
 block discarded – undo
447 447
     $tag_template_php .= 'if ($_' . $tag_args . '_count) {';
448 448
 
449 449
     /**
450
-    * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory
451
-    * <code>
452
-    * if (!$offset)
453
-    * {
454
-    *   $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){';
455
-    * }
456
-    * </code>
457
-    */
450
+     * The following uses foreach for iteration instead of a for loop, foreach is faster but requires PHP to make a copy of the contents of the array which uses more memory
451
+     * <code>
452
+     * if (!$offset)
453
+     * {
454
+     *   $tag_template_php .= 'foreach (' . $varref . ' as $_' . $tag_args . '_i => $_' . $tag_args . '_val){';
455
+     * }
456
+     * </code>
457
+     */
458 458
 
459 459
     $tag_template_php .= 'for ($_' . $tag_args . '_i = ' . $loop_start . '; $_' . $tag_args . '_i < ' . $loop_end . '; ++$_' . $tag_args . '_i){';
460 460
 //    $tag_template_php .= '$this->_block_counter["'. $tag_args . '"] = $_' . $tag_args . '_i;';
@@ -465,10 +465,10 @@  discard block
 block discarded – undo
465 465
   }
466 466
 
467 467
   /**
468
-  * Compile IF tags - much of this is from Smarty with
469
-  * some adaptions for our block level methods
470
-  * @access private
471
-  */
468
+   * Compile IF tags - much of this is from Smarty with
469
+   * some adaptions for our block level methods
470
+   * @access private
471
+   */
472 472
   function compile_tag_if($tag_args, $elseif)
473 473
   {
474 474
     // Tokenize args for 'if' tag.
@@ -623,9 +623,9 @@  discard block
 block discarded – undo
623 623
   }
624 624
 
625 625
   /**
626
-  * Compile DEFINE tags
627
-  * @access private
628
-  */
626
+   * Compile DEFINE tags
627
+   * @access private
628
+   */
629 629
   function compile_tag_define($tag_args, $op)
630 630
   {
631 631
     preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match);
@@ -676,9 +676,9 @@  discard block
 block discarded – undo
676 676
   }
677 677
 
678 678
   /**
679
-  * Compile INCLUDE tag
680
-  * @access private
681
-  */
679
+   * Compile INCLUDE tag
680
+   * @access private
681
+   */
682 682
   function compile_tag_include($tag_args)
683 683
   {
684 684
     // Process dynamic includes
@@ -691,19 +691,19 @@  discard block
 block discarded – undo
691 691
   }
692 692
 
693 693
   /**
694
-  * Compile INCLUDE_PHP tag
695
-  * @access private
696
-  */
694
+   * Compile INCLUDE_PHP tag
695
+   * @access private
696
+   */
697 697
   function compile_tag_include_php($tag_args)
698 698
   {
699 699
     return "\$this->_php_include('$tag_args');";
700 700
   }
701 701
 
702 702
   /**
703
-  * parse expression
704
-  * This is from Smarty
705
-  * @access private
706
-  */
703
+   * parse expression
704
+   * This is from Smarty
705
+   * @access private
706
+   */
707 707
   function _parse_is_expr($is_arg, $tokens)
708 708
   {
709 709
     $expr_end = 0;
@@ -768,13 +768,13 @@  discard block
 block discarded – undo
768 768
   }
769 769
 
770 770
   /**
771
-  * Generates a reference to the given variable inside the given (possibly nested)
772
-  * block namespace. This is a string of the form:
773
-  * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . '
774
-  * It's ready to be inserted into an "echo" line in one of the templates.
775
-  * NOTE: expects a trailing "." on the namespace.
776
-  * @access private
777
-  */
771
+   * Generates a reference to the given variable inside the given (possibly nested)
772
+   * block namespace. This is a string of the form:
773
+   * ' . $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['varname'] . '
774
+   * It's ready to be inserted into an "echo" line in one of the templates.
775
+   * NOTE: expects a trailing "." on the namespace.
776
+   * @access private
777
+   */
778 778
   function generate_block_varref($namespace, $varname, $echo = true, $defop = false)
779 779
   {
780 780
     // Strip the trailing period.
@@ -792,14 +792,14 @@  discard block
 block discarded – undo
792 792
   }
793 793
 
794 794
   /**
795
-  * Generates a reference to the array of data values for the given
796
-  * (possibly nested) block namespace. This is a string of the form:
797
-  * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN']
798
-  *
799
-  * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.
800
-  * NOTE: does not expect a trailing "." on the blockname.
801
-  * @access private
802
-  */
795
+   * Generates a reference to the array of data values for the given
796
+   * (possibly nested) block namespace. This is a string of the form:
797
+   * $this->_tpldata['parent'][$_parent_i]['$child1'][$_child1_i]['$child2'][$_child2_i]...['$childN']
798
+   *
799
+   * If $include_last_iterator is true, then [$_childN_i] will be appended to the form shown above.
800
+   * NOTE: does not expect a trailing "." on the blockname.
801
+   * @access private
802
+   */
803 803
   function generate_block_data_ref($blockname, $include_last_iterator, $defop = false)
804 804
   {
805 805
     // Get an array of the blocks involved.
@@ -835,9 +835,9 @@  discard block
 block discarded – undo
835 835
   }
836 836
 
837 837
   /**
838
-  * Write compiled file to cache directory
839
-  * @access private
840
-  */
838
+   * Write compiled file to cache directory
839
+   * @access private
840
+   */
841 841
   function compile_write($handle, $data)
842 842
   {
843 843
     $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX;
@@ -860,9 +860,9 @@  discard block
 block discarded – undo
860 860
 
861 861
   // Gorlum's minifier BOF
862 862
   /**
863
-  * Minifies template w/i PHP code by removing extra spaces
864
-  * @access private
865
-  */
863
+   * Minifies template w/i PHP code by removing extra spaces
864
+   * @access private
865
+   */
866 866
   function minify($html)
867 867
   {
868 868
     global $config;
Please login to merge, or discard this patch.
Braces   +33 added lines, -66 removed lines patch added patch discarded remove patch
@@ -37,8 +37,7 @@  discard block
 block discarded – undo
37 37
 *
38 38
 * @package phpBB3
39 39
 */
40
-class template_compile
41
-{
40
+class template_compile {
42 41
   var $template;
43 42
 
44 43
   // Various storage arrays
@@ -58,8 +57,7 @@  discard block
 block discarded – undo
58 57
   * Load template source from file
59 58
   * @access private
60 59
   */
61
-  function _tpl_load_file($handle, $store_in_db = false)
62
-  {
60
+  function _tpl_load_file($handle, $store_in_db = false) {
63 61
     // Try and open template for read
64 62
     if (!file_exists($this->template->files[$handle]))
65 63
     {
@@ -67,8 +65,7 @@  discard block
 block discarded – undo
67 65
       {
68 66
         return;
69 67
         trigger_error("template->_tpl_load_file(): File {$this->template->files[$handle]} does not exist or is empty", E_USER_ERROR);
70
-      }
71
-      else
68
+      } else
72 69
       {
73 70
         $this->template->files[$handle] = $this->template->files_inherit[$handle];
74 71
       }
@@ -104,8 +101,7 @@  discard block
 block discarded – undo
104 101
   * the ones that exist in zend_language_scanner.l
105 102
   * @access private
106 103
   */
107
-  function remove_php_tags(&$code)
108
-  {
104
+  function remove_php_tags(&$code) {
109 105
     // This matches the information gathered from the internal PHP lexer
110 106
     $match = array(
111 107
       '#<([\?%])=?.*?\1>#s',
@@ -120,8 +116,7 @@  discard block
 block discarded – undo
120 116
   * The all seeing all doing compile method. Parts are inspired by or directly from Smarty
121 117
   * @access private
122 118
   */
123
-  function compile($code, $no_echo = false, $echo_var = '')
124
-  {
119
+  function compile($code, $no_echo = false, $echo_var = '') {
125 120
     global $config;
126 121
 
127 122
     if ($echo_var)
@@ -226,15 +221,13 @@  discard block
 block discarded – undo
226 221
               $var = substr($temp, 2, -1);
227 222
               //$file = $this->template->_tpldata['DEFINE']['.'][$var];
228 223
               $temp = "\$this->_tpldata['DEFINE']['.']['$var']";
229
-            }
230
-            else
224
+            } else
231 225
             {
232 226
               $var = substr($temp, 1, -1);
233 227
               //$file = $this->template->_rootref[$var];
234 228
               $temp = "\$this->_rootref['$var']";
235 229
             }
236
-          }
237
-          else
230
+          } else
238 231
           {
239 232
             $file = $temp;
240 233
           }
@@ -293,8 +286,7 @@  discard block
 block discarded – undo
293 286
   * Compile variables
294 287
   * @access private
295 288
   */
296
-  function compile_var_tags(&$text_blocks)
297
-  {
289
+  function compile_var_tags(&$text_blocks) {
298 290
     // including $lang variable
299 291
     global $lang, $config;
300 292
 
@@ -362,8 +354,7 @@  discard block
 block discarded – undo
362 354
   * Compile blocks
363 355
   * @access private
364 356
   */
365
-  function compile_tag_block($tag_args)
366
-  {
357
+  function compile_tag_block($tag_args) {
367 358
     $no_nesting = false;
368 359
 
369 360
     // Is the designer wanting to call another loop in a loop?
@@ -386,8 +377,7 @@  discard block
 block discarded – undo
386 377
       if ($match[2] < 0)
387 378
       {
388 379
         $loop_start = '($_' . $tag_args . '_count ' . $match[2] . ' < 0 ? 0 : $_' . $tag_args . '_count ' . $match[2] . ')';
389
-      }
390
-      else
380
+      } else
391 381
       {
392 382
         $loop_start = '($_' . $tag_args . '_count < ' . $match[2] . ' ? $_' . $tag_args . '_count : ' . $match[2] . ')';
393 383
       }
@@ -395,17 +385,14 @@  discard block
 block discarded – undo
395 385
       if (strlen($match[3]) < 1 || $match[3] == -1)
396 386
       {
397 387
         $loop_end = '$_' . $tag_args . '_count';
398
-      }
399
-      else if ($match[3] >= 0)
388
+      } else if ($match[3] >= 0)
400 389
       {
401 390
         $loop_end = '(' . ($match[3] + 1) . ' > $_' . $tag_args . '_count ? $_' . $tag_args . '_count : ' . ($match[3] + 1) . ')';
402
-      }
403
-      else //if ($match[3] < -1)
391
+      } else //if ($match[3] < -1)
404 392
       {
405 393
         $loop_end = '$_' . $tag_args . '_count' . ($match[3] + 1);
406 394
       }
407
-    }
408
-    else
395
+    } else
409 396
     {
410 397
       $loop_start = 0;
411 398
       $loop_end = '$_' . $tag_args . '_count';
@@ -418,8 +405,7 @@  discard block
 block discarded – undo
418 405
     {
419 406
       // We need to implode $no_nesting times from the end...
420 407
       $block = array_slice($this->block_names, -$no_nesting);
421
-    }
422
-    else
408
+    } else
423 409
     {
424 410
       $block = $this->block_names;
425 411
     }
@@ -429,8 +415,7 @@  discard block
 block discarded – undo
429 415
       // Block is not nested.
430 416
       $tag_template_php = '$_' . $tag_args . "_count = (isset(\$this->_tpldata['$tag_args'])) ? sizeof(\$this->_tpldata['$tag_args']) : 0;";
431 417
       $varref = "\$this->_tpldata['$tag_args']";
432
-    }
433
-    else
418
+    } else
434 419
     {
435 420
       // This block is nested.
436 421
       // Generate a namespace string for this block.
@@ -469,8 +454,7 @@  discard block
 block discarded – undo
469 454
   * some adaptions for our block level methods
470 455
   * @access private
471 456
   */
472
-  function compile_tag_if($tag_args, $elseif)
473
-  {
457
+  function compile_tag_if($tag_args, $elseif) {
474 458
     // Tokenize args for 'if' tag.
475 459
     preg_match_all('/(?:
476 460
       "[^"\\\\]*(?:\\\\.[^"\\\\]*)*"         |
@@ -578,8 +562,7 @@  discard block
 block discarded – undo
578 562
           if (preg_match('#^((?:[a-z0-9\-_]+\.)+)?(\$)?(?=[A-Za-z])([A-Za-z0-9\-_]+)#s', $token, $varrefs))
579 563
           {
580 564
             $token = (!empty($varrefs[1])) ? $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']' : (($varrefs[2]) ? '$this->_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$this->_rootref[\'' . $varrefs[3] . '\']');
581
-          }
582
-          else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs))
565
+          } else if (preg_match('#^\.((?:[a-z0-9\-_]+\.?)+)$#s', $token, $varrefs))
583 566
           {
584 567
             // Allow checking if loops are set with .loopname
585 568
             // It is also possible to check the loop count by doing <!-- IF .loopname > 1 --> for example
@@ -595,8 +578,7 @@  discard block
 block discarded – undo
595 578
 
596 579
               // Add the block reference for the last child.
597 580
               $varref .= "['" . $block . "']";
598
-            }
599
-            else
581
+            } else
600 582
             {
601 583
               $varref = '$this->_tpldata';
602 584
 
@@ -604,8 +586,7 @@  discard block
 block discarded – undo
604 586
               $varref .= "['" . $blocks[0] . "']";
605 587
             }
606 588
             $token = "sizeof($varref)";
607
-          }
608
-          else if (!empty($token))
589
+          } else if (!empty($token))
609 590
           {
610 591
             $token = '(' . $token . ')';
611 592
           }
@@ -626,8 +607,7 @@  discard block
 block discarded – undo
626 607
   * Compile DEFINE tags
627 608
   * @access private
628 609
   */
629
-  function compile_tag_define($tag_args, $op)
630
-  {
610
+  function compile_tag_define($tag_args, $op) {
631 611
     preg_match('#^((?:[a-z0-9\-_]+\.)+)?\$(?=[A-Z])([A-Z0-9_\-]*)(?: = (\'?)([^\']*)(\'?))?$#', $tag_args, $match);
632 612
 
633 613
     if (empty($match[2]) || (!isset($match[4]) && $op))
@@ -650,8 +630,7 @@  discard block
 block discarded – undo
650 630
 
651 631
       // Now replace the php code
652 632
       $match[4] = "'" . str_replace(array('<?php echo ', '; ?>'), array("' . ", " . '"), $match[4]) . "'";
653
-    }
654
-    else
633
+    } else
655 634
     {
656 635
       preg_match('#true|false|\.#i', $match[4], $type);
657 636
 
@@ -679,8 +658,7 @@  discard block
 block discarded – undo
679 658
   * Compile INCLUDE tag
680 659
   * @access private
681 660
   */
682
-  function compile_tag_include($tag_args)
683
-  {
661
+  function compile_tag_include($tag_args) {
684 662
     // Process dynamic includes
685 663
     if ($tag_args[0] == '$')
686 664
     {
@@ -694,8 +672,7 @@  discard block
 block discarded – undo
694 672
   * Compile INCLUDE_PHP tag
695 673
   * @access private
696 674
   */
697
-  function compile_tag_include_php($tag_args)
698
-  {
675
+  function compile_tag_include_php($tag_args) {
699 676
     return "\$this->_php_include('$tag_args');";
700 677
   }
701 678
 
@@ -704,8 +681,7 @@  discard block
 block discarded – undo
704 681
   * This is from Smarty
705 682
   * @access private
706 683
   */
707
-  function _parse_is_expr($is_arg, $tokens)
708
-  {
684
+  function _parse_is_expr($is_arg, $tokens) {
709 685
     $expr_end = 0;
710 686
     $negate_expr = false;
711 687
 
@@ -713,8 +689,7 @@  discard block
 block discarded – undo
713 689
     {
714 690
       $negate_expr = true;
715 691
       $expr_type = array_shift($tokens);
716
-    }
717
-    else
692
+    } else
718 693
     {
719 694
       $expr_type = $first_token;
720 695
     }
@@ -727,8 +702,7 @@  discard block
 block discarded – undo
727 702
           $expr_end++;
728 703
           $expr_arg = $tokens[$expr_end++];
729 704
           $expr = "!(($is_arg / $expr_arg) % $expr_arg)";
730
-        }
731
-        else
705
+        } else
732 706
         {
733 707
           $expr = "!($is_arg & 1)";
734 708
         }
@@ -740,8 +714,7 @@  discard block
 block discarded – undo
740 714
           $expr_end++;
741 715
           $expr_arg = $tokens[$expr_end++];
742 716
           $expr = "(($is_arg / $expr_arg) % $expr_arg)";
743
-        }
744
-        else
717
+        } else
745 718
         {
746 719
           $expr = "($is_arg & 1)";
747 720
         }
@@ -775,8 +748,7 @@  discard block
 block discarded – undo
775 748
   * NOTE: expects a trailing "." on the namespace.
776 749
   * @access private
777 750
   */
778
-  function generate_block_varref($namespace, $varname, $echo = true, $defop = false)
779
-  {
751
+  function generate_block_varref($namespace, $varname, $echo = true, $defop = false) {
780 752
     // Strip the trailing period.
781 753
     $namespace = substr($namespace, 0, -1);
782 754
 
@@ -800,8 +772,7 @@  discard block
 block discarded – undo
800 772
   * NOTE: does not expect a trailing "." on the blockname.
801 773
   * @access private
802 774
   */
803
-  function generate_block_data_ref($blockname, $include_last_iterator, $defop = false)
804
-  {
775
+  function generate_block_data_ref($blockname, $include_last_iterator, $defop = false) {
805 776
     // Get an array of the blocks involved.
806 777
     $blocks = explode('.', $blockname);
807 778
     $blockcount = sizeof($blocks) - 1;
@@ -823,12 +794,10 @@  discard block
 block discarded – undo
823 794
         $varref .= '[$_' . $blocks[$blockcount] . '_i]';
824 795
       }
825 796
       return $varref;
826
-    }
827
-    else if ($include_last_iterator)
797
+    } else if ($include_last_iterator)
828 798
     {
829 799
       return '$_'. $blocks[$blockcount] . '_val';
830
-    }
831
-    else
800
+    } else
832 801
     {
833 802
       return '$_'. $blocks[$blockcount - 1] . '_val[\''. $blocks[$blockcount]. '\']';
834 803
     }
@@ -838,8 +807,7 @@  discard block
 block discarded – undo
838 807
   * Write compiled file to cache directory
839 808
   * @access private
840 809
   */
841
-  function compile_write($handle, $data)
842
-  {
810
+  function compile_write($handle, $data) {
843 811
     $filename = $this->template->cachepath . str_replace('/', '.', $this->template->filename[$handle]) . DOT_PHP_EX;
844 812
 
845 813
     $data = "<?php if (!defined('INSIDE')) exit;" . ((strpos($data, '<?php') === 0) ? substr($data, 5) : ' ?>' . $data);
@@ -863,8 +831,7 @@  discard block
 block discarded – undo
863 831
   * Minifies template w/i PHP code by removing extra spaces
864 832
   * @access private
865 833
   */
866
-  function minify($html)
867
-  {
834
+  function minify($html) {
868 835
     global $config;
869 836
 
870 837
     if(!$config->tpl_minifier)
Please login to merge, or discard this patch.
classes/RequestInfo.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -89,15 +89,15 @@  discard block
 block discarded – undo
89 89
     // Инфа об устройстве и браузере - общая для всех
90 90
     sn_db_transaction_start();
91 91
     $this->device_cypher = $_COOKIE[SN_COOKIE_D];
92
-    if($this->device_cypher) {
92
+    if ($this->device_cypher) {
93 93
       $cypher_safe = db_escape($this->device_cypher);
94 94
       $device_id = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true);
95
-      if(!empty($device_id['device_id'])) {
95
+      if (!empty($device_id['device_id'])) {
96 96
         $this->device_id = $device_id['device_id'];
97 97
       }
98 98
     }
99 99
 
100
-    if($this->device_id <= 0) {
100
+    if ($this->device_id <= 0) {
101 101
       do {
102 102
         $cypher_safe = db_escape($this->device_cypher = sys_random_string());
103 103
         $row = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true);
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
     $this->page_address_id = db_get_set_unique_id_value($this->page_address, 'url_id', 'security_url', 'url_string');
119 119
     sn_db_transaction_commit();
120 120
 
121
-    if($this->write_full_url) {
121
+    if ($this->write_full_url) {
122 122
       sn_db_transaction_start();
123 123
       $this->page_url = substr($_SERVER['REQUEST_URI'], strlen(SN_ROOT_RELATIVE));
124
-      if(strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) {
124
+      if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) {
125 125
         $this->page_url = '/simulator.php';
126 126
       }
127 127
       $this->page_url_id = db_get_set_unique_id_value($this->page_url, 'url_id', 'security_url', 'url_string');
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
    */
145 145
   public function db_security_entry_insert($user_id_unsafe) {
146 146
     // TODO $user_id = !empty(self::$user['id']) ? self::$user['id'] : 'NULL';
147
-    if(empty($user_id_unsafe)) {
147
+    if (empty($user_id_unsafe)) {
148 148
       // self::flog('Нет ИД пользователя');
149 149
       return true;
150 150
     }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
   public function db_counter_insert($user_id_unsafe) {
168 168
     global $config, $sys_stop_log_hit, $is_watching;
169 169
 
170
-    if($sys_stop_log_hit || !$config->game_counter) {
170
+    if ($sys_stop_log_hit || !$config->game_counter) {
171 171
       return;
172 172
     }
173 173
 
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
 //      $this->ip_v4_int . ", '{$proxy_safe}', " . $this->page_address_id . ", " . $this->page_url_id . ");");
184 184
     doquery(
185 185
       "INSERT INTO {{counter}} SET
186
-        `visit_time` = '" . SN_TIME_SQL. "',
186
+        `visit_time` = '" . SN_TIME_SQL . "',
187 187
         `user_id` = {$user_id_safe},
188 188
         `device_id` = {$this->device_id},
189 189
         `browser_id` = {$this->browser_id},
190 190
         `user_ip` = {$this->ip_v4_int},
191 191
         `user_proxy` = '{$proxy_safe}',
192 192
         `page_url_id` = {$this->page_address_id}" .
193
-        ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '' ).
193
+        ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '') .
194 194
       ";");
195 195
 
196 196
     $is_watching = false;
Please login to merge, or discard this patch.
classes/core_auth.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -205,18 +205,18 @@  discard block
 block discarded – undo
205 205
     // TODO Хотя тут может получится вечный цикл - ПОДУМАТЬ
206 206
     // TODO Тут же можно пробовать провести попытку слияния аккаунтов - хотя это и очень небезопасно
207 207
 
208
-    if(sys_get_param('login_player_register_logout')) {
208
+    if (sys_get_param('login_player_register_logout')) {
209 209
       $this->logout();
210 210
     }
211 211
 
212 212
     $original_suggest = '';
213 213
     // Смотрим - есть ли у нас данные от пользователя
214
-    if(($player_name_submitted = sys_get_param('submit_player_name'))) {
214
+    if (($player_name_submitted = sys_get_param('submit_player_name'))) {
215 215
       // Попытка регистрации нового игрока из данных, введенных пользователем
216 216
       $this->player_suggested_name = sys_get_param_str_unsafe('player_suggested_name');
217 217
     } else {
218
-      foreach($this->providers_authorised as $provider) {
219
-        if($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5
218
+      foreach ($this->providers_authorised as $provider) {
219
+        if ($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5
220 220
           $original_suggest = $provider->player_name_suggest();
221 221
           break;
222 222
         }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
     }
225 225
 
226 226
     // Если у нас провайдеры не дают имени и пользователь не дал свой вариант - это у нас первый логин в игру
227
-    if(!$this->player_suggested_name) {
227
+    if (!$this->player_suggested_name) {
228 228
       $max_user_id = db_player_get_max_id(); // 4.5
229 229
       // TODO - предлагать имя игрока по локали
230 230
 
@@ -233,15 +233,15 @@  discard block
 block discarded – undo
233 233
         sn_db_transaction_rollback();
234 234
         $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000);
235 235
         sn_db_transaction_start();
236
-      } while(db_player_name_exists($this->player_suggested_name));
236
+      } while (db_player_name_exists($this->player_suggested_name));
237 237
 
238 238
     }
239 239
 
240
-    if($player_name_submitted) {
240
+    if ($player_name_submitted) {
241 241
       $this->register_player_db_create($this->player_suggested_name); // OK 4.5
242
-      if($this->register_status == LOGIN_SUCCESS) {
242
+      if ($this->register_status == LOGIN_SUCCESS) {
243 243
         sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
244
-      } elseif($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
244
+      } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
245 245
         // self::$player_suggested_name .= ' ' . $this->account->account_id;
246 246
       }
247 247
 //      if(self::$login_status != LOGIN_SUCCESS) {
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         : false
266 266
       );
267 267
 
268
-    if($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
268
+    if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
269 269
       $prohibited_characters = array_map(function($value) {
270 270
         return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
271 271
       }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
@@ -297,27 +297,27 @@  discard block
 block discarded – undo
297 297
     global $sn_module_list, $lang;
298 298
 
299 299
     // !self::$is_init ? self::init() : false;
300
-    if(empty($sn_module_list['auth'])) {
300
+    if (empty($sn_module_list['auth'])) {
301 301
       die('{Не обнаружено ни одного провайдера авторизации в core_auth::login()!}');
302 302
     }
303 303
 
304 304
     !empty($_POST) ? self::flog(dump($_POST, '$_POST')) : false;
305 305
     !empty($_GET) ? self::flog(dump($_GET, '$_GET')) : false;
306
-    !empty($_COOKIE) ? self::flog(dump($_COOKIE,'$_COOKIE')) : false;
306
+    !empty($_COOKIE) ? self::flog(dump($_COOKIE, '$_COOKIE')) : false;
307 307
 
308 308
     $this->auth_reset(); // OK v4.5
309 309
 
310 310
     $this->providers = array();
311
-    foreach($sn_module_list['auth'] as $module_name => $module) {
311
+    foreach ($sn_module_list['auth'] as $module_name => $module) {
312 312
       $this->providers[$module->provider_id] = $module;
313 313
     }
314 314
 
315 315
     // $this->providers = array_reverse($this->providers, true); // НИНАДА! СН-аккаунт должен всегда авторизироваться первым!
316 316
 //pdump($this->providers);
317
-    foreach($this->providers as $provider_id => $provider) {
317
+    foreach ($this->providers as $provider_id => $provider) {
318 318
       $login_status = $provider->login(); // OK v4.5
319 319
       self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? $lang['sys_login_messages'][$provider->account_login_status] : dump($provider)));
320
-      if($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
320
+      if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
321 321
         $this->providers_authorised[$provider_id] = &$this->providers[$provider_id];
322 322
 
323 323
         $this->user_id_to_provider = array_replace_recursive(
@@ -325,20 +325,20 @@  discard block
 block discarded – undo
325 325
           // static::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5
326 326
           PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5
327 327
         );
328
-      } elseif($login_status != LOGIN_UNDEFINED) {
328
+      } elseif ($login_status != LOGIN_UNDEFINED) {
329 329
         $this->provider_error_list[$provider_id] = $login_status;
330 330
       }
331 331
     }
332 332
 
333
-    if(empty($this->providers_authorised)) {
333
+    if (empty($this->providers_authorised)) {
334 334
       // Ни один аккаунт не авторизирован
335 335
       // Проверяем - есть ли у нас ошибки в аккаунтах?
336
-      if(!empty($this->provider_error_list)) {
336
+      if (!empty($this->provider_error_list)) {
337 337
         // Если есть - выводим их
338 338
         self::$login_status = reset($this->provider_error_list);
339 339
         $providerError = $this->providers[key($this->provider_error_list)]->account_login_message;
340 340
 
341
-        if(!empty($providerError)) {
341
+        if (!empty($providerError)) {
342 342
           self::$login_message = $providerError;
343 343
         }
344 344
       }
@@ -353,12 +353,12 @@  discard block
 block discarded – undo
353 353
       // В self::$accessible_user_row_list - список доступных игроков для данных аккаунтов с соответствующими записями из таблицы `users`
354 354
 
355 355
       // Остались ли у нас в списке доступные игроки?
356
-      if(empty($this->accessible_user_row_list)) {
356
+      if (empty($this->accessible_user_row_list)) {
357 357
         // Нет ни одного игрока ни на одном авторизированном аккаунте
358 358
         // Надо регать нового игрока
359 359
 
360 360
         // Сейчас происходит процесс регистрации игрока?
361
-        if(!$this->is_player_register) {
361
+        if (!$this->is_player_register) {
362 362
           // Нет - отправляем на процесс регистрации
363 363
           $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id'));
364 364
           sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : ''));
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
         // Да, есть доступные игроки, которые так же прописаны в базе
368 368
         $this->get_active_user(); // 4.5
369 369
 
370
-        if($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) {
370
+        if ($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) {
371 371
           $a_user = db_user_by_id($this->is_impersonating);
372 372
           $this->impersonator_username = $a_user['username'];
373 373
         }
@@ -375,9 +375,9 @@  discard block
 block discarded – undo
375 375
 
376 376
         //Прописываем текущего игрока на все авторизированные аккаунты
377 377
         // TODO - ИЛИ ВСЕХ ИГРОКОВ??
378
-        if(empty($this->is_impersonating)) {
379
-          foreach($this->providers_authorised as $provider_id => $provider) {
380
-            if(empty($this->user_id_to_provider[self::$user['id']][$provider_id])) {
378
+        if (empty($this->is_impersonating)) {
379
+          foreach ($this->providers_authorised as $provider_id => $provider) {
380
+            if (empty($this->user_id_to_provider[self::$user['id']][$provider_id])) {
381 381
               // self::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']);
382 382
               PlayerToAccountTranslate::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']);
383 383
               $this->user_id_to_provider[self::$user['id']][$provider_id][$provider->account->account_id] = true;
@@ -387,9 +387,9 @@  discard block
 block discarded – undo
387 387
       }
388 388
     }
389 389
 
390
-    if(empty(self::$user['id'])) {
390
+    if (empty(self::$user['id'])) {
391 391
       self::cookie_set(''); // OK 4.5
392
-    } elseif(self::$user['id'] != $_COOKIE[SN_COOKIE_U]) {
392
+    } elseif (self::$user['id'] != $_COOKIE[SN_COOKIE_U]) {
393 393
       self::cookie_set(self::$user['id']); // OK 4.5
394 394
     }
395 395
 
@@ -408,21 +408,21 @@  discard block
 block discarded – undo
408 408
    */
409 409
   // OK v4.7
410 410
   public function logout($redirect = true) {
411
-    if(!empty($_COOKIE[SN_COOKIE_U_I])) {
411
+    if (!empty($_COOKIE[SN_COOKIE_U_I])) {
412 412
       self::cookie_set($_COOKIE[SN_COOKIE_U_I]);
413 413
       self::cookie_set(0, true);
414 414
       self::$main_provider->logout();
415 415
     } else {
416
-      foreach($this->providers as $provider_name => $provider) {
416
+      foreach ($this->providers as $provider_name => $provider) {
417 417
         $provider->logout();
418 418
       }
419 419
 
420 420
       self::cookie_set(0);
421 421
     }
422 422
 
423
-    if($redirect === true) {
423
+    if ($redirect === true) {
424 424
       sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php'));
425
-    } elseif($redirect !== false) {
425
+    } elseif ($redirect !== false) {
426 426
       sys_redirect($redirect);
427 427
     }
428 428
   }
@@ -433,15 +433,15 @@  discard block
 block discarded – undo
433 433
    * @param $user_selected
434 434
    */
435 435
   public function impersonate($user_selected) {
436
-    if($_COOKIE[SN_COOKIE_U_I]) {
436
+    if ($_COOKIE[SN_COOKIE_U_I]) {
437 437
       die('You already impersonating someone. Go back to living other\'s life! Or clear your cookies and try again'); // TODO: Log it
438 438
     }
439 439
 
440
-    if($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) {
440
+    if ($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) {
441 441
       die('You can\'t impersonate - too low level'); // TODO: Log it
442 442
     }
443 443
 
444
-    if($this->auth_level_max_local <= $user_selected['authlevel']) {
444
+    if ($this->auth_level_max_local <= $user_selected['authlevel']) {
445 445
       die('You can\'t impersonate this account - level is greater or equal to yours'); // TODO: Log it
446 446
     }
447 447
 
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
     $account_translate = reset($account_translate[$user_selected['id']][self::$main_provider->provider_id]);
450 450
     $account_to_impersonate = new Account(self::$main_provider->db);
451 451
     $account_to_impersonate->db_get_by_id($account_translate['provider_account_id']);
452
-    if(!$account_to_impersonate->is_exists) {
452
+    if (!$account_to_impersonate->is_exists) {
453 453
       die('Какая-то ошибка - не могу найти аккаунт для имперсонации'); // TODO: Log it
454 454
     }
455 455
     self::$main_provider->impersonate($account_to_impersonate);
@@ -475,12 +475,12 @@  discard block
 block discarded – undo
475 475
   public function password_check($password_unsafe) {
476 476
     $result = false;
477 477
 
478
-    if(empty($this->providers_authorised)) {
478
+    if (empty($this->providers_authorised)) {
479 479
       // TODO - такого быть не может!
480 480
       self::flog("password_check: Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true);
481 481
     } else {
482
-      foreach($this->providers_authorised as $provider_id => $provider) {
483
-        if($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) {
482
+      foreach ($this->providers_authorised as $provider_id => $provider) {
483
+        if ($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) {
484 484
           $result = $result || $provider->password_check($password_unsafe);
485 485
         }
486 486
       }
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
   public function password_change($old_password_unsafe, $new_password_unsafe) {
502 502
     global $lang;
503 503
 
504
-    if(empty($this->providers_authorised)) {
504
+    if (empty($this->providers_authorised)) {
505 505
       // TODO - такого быть не может!
506 506
       self::flog("Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true);
507 507
       return false;
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
     $salt_unsafe = self::password_salt_generate();
515 515
 
516 516
     $providers_changed_password = array();
517
-    foreach($this->providers_authorised as $provider_id => $provider) {
518
-      if(
517
+    foreach ($this->providers_authorised as $provider_id => $provider) {
518
+      if (
519 519
         !$provider->is_feature_supported(AUTH_FEATURE_PASSWORD_CHANGE)
520 520
         || !$provider->password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe)
521 521
       ) {
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
       $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id);
528 528
 
529 529
       // Рассылаем уведомления о смене пароля в ЛС
530
-      foreach($account_translation as $user_id => $provider_info) {
530
+      foreach ($account_translation as $user_id => $provider_info) {
531 531
         // TODO - УКазывать тип аккаунта, на котором сменён пароль
532 532
         msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN,
533 533
           $lang['sys_administration'], $lang['sys_login_register_message_title'],
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
       sn_db_transaction_start();
575 575
       // Проверить наличие такого имени в истории имён
576 576
 
577
-      if(db_player_name_exists($player_name_unsafe)) {
577
+      if (db_player_name_exists($player_name_unsafe)) {
578 578
         throw new Exception(REGISTER_ERROR_PLAYER_NAME_EXISTS, ERR_ERROR);
579 579
       }
580 580
 
@@ -582,11 +582,11 @@  discard block
 block discarded – undo
582 582
       $player_language = '';
583 583
       $player_email = '';
584 584
       // TODO - порнография - работа должна происходить над списком аккаунтов, а не только на одном аккаунте...
585
-      foreach($this->providers_authorised as $provider) {
586
-        if(!$player_language && $provider->account->account_language) {
585
+      foreach ($this->providers_authorised as $provider) {
586
+        if (!$player_language && $provider->account->account_language) {
587 587
           $player_language = $provider->account->account_language;
588 588
         }
589
-        if(!$player_email && $provider->account->account_email) {
589
+        if (!$player_email && $provider->account->account_email) {
590 590
           $player_email = $provider->account->account_email;
591 591
         }
592 592
       }
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
       ));
603 603
       // Зарегестрировать на него аккаунты из self::$accounts_authorised
604 604
       $a_user = self::$user;
605
-      foreach($this->providers_authorised as $provider) {
605
+      foreach ($this->providers_authorised as $provider) {
606 606
         // TODO - порнография. Должен быть отдельный класс трансляторов - в т.ч. и кэширующий транслятор
607 607
         // TODO - ну и работа должна происходить над списком аккаунтов, а не только на одном аккаунте...
608 608
         // self::db_translate_register_user($provider->provider_id, $provider->account->account_id, $a_user['id']);
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 
615 615
       sn_db_transaction_commit();
616 616
       $this->register_status = LOGIN_SUCCESS;
617
-    } catch(Exception $e) {
617
+    } catch (Exception $e) {
618 618
       sn_db_transaction_rollback();
619 619
 
620 620
       // Если старое имя занято
@@ -633,10 +633,10 @@  discard block
 block discarded – undo
633 633
     // Пробиваем все ИД игроков по базе - есть ли вообще такие записи
634 634
     // Вообще-то это не особо нужно - у нас по определению стоят констраинты
635 635
     // Зато так мы узнаем максимальный authlevel, проверим права имперсонейта и вытащим все записи юзеров
636
-    foreach($this->user_id_to_provider as $user_id => $cork) {
636
+    foreach ($this->user_id_to_provider as $user_id => $cork) {
637 637
       $user = db_user_by_id($user_id);
638 638
       // Если записи игрока в БД не существует?
639
-      if(empty($user['id'])) {
639
+      if (empty($user['id'])) {
640 640
         // Удаляем этого и переходим к следующему
641 641
         unset($this->user_id_to_provider[$user_id]);
642 642
         // Де-регистрируем игрока из таблицы трансляции игроков
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
   // OK v4.5
658 658
   protected function get_active_user() {
659 659
     // Проверяем куку "текущего игрока" из браузера
660
-    if(
660
+    if (
661 661
       // Кука не пустая
662 662
       ($_COOKIE[SN_COOKIE_U] = trim($_COOKIE[SN_COOKIE_U])) && !empty($_COOKIE[SN_COOKIE_U])
663 663
       // И в куке находится ID
@@ -682,7 +682,7 @@  discard block
 block discarded – undo
682 682
     }
683 683
 
684 684
     // В куке нет валидного ИД записи игрока, доступной с текущих аккаунтов
685
-    if(empty(self::$user['id'])) {
685
+    if (empty(self::$user['id'])) {
686 686
       // Берем первого из доступных
687 687
       // TODO - default_user
688 688
       self::$user = reset($this->accessible_user_row_list);
@@ -706,7 +706,7 @@  discard block
 block discarded – undo
706 706
 
707 707
     $result = array();
708 708
 
709
-    if($user_id && empty($this->is_impersonating)) {
709
+    if ($user_id && empty($this->is_impersonating)) {
710 710
       // self::db_counter_insert();
711 711
       self::$device->db_counter_insert($user_id);
712 712
 
@@ -714,12 +714,12 @@  discard block
 block discarded – undo
714 714
 
715 715
       sys_user_options_unpack($user);
716 716
 
717
-      if($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) {
717
+      if ($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) {
718 718
         $user['banaday'] = 0;
719 719
         $user['vacation'] = SN_TIME_NOW;
720 720
       }
721 721
 
722
-      $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip'];
722
+      $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip'];
723 723
       $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain'];
724 724
 
725 725
       $result[F_BANNED_STATUS] = $user['banaday'];
@@ -733,13 +733,13 @@  discard block
 block discarded – undo
733 733
       );
734 734
     }
735 735
 
736
-    if($extra = $config->security_ban_extra) {
736
+    if ($extra = $config->security_ban_extra) {
737 737
       $extra = explode(',', $extra);
738
-      array_walk($extra,'trim');
738
+      array_walk($extra, 'trim');
739 739
       in_array(self::$device->device_id, $extra) and die();
740 740
     }
741 741
 
742
-    if(self::$login_message) {
742
+    if (self::$login_message) {
743 743
       $result[F_LOGIN_MESSAGE] = self::$login_message;
744 744
     }
745 745
 
@@ -775,21 +775,21 @@  discard block
 block discarded – undo
775 775
   protected function register_player_name_validate($player_name_unsafe) {
776 776
     // TODO - переделать под RAW-строки
777 777
     // Если имя игрока пустое - NO GO!
778
-    if(trim($player_name_unsafe) == '') {
778
+    if (trim($player_name_unsafe) == '') {
779 779
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_EMPTY, ERR_ERROR);
780 780
     }
781 781
     // Проверяем, что бы в начале и конце не было пустых символов
782
-    if($player_name_unsafe != trim($player_name_unsafe)) {
782
+    if ($player_name_unsafe != trim($player_name_unsafe)) {
783 783
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_TRIMMED, ERR_ERROR);
784 784
     }
785 785
     // Если логин имеет запрещенные символы - NO GO!
786
-    if(strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
786
+    if (strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
787 787
       // TODO - выдавать в сообщение об ошибке список запрещенных символов
788 788
       // TODO - заранее извещать игрока, какие символы являются запрещенными
789 789
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_RESTRICTED_CHARACTERS, ERR_ERROR);
790 790
     }
791 791
     // Если логин меньше минимальной длины - NO GO!
792
-    if(strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) {
792
+    if (strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) {
793 793
       // TODO - выдавать в сообщение об ошибке минимальную длину имени игрока
794 794
       // TODO - заранее извещать игрока, какая минимальная и максимальная длина имени
795 795
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_SHORT, ERR_ERROR);
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
   }
848 848
 
849 849
   protected static function flog($message, $die = false) {
850
-    if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
850
+    if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
851 851
       return;
852 852
     }
853 853
     list($called, $caller) = debug_backtrace(false);
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
     $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false;
861 861
 
862 862
     classSupernova::log_file("$message - $caller_name");
863
-    if($die) {
863
+    if ($die) {
864 864
       $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
865 865
     }
866 866
   }
Please login to merge, or discard this patch.
classes/debug.php 3 patches
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
 
77 77
     $result = array();
78 78
     $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++;
79
-    $result[] = "tID {$transaction_id}";
79
+    $result[] = "tid {$transaction_id}";
80 80
     foreach($backtrace as $a_trace) {
81 81
       if(in_array($a_trace['function'], $exclude_functions)) {
82 82
         continue;
Please login to merge, or discard this patch.
Spacing   +42 added lines, -43 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * que esperabas!!! soy newbie!!! D':<
25 25
 */
26 26
 
27
-if(!defined('INSIDE')) {
27
+if (!defined('INSIDE')) {
28 28
   die("attemp hacking");
29 29
 }
30 30
 
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
   function log_file($message, $ident_change = 0) {
38 38
     static $ident = 0;
39 39
 
40
-    if(!defined('SN_DEBUG_LOG')) {
40
+    if (!defined('SN_DEBUG_LOG')) {
41 41
       return;
42 42
     }
43 43
 
44
-    if($this->log_file_handler === null) {
44
+    if ($this->log_file_handler === null) {
45 45
       $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+');
46 46
       @fwrite($this->log_file_handler, "\r\n\r\n");
47 47
     }
48 48
     $ident_change < 0 ? $ident += $ident_change * 2 : false;
49
-    if($this->log_file_handler) {
49
+    if ($this->log_file_handler) {
50 50
       @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n");
51 51
     }
52 52
     $ident_change > 0 ? $ident += $ident_change * 2 : false;
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     $result = array();
82 82
     $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++;
83 83
     $result[] = "tID {$transaction_id}";
84
-    foreach($backtrace as $a_trace) {
85
-      if(in_array($a_trace['function'], $exclude_functions)) {
84
+    foreach ($backtrace as $a_trace) {
85
+      if (in_array($a_trace['function'], $exclude_functions)) {
86 86
         continue;
87 87
       }
88 88
       $function =
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
       $result[] = "{$function} - '{$file}' Line {$a_trace['line']}";
100 100
 
101
-      if(!$long_comment) {
101
+      if (!$long_comment) {
102 102
         break;
103 103
       }
104 104
     }
@@ -107,26 +107,26 @@  discard block
 block discarded – undo
107 107
   }
108 108
 
109 109
   function dump($dump = false, $force_base = false, $deadlock = false) {
110
-    if($dump === false) {
110
+    if ($dump === false) {
111 111
       return;
112 112
     }
113 113
 
114 114
     $error_backtrace = array();
115 115
     $base_dump = false;
116 116
 
117
-    if($force_base === true) {
117
+    if ($force_base === true) {
118 118
       $base_dump = true;
119 119
     }
120 120
 
121
-    if($dump === true) {
121
+    if ($dump === true) {
122 122
       $base_dump = true;
123 123
     } else {
124
-      if(!is_array($dump)) {
124
+      if (!is_array($dump)) {
125 125
         $dump = array('var' => $dump);
126 126
       }
127 127
 
128
-      foreach($dump as $dump_var_name => $dump_var) {
129
-        if($dump_var_name == 'base_dump') {
128
+      foreach ($dump as $dump_var_name => $dump_var) {
129
+        if ($dump_var_name == 'base_dump') {
130 130
           $base_dump = $dump_var;
131 131
         } else {
132 132
           $error_backtrace[$dump_var_name] = $dump_var;
@@ -134,24 +134,23 @@  discard block
 block discarded – undo
134 134
       }
135 135
     }
136 136
 
137
-    if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
137
+    if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
138 138
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
139 139
       $error_backtrace['locks'] = _SnCacheInternal::$locks;
140 140
       $error_backtrace['cSN_data'] = _SnCacheInternal::$data;
141
-      foreach($error_backtrace['cSN_data'] as &$location) {
142
-        foreach($location as $location_id => &$location_data) //          $location_data = $location_id;
141
+      foreach ($error_backtrace['cSN_data'] as &$location) {
142
+        foreach ($location as $location_id => &$location_data) //          $location_data = $location_id;
143 143
         {
144
-          $location_data = isset($location_data['username']) ? $location_data['username'] :
145
-            (isset($location_data['name']) ? $location_data['name'] : $location_id);
144
+          $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id);
146 145
         }
147 146
       }
148 147
     }
149 148
 
150
-    if($base_dump) {
151
-      if(!is_array($this->log_array) || empty($this->log_array)) {
149
+    if ($base_dump) {
150
+      if (!is_array($this->log_array) || empty($this->log_array)) {
152 151
         $this->log_array = [];
153 152
       } else {
154
-        foreach($this->log_array as $log) {
153
+        foreach ($this->log_array as $log) {
155 154
           $error_backtrace['queries'][] = $log;
156 155
         }
157 156
       }
@@ -163,17 +162,17 @@  discard block
 block discarded – undo
163 162
       // Converting object instances to object names
164 163
 
165 164
       foreach ($error_backtrace['backtrace'] as &$backtrace) {
166
-        if(is_object($backtrace['object'])) {
165
+        if (is_object($backtrace['object'])) {
167 166
           $backtrace['object'] = get_class($backtrace['object']);
168 167
         }
169 168
 
170
-        if(empty($backtrace['args'])) {
169
+        if (empty($backtrace['args'])) {
171 170
           continue;
172 171
         }
173 172
 
174 173
         // Doing same conversion for backtrace params
175
-        foreach($backtrace['args'] as &$arg) {
176
-          if(is_object($arg)) {
174
+        foreach ($backtrace['args'] as &$arg) {
175
+          if (is_object($arg)) {
177 176
             $arg = 'object::' . get_class($arg);
178 177
           }
179 178
         }
@@ -202,14 +201,14 @@  discard block
 block discarded – undo
202 201
   function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) {
203 202
     global $config, $sys_stop_log_hit, $lang, $sys_log_disabled, $user;
204 203
 
205
-    if(empty(classSupernova::$db->connected)) {
204
+    if (empty(classSupernova::$db->connected)) {
206 205
       // TODO - писать ошибку в файл
207 206
       die('SQL server currently unavailable. Please contact Administration...');
208 207
     }
209 208
 
210 209
     sn_db_transaction_rollback();
211 210
 
212
-    if(classSupernova::$config->debug == 1) {
211
+    if (classSupernova::$config->debug == 1) {
213 212
       echo "<h2>{$title}</h2><br><font color=red>" . htmlspecialchars($message) . "</font><br><hr>";
214 213
       echo "<table>{$this->log}</table>";
215 214
     }
@@ -219,7 +218,7 @@  discard block
 block discarded – undo
219 218
     $error_text = db_escape($message);
220 219
     $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false);
221 220
 
222
-    if(!$sys_log_disabled) {
221
+    if (!$sys_log_disabled) {
223 222
       $query = "INSERT INTO `{{logs}}` SET
224 223
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "',
225 224
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -237,7 +236,7 @@  discard block
 block discarded – undo
237 236
       ob_start();
238 237
       print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}");
239 238
 
240
-      foreach($error_backtrace as $name => $value) {
239
+      foreach ($error_backtrace as $name => $value) {
241 240
         print('<hr>');
242 241
         pdump($value, $name);
243 242
       }
@@ -249,14 +248,14 @@  discard block
 block discarded – undo
249 248
   function warning($message, $title = 'System Message', $log_code = 300, $dump = false) {
250 249
     global $user, $lang, $sys_log_disabled;
251 250
 
252
-    if(empty(classSupernova::$db->connected)) {
251
+    if (empty(classSupernova::$db->connected)) {
253 252
       // TODO - писать ошибку в файл
254 253
       die('SQL server currently unavailable. Please contact Administration...');
255 254
     }
256 255
 
257 256
     $error_backtrace = $this->dump($dump, false);
258 257
 
259
-    if(!$sys_log_disabled) {
258
+    if (!$sys_log_disabled) {
260 259
       $query = "INSERT INTO `{{logs}}` SET
261 260
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "',
262 261
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -274,11 +273,11 @@  discard block
 block discarded – undo
274 273
 // Dump variables nicer then var_dump()
275 274
 
276 275
 function dump($value, $varname = null, $level = 0, $dumper = '') {
277
-  if(isset($varname)) {
276
+  if (isset($varname)) {
278 277
     $varname .= " = ";
279 278
   }
280 279
 
281
-  if($level == -1) {
280
+  if ($level == -1) {
282 281
     $trans[' '] = '&there4;';
283 282
     $trans["\t"] = '&rArr;';
284 283
     $trans["\n"] = '&para;;';
@@ -287,7 +286,7 @@  discard block
 block discarded – undo
287 286
 
288 287
     return strtr(htmlspecialchars($value), $trans);
289 288
   }
290
-  if($level == 0) {
289
+  if ($level == 0) {
291 290
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
292 291
     $dumper = mt_rand(10, 99) . '|' . $varname;
293 292
   }
@@ -295,22 +294,22 @@  discard block
 block discarded – undo
295 294
   $type = gettype($value);
296 295
   $dumper .= $type;
297 296
 
298
-  if($type == 'string') {
297
+  if ($type == 'string') {
299 298
     $dumper .= '(' . strlen($value) . ')';
300 299
     $value = dump($value, '', -1);
301
-  } elseif($type == 'boolean') {
300
+  } elseif ($type == 'boolean') {
302 301
     $value = ($value ? 'true' : 'false');
303
-  } elseif($type == 'object') {
302
+  } elseif ($type == 'object') {
304 303
     $props = get_class_vars(get_class($value));
305 304
     $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
306
-    foreach($props as $key => $val) {
305
+    foreach ($props as $key => $val) {
307 306
       $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
308 307
       $dumper .= dump($value->$key, '', $level + 1);
309 308
     }
310 309
     $value = '';
311
-  } elseif($type == 'array') {
310
+  } elseif ($type == 'array') {
312 311
     $dumper .= '(' . count($value) . ')';
313
-    foreach($value as $key => $val) {
312
+    foreach ($value as $key => $val) {
314 313
       $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
315 314
       $dumper .= dump($val, '', $level + 1);
316 315
     }
@@ -330,7 +329,7 @@  discard block
 block discarded – undo
330 329
 //  $backtrace = $backtrace[1];
331 330
 
332 331
   $caller = '';
333
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
332
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
334 333
     $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
335 334
       (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
336 335
       $backtrace[1]['function'] .
@@ -357,7 +356,7 @@  discard block
 block discarded – undo
357 356
 }
358 357
 
359 358
 function pr($prePrint = false) {
360
-  if($prePrint) {
359
+  if ($prePrint) {
361 360
     print("<br>");
362 361
   }
363 362
   print(mt_rand() . "<br>");
@@ -367,7 +366,7 @@  discard block
 block discarded – undo
367 366
   global $_PRINT_COUNT_VALUE;
368 367
   $_PRINT_COUNT_VALUE++;
369 368
 
370
-  if($prePrint) {
369
+  if ($prePrint) {
371 370
     print("<br>");
372 371
   }
373 372
   print($_PRINT_COUNT_VALUE . "<br>");
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -139,11 +139,13 @@
 block discarded – undo
139 139
       $error_backtrace['locks'] = _SnCacheInternal::$locks;
140 140
       $error_backtrace['cSN_data'] = _SnCacheInternal::$data;
141 141
       foreach($error_backtrace['cSN_data'] as &$location) {
142
-        foreach($location as $location_id => &$location_data) //          $location_data = $location_id;
142
+        foreach($location as $location_id => &$location_data) {
143
+          //          $location_data = $location_id;
143 144
         {
144 145
           $location_data = isset($location_data['username']) ? $location_data['username'] :
145 146
             (isset($location_data['name']) ? $location_data['name'] : $location_id);
146 147
         }
148
+        }
147 149
       }
148 150
     }
149 151
 
Please login to merge, or discard this patch.
includes/db/db_queries.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
 function db_unit_records_sum($unit_id, $user_skip_list_unit)
105 105
 {
106
-  return doquery (
106
+  return doquery(
107 107
     "SELECT unit_player_id, username, sum(unit_level) as unit_level
108 108
           FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id
109 109
           WHERE unit_player_id != 0 AND unit_snid = {$unit_id} {$user_skip_list_unit}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 
116 116
 function db_unit_records_plain($unit_id, $user_skip_list_unit)
117 117
 {
118
-  return doquery (
118
+  return doquery(
119 119
     "SELECT unit_player_id, username, unit_level
120 120
           FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id
121 121
           WHERE unit_player_id != 0 AND unit_snid = {$unit_id} {$user_skip_list_unit}
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 }
126 126
 
127 127
 function db_stat_list_statistic($who, $is_common_stat, $Rank, $start, $source = false) {
128
-  if(!$source) {
128
+  if (!$source) {
129 129
     $source = array(
130 130
       'statpoints' => 'statpoints',
131 131
       'users' => 'users',
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
     );
147 147
   }
148 148
 
149
-  if($who == 1) {
150
-    if($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday`
149
+  if ($who == 1) {
150
+    if ($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday`
151 151
       $query_str =
152 152
         "SELECT
153 153
       @rownum:=@rownum+1 rownum, subject.{$source['id']} as `id`, sp.{$Rank}_rank as rank, sp.{$Rank}_old_rank as rank_old, sp.{$Rank}_points as points, subject.{$source['username']} as `name`, subject.*
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
     ORDER BY
162 162
       sp.`{$Rank}_rank`, subject.{$source['id']}
163 163
     LIMIT
164
-      ". $start .",100;";
164
+      " . $start . ",100;";
165 165
     } else { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday`
166 166
       $query_str =
167 167
         "SELECT
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
     ORDER BY
175 175
       subject.{$Rank} DESC, subject.{$source['id']}
176 176
     LIMIT
177
-      ". $start .",100;";
177
+      " . $start . ",100;";
178 178
     }
179 179
   } else {
180 180
     // TODO
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
   ORDER BY
192 192
     sp.`{$Rank}_rank`, subject.id
193 193
   LIMIT
194
-    ". $start .",100;";
194
+    " . $start . ",100;";
195 195
   }
196 196
 
197 197
   return doquery($query_str);
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) {
278 278
   $current_value_safe = db_escape($current_value_unsafe);
279 279
   $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true);
280
-  if(!isset($value_id['id_field']) || !$value_id['id_field']) {
280
+  if (!isset($value_id['id_field']) || !$value_id['id_field']) {
281 281
     doquery("INSERT INTO {{{$db_table_name}}} (`{$db_value_field_name}`) VALUES ('{$current_value_safe}');");
282 282
     $variable_id = db_insert_id();
283 283
   } else {
Please login to merge, or discard this patch.
Braces   +11 added lines, -22 removed lines patch added patch discarded remove patch
@@ -6,8 +6,7 @@  discard block
 block discarded – undo
6 6
 require_once('db_queries_fleet.php');
7 7
 
8 8
 
9
-function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type)
10
-{
9
+function db_planet_list_admin_list($table_parent_columns, $planet_active, $active_time, $planet_type) {
11 10
   return doquery(
12 11
     "SELECT p.*, u.username" . ($table_parent_columns ? ', p1.name AS parent_name' : '') .
13 12
     " FROM {{planets}} AS p
@@ -16,8 +15,7 @@  discard block
 block discarded – undo
16 15
     " WHERE " . ($planet_active ? "p.last_update >= {$active_time}" : "p.planet_type = {$planet_type}"));
17 16
 }
18 17
 
19
-function db_planet_list_search($searchtext)
20
-{
18
+function db_planet_list_search($searchtext) {
21 19
   return doquery(
22 20
     "SELECT
23 21
       p.galaxy, p.system, p.planet, p.planet_type, p.name as planet_name,
@@ -37,8 +35,7 @@  discard block
 block discarded – undo
37 35
 
38 36
 
39 37
 
40
-function db_user_list_search($searchtext)
41
-{
38
+function db_user_list_search($searchtext) {
42 39
   return doquery(
43 40
     "SELECT
44 41
       pn.player_name, u.id as uid, u.username, u.ally_id, u.id_planet, u.total_points, u.total_rank,
@@ -56,8 +53,7 @@  discard block
 block discarded – undo
56 53
   );
57 54
 }
58 55
 
59
-function db_buddy_list_by_user($user_id)
60
-{
56
+function db_buddy_list_by_user($user_id) {
61 57
 //  return ($user_id = intval($user_id)) ? doquery(
62 58
   return ($user_id = idval($user_id)) ? doquery(
63 59
     "SELECT
@@ -87,8 +83,7 @@  discard block
 block discarded – undo
87 83
 
88 84
 
89 85
 
90
-function db_unit_records_sum($unit_id, $user_skip_list_unit)
91
-{
86
+function db_unit_records_sum($unit_id, $user_skip_list_unit) {
92 87
   return doquery (
93 88
     "SELECT unit_player_id, username, sum(unit_level) as unit_level
94 89
           FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id
@@ -99,8 +94,7 @@  discard block
 block discarded – undo
99 94
     , true);
100 95
 }
101 96
 
102
-function db_unit_records_plain($unit_id, $user_skip_list_unit)
103
-{
97
+function db_unit_records_plain($unit_id, $user_skip_list_unit) {
104 98
   return doquery (
105 99
     "SELECT unit_player_id, username, unit_level
106 100
           FROM {{unit}} JOIN {{users}} AS u ON u.id = unit_player_id
@@ -184,15 +178,13 @@  discard block
 block discarded – undo
184 178
 }
185 179
 
186 180
 
187
-function db_stat_list_delete_ally_player()
188
-{
181
+function db_stat_list_delete_ally_player() {
189 182
   return doquery('DELETE s FROM `{{statpoints}}` AS s JOIN `{{users}}` AS u ON u.id = s.id_owner WHERE s.id_ally IS NULL AND u.user_as_ally IS NOT NULL');
190 183
 }
191 184
 
192 185
 
193 186
 
194
-function db_chat_player_list_online($chat_refresh_rate, $ally_add)
195
-{
187
+function db_chat_player_list_online($chat_refresh_rate, $ally_add) {
196 188
   $sql_date = SN_TIME_NOW - $chat_refresh_rate * 2;
197 189
 
198 190
   return doquery(
@@ -206,13 +198,11 @@  discard block
 block discarded – undo
206 198
     ORDER BY authlevel DESC, `username`");
207 199
 }
208 200
 
209
-function db_referrals_list_by_id($user_id)
210
-{
201
+function db_referrals_list_by_id($user_id) {
211 202
   return doquery("SELECT r.*, u.username, u.register_time FROM {{referrals}} AS r LEFT JOIN {{users}} AS u ON u.id = r.id WHERE id_partner = {$user_id}");
212 203
 }
213 204
 
214
-function db_message_list_admin_by_type($int_type_selected, $StartRec)
215
-{
205
+function db_message_list_admin_by_type($int_type_selected, $StartRec) {
216 206
   return doquery("SELECT
217 207
   message_id as `ID`,
218 208
   message_from as `FROM`,
@@ -231,8 +221,7 @@  discard block
 block discarded – undo
231 221
 }
232 222
 
233 223
 
234
-function db_message_insert_all($message_type, $from, $subject, $text)
235
-{
224
+function db_message_insert_all($message_type, $from, $subject, $text) {
236 225
   return doquery($QryInsertMessage = 'INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' .
237 226
     "SELECT `id`, 0, unix_timestamp(now()), {$message_type}, '{$from}', '{$subject}', '{$text}' FROM {{users}}");
238 227
 }
Please login to merge, or discard this patch.
includes/db/db_helpers.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@  discard block
 block discarded – undo
27 27
  */
28 28
 function db_set_make_safe_string($set, $delta = false) {
29 29
   $set_safe = array();
30
-  foreach($set as $field => $value) {
31
-    if(empty($field)) {
30
+  foreach ($set as $field => $value) {
31
+    if (empty($field)) {
32 32
       continue;
33 33
     }
34 34
 
35 35
     $field = '`' . db_escape($field) . '`';
36 36
     $new_value = $value;
37
-    if($value === null) {
37
+    if ($value === null) {
38 38
       $new_value = 'NULL';
39
-    } elseif(is_string($value) && (string)($new_value = floatval($value)) != (string)$value) {
39
+    } elseif (is_string($value) && (string) ($new_value = floatval($value)) != (string) $value) {
40 40
       // non-float
41 41
       $new_value = '"' . db_escape($value) . '"';
42
-    } elseif($delta) {
42
+    } elseif ($delta) {
43 43
       // float and DELTA-set
44 44
       $new_value = "{$field} + ({$new_value})";
45 45
     }
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function missile_list_convert_to_fleet(&$missile_db_list, &$fleet_db_list) {
61 61
   // Missile attack
62
-  foreach($missile_db_list as $irak) {
63
-    if($irak['fleet_end_time'] >= SN_TIME_NOW) {
62
+  foreach ($missile_db_list as $irak) {
63
+    if ($irak['fleet_end_time'] >= SN_TIME_NOW) {
64 64
       $irak['fleet_start_type'] = PT_PLANET;
65 65
       $planet_start = DBStaticPlanet::db_planet_by_vector($irak, 'fleet_start_', false, 'name');
66 66
       $irak['fleet_id'] = -$irak['id'];
Please login to merge, or discard this patch.