Completed
Push — work-fleets ( 6257a1...22b5bc )
by SuperNova.WS
06:47
created
includes/classes/sn_module_payment.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
   public function compile_request($request) {
449 449
     global $user;
450 450
 
451
-    if(!(classSupernova::$auth->account instanceof Account)) {
451
+    if (!(classSupernova::$auth->account instanceof Account)) {
452 452
       // TODO - throw new Exception(lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT);
453 453
     }
454 454
     $this->account = classSupernova::$auth->account;
@@ -469,15 +469,15 @@  discard block
 block discarded – undo
469 469
     $this->payment_currency = classSupernova::$config->payment_currency_default;
470 470
     $this->payment_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_currency);
471 471
 
472
-    if(empty($this->payment_external_currency) && !empty($this->config['currency'])) {
472
+    if (empty($this->payment_external_currency) && !empty($this->config['currency'])) {
473 473
       $this->payment_external_currency = $this->config['currency'];
474 474
     }
475
-    if(empty($this->payment_external_currency)) {
475
+    if (empty($this->payment_external_currency)) {
476 476
       throw new Exception(classLocale::$lang['pay_error_internal_no_external_currency_set'], SN_PAYMENT_ERROR_INTERNAL_NO_EXTERNAL_CURRENCY_SET);
477 477
     }
478 478
 
479 479
     $this->payment_external_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_external_currency);
480
-    if($this->payment_external_amount < 0.01) {
480
+    if ($this->payment_external_amount < 0.01) {
481 481
       throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT);
482 482
     }
483 483
 
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
     $this->generate_description();
487 487
 
488 488
     $this->db_insert();
489
-    if(!$this->is_exists) {
489
+    if (!$this->is_exists) {
490 490
       throw new Exception(classLocale::$lang['pay_msg_request_error_db_payment_create'], SN_PAYMENT_REQUEST_DB_ERROR_PAYMENT_CREATE);
491 491
     }
492 492
   }
@@ -498,26 +498,26 @@  discard block
 block discarded – undo
498 498
    * @throws Exception
499 499
    */
500 500
   protected function payment_request_process($options = array()) {
501
-    if(!$this->manifest['active']) {
501
+    if (!$this->manifest['active']) {
502 502
       throw new Exception(classLocale::$lang['pay_msg_module_disabled'], SN_MODULE_DISABLED);
503 503
     }
504 504
 
505 505
     // Если есть payment_id - загружаем под него данные
506
-    if(!empty($this->payment_params['payment_id'])) {
506
+    if (!empty($this->payment_params['payment_id'])) {
507 507
       $this->request_payment_id = sys_get_param_id($this->payment_params['payment_id']);
508
-      if(!$this->request_payment_id) {
508
+      if (!$this->request_payment_id) {
509 509
         throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG);
510 510
       }
511 511
 
512
-      if(!$this->db_get_by_id($this->request_payment_id)) {
512
+      if (!$this->db_get_by_id($this->request_payment_id)) {
513 513
         throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG);
514 514
       }
515 515
 
516 516
       // Проверяем - был ли этот платеж обработан?
517 517
       // TODO - Статусы бывают разные. Нужен спецфлаг payment_processed
518
-      if($this->payment_status != PAYMENT_STATUS_NONE) {
518
+      if ($this->payment_status != PAYMENT_STATUS_NONE) {
519 519
         sn_db_transaction_rollback();
520
-        sys_redirect(SN_ROOT_VIRTUAL . 'metamatter.php?payment_id=' . $this->payment_id);
520
+        sys_redirect(SN_ROOT_VIRTUAL.'metamatter.php?payment_id='.$this->payment_id);
521 521
         die();
522 522
       }
523 523
     }
@@ -525,89 +525,89 @@  discard block
 block discarded – undo
525 525
     // Пытаемся получить из запроса ИД аккаунта
526 526
     $request_account_id = !empty($this->payment_params['account_id']) ? sys_get_param_id($this->payment_params['account_id']) : 0;
527 527
     // Если в запросе нет ИД аккаунта - пытаемся использовать payment_account_id
528
-    if(empty($request_account_id) && !empty($this->payment_account_id)) {
528
+    if (empty($request_account_id) && !empty($this->payment_account_id)) {
529 529
       $request_account_id = $this->payment_account_id;
530 530
     }
531 531
     // Если теперь у нас нету ИД аккаунта ни в запросе, ни в записи таблицы - можно паниковать
532
-    if(empty($request_account_id)) {
532
+    if (empty($request_account_id)) {
533 533
       // TODO - аккаунт
534 534
       throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
535 535
     }
536 536
     // Если нет записи в таблице - тогда берем payment_account_id из запроса
537
-    if(empty($this->payment_account_id)) {
537
+    if (empty($this->payment_account_id)) {
538 538
       $this->payment_account_id = $request_account_id;
539 539
     }
540 540
     // Если у нас отличаются ИД аккаунта в запросе и ИД аккаунта в записи - тоже можно паниковать
541
-    if($this->payment_account_id != $request_account_id) {
541
+    if ($this->payment_account_id != $request_account_id) {
542 542
       // TODO - Поменять сообщение об ошибке
543 543
       throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
544 544
     }
545 545
     // Проверяем существование аккаунта с данным ИД
546
-    if(!$this->account->db_get_by_id($this->payment_account_id)) {
547
-      throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'] . ' ID ' . $this->payment_account_id, $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
546
+    if (!$this->account->db_get_by_id($this->payment_account_id)) {
547
+      throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'].' ID '.$this->payment_account_id, $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
548 548
     }
549 549
 
550 550
     // TODO Проверка на сервер_ид - как бы и не нужна, наверное?
551
-    if(!empty($this->payment_params['server_id'])) {
551
+    if (!empty($this->payment_params['server_id'])) {
552 552
       $this->request_server_id = sys_get_param_str($this->payment_params['server_id']);
553
-      if(SN_ROOT_VIRTUAL != $this->request_server_id) {
554
-        throw new Exception(classLocale::$lang['pay_msg_request_server_wrong'] . " {$this->request_server_id} вместо " . SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG);
553
+      if (SN_ROOT_VIRTUAL != $this->request_server_id) {
554
+        throw new Exception(classLocale::$lang['pay_msg_request_server_wrong']." {$this->request_server_id} вместо ".SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG);
555 555
       }
556 556
     }
557 557
 
558 558
     // Сверка количества оплаченной ММ с учётом бонусов
559
-    if(!empty($this->payment_params['payment_dark_matter_gained'])) {
559
+    if (!empty($this->payment_params['payment_dark_matter_gained'])) {
560 560
       $request_mm_amount = sys_get_param_id($this->payment_params['payment_dark_matter_gained']);
561
-      if($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) {
562
-        throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'] . " пришло {$request_mm_amount} ММ вместо {$this->payment_dark_matter_gained} ММ", SN_PAYMENT_REQUEST_MM_AMOUNT_INVALID);
561
+      if ($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) {
562
+        throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid']." пришло {$request_mm_amount} ММ вместо {$this->payment_dark_matter_gained} ММ", SN_PAYMENT_REQUEST_MM_AMOUNT_INVALID);
563 563
       }
564 564
       empty($this->payment_dark_matter_gained) ? $this->payment_dark_matter_gained = $request_mm_amount : false;
565 565
     }
566
-    if(empty($this->payment_dark_matter_paid)) {
566
+    if (empty($this->payment_dark_matter_paid)) {
567 567
       // TODO - обратный расчёт из gained
568 568
     }
569 569
 
570 570
     // Проверка наличия внешнего ИД платежа
571
-    if(!empty($this->payment_params['payment_external_id'])) {
571
+    if (!empty($this->payment_params['payment_external_id'])) {
572 572
       $request_payment_external_id = sys_get_param_id($this->payment_params['payment_external_id']);
573
-      if(empty($request_payment_external_id)) {
573
+      if (empty($request_payment_external_id)) {
574 574
         throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG);
575
-      } elseif(!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) {
575
+      } elseif (!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) {
576 576
         // TODO - Может быть поменять сообщение
577 577
         throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG);
578 578
       }
579 579
       $this->payment_external_id = $request_payment_external_id;
580 580
     }
581 581
     // Сверка суммы, запрошенной СН к оплате
582
-    if(!empty($this->payment_params['payment_external_money'])) {
582
+    if (!empty($this->payment_params['payment_external_money'])) {
583 583
       $request_money_out = sys_get_param_float($this->payment_params['payment_external_money']);
584
-      if($request_money_out != $this->payment_external_amount && $this->is_loaded) {
585
-        throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " пришло {$request_money_out} денег вместо {$this->payment_external_amount} денег", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID);
584
+      if ($request_money_out != $this->payment_external_amount && $this->is_loaded) {
585
+        throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid']." пришло {$request_money_out} денег вместо {$this->payment_external_amount} денег", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID);
586 586
       }
587 587
       empty($this->payment_external_amount) ? $this->payment_external_amount = $request_money_out : false;
588 588
     }
589 589
     // Заполняем поле валюты платёжной системы
590
-    if(!empty($this->payment_params['payment_external_currency'])) {
590
+    if (!empty($this->payment_params['payment_external_currency'])) {
591 591
       $this->payment_external_currency = sys_get_param_str($this->payment_params['payment_external_currency']);
592
-      if(empty($this->payment_external_currency)) {
592
+      if (empty($this->payment_external_currency)) {
593 593
         // TODO - поменять сообщение
594
-        throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID);
594
+        throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid']." {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID);
595 595
       }
596 596
     }
597
-    if(empty($this->payment_external_currency)) {
597
+    if (empty($this->payment_external_currency)) {
598 598
       $this->payment_external_currency = $this->config['currency'];
599 599
     }
600 600
 
601 601
     // Заполнение внутренней суммы и валюты из внешних данных
602
-    if(empty($this->payment_currency)) {
602
+    if (empty($this->payment_currency)) {
603 603
       $this->payment_currency = classSupernova::$config->payment_currency_default;
604 604
     }
605
-    if(empty($this->payment_amount) && !empty($this->payment_external_currency)) {
605
+    if (empty($this->payment_amount) && !empty($this->payment_external_currency)) {
606 606
       $this->payment_amount = self::currency_convert($this->payment_external_amount, $this->payment_external_currency, $this->payment_currency);
607 607
     }
608 608
 
609 609
     // TODO - Тестовый режим
610
-    if(!empty($this->payment_params['test'])) {
610
+    if (!empty($this->payment_params['test'])) {
611 611
       $this->payment_test = $this->config['test'] || sys_get_param_int($this->payment_params['test']);
612 612
     }
613 613
 
@@ -634,21 +634,21 @@  discard block
 block discarded – undo
634 634
     sn_db_transaction_start();
635 635
     try {
636 636
       $response = $this->payment_request_process();
637
-    } catch(Exception $e) {
637
+    } catch (Exception $e) {
638 638
       $response['result'] = $e->getCode();
639 639
       $response['message'] = $e->getMessage();
640 640
     }
641 641
 
642
-    if($response['result'] == SN_PAYMENT_REQUEST_OK) {
642
+    if ($response['result'] == SN_PAYMENT_REQUEST_OK) {
643 643
       sn_db_transaction_commit();
644
-      classSupernova::$debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Успешный платёж', LOG_INFO_PAYMENT);
644
+      classSupernova::$debug->warning('Результат операции: код '.$response['result'].' сообщение "'.$response['message'].'"', 'Успешный платёж', LOG_INFO_PAYMENT);
645 645
     } else {
646 646
       sn_db_transaction_rollback();
647
-      classSupernova::$debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Ошибка платежа', LOG_INFO_PAYMENT, true);
647
+      classSupernova::$debug->warning('Результат операции: код '.$response['result'].' сообщение "'.$response['message'].'"', 'Ошибка платежа', LOG_INFO_PAYMENT, true);
648 648
     }
649 649
 
650 650
     // Переводим код результата из СН в код платежной системы
651
-    if(is_array($this->result_translations) && !empty($this->result_translations)) {
651
+    if (is_array($this->result_translations) && !empty($this->result_translations)) {
652 652
       $response['result'] = isset($this->result_translations[$response['result']]) ? $this->result_translations[$response['result']] : $this->result_translations[SN_PAYMENT_REQUEST_UNDEFINED_ERROR];
653 653
     }
654 654
 
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
     $currency_from = strtolower($currency_from);
672 672
     $currency_to = strtolower($currency_to);
673 673
 
674
-    if($currency_from != $currency_to) {
674
+    if ($currency_from != $currency_to) {
675 675
       $exchange_from = get_exchange_rate($currency_from);
676 676
       $exchange_to = get_exchange_rate($currency_to);
677 677
 
@@ -695,10 +695,10 @@  discard block
 block discarded – undo
695 695
   public static function bonus_calculate($dark_matter, $direct = true, $return_bonus = false) {
696 696
     $bonus = 0;
697 697
     $dark_matter_new = $dark_matter;
698
-    if(!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) {
699
-      if($direct) {
700
-        foreach(self::$bonus_table as $dm_for_bonus => $multiplier) {
701
-          if($dm_for_bonus <= $dark_matter) {
698
+    if (!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) {
699
+      if ($direct) {
700
+        foreach (self::$bonus_table as $dm_for_bonus => $multiplier) {
701
+          if ($dm_for_bonus <= $dark_matter) {
702 702
             $dark_matter_new = $dark_matter * (1 + $multiplier);
703 703
             $bonus = $multiplier;
704 704
           } else {
@@ -706,9 +706,9 @@  discard block
 block discarded – undo
706 706
           }
707 707
         }
708 708
       } else {
709
-        foreach(self::$bonus_table as $dm_for_bonus => $multiplier) {
709
+        foreach (self::$bonus_table as $dm_for_bonus => $multiplier) {
710 710
           $temp = $dm_for_bonus * (1 + $multiplier);
711
-          if($dark_matter >= $temp) {
711
+          if ($dark_matter >= $temp) {
712 712
             $dark_matter_new = round($dark_matter / (1 + $multiplier));
713 713
             $bonus = $multiplier;
714 714
           } else {
@@ -761,7 +761,7 @@  discard block
 block discarded – undo
761 761
       'payment_external_lots' => $this->payment_dark_matter_paid / get_mm_cost(),
762 762
     );
763 763
 
764
-    if($this->payment_id) {
764
+    if ($this->payment_id) {
765 765
       $payment['payment_id'] = $this->payment_id;
766 766
       classSupernova::$gc->db->doReplaceSet('payment', $payment);
767 767
     } else {
@@ -773,12 +773,12 @@  discard block
 block discarded – undo
773 773
 
774 774
 
775 775
   public function payment_adjust_mm_new() {
776
-    if(!$this->payment_test) {
776
+    if (!$this->payment_test) {
777 777
       // Not a test payment. Adding DM to account
778 778
       $this->account = new Account($this->db);
779 779
       $this->account->db_get_by_id($this->payment_account_id);
780 780
       $result = $this->account->metamatter_change(RPG_PURCHASE, $this->payment_dark_matter_gained, $this->payment_comment);
781
-      if(!$result) {
781
+      if (!$result) {
782 782
         throw new Exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST);
783 783
       }
784 784
     }
@@ -787,25 +787,25 @@  discard block
 block discarded – undo
787 787
   public function payment_cancel(&$payment) {
788 788
     die('{НЕ РАБОТАЕТ! СООБЩИТЕ АДМИНИСТРАЦИИ!}');
789 789
 
790
-    if(!isset($payment['payment_status'])) {
790
+    if (!isset($payment['payment_status'])) {
791 791
       throw new exception(classLocale::$lang['pay_msg_request_payment_not_found'], SN_PAYMENT_REQUEST_ORDER_NOT_FOUND);
792 792
     }
793 793
 
794
-    if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
795
-      $comment_unsafe = $payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] .' ' . $payment['payment_comment'];
794
+    if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
795
+      $comment_unsafe = $payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'].' '.$payment['payment_comment'];
796 796
 
797
-      if(!$payment['payment_test']) {
797
+      if (!$payment['payment_test']) {
798 798
         $result = $this->account->metamatter_change(RPG_PURCHASE_CANCEL, -$payment['payment_dark_matter_gained'], $payment['payment_comment']);
799
-        if(!$result) {
799
+        if (!$result) {
800 800
           throw new exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST);
801 801
         }
802 802
       }
803 803
       $payment['payment_status'] = PAYMENT_STATUS_CANCELED;
804 804
       db_payment_update($payment['payment_id'], $payment['payment_status'], $comment_unsafe);
805 805
       throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_complete'], SN_PAYMENT_REQUEST_OK);
806
-    } elseif($payment['payment_status'] == PAYMENT_STATUS_CANCELED) {
806
+    } elseif ($payment['payment_status'] == PAYMENT_STATUS_CANCELED) {
807 807
       throw new exception(classLocale::$lang['pay_msg_request_payment_cancelled_already'], SN_PAYMENT_REQUEST_OK);
808
-    } elseif($payment['payment_status'] == PAYMENT_STATUS_NONE) {
808
+    } elseif ($payment['payment_status'] == PAYMENT_STATUS_NONE) {
809 809
       throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_not_complete'], SN_PAYMENT_REQUEST_PAYMENT_NOT_COMPLETE);
810 810
     }
811 811
   }
@@ -828,8 +828,8 @@  discard block
 block discarded – undo
828 828
 
829 829
   protected function db_complete_payment() {
830 830
     // TODO - поле payment_processed
831
-    if($this->payment_status == PAYMENT_STATUS_NONE) {
832
-      if(!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) {
831
+    if ($this->payment_status == PAYMENT_STATUS_NONE) {
832
+      if (!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) {
833 833
         $this->payment_adjust_mm_new();
834 834
         $this->payment_status = PAYMENT_STATUS_COMPLETE;
835 835
       } else {
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
   protected function db_assign_payment($payment = null) {
877 877
     $this->payment_reset();
878 878
 
879
-    if(is_array($payment) && isset($payment['payment_id'])) {
879
+    if (is_array($payment) && isset($payment['payment_id'])) {
880 880
       $this->payment_id = $payment['payment_id'];
881 881
       $this->payment_status = $payment['payment_status'];
882 882
       $this->payment_date = $payment['payment_date'];
@@ -918,11 +918,11 @@  discard block
 block discarded – undo
918 918
   protected function generate_description() {
919 919
     // TODO - системная локализация
920 920
     $this->description_generated = array(
921
-      PAYMENT_DESCRIPTION_100 => substr("{$this->payment_dark_matter_gained} ММ аккаунт [{$this->account->account_name}] ID {$this->account->account_id} на " . SN_ROOT_VIRTUAL, 0, 100),
922
-      PAYMENT_DESCRIPTION_250 => substr("Оплата {$this->payment_dark_matter_gained} ММ для аккаунта [{$this->payment_user_name}] ID {$this->payment_user_id} на сервере " . SN_ROOT_VIRTUAL, 0, 250),
923
-      PAYMENT_DESCRIPTION_MAX => ($this->payment_test ? "ТЕСТОВЫЙ ПЛАТЕЖ! " : '') .
924
-        "Платеж от аккаунта '{$this->payment_account_name}' ID {$this->payment_account_id} игрока '{$this->payment_user_name}' ID {$this->payment_user_id} на сервере " . SN_ROOT_VIRTUAL .
925
-        " сумма {$this->payment_amount} {$this->payment_currency} за {$this->payment_dark_matter_paid} ММ (начислено {$this->payment_dark_matter_gained} ММ)" .
921
+      PAYMENT_DESCRIPTION_100 => substr("{$this->payment_dark_matter_gained} ММ аккаунт [{$this->account->account_name}] ID {$this->account->account_id} на ".SN_ROOT_VIRTUAL, 0, 100),
922
+      PAYMENT_DESCRIPTION_250 => substr("Оплата {$this->payment_dark_matter_gained} ММ для аккаунта [{$this->payment_user_name}] ID {$this->payment_user_id} на сервере ".SN_ROOT_VIRTUAL, 0, 250),
923
+      PAYMENT_DESCRIPTION_MAX => ($this->payment_test ? "ТЕСТОВЫЙ ПЛАТЕЖ! " : '').
924
+        "Платеж от аккаунта '{$this->payment_account_name}' ID {$this->payment_account_id} игрока '{$this->payment_user_name}' ID {$this->payment_user_id} на сервере ".SN_ROOT_VIRTUAL.
925
+        " сумма {$this->payment_amount} {$this->payment_currency} за {$this->payment_dark_matter_paid} ММ (начислено {$this->payment_dark_matter_gained} ММ)".
926 926
         " через '{$this->manifest['name']}' сумма {$this->payment_external_amount} {$this->payment_external_currency}",
927 927
     );
928 928
   }
Please login to merge, or discard this patch.
includes/classes/DBStaticChat.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@
 block discarded – undo
12 12
       JOIN {{users}} AS u ON u.id = cp.chat_player_player_id
13 13
     WHERE
14 14
       `chat_player_refresh_last` >= '{$sql_date}'
15
-      AND (`banaday` IS NULL OR `banaday` <= " . SN_TIME_NOW . ")
15
+      AND (`banaday` IS NULL OR `banaday` <= ".SN_TIME_NOW.")
16 16
       {$ally_add}
17 17
     ORDER BY authlevel DESC, `username`");
18 18
   }
Please login to merge, or discard this patch.
includes/classes/DBStaticMessages.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         sys_user_options_unpack($owner_row);
116 116
 
117 117
         if ($force || !$message_class['switchable'] || $owner_row["opt_{$message_class_name}"]) {
118
-          $insert_values[] = "('" . idval($owner) . "', '{$sender}', '{$timestamp}', '{$message_type}', '" . db_escape($from_unsafe) . "', '" . db_escape($subject_unsafe) . "', '" . db_escape($text_unsafe) . "')";
118
+          $insert_values[] = "('".idval($owner)."', '{$sender}', '{$timestamp}', '{$message_type}', '".db_escape($from_unsafe)."', '".db_escape($subject_unsafe)."', '".db_escape($text_unsafe)."')";
119 119
         }
120 120
 
121 121
         // TODO - allow sending HTML email only from admin
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
     $sendList = array();
160 160
     $list = '';
161 161
     $query = DBStaticUser::db_user_list(
162
-      "ally_id = '{$ally_id}'" . ($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''),
162
+      "ally_id = '{$ally_id}'".($ally_rank_id >= 0 ? " AND ally_rank_id = {$ally_rank_id}" : ''),
163 163
       false, 'id, username');
164 164
     foreach ($query as $u) {
165 165
       $sendList[] = $u['id'];
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
       $subject_unsafe = substr($subject_unsafe, strlen(classLocale::$lang['msg_answer_prefix']));
249 249
       $re++;
250 250
     }
251
-    $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'] . $subject_unsafe : false;
251
+    $re ? $subject_unsafe = classLocale::$lang['msg_answer_prefix'].$subject_unsafe : false;
252 252
 
253 253
     $subject_unsafe = $subject_unsafe ? $subject_unsafe : classLocale::$lang['msg_subject_default'];
254 254
 
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
     return classSupernova::$db->doSelect(
417 417
       "SELECT * FROM {{messages}}
418 418
         WHERE
419
-          `message_type` = '" . MSG_TYPE_PLAYER . "' AND
419
+          `message_type` = '" . MSG_TYPE_PLAYER."' AND
420 420
           ((`message_owner` = '{$user['id']}' AND `message_sender` = '{$recipient_id}')
421 421
           OR
422 422
           (`message_sender` = '{$user['id']}' AND `message_owner` = '{$recipient_id}')) ORDER BY `message_time` DESC LIMIT 20;");
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 FROM
461 461
   {{messages}} AS m
462 462
   LEFT JOIN {{users}} AS u ON u.id = m.message_owner " .
463
-      ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '') .
463
+      ($int_type_selected >= 0 ? "WHERE `message_type` = {$int_type_selected} " : '').
464 464
       "ORDER BY
465 465
   `message_id` DESC
466 466
 LIMIT
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
     $subject_safe = db_escape($subject_unsafe);
474 474
     $text_safe = db_escape($text_unsafe);
475 475
 
476
-    return classSupernova::$db->doInsertComplex('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) ' .
476
+    return classSupernova::$db->doInsertComplex('INSERT INTO {{messages}} (`message_owner`, `message_sender`, `message_time`, `message_type`, `message_from`, `message_subject`, `message_text`) '.
477 477
       "SELECT `id`, 0, unix_timestamp(now()), {$message_type_safe}, '{$from_safe}', '{$subject_safe}', '{$text_safe}' FROM {{users}}");
478 478
   }
479 479
 
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
    * @return array|bool|mysqli_result|null
484 484
    */
485 485
   public static function db_message_count_by_type($int_type_selected) {
486
-    $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`' . ($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : ''));
486
+    $page_max = classSupernova::$db->doSelectFetch('SELECT COUNT(*) AS `max` FROM `{{messages}}`'.($int_type_selected >= 0 ? " WHERE `message_type` = {$int_type_selected};" : ''));
487 487
 
488 488
     return $page_max;
489 489
   }
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
    */
508 508
   public static function db_message_list_delete_by_date($delete_date, $int_type_selected) {
509 509
     $where[] = "message_time <= UNIX_TIMESTAMP('{$delete_date}')";
510
-    if($int_type_selected >= 0) {
510
+    if ($int_type_selected >= 0) {
511 511
       $where['message_type'] = $int_type_selected;
512 512
     }
513 513
     classSupernova::$db->doDeleteDeprecated(TABLE_MESSAGES, $where);
Please login to merge, or discard this patch.
includes/alliance/ali_internal_admin_mail.inc 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
3
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
4 4
   classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
5 5
 }
6 6
 
7
-if(!$user_can_send_mails) {
7
+if (!$user_can_send_mails) {
8 8
   message(classLocale::$lang['Denied_access'], classLocale::$lang['Send_circular_mail']);
9 9
 }
10 10
 
11 11
 $POST_text = sys_get_param_str('text');
12 12
 $internalAliSendTextUnsafe = sys_get_param_str_unsafe('text');
13
-if($internalAliSendTextUnsafe) {
14
-  message(classLocale::$lang['members_who_recived_message'] . DBStaticMessages::msg_ali_send($internalAliSendTextUnsafe, classLocale::$lang['ali_adm_msg_subject'], sys_get_param_int('r')), classLocale::$lang['Circular_sended'], "alliance.php", '');
13
+if ($internalAliSendTextUnsafe) {
14
+  message(classLocale::$lang['members_who_recived_message'].DBStaticMessages::msg_ali_send($internalAliSendTextUnsafe, classLocale::$lang['ali_adm_msg_subject'], sys_get_param_int('r')), classLocale::$lang['Circular_sended'], "alliance.php", '');
15 15
 }
16 16
 
17
-$r_list = "<option value=\"-1\">" . classLocale::$lang['All_players'] . "</option>";
18
-if($ranks) {
19
-  foreach($ranks as $id => $array) {
20
-    $r_list .= "<option value=\"" . $id . "\">" . $array['name'] . "</option>";
17
+$r_list = "<option value=\"-1\">".classLocale::$lang['All_players']."</option>";
18
+if ($ranks) {
19
+  foreach ($ranks as $id => $array) {
20
+    $r_list .= "<option value=\"".$id."\">".$array['name']."</option>";
21 21
   }
22 22
 }
23 23
 
Please login to merge, or discard this patch.
includes/update_old.php 1 patch
Spacing   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('IN_UPDATE') || IN_UPDATE !== true) {
3
+if (!defined('IN_UPDATE') || IN_UPDATE !== true) {
4 4
   die('Hack attempt');
5 5
 }
6 6
 
7
-switch($new_version) {
7
+switch ($new_version) {
8 8
   case 0:
9 9
   case 1:
10 10
   case 2:
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
     );
33 33
     upd_drop_table('lunas');
34 34
 
35
-    if($update_tables['galaxy']) {
35
+    if ($update_tables['galaxy']) {
36 36
       upd_do_query(
37 37
         'UPDATE `{{planets}}`
38 38
           LEFT JOIN `{{galaxy}}` ON {{galaxy}}.id_planet = {{planets}}.id
@@ -82,12 +82,12 @@  discard block
 block discarded – undo
82 82
     );
83 83
     upd_add_more_time();
84 84
 
85
-    if($update_tables['users']['rpg_points']) {
85
+    if ($update_tables['users']['rpg_points']) {
86 86
       upd_do_query(
87 87
         "UPDATE {{users}} AS u
88 88
           RIGHT JOIN {{referrals}} AS r
89
-            ON r.id_partner = u.id AND r.dark_matter >= " . classSupernova::$config->rpg_bonus_divisor . "
90
-        SET u.rpg_points = u.rpg_points + FLOOR(r.dark_matter/" . classSupernova::$config->rpg_bonus_divisor . ");"
89
+            ON r.id_partner = u.id AND r.dark_matter >= " . classSupernova::$config->rpg_bonus_divisor."
90
+        SET u.rpg_points = u.rpg_points + FLOOR(r.dark_matter/" . classSupernova::$config->rpg_bonus_divisor.");"
91 91
       );
92 92
     }
93 93
 
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
     upd_alter_table('planets', "ADD `governor_level` smallint unsigned NOT NULL DEFAULT '0' COMMENT 'Governor level'", !$update_tables['planets']['governor_level']);
176 176
     upd_alter_table('planets', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'Planet que'", !$update_tables['planets']['que']);
177 177
 
178
-    if($update_tables['planets']['b_building']) {
178
+    if ($update_tables['planets']['b_building']) {
179 179
       $planet_query = upd_do_query('SELECT * FROM {{planets}} WHERE `b_building` <> 0;');
180 180
       $const_que_structures = QUE_STRUCTURES;
181
-      while($planet_data = db_fetch($planet_query)) {
181
+      while ($planet_data = db_fetch($planet_query)) {
182 182
         $old_que = explode(';', $planet_data['b_building_id']);
183
-        foreach($old_que as $old_que_item_string) {
184
-          if(!$old_que_item_string) {
183
+        foreach ($old_que as $old_que_item_string) {
184
+          if (!$old_que_item_string) {
185 185
             continue;
186 186
           }
187 187
 
188 188
           $old_que_item = explode(',', $old_que_item_string);
189
-          if($old_que_item[4] == 'build') {
189
+          if ($old_que_item[4] == 'build') {
190 190
             $old_que_item[4] = BUILD_CREATE;
191 191
           } else {
192 192
             $old_que_item[4] = BUILD_DESTROY;
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
       ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
220 220
     );
221 221
 
222
-    if($update_tables['users']['urlaubs_until']) {
222
+    if ($update_tables['users']['urlaubs_until']) {
223 223
       upd_alter_table('users', "ADD `vacation` int(11) NOT NULL DEFAULT '0' COMMENT 'Time when user can leave vacation mode'", !$update_tables['users']['vacation']);
224 224
       upd_do_query('UPDATE {{users}} SET `vacation` = `urlaubs_until` WHERE `urlaubs_modus` <> 0;');
225 225
       upd_alter_table('users', 'DROP COLUMN `urlaubs_until`, DROP COLUMN `urlaubs_modus`, DROP COLUMN `urlaubs_modus_time`', $update_tables['users']['urlaubs_until']);
@@ -269,12 +269,12 @@  discard block
 block discarded – undo
269 269
     ), !$update_tables['logs']['log_timestamp']);
270 270
     upd_do_query('DELETE FROM `{{logs}}` WHERE `log_code` = 303;');
271 271
 
272
-    if($update_tables['errors']) {
272
+    if ($update_tables['errors']) {
273 273
       upd_do_query('INSERT INTO `{{logs}}` (`log_code`, `log_sender`, `log_title`, `log_text`, `log_page`, `log_time`) SELECT 500, `error_sender`, `error_type`, `error_text`, `error_page`, `error_time` FROM `{{errors}}`;');
274
-      if($update_tables['errors_backup']) {
274
+      if ($update_tables['errors_backup']) {
275 275
         upd_drop_table('errors_backup');
276 276
       }
277
-      upd_alter_table('errors', ' RENAME TO ' . classSupernova::$config->db_prefix . 'errors_backup');
277
+      upd_alter_table('errors', ' RENAME TO '.classSupernova::$config->db_prefix.'errors_backup');
278 278
 
279 279
       upd_drop_table('errors');
280 280
     }
@@ -332,7 +332,7 @@  discard block
 block discarded – undo
332 332
 
333 333
     upd_alter_table('users', 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci');
334 334
 
335
-    if(!$update_tables['shortcut']) {
335
+    if (!$update_tables['shortcut']) {
336 336
       upd_create_table('shortcut',
337 337
         "(
338 338
           `shortcut_id` SERIAL,
@@ -356,10 +356,10 @@  discard block
 block discarded – undo
356 356
       $temp_planet_types = array(PT_PLANET, PT_DEBRIS, PT_MOON);
357 357
 
358 358
       $query = upd_do_query("SELECT id, fleet_shortcut FROM {{users}} WHERE fleet_shortcut > '';");
359
-      while($user_data = db_fetch($query)) {
359
+      while ($user_data = db_fetch($query)) {
360 360
         $shortcuts = explode("\r\n", $user_data['fleet_shortcut']);
361
-        foreach($shortcuts as $shortcut) {
362
-          if(!$shortcut) {
361
+        foreach ($shortcuts as $shortcut) {
362
+          if (!$shortcut) {
363 363
             continue;
364 364
           }
365 365
 
@@ -370,7 +370,7 @@  discard block
 block discarded – undo
370 370
           $shortcut[3] = intval($shortcut[3]);
371 371
           $shortcut[4] = intval($shortcut[4]);
372 372
 
373
-          if($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types)) {
373
+          if ($shortcut[0] && $shortcut[1] && $shortcut[2] && $shortcut[3] && in_array($shortcut[4], $temp_planet_types)) {
374 374
             $db_prefix = classSupernova::$config->db_prefix;
375 375
             upd_do_query("INSERT INTO {$db_prefix}shortcut (shortcut_user_id, shortcut_galaxy, shortcut_system, shortcut_planet, shortcut_planet_type, shortcut_text) VALUES ({$user_data['id']}, {$shortcut[1]}, {$shortcut[2]}, {$shortcut[3]}, {$shortcut[4]}, '{$shortcut[0]}');", true);
376 376
           }
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 
524 524
     upd_check_key('quest_total', 0, !isset(classSupernova::$config->quest_total));
525 525
 
526
-    for($i = 0; $i < 25; $i++) {
526
+    for ($i = 0; $i < 25; $i++) {
527 527
       upd_alter_table('alliance', array("DROP INDEX `id_{$i}`",), $update_indexes['alliance']["id_{$i}"]);
528 528
       upd_alter_table('users', array("DROP INDEX `id_{$i}`",), $update_indexes['users']["id_{$i}"]);
529 529
       upd_alter_table('planets', array("DROP INDEX `id_{$i}`",), $update_indexes['planets']["id_{$i}"]);
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
       "ADD `msg_admin` bigint(11) unsigned DEFAULT '0' AFTER mnl_buildlist"
552 552
     ), !$update_tables['users']['msg_admin']);
553 553
 
554
-    if(!$update_foreigns['users']['FK_users_ally_id']) {
554
+    if (!$update_foreigns['users']['FK_users_ally_id']) {
555 555
       upd_alter_table('users', array(
556 556
         'MODIFY COLUMN `ally_name` VARCHAR(32) DEFAULT NULL',
557 557
         'MODIFY COLUMN `ally_id` BIGINT(20) UNSIGNED DEFAULT NULL',
@@ -573,7 +573,7 @@  discard block
 block discarded – undo
573 573
     ), strtoupper($update_tables['planets']['debris_metal']['Type']) != 'BIGINT(20) UNSIGNED');
574 574
 
575 575
     $illegal_moon_query = upd_do_query("SELECT id FROM `{{planets}}` WHERE `id_owner` <> 0 AND `planet_type` = 3 AND `parent_planet` <> 0 AND `parent_planet` NOT IN (SELECT `id` FROM {{planets}} WHERE `planet_type` = 1);");
576
-    while($illegal_moon_row = db_fetch($illegal_moon_query)) {
576
+    while ($illegal_moon_row = db_fetch($illegal_moon_query)) {
577 577
       upd_do_query("DELETE FROM {{planets}} WHERE id = {$illegal_moon_row['id']} LIMIT 1;", true);
578 578
     }
579 579
 
@@ -610,16 +610,16 @@  discard block
 block discarded – undo
610 610
     upd_do_query('COMMIT;', true);
611 611
 
612 612
     $records = 1;
613
-    while($records) {
613
+    while ($records) {
614 614
       upd_do_query('START TRANSACTION;', true);
615 615
       $query = upd_do_query("SELECT * FROM {{LOGS}} WHERE log_code = 102 ORDER BY log_id LIMIT 1000;");
616 616
       $records = classSupernova::$db->db_num_rows($query);
617
-      while($row = db_fetch($query)) {
617
+      while ($row = db_fetch($query)) {
618 618
         $result = preg_match('/^Player ID (\d+) Dark Matter was adjusted with (\-?\d+). Reason: (.+)$/', $row['log_text'], $matches);
619 619
 
620 620
         $reason = RPG_NONE;
621 621
         $comment = $matches[3];
622
-        switch($matches[3]) {
622
+        switch ($matches[3]) {
623 623
           case 'Level Up For Structure Building':
624 624
             $reason = RPG_STRUCTURE;
625 625
           break;
@@ -635,22 +635,22 @@  discard block
 block discarded – undo
635 635
           break;
636 636
 
637 637
           default:
638
-            if(preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2)) {
638
+            if (preg_match('/^Using Black Market page (\d+)$/', $comment, $matches2)) {
639 639
               $reason = RPG_MARKET;
640
-            } elseif(preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2)) {
640
+            } elseif (preg_match('/^Spent for officer (.+) ID (\d+)$/', $comment, $matches2)) {
641 641
               $reason = RPG_MERCENARY;
642 642
               $comment = "Spent for mercenary {$matches2[1]} GUID {$matches2[2]}";
643
-            } elseif(preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2)) {
643
+            } elseif (preg_match('/^Incoming From Referral ID\ ?(\d+)$/', $comment, $matches2)) {
644 644
               $reason = RPG_REFERRAL;
645 645
               $comment = "Incoming from referral ID {$matches[1]}";
646
-            } elseif(preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2)) {
646
+            } elseif (preg_match('/^Through admin interface for user .* ID \d+ (.*)$/', $comment, $matches2)) {
647 647
               $reason = RPG_ADMIN;
648 648
               $comment = $matches2[1];
649 649
             }
650 650
           break;
651 651
         }
652 652
 
653
-        if($matches[2]) {
653
+        if ($matches[2]) {
654 654
           $row['log_username'] = db_escape($row['log_username']);
655 655
           $row['log_page'] = db_escape($row['log_page']);
656 656
           $comment = db_escape($comment);
@@ -669,12 +669,12 @@  discard block
 block discarded – undo
669 669
       upd_do_query('COMMIT;', true);
670 670
     }
671 671
 
672
-    foreach($update_tables as $table_name => $cork) {
673
-      $row = db_fetch(upd_do_query("SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '" . classSupernova::$config->db_prefix . "{$table_name}';", true));
674
-      if($row['ENGINE'] != 'InnoDB') {
672
+    foreach ($update_tables as $table_name => $cork) {
673
+      $row = db_fetch(upd_do_query("SELECT * FROM information_schema.TABLES WHERE TABLE_SCHEMA = '".db_escape(classSupernova::$db_name)."' AND TABLE_NAME = '".classSupernova::$config->db_prefix."{$table_name}';", true));
674
+      if ($row['ENGINE'] != 'InnoDB') {
675 675
         upd_alter_table($table_name, 'ENGINE=InnoDB', true);
676 676
       }
677
-      if($row['TABLE_COLLATION'] != 'utf8_general_ci') {
677
+      if ($row['TABLE_COLLATION'] != 'utf8_general_ci') {
678 678
         upd_alter_table($table_name, 'CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci', true);
679 679
       }
680 680
     }
@@ -694,7 +694,7 @@  discard block
 block discarded – undo
694 694
       "CHANGE COLUMN `governor_level` `PLANET_GOVERNOR_LEVEL` SMALLINT(5) NOT NULL DEFAULT 0",
695 695
     ), !$update_tables['planets']['PLANET_GOVERNOR_ID']);
696 696
 
697
-    if($update_tables['users']['rpg_geologue']) {
697
+    if ($update_tables['users']['rpg_geologue']) {
698 698
       classSupernova::$db->doUpdateOld("UPDATE `{{users}}` SET `dark_matter` = `dark_matter` + (`rpg_geologue` + `rpg_ingenieur` + `rpg_constructeur` + `rpg_technocrate` + `rpg_scientifique` + `rpg_defenseur`) * 3;");
699 699
 
700 700
       upd_alter_table('users', array(
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
       ), $update_tables['users']['rpg_geologue']);
708 708
     }
709 709
 
710
-    if($update_tables['users']['rpg_bunker']) {
710
+    if ($update_tables['users']['rpg_bunker']) {
711 711
       classSupernova::$db->doUpdateOld("UPDATE {{users}} SET `dark_matter` = `dark_matter` + (`rpg_bunker`) * 3;");
712 712
 
713 713
       upd_alter_table('users', array(
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
     ), !isset($update_tables['alliance']['total_rank']));
758 758
     classSupernova::$db->doUpdateOld("UPDATE {{alliance}} AS a JOIN {{statpoints}} AS sp ON sp.id_owner = a.id AND sp.stat_code = 1 AND sp.stat_type = 2 SET a.total_rank = sp.total_rank, a.total_points = sp.total_points;");
759 759
 
760
-    if(!isset($update_tables['users']['ally_tag'])) {
760
+    if (!isset($update_tables['users']['ally_tag'])) {
761 761
       upd_alter_table('users', array(
762 762
         "ADD COLUMN `ally_tag` varchar(8) DEFAULT NULL AFTER `ally_id`",
763 763
       ), !isset($update_tables['users']['ally_tag']));
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
       "ADD COLUMN `player_artifact_list` TEXT",
773 773
     ), !isset($update_tables['users']['player_artifact_list']));
774 774
 
775
-    if(!isset($update_tables['users']['player_rpg_tech_xp'])) {
775
+    if (!isset($update_tables['users']['player_rpg_tech_xp'])) {
776 776
       upd_check_key('eco_scale_storage', 1, !isset(classSupernova::$config->eco_scale_storage));
777 777
 
778 778
       upd_alter_table('users', array(
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
       "MODIFY COLUMN `ally_owner` BIGINT(20) UNSIGNED DEFAULT NULL",
803 803
     ), strtoupper($update_tables['alliance']['ally_owner']['Type']) != 'BIGINT(20) UNSIGNED');
804 804
 
805
-    if(strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') {
805
+    if (strtoupper($update_tables['alliance_diplomacy']['alliance_diplomacy_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') {
806 806
       upd_alter_table('alliance_diplomacy', array(
807 807
         "DROP FOREIGN KEY `FK_diplomacy_ally_id`",
808 808
         "DROP FOREIGN KEY `FK_diplomacy_contr_ally_id`"
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
       ), true);
818 818
     }
819 819
 
820
-    if(strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') {
820
+    if (strtoupper($update_tables['alliance_negotiation']['alliance_negotiation_ally_id']['Type']) != 'BIGINT(20) UNSIGNED') {
821 821
       upd_alter_table('alliance_negotiation', array(
822 822
         "DROP FOREIGN KEY `FK_negotiation_ally_id`",
823 823
         "DROP FOREIGN KEY `FK_negotiation_contr_ally_id`"
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
       ), true);
834 834
     }
835 835
 
836
-    if(strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') {
836
+    if (strtoupper($update_tables['alliance_requests']['id_user']['Type']) != 'BIGINT(20) UNSIGNED') {
837 837
       upd_do_query('DELETE FROM {{alliance_requests}} WHERE id_user NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true);
838 838
 
839 839
       upd_alter_table('alliance_requests', array(
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
       ), true);
848 848
     }
849 849
 
850
-    if(strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') {
850
+    if (strtoupper($update_tables['annonce']['id']['Type']) != 'BIGINT(20) UNSIGNED') {
851 851
       upd_do_query('DELETE FROM {{annonce}} WHERE USER NOT IN (SELECT username FROM {{users}});', true);
852 852
 
853 853
       upd_alter_table('annonce', array(
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
       ), true);
861 861
     }
862 862
 
863
-    if(strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') {
863
+    if (strtoupper($update_tables['bashing']['bashing_user_id']['Type']) != 'BIGINT(20) UNSIGNED') {
864 864
       upd_alter_table('bashing', array(
865 865
         "DROP FOREIGN KEY `FK_bashing_user_id`",
866 866
         "DROP FOREIGN KEY `FK_bashing_planet_id`",
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
       ), true);
876 876
     }
877 877
 
878
-    if(strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') {
878
+    if (strtoupper($update_tables['buddy']['id']['Type']) != 'BIGINT(20) UNSIGNED') {
879 879
       upd_do_query('DELETE FROM {{buddy}} WHERE sender NOT IN (SELECT id FROM {{users}}) OR OWNER NOT IN (SELECT id FROM {{users}});', true);
880 880
 
881 881
       upd_alter_table('buddy', array(
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
       "MODIFY COLUMN `fleet_resource_deuterium` DECIMAL(65,0) DEFAULT '0'",
914 914
     ), strtoupper($update_tables['fleets']['fleet_resource_metal']['Type']) != 'DECIMAL(65,0)');
915 915
 
916
-    if(strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') {
916
+    if (strtoupper($update_tables['iraks']['fleet_owner']['Type']) != 'BIGINT(20) UNSIGNED') {
917 917
       upd_do_query('DELETE FROM {{iraks}} WHERE OWNER NOT IN (SELECT id FROM {{users}}) OR zielid NOT IN (SELECT id FROM {{users}});', true);
918 918
 
919 919
       upd_alter_table('iraks', array(
@@ -937,7 +937,7 @@  discard block
 block discarded – undo
937 937
       ), true);
938 938
     }
939 939
 
940
-    if(strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') {
940
+    if (strtoupper($update_tables['notes']['owner']['Type']) != 'BIGINT(20) UNSIGNED') {
941 941
       upd_do_query('DELETE FROM {{notes}} WHERE OWNER NOT IN (SELECT id FROM {{users}});', true);
942 942
 
943 943
       upd_alter_table('notes', array(
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
       "DROP COLUMN `b_hangar_plus`",
1063 1063
     ), isset($update_tables['planets']['b_hangar_plus']));
1064 1064
 
1065
-    if(strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') {
1065
+    if (strtoupper($update_tables['referrals']['id_partner']['Type']) != 'BIGINT(20) UNSIGNED') {
1066 1066
       upd_do_query('DELETE FROM {{referrals}} WHERE id NOT IN (SELECT id FROM {{users}}) OR id_partner NOT IN (SELECT id FROM {{users}});', true);
1067 1067
 
1068 1068
       upd_alter_table('referrals', array(
@@ -1081,7 +1081,7 @@  discard block
 block discarded – undo
1081 1081
       "MODIFY COLUMN `id_owner2` BIGINT(20) UNSIGNED",
1082 1082
     ), strtoupper($update_tables['rw']['id_owner1']['Type']) != 'BIGINT(20) UNSIGNED');
1083 1083
 
1084
-    if(strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') {
1084
+    if (strtoupper($update_tables['shortcut']['shortcut_user_id']['Type']) != 'BIGINT(20) UNSIGNED') {
1085 1085
       upd_do_query('DELETE FROM {{shortcut}} WHERE shortcut_user_id NOT IN (SELECT id FROM {{users}}) OR shortcut_planet_id NOT IN (SELECT id FROM {{planets}});', true);
1086 1086
 
1087 1087
       upd_alter_table('shortcut', array(
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
       ), true);
1097 1097
     }
1098 1098
 
1099
-    if(strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') {
1099
+    if (strtoupper($update_tables['statpoints']['id_owner']['Type']) != 'BIGINT(20) UNSIGNED') {
1100 1100
       upd_do_query('DELETE FROM {{statpoints}} WHERE id_owner NOT IN (SELECT id FROM {{users}}) OR id_ally NOT IN (SELECT id FROM {{alliance}});', true);
1101 1101
 
1102 1102
       upd_alter_table('statpoints', array(
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
       "DROP COLUMN `settings_allylogo`",
1251 1251
     ), isset($update_tables['users']['settings_allylogo']));
1252 1252
 
1253
-    if(!isset($update_tables['powerup'])) {
1253
+    if (!isset($update_tables['powerup'])) {
1254 1254
       upd_do_query("DROP TABLE IF EXISTS {{mercenaries}};");
1255 1255
 
1256 1256
       upd_create_table('powerup',
@@ -1280,24 +1280,24 @@  discard block
 block discarded – undo
1280 1280
 
1281 1281
       $update_query_template = "UPDATE {{users}} SET id = id %s WHERE id = %d LIMIT 1;";
1282 1282
       $user_list = upd_do_query("SELECT * FROM {{users}};");
1283
-      while($user_row = db_fetch($user_list)) {
1283
+      while ($user_row = db_fetch($user_list)) {
1284 1284
         $update_query_str = '';
1285
-        foreach(sn_get_groups('mercenaries') as $mercenary_id) {
1285
+        foreach (sn_get_groups('mercenaries') as $mercenary_id) {
1286 1286
           $mercenary_data_name = get_unit_param($mercenary_id, P_NAME);
1287
-          if($mercenary_level = $user_row[$mercenary_data_name]) {
1287
+          if ($mercenary_level = $user_row[$mercenary_data_name]) {
1288 1288
             $update_query_str = ", `{$mercenary_data_name}` = 0";
1289 1289
             upd_do_query("DELETE FROM {{powerup}} WHERE powerup_user_id = {$user_row['id']} AND powerup_unit_id = {$mercenary_id} LIMIT 1;");
1290 1290
             upd_do_query("INSERT {{powerup}} SET powerup_user_id = {$user_row['id']}, powerup_unit_id = {$mercenary_id}, powerup_unit_level = {$mercenary_level};");
1291 1291
           }
1292 1292
         }
1293 1293
 
1294
-        if($update_query_str) {
1294
+        if ($update_query_str) {
1295 1295
           upd_do_query(sprintf($update_query_template, $update_query_str, $user_row['id']));
1296 1296
         }
1297 1297
       }
1298 1298
     }
1299 1299
 
1300
-    if(!isset($update_tables['universe'])) {
1300
+    if (!isset($update_tables['universe'])) {
1301 1301
       upd_create_table('universe',
1302 1302
         "(
1303 1303
           `universe_galaxy` SMALLINT UNSIGNED NOT NULL DEFAULT '0',
@@ -1320,7 +1320,7 @@  discard block
 block discarded – undo
1320 1320
 
1321 1321
     // ------------------------------------------------------------------------
1322 1322
     // Modifying tables
1323
-    if(strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') {
1323
+    if (strtoupper($update_tables['users']['user_as_ally']['Type']) != 'BIGINT(20) UNSIGNED') {
1324 1324
       upd_alter_table('users', array(
1325 1325
         "ADD COLUMN user_as_ally BIGINT(20) UNSIGNED DEFAULT NULL",
1326 1326
 
@@ -1341,7 +1341,7 @@  discard block
 block discarded – undo
1341 1341
     // ------------------------------------------------------------------------
1342 1342
     // Creating players for allies
1343 1343
     $ally_row_list = classSupernova::$db->doSelect("SELECT `id`, `ally_tag` FROM {{alliance}} WHERE ally_user_id IS NULL;");
1344
-    while($ally_row = db_fetch($ally_row_list)) {
1344
+    while ($ally_row = db_fetch($ally_row_list)) {
1345 1345
       classSupernova::$db->doInsertSet(TABLE_USERS, array(
1346 1346
         'username'      => "[{$ally_row['ally_tag']}]",
1347 1347
         'register_time' => SN_TIME_NOW,
@@ -1354,12 +1354,12 @@  discard block
 block discarded – undo
1354 1354
     // Renaming old ally players TODO: Remove on release
1355 1355
     upd_do_query("UPDATE {{users}} AS u LEFT JOIN {{alliance}} AS a ON u.user_as_ally = a.id SET u.username = CONCAT('[', a.ally_tag, ']') WHERE u.user_as_ally IS NOT NULL AND u.username = '';");
1356 1356
     // Setting last online time to old ally players TODO: Remove on release
1357
-    upd_do_query("UPDATE {{users}} SET `onlinetime` = " . SN_TIME_NOW . " WHERE onlinetime = 0;");
1357
+    upd_do_query("UPDATE {{users}} SET `onlinetime` = ".SN_TIME_NOW." WHERE onlinetime = 0;");
1358 1358
 
1359 1359
     // ------------------------------------------------------------------------
1360 1360
     // Creating planets for allies
1361 1361
     $ally_user_list = classSupernova::$db->doSelect("SELECT `id`, `username` FROM {{users}} WHERE `user_as_ally` IS NOT NULL AND `id_planet` = 0;");
1362
-    while($ally_user_row = db_fetch($ally_user_list)) {
1362
+    while ($ally_user_row = db_fetch($ally_user_list)) {
1363 1363
       classSupernova::$db->doInsertSet(TABLE_PLANETS, array(
1364 1364
         'name'        => $ally_user_row['username'],
1365 1365
         'last_update' => SN_TIME_NOW,
@@ -1394,10 +1394,10 @@  discard block
 block discarded – undo
1394 1394
     // Adding db field
1395 1395
     upd_alter_table('users', "ADD `que` varchar(4096) NOT NULL DEFAULT '' COMMENT 'User que'", !$update_tables['users']['que']);
1396 1396
     // Converting old data to new one and dropping old fields
1397
-    if($update_tables['users']['b_tech_planet']) {
1397
+    if ($update_tables['users']['b_tech_planet']) {
1398 1398
       $query = classSupernova::$db->doSelect("SELECT * FROM `{{planets}}` WHERE `b_tech_id` <> 0;");
1399
-      while($planet_row = db_fetch($query)) {
1400
-        $que_item_string = "{$planet_row['b_tech_id']},1," . max(0, $planet_row['b_tech'] - SN_TIME_NOW) . "," . BUILD_CREATE . "," . QUE_RESEARCH;
1399
+      while ($planet_row = db_fetch($query)) {
1400
+        $que_item_string = "{$planet_row['b_tech_id']},1,".max(0, $planet_row['b_tech'] - SN_TIME_NOW).",".BUILD_CREATE.",".QUE_RESEARCH;
1401 1401
         classSupernova::$db->doUpdateOld("UPDATE {{users}} SET `que` = '{$que_item_string}' WHERE `id` = {$planet_row['id_owner']} LIMIT 1;");
1402 1402
       }
1403 1403
 
@@ -1409,10 +1409,10 @@  discard block
 block discarded – undo
1409 1409
       upd_alter_table('users', "DROP COLUMN `b_tech_planet`", $update_tables['users']['b_tech_planet']);
1410 1410
     }
1411 1411
 
1412
-    if(!$update_tables['powerup']['powerup_category']) {
1412
+    if (!$update_tables['powerup']['powerup_category']) {
1413 1413
       upd_alter_table('powerup', "ADD COLUMN `powerup_category` SMALLINT NOT NULL DEFAULT 0 AFTER `powerup_planet_id`", !$update_tables['powerup']['powerup_category']);
1414 1414
 
1415
-      classSupernova::$db->doUpdateOld("UPDATE {{powerup}} SET powerup_category = " . BONUS_MERCENARY);
1415
+      classSupernova::$db->doUpdateOld("UPDATE {{powerup}} SET powerup_category = ".BONUS_MERCENARY);
1416 1416
     }
1417 1417
 
1418 1418
     upd_check_key('rpg_cost_info', 10000, !isset(classSupernova::$config->rpg_cost_info));
@@ -1430,7 +1430,7 @@  discard block
 block discarded – undo
1430 1430
     upd_check_key('ali_bonus_brackets', 10, !isset(classSupernova::$config->ali_bonus_brackets));
1431 1431
     upd_check_key('ali_bonus_brackets_divisor', 50, !isset(classSupernova::$config->ali_bonus_brackets_divisor));
1432 1432
 
1433
-    if(!classSupernova::$config->db_loadItem('rpg_flt_explore')) {
1433
+    if (!classSupernova::$config->db_loadItem('rpg_flt_explore')) {
1434 1434
       $inflation_rate = 1000;
1435 1435
 
1436 1436
       classSupernova::$config->db_saveItem('rpg_cost_banker', classSupernova::$config->rpg_cost_banker * $inflation_rate);
@@ -1447,17 +1447,17 @@  discard block
 block discarded – undo
1447 1447
       classSupernova::$db->doUpdateOld("UPDATE {{users}} SET `dark_matter` = `dark_matter` * {$inflation_rate};");
1448 1448
 
1449 1449
       $query = classSupernova::$db->doSelect("SELECT * FROM `{{quest}}`");
1450
-      while($row = db_fetch($query)) {
1450
+      while ($row = db_fetch($query)) {
1451 1451
         $query_add = '';
1452 1452
         $quest_reward_list = explode(';', $row['quest_rewards']);
1453
-        foreach($quest_reward_list as &$quest_reward) {
1453
+        foreach ($quest_reward_list as &$quest_reward) {
1454 1454
           list($reward_resource, $reward_amount) = explode(',', $quest_reward);
1455
-          if($reward_resource == RES_DARK_MATTER) {
1456
-            $quest_reward = "{$reward_resource}," . $reward_amount * 1000;
1455
+          if ($reward_resource == RES_DARK_MATTER) {
1456
+            $quest_reward = "{$reward_resource},".$reward_amount * 1000;
1457 1457
           }
1458 1458
         }
1459 1459
         $new_rewards = implode(';', $quest_reward_list);
1460
-        if($new_rewards != $row['quest_rewards']) {
1460
+        if ($new_rewards != $row['quest_rewards']) {
1461 1461
           classSupernova::$db->doUpdateOld("UPDATE {{quest}} SET `quest_rewards` = '{$new_rewards}' WHERE quest_id = {$row['quest_id']} LIMIT 1;");
1462 1462
         }
1463 1463
       }
@@ -1487,7 +1487,7 @@  discard block
 block discarded – undo
1487 1487
     upd_check_key('user_birthday_range', 30, !isset(classSupernova::$config->user_birthday_range));
1488 1488
     upd_check_key('user_birthday_celebrate', 0, !isset(classSupernova::$config->user_birthday_celebrate));
1489 1489
 
1490
-    if(!isset($update_tables['payment'])) {
1490
+    if (!isset($update_tables['payment'])) {
1491 1491
       upd_alter_table('users', array(
1492 1492
         "ADD KEY `I_user_id_name` (`id`, `username`)",
1493 1493
       ), !$update_indexes['users']['I_user_id_name']);
@@ -1521,15 +1521,15 @@  discard block
 block discarded – undo
1521 1521
     upd_check_key('payment_lot_price', 1, !isset(classSupernova::$config->payment_lot_price));
1522 1522
 
1523 1523
     // Updating category for Mercenaries
1524
-    upd_do_query("UPDATE {{powerup}} SET powerup_category = " . UNIT_MERCENARIES . " WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;");
1524
+    upd_do_query("UPDATE {{powerup}} SET powerup_category = ".UNIT_MERCENARIES." WHERE powerup_unit_id > 600 AND powerup_unit_id < 700;");
1525 1525
 
1526 1526
     // Convert Destructor to Death Star schematic
1527 1527
     upd_do_query("UPDATE {{powerup}}
1528
-      SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_DEATH_STAR . "
1528
+      SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS.", powerup_unit_id = ".UNIT_PLAN_SHIP_DEATH_STAR."
1529 1529
       WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 612;");
1530 1530
     // Convert Assasin to SuperNova schematic
1531 1531
     upd_do_query("UPDATE {{powerup}}
1532
-      SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS . ", powerup_unit_id = " . UNIT_PLAN_SHIP_SUPERNOVA . "
1532
+      SET powerup_time_start = 0, powerup_time_finish = 0, powerup_category = " . UNIT_PLANS.", powerup_unit_id = ".UNIT_PLAN_SHIP_SUPERNOVA."
1533 1533
       WHERE (powerup_time_start = 0 OR powerup_time_finish >= UNIX_TIMESTAMP()) AND powerup_unit_id = 614;");
1534 1534
 
1535 1535
     upd_alter_table('iraks', array(
@@ -1538,7 +1538,7 @@  discard block
 block discarded – undo
1538 1538
     ), !$update_tables['iraks']['fleet_start_type']);
1539 1539
 
1540 1540
 
1541
-    if(!$update_tables['payment']['payment_status']) {
1541
+    if (!$update_tables['payment']['payment_status']) {
1542 1542
       upd_alter_table('payment', array(
1543 1543
         "ADD COLUMN `payment_status` INT DEFAULT 0 COMMENT 'Payment status' AFTER `payment_id`",
1544 1544
 
@@ -1553,7 +1553,7 @@  discard block
 block discarded – undo
1553 1553
       ), !$update_tables['payment']['payment_status']);
1554 1554
     }
1555 1555
 
1556
-    upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = " . UNIT_PLANS . ";");
1556
+    upd_do_query("UPDATE {{powerup}} SET powerup_time_start = 0, powerup_time_finish = 0 WHERE powerup_category = ".UNIT_PLANS.";");
1557 1557
 
1558 1558
     upd_check_key('server_start_date', date('d.m.Y', SN_TIME_NOW), !isset(classSupernova::$config->server_start_date));
1559 1559
     upd_check_key('server_que_length_structures', 5, !isset(classSupernova::$config->server_que_length_structures));
@@ -1565,7 +1565,7 @@  discard block
 block discarded – undo
1565 1565
 
1566 1566
     upd_check_key('chat_highlight_premium', '<span class="nick_premium">$1</span>', !isset(classSupernova::$config->chat_highlight_premium));
1567 1567
 
1568
-    upd_do_query("UPDATE {{planets}} SET `PLANET_GOVERNOR_LEVEL` = CEILING(`PLANET_GOVERNOR_LEVEL`/2) WHERE PLANET_GOVERNOR_ID = " . MRC_ENGINEER . " AND `PLANET_GOVERNOR_LEVEL` > 8;");
1568
+    upd_do_query("UPDATE {{planets}} SET `PLANET_GOVERNOR_LEVEL` = CEILING(`PLANET_GOVERNOR_LEVEL`/2) WHERE PLANET_GOVERNOR_ID = ".MRC_ENGINEER." AND `PLANET_GOVERNOR_LEVEL` > 8;");
1569 1569
 
1570 1570
 
1571 1571
     upd_do_query('COMMIT;', true);
@@ -1622,7 +1622,7 @@  discard block
 block discarded – undo
1622 1622
       "ADD INDEX `I_owner_priority_time` (`owner`, `priority`, `time`)",
1623 1623
     ), !$update_indexes['notes']['I_owner_priority_time']);
1624 1624
 
1625
-    if(!$update_tables['buddy']['BUDDY_ID']) {
1625
+    if (!$update_tables['buddy']['BUDDY_ID']) {
1626 1626
       upd_alter_table('buddy', array(
1627 1627
         "CHANGE COLUMN `id` `BUDDY_ID` SERIAL COMMENT 'Buddy\Buddy table row ID'",
1628 1628
         "CHANGE COLUMN `active` `BUDDY_STATUS` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Buddy\Buddy request status'",
@@ -1643,16 +1643,16 @@  discard block
 block discarded – undo
1643 1643
 
1644 1644
       $query = upd_do_query("SELECT `BUDDY_ID`, `BUDDY_SENDER_ID`, `BUDDY_OWNER_ID` FROM {{buddy}} ORDER BY `BUDDY_ID`;");
1645 1645
       $found = $lost = array();
1646
-      while($row = db_fetch($query)) {
1647
-        $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']) . ';' . max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']);
1648
-        if(!isset($found[$index])) {
1646
+      while ($row = db_fetch($query)) {
1647
+        $index = min($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']).';'.max($row['BUDDY_SENDER_ID'], $row['BUDDY_OWNER_ID']);
1648
+        if (!isset($found[$index])) {
1649 1649
           $found[$index] = $row['BUDDY_ID'];
1650 1650
         } else {
1651 1651
           $lost[] = $row['BUDDY_ID'];
1652 1652
         }
1653 1653
       }
1654 1654
       $lost = implode(',', $lost);
1655
-      if($lost) {
1655
+      if ($lost) {
1656 1656
         upd_do_query("DELETE FROM {{buddy}} WHERE `BUDDY_ID` IN ({$lost})");
1657 1657
       }
1658 1658
 
@@ -1673,7 +1673,7 @@  discard block
 block discarded – undo
1673 1673
 
1674 1674
     upd_do_query("UPDATE {{users}} SET `ally_name` = NULL, `ally_tag` = NULL, ally_register_time = 0, ally_rank_id = 0 WHERE `ally_id` IS NULL");
1675 1675
 
1676
-    if(!$update_tables['ube_report']) {
1676
+    if (!$update_tables['ube_report']) {
1677 1677
       upd_create_table('ube_report',
1678 1678
         "(
1679 1679
           `ube_report_id` SERIAL COMMENT 'Report ID',
@@ -1714,7 +1714,7 @@  discard block
 block discarded – undo
1714 1714
       );
1715 1715
     }
1716 1716
 
1717
-    if(!$update_tables['ube_report_player']) {
1717
+    if (!$update_tables['ube_report_player']) {
1718 1718
       upd_create_table('ube_report_player',
1719 1719
         "(
1720 1720
           `ube_report_player_id` SERIAL COMMENT 'Record ID',
@@ -1735,7 +1735,7 @@  discard block
 block discarded – undo
1735 1735
       );
1736 1736
     }
1737 1737
 
1738
-    if(!$update_tables['ube_report_fleet']) {
1738
+    if (!$update_tables['ube_report_fleet']) {
1739 1739
       upd_create_table('ube_report_fleet',
1740 1740
         "(
1741 1741
           `ube_report_fleet_id` SERIAL COMMENT 'Record DB ID',
@@ -1765,7 +1765,7 @@  discard block
 block discarded – undo
1765 1765
       );
1766 1766
     }
1767 1767
 
1768
-    if(!$update_tables['ube_report_unit']) {
1768
+    if (!$update_tables['ube_report_unit']) {
1769 1769
       // TODO: Сохранять так же имя корабля - на случай конструкторов - не, хуйня. Конструктор может давать имена разные на разных языках
1770 1770
       // Может сохранять имена удаленных кораблей долго?
1771 1771
 
@@ -1802,7 +1802,7 @@  discard block
 block discarded – undo
1802 1802
       );
1803 1803
     }
1804 1804
 
1805
-    if(!$update_tables['ube_report_outcome_fleet']) {
1805
+    if (!$update_tables['ube_report_outcome_fleet']) {
1806 1806
       upd_create_table('ube_report_outcome_fleet',
1807 1807
         "(
1808 1808
           `ube_report_outcome_fleet_id` SERIAL COMMENT 'Record DB ID',
@@ -1831,7 +1831,7 @@  discard block
 block discarded – undo
1831 1831
       );
1832 1832
     }
1833 1833
 
1834
-    if(!$update_tables['ube_report_outcome_unit']) {
1834
+    if (!$update_tables['ube_report_outcome_unit']) {
1835 1835
       upd_create_table('ube_report_outcome_unit',
1836 1836
         "(
1837 1837
           `ube_report_outcome_unit_id` SERIAL COMMENT 'Record DB ID',
@@ -1852,7 +1852,7 @@  discard block
 block discarded – undo
1852 1852
       );
1853 1853
     }
1854 1854
 
1855
-    if(!$update_tables['unit']) {
1855
+    if (!$update_tables['unit']) {
1856 1856
       upd_create_table('unit',
1857 1857
         "(
1858 1858
           `unit_id` SERIAL COMMENT 'Record ID',
@@ -1871,7 +1871,7 @@  discard block
 block discarded – undo
1871 1871
       );
1872 1872
     }
1873 1873
 
1874
-    if(!$update_tables['captain']) {
1874
+    if (!$update_tables['captain']) {
1875 1875
       upd_create_table('captain',
1876 1876
         "(
1877 1877
           `captain_id` SERIAL COMMENT 'Record ID',
@@ -1891,7 +1891,7 @@  discard block
 block discarded – undo
1891 1891
       );
1892 1892
     }
1893 1893
 
1894
-    if(!$update_tables['fleets']['fleet_start_planet_id']) {
1894
+    if (!$update_tables['fleets']['fleet_start_planet_id']) {
1895 1895
       upd_alter_table('fleets', array(
1896 1896
         "ADD `fleet_start_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet start planet ID' AFTER `fleet_start_time`",
1897 1897
         "ADD `fleet_end_planet_id` BIGINT(20) UNSIGNED DEFAULT NULL COMMENT 'Fleet end planet ID' AFTER `fleet_end_stay`",
@@ -1913,7 +1913,7 @@  discard block
 block discarded – undo
1913 1913
 
1914 1914
     upd_alter_table('fleets', array("DROP COLUMN `processing_start`"), $update_tables['fleets']['processing_start']);
1915 1915
 
1916
-    if(!$update_tables['chat_player']) {
1916
+    if (!$update_tables['chat_player']) {
1917 1917
       upd_create_table('chat_player',
1918 1918
         "(
1919 1919
           `chat_player_id` SERIAL COMMENT 'Record ID',
@@ -1975,7 +1975,7 @@  discard block
 block discarded – undo
1975 1975
       "DROP FOREIGN KEY `FK_payment_user`",
1976 1976
     ), $update_foreigns['payment']['FK_payment_user']);
1977 1977
 
1978
-    if($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') {
1978
+    if ($update_foreigns['chat']['FK_chat_message_sender_user_id'] != 'chat_message_sender_id,users,id;') {
1979 1979
       upd_alter_table('chat', array(
1980 1980
         "DROP FOREIGN KEY `FK_chat_message_sender_user_id`",
1981 1981
         "DROP FOREIGN KEY `FK_chat_message_sender_recipient_id`",
@@ -2008,7 +2008,7 @@  discard block
 block discarded – undo
2008 2008
       "ADD KEY `I_ube_report_time_combat` (`ube_report_time_combat`)",
2009 2009
     ), !$update_indexes['ube_report']['I_ube_report_time_combat']);
2010 2010
 
2011
-    if(!$update_tables['unit']['unit_time_start']) {
2011
+    if (!$update_tables['unit']['unit_time_start']) {
2012 2012
       upd_alter_table('unit', array(
2013 2013
         "ADD COLUMN `unit_time_start` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation start time'",
2014 2014
         "ADD COLUMN `unit_time_finish` DATETIME NULL DEFAULT NULL COMMENT 'Unit activation end time'",
@@ -2018,13 +2018,13 @@  discard block
 block discarded – undo
2018 2018
         "INSERT INTO {{unit}}
2019 2019
           (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level, unit_time_start, unit_time_finish)
2020 2020
         SELECT
2021
-          `powerup_user_id`, " . LOC_USER . ", `powerup_user_id`, `powerup_category`, `powerup_unit_id`, `powerup_unit_level`
2021
+          `powerup_user_id`, " . LOC_USER.", `powerup_user_id`, `powerup_category`, `powerup_unit_id`, `powerup_unit_level`
2022 2022
           , IF(`powerup_time_start`, FROM_UNIXTIME(`powerup_time_start`), NULL), IF(`powerup_time_finish`, FROM_UNIXTIME(`powerup_time_finish`), NULL)
2023 2023
         FROM {{powerup}}"
2024 2024
       );
2025 2025
     }
2026 2026
 
2027
-    if(!$update_tables['que']) {
2027
+    if (!$update_tables['que']) {
2028 2028
       upd_create_table('que',
2029 2029
         "(
2030 2030
           `que_id` SERIAL COMMENT 'Internal que id',
@@ -2056,25 +2056,25 @@  discard block
 block discarded – undo
2056 2056
     }
2057 2057
 
2058 2058
     // Конвертирум очередь исследований
2059
-    if($update_tables['users']['que']) {
2059
+    if ($update_tables['users']['que']) {
2060 2060
       $que_lines = array();
2061 2061
       $que_query = upd_do_query("SELECT * FROM {{users}} WHERE `que`");
2062
-      while($que_row = db_fetch($que_query)) {
2062
+      while ($que_row = db_fetch($que_query)) {
2063 2063
         $que_data = explode(',', $que_row['que']);
2064 2064
 
2065
-        if(!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) {
2065
+        if (!in_array($que_data[QI_UNIT_ID], sn_get_groups('tech'))) {
2066 2066
           continue;
2067 2067
         }
2068 2068
 
2069 2069
         $que_data[QI_TIME] = $que_data[QI_TIME] >= 0 ? $que_data[QI_TIME] : 0;
2070 2070
         // Если планета пустая - ставим главку
2071 2071
         $que_data[QI_PLANET_ID] = $que_data[QI_PLANET_ID] ? $que_data[QI_PLANET_ID] : $que_row['id_planet'];
2072
-        if($que_data[QI_PLANET_ID]) {
2072
+        if ($que_data[QI_PLANET_ID]) {
2073 2073
           $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}"));
2074
-          if(!$que_planet_check['id']) {
2074
+          if (!$que_planet_check['id']) {
2075 2075
             $que_data[QI_PLANET_ID] = $que_row['id_planet'];
2076 2076
             $que_planet_check = db_fetch(upd_do_query("SELECT `id` FROM {{planets}} WHERE `id` = {$que_data[QI_PLANET_ID]}"));
2077
-            if(!$que_planet_check['id']) {
2077
+            if (!$que_planet_check['id']) {
2078 2078
               $que_data[QI_PLANET_ID] = 'NULL';
2079 2079
             }
2080 2080
           }
@@ -2088,20 +2088,20 @@  discard block
 block discarded – undo
2088 2088
         $price_increase = pow($unit_factor, $unit_level);
2089 2089
         $unit_level++;
2090 2090
         $unit_cost = array();
2091
-        foreach($unit_info[P_COST] as $resource_id => $resource_amount) {
2092
-          if($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) {
2091
+        foreach ($unit_info[P_COST] as $resource_id => $resource_amount) {
2092
+          if ($resource_id === P_FACTOR || $resource_id == RES_ENERGY || !($resource_cost = $resource_amount * $price_increase)) {
2093 2093
             continue;
2094 2094
           }
2095
-          $unit_cost[] = $resource_id . ',' . floor($resource_cost);
2095
+          $unit_cost[] = $resource_id.','.floor($resource_cost);
2096 2096
         }
2097 2097
         $unit_cost = implode(';', $unit_cost);
2098 2098
 
2099
-        $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]}," . QUE_RESEARCH . ",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1," .
2100
-          BUILD_CREATE . ",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')";
2099
+        $que_lines[] = "({$que_row['id']},{$que_data[QI_PLANET_ID]},".QUE_RESEARCH.",{$que_data[QI_TIME]},{$que_data[QI_UNIT_ID]},1,".
2100
+          BUILD_CREATE.",{$unit_level},{$que_data[QI_TIME]},'{$unit_cost}')";
2101 2101
       }
2102 2102
 
2103
-      if(!empty($que_lines)) {
2104
-        upd_do_query('INSERT INTO `{{que}}` (`que_player_id`,`que_planet_id_origin`,`que_type`,`que_time_left`,`que_unit_id`,`que_unit_amount`,`que_unit_mode`,`que_unit_level`,`que_unit_time`,`que_unit_price`) VALUES ' . implode(',', $que_lines));
2103
+      if (!empty($que_lines)) {
2104
+        upd_do_query('INSERT INTO `{{que}}` (`que_player_id`,`que_planet_id_origin`,`que_type`,`que_time_left`,`que_unit_id`,`que_unit_amount`,`que_unit_mode`,`que_unit_level`,`que_unit_time`,`que_unit_price`) VALUES '.implode(',', $que_lines));
2105 2105
       }
2106 2106
 
2107 2107
       upd_alter_table('users', array(
@@ -2114,23 +2114,23 @@  discard block
 block discarded – undo
2114 2114
 
2115 2115
 
2116 2116
     // Ковертируем технологии в таблицы
2117
-    if($update_tables['users']['graviton_tech']) {
2118
-      upd_do_query("DELETE FROM {{unit}} WHERE unit_type = " . UNIT_TECHNOLOGIES);
2117
+    if ($update_tables['users']['graviton_tech']) {
2118
+      upd_do_query("DELETE FROM {{unit}} WHERE unit_type = ".UNIT_TECHNOLOGIES);
2119 2119
 
2120 2120
       $que_lines = array();
2121 2121
       $user_query = upd_do_query("SELECT * FROM {{users}}");
2122 2122
       upd_add_more_time(300);
2123 2123
       $sn_group_tech = sn_get_groups('tech');
2124
-      while($user_row = db_fetch($user_query)) {
2125
-        foreach($sn_group_tech as $tech_id) {
2126
-          if($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) {
2127
-            $que_lines[] = "({$user_row['id']}," . LOC_USER . ",{$user_row['id']}," . UNIT_TECHNOLOGIES . ",{$tech_id},{$tech_level})";
2124
+      while ($user_row = db_fetch($user_query)) {
2125
+        foreach ($sn_group_tech as $tech_id) {
2126
+          if ($tech_level = intval($user_row[get_unit_param($tech_id, P_NAME)])) {
2127
+            $que_lines[] = "({$user_row['id']},".LOC_USER.",{$user_row['id']},".UNIT_TECHNOLOGIES.",{$tech_id},{$tech_level})";
2128 2128
           }
2129 2129
         }
2130 2130
       }
2131 2131
 
2132
-      if(!empty($que_lines)) {
2133
-        upd_do_query("INSERT INTO {{unit}} (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level) VALUES " . implode(',', $que_lines));
2132
+      if (!empty($que_lines)) {
2133
+        upd_do_query("INSERT INTO {{unit}} (unit_player_id, unit_location_type, unit_location_id, unit_type, unit_snid, unit_level) VALUES ".implode(',', $que_lines));
2134 2134
       }
2135 2135
 
2136 2136
       upd_alter_table('users', array(
@@ -2138,25 +2138,25 @@  discard block
 block discarded – undo
2138 2138
       ), $update_tables['users']['graviton_tech']);
2139 2139
     }
2140 2140
 
2141
-    if(!$update_indexes['unit']['I_unit_record_search']) {
2141
+    if (!$update_indexes['unit']['I_unit_record_search']) {
2142 2142
       upd_alter_table('unit', array(
2143 2143
         "ADD KEY `I_unit_record_search` (`unit_snid`,`unit_player_id`,`unit_level` DESC,`unit_id`)",
2144 2144
       ), !$update_indexes['unit']['I_unit_record_search']);
2145 2145
 
2146
-      foreach(sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) {
2146
+      foreach (sn_get_groups(array('structures', 'fleet', 'defense')) as $unit_id) {
2147 2147
         $planet_units[get_unit_param($unit_id, P_NAME)] = 1;
2148 2148
       }
2149 2149
       $drop_index = array();
2150 2150
       $create_index = &$drop_index; // array();
2151
-      foreach($planet_units as $unit_name => $unit_create) {
2152
-        if($update_indexes['planets']['I_' . $unit_name]) {
2151
+      foreach ($planet_units as $unit_name => $unit_create) {
2152
+        if ($update_indexes['planets']['I_'.$unit_name]) {
2153 2153
           $drop_index[] = "DROP KEY I_{$unit_name}";
2154 2154
         }
2155
-        if($update_indexes['planets']['i_' . $unit_name]) {
2155
+        if ($update_indexes['planets']['i_'.$unit_name]) {
2156 2156
           $drop_index[] = "DROP KEY i_{$unit_name}";
2157 2157
         }
2158 2158
 
2159
-        if($unit_create) {
2159
+        if ($unit_create) {
2160 2160
           $create_index[] = "ADD KEY `I_{$unit_name}` (`id_owner`, {$unit_name} DESC)";
2161 2161
         }
2162 2162
       }
@@ -2167,7 +2167,7 @@  discard block
 block discarded – undo
2167 2167
       "ADD `user_time_utc_offset` INT(11) DEFAULT NULL COMMENT 'User time difference with server time' AFTER `user_time_diff`",
2168 2168
     ), !$update_tables['users']['user_time_utc_offset']);
2169 2169
 
2170
-    if(!$update_foreigns['alliance']['FK_alliance_owner']) {
2170
+    if (!$update_foreigns['alliance']['FK_alliance_owner']) {
2171 2171
       upd_do_query("UPDATE {{alliance}} SET ally_owner = NULL WHERE ally_owner NOT IN (SELECT id FROM {{users}})");
2172 2172
 
2173 2173
       upd_alter_table('alliance', array(
@@ -2187,7 +2187,7 @@  discard block
 block discarded – undo
2187 2187
 
2188 2188
     upd_check_key('chat_highlight_developer', '<span class="nick_developer">$1</span>', !classSupernova::$config->chat_highlight_developer);
2189 2189
 
2190
-    if(!$update_tables['player_name_history']) {
2190
+    if (!$update_tables['player_name_history']) {
2191 2191
       upd_check_key('game_user_changename_cost', 100000, !classSupernova::$config->game_user_changename_cost);
2192 2192
       upd_check_key('game_user_changename', SERVER_PLAYER_NAME_CHANGE_PAY, classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_PAY);
2193 2193
 
@@ -2213,10 +2213,10 @@  discard block
 block discarded – undo
2213 2213
 
2214 2214
     upd_alter_table('planets', array(
2215 2215
       "ADD `density` SMALLINT NOT NULL DEFAULT 5500 COMMENT 'Planet average density kg/m3'",
2216
-      "ADD `density_index` TINYINT NOT NULL DEFAULT " . PLANET_DENSITY_STANDARD . " COMMENT 'Planet cached density index'",
2216
+      "ADD `density_index` TINYINT NOT NULL DEFAULT ".PLANET_DENSITY_STANDARD." COMMENT 'Planet cached density index'",
2217 2217
     ), !$update_tables['planets']['density_index']);
2218 2218
 
2219
-    if($update_tables['users']['player_artifact_list']) {
2219
+    if ($update_tables['users']['player_artifact_list']) {
2220 2220
       upd_alter_table('unit', "DROP KEY `unit_id`", $update_indexes['unit']['unit_id']);
2221 2221
 
2222 2222
       upd_alter_table('unit', "ADD KEY `I_unit_player_location_snid` (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_snid`)", !$update_indexes['unit']['I_unit_player_location_snid']);
@@ -2226,14 +2226,14 @@  discard block
 block discarded – undo
2226 2226
       $db_changeset = array();
2227 2227
 
2228 2228
       $query = upd_do_query("SELECT `id`, `player_artifact_list` FROM {{users}} WHERE `player_artifact_list` IS NOT NULL AND `player_artifact_list` != '' FOR UPDATE");
2229
-      while($row = db_fetch($query)) {
2229
+      while ($row = db_fetch($query)) {
2230 2230
         $artifact_list = explode(';', $row['player_artifact_list']);
2231
-        if(!$row['player_artifact_list'] || empty($artifact_list)) {
2231
+        if (!$row['player_artifact_list'] || empty($artifact_list)) {
2232 2232
           continue;
2233 2233
         }
2234
-        foreach($artifact_list as $key => &$value) {
2234
+        foreach ($artifact_list as $key => &$value) {
2235 2235
           $value = explode(',', $value);
2236
-          if(!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) {
2236
+          if (!isset($value[1]) || $value[1] <= 0 || !isset($sn_data_artifacts[$value[0]])) {
2237 2237
             unset($artifact_list[$key]);
2238 2238
             continue;
2239 2239
           }
Please login to merge, or discard this patch.
includes/classes/DBRow.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
    * @param db_mysql|null $db
87 87
    */
88 88
   public static function setDb($db = null) {
89
-    if(empty($db) || !($db instanceof db_mysql)) {
89
+    if (empty($db) || !($db instanceof db_mysql)) {
90 90
       $db = null;
91 91
     }
92 92
     static::$db = !empty($db) || !class_exists('classSupernova', false) ? $db : classSupernova::$db;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
   public function dbLoad($dbId, $lockSkip = false) {
150 150
     $dbId = idval($dbId);
151 151
     if ($dbId <= 0) {
152
-      classSupernova::$debug->error(get_called_class() . '::' . __METHOD__ . ' $dbId not positive = ' . $dbId);
152
+      classSupernova::$debug->error(get_called_class().'::'.__METHOD__.' $dbId not positive = '.$dbId);
153 153
 
154 154
       return;
155 155
     }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
       $this->dbGetLockById($this->_dbId);
162 162
     }
163 163
 
164
-    $db_row = classSupernova::$db->doSelectFetch("SELECT * FROM `{{" . static::$_table . "}}` WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId . " LIMIT 1 FOR UPDATE;");
164
+    $db_row = classSupernova::$db->doSelectFetch("SELECT * FROM `{{".static::$_table."}}` WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId." LIMIT 1 FOR UPDATE;");
165 165
     if (empty($db_row)) {
166 166
       return;
167 167
     }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     if ($this->isNew()) {
194 194
       // No DB_ID - new unit
195 195
       if ($this->isEmpty()) {
196
-        classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - object is empty on ' . get_called_class() . '::dbSave');
196
+        classSupernova::$debug->error(__FILE__.':'.__LINE__.' - object is empty on '.get_called_class().'::dbSave');
197 197
       }
198 198
       $this->dbInsert();
199 199
     } else {
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
         $this->dbDelete();
203 203
       } else {
204 204
         if (!sn_db_transaction_check(false)) {
205
-          classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - transaction should always be started on ' . get_called_class() . '::dbUpdate');
205
+          classSupernova::$debug->error(__FILE__.':'.__LINE__.' - transaction should always be started on '.get_called_class().'::dbUpdate');
206 206
         }
207 207
         $this->dbUpdate();
208 208
       }
@@ -230,13 +230,13 @@  discard block
 block discarded – undo
230 230
   // TODO - protected
231 231
   public function dbInsert() {
232 232
     if (!$this->isNew()) {
233
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - record db_id is not empty on ' . get_called_class() . '::dbInsert');
233
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - record db_id is not empty on '.get_called_class().'::dbInsert');
234 234
     }
235 235
 
236 236
     $fieldSet = $this->dbMakeFieldSet(false);
237 237
 
238 238
     if (!static::$db->doInsertSet(static::$_table, $fieldSet)) {
239
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - error saving record ' . get_called_class() . '::dbInsert');
239
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - error saving record '.get_called_class().'::dbInsert');
240 240
     }
241 241
     $this->_dbId = static::$db->db_insert_id();
242 242
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
   public function dbUpdate() {
251 251
     // TODO - Update
252 252
     if ($this->isNew()) {
253
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbUpdate');
253
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbUpdate');
254 254
     }
255 255
     $this->db_field_update($this->dbMakeFieldUpdate());
256 256
   }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
   // TODO - protected
262 262
   public function dbDelete() {
263 263
     if ($this->isNew()) {
264
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbDelete');
264
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbDelete');
265 265
     }
266 266
     classSupernova::$gc->db->doDeleteRowWhere(static::$_table, array(static::$_dbIdFieldName => $this->_dbId));
267 267
     $this->_dbId = 0;
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
       }
448 448
     }
449 449
 
450
-    if(empty($set)) {
450
+    if (empty($set)) {
451 451
       $theResult = true;
452 452
     } else {
453 453
       $theResult = classSupernova::$db->doUpdateRowAdjust(
Please login to merge, or discard this patch.
includes/includes/market_trader.inc 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if((!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) && (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)) {
3
+if ((!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) && (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true)) {
4 4
   classSupernova::$debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403);
5 5
 }
6 6
 
@@ -26,11 +26,11 @@  discard block
 block discarded – undo
26 26
 
27 27
   // $dm_db_name = pname_resource_name(RES_DARK_MATTER);
28 28
   $exchangeTo = in_array($exchangeTo = sys_get_param_int('exchangeTo'), sn_get_groups('resources_trader')) ? $exchangeTo : 0;
29
-  if($exchangeTo && is_array($tradeList = $_POST['spend'])) {
29
+  if ($exchangeTo && is_array($tradeList = $_POST['spend'])) {
30 30
     $value = 0;
31 31
 
32 32
     sn_db_transaction_start();
33
-    if($planetrow['id_owner']) {
33
+    if ($planetrow['id_owner']) {
34 34
       $global_data = sys_o_get_updated($user, $planetrow, SN_TIME_NOW);
35 35
       $planetrow = $global_data['planet'];
36 36
     }
@@ -40,26 +40,26 @@  discard block
 block discarded – undo
40 40
     }
41 41
 
42 42
     $fields = array();
43
-    foreach(sn_get_groups('resources_trader') as $resource_id) {
43
+    foreach (sn_get_groups('resources_trader') as $resource_id) {
44 44
       $amount = floatval($tradeList[$resource_id]);
45
-      if($amount < 0) {
45
+      if ($amount < 0) {
46 46
         classSupernova::$debug->error('Trying to supply negative resource amount on Black Market Page', 'Hack Attempt', 305);
47 47
       }
48 48
 
49
-      if($resource_id == RES_DARK_MATTER && $exchangeTo == RES_DARK_MATTER) {
49
+      if ($resource_id == RES_DARK_MATTER && $exchangeTo == RES_DARK_MATTER) {
50 50
         continue;
51 51
       }
52 52
 
53 53
       $sign = '+';
54
-      if($exchangeTo == RES_DARK_MATTER) {
54
+      if ($exchangeTo == RES_DARK_MATTER) {
55 55
         $amount = floor($tradeList[RES_DARK_MATTER] / 3 * $rates[RES_DARK_MATTER] / $rates[$resource_id]);
56 56
         $value += $amount;
57 57
       } else {
58 58
         $value += floor($amount * $rates[$resource_id] / $rates[$exchangeTo]);
59
-        if($resource_id == RES_DARK_MATTER) {
59
+        if ($resource_id == RES_DARK_MATTER) {
60 60
           $amount = 0;
61 61
         } else {
62
-          if(mrc_get_level($user, $planetrow, $resource_id, true) < $amount) {
62
+          if (mrc_get_level($user, $planetrow, $resource_id, true) < $amount) {
63 63
             $intError = MARKET_NO_RESOURCES;
64 64
             break;
65 65
           }
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         }
69 69
       }
70 70
 
71
-      if($amount) {
71
+      if ($amount) {
72 72
         $fields[pname_resource_name($resource_id)] = "{$sign} {$amount}";
73 73
       }
74 74
     }
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
     $intError = $value <= 0 ? MARKET_ZERO_DEAL : $intError;
79 79
     $intError = mrc_get_level($user, null, RES_DARK_MATTER) < $operation_cost ? MARKET_NO_DM : $intError;
80 80
 
81
-    if($intError == MARKET_DEAL) {
82
-      if($exchangeTo != RES_DARK_MATTER) {
81
+    if ($intError == MARKET_DEAL) {
82
+      if ($exchangeTo != RES_DARK_MATTER) {
83 83
         $amountExchangeTo = floor($value);
84 84
         $fields[pname_resource_name($exchangeTo)] = $amountExchangeTo;
85 85
       }
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
     'EXCHANGE_TO_RESOURCE_ID' => $exchangeTo,
116 116
   ));
117 117
 
118
-  foreach(sn_get_groups('resources_trader') as $resource_id) {
119
-    if($resource_id == RES_DARK_MATTER) {
118
+  foreach (sn_get_groups('resources_trader') as $resource_id) {
119
+    if ($resource_id == RES_DARK_MATTER) {
120 120
       $amount = floor(mrc_get_level($user, null, RES_DARK_MATTER) - classSupernova::$config->rpg_cost_trader);
121 121
     } else {
122 122
       $amount = floor(mrc_get_level($user, $planetrow, $resource_id));
Please login to merge, or discard this patch.
includes/classes/Fleet.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -408,31 +408,31 @@  discard block
 block discarded – undo
408 408
 
409 409
     return classSupernova::$db->doSelect(
410 410
     // Блокировка самого флота
411
-      "SELECT 1 FROM {{fleets}} AS f " .
411
+      "SELECT 1 FROM {{fleets}} AS f ".
412 412
 
413 413
       // Блокировка всех юнитов, принадлежащих этому флоту
414
-      "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = " . static::$locationType . " AND unit.unit_location_id = f.fleet_id " .
414
+      "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = ".static::$locationType." AND unit.unit_location_id = f.fleet_id ".
415 415
 
416 416
       // Блокировка всех прилетающих и улетающих флотов, если нужно
417 417
       // TODO - lock fleets by COORDINATES
418
-      ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '') .
418
+      ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '').
419 419
       // Блокировка всех юнитов, принадлежащих прилетающим и улетающим флотам - ufd = unit_fleet_destination
420
-      ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = " . static::$locationType . " AND ufd.unit_location_id = fd.fleet_id " : '') .
420
+      ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = ".static::$locationType." AND ufd.unit_location_id = fd.fleet_id " : '').
421 421
 
422
-      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '') .
422
+      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '').
423 423
       // Блокировка всех юнитов, принадлежащих владельцу планеты-цели
424
-      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '') .
424
+      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '').
425 425
       // Блокировка планеты-цели
426
-      ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '') .
426
+      ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '').
427 427
       // Блокировка всех юнитов, принадлежащих планете-цели - НЕ НУЖНО. Уже залочили ранее, как принадлежащие игроку-цели
428 428
 //      ($mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS upd ON upd.unit_location_type = " . LOC_PLANET . " AND upd.unit_location_id = pd.id " : '') .
429 429
 
430 430
 
431
-      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '') .
431
+      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '').
432 432
       // Блокировка всех юнитов, принадлежащих владельцу флота
433
-      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '') .
433
+      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '').
434 434
       // Блокировка планеты отправления
435
-      ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '') .
435
+      ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '').
436 436
       // Блокировка всех юнитов, принадлежащих планете с которой юниты были отправлены - НЕ НУЖНО. Уже залочили ранее, как принадлежащие владельцу флота
437 437
 //      ($mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS ups ON ups.unit_location_type = " . LOC_PLANET . " AND ups.unit_location_id = ps.id " : '') .
438 438
 
@@ -449,11 +449,11 @@  discard block
 block discarded – undo
449 449
   public function dbGetLockById($dbId) {
450 450
     classSupernova::$db->doSelect(
451 451
     // Блокировка самого флота
452
-      "SELECT 1 FROM {{fleets}} AS FLEET0 " .
452
+      "SELECT 1 FROM {{fleets}} AS FLEET0 ".
453 453
       // Lock fleet owner
454
-      "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner " .
454
+      "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner ".
455 455
       // Блокировка всех юнитов, принадлежащих этому флоту
456
-      "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = " . LOC_FLEET . " AND UNIT0.unit_location_id = FLEET0.fleet_id " .
456
+      "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = ".LOC_FLEET." AND UNIT0.unit_location_id = FLEET0.fleet_id ".
457 457
 
458 458
       // Без предварительной выборки неизвестно - куда летит этот флот.
459 459
       // Поэтому надо выбирать флоты, чьи координаты прибытия ИЛИ отбытия совпадают с координатами прибытия ИЛИ отбытия текущего флота.
@@ -469,9 +469,9 @@  discard block
 block discarded – undo
469 469
         FLEET1.fleet_end_planet = FLEET0.fleet_end_planet
470 470
       " .
471 471
       // Блокировка всех юнитов, принадлежащих этим флотам
472
-      "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = " . LOC_FLEET . " AND UNIT1.unit_location_id = FLEET1.fleet_id " .
472
+      "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = ".LOC_FLEET." AND UNIT1.unit_location_id = FLEET1.fleet_id ".
473 473
       // Lock fleet owner
474
-      "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner " .
474
+      "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner ".
475 475
 
476 476
       "LEFT JOIN {{fleets}} AS FLEET2 ON
477 477
         FLEET2.fleet_mess = 1   AND FLEET0.fleet_mess = 0 AND
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
       " .
482 482
       // Блокировка всех юнитов, принадлежащих этим флотам
483 483
       "LEFT JOIN {{unit}} as UNIT2 ON
484
-        UNIT2.unit_location_type = " . LOC_FLEET . " AND
484
+        UNIT2.unit_location_type = " . LOC_FLEET." AND
485 485
         UNIT2.unit_location_id = FLEET2.fleet_id
486 486
       " .
487 487
       // Lock fleet owner
@@ -498,11 +498,11 @@  discard block
 block discarded – undo
498 498
       " .
499 499
       // Блокировка всех юнитов, принадлежащих этим флотам
500 500
       "LEFT JOIN {{unit}} as UNIT3 ON
501
-        UNIT3.unit_location_type = " . LOC_FLEET . " AND
501
+        UNIT3.unit_location_type = " . LOC_FLEET." AND
502 502
         UNIT3.unit_location_id = FLEET3.fleet_id
503 503
       " .
504 504
       // Lock fleet owner
505
-      "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner " .
505
+      "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner ".
506 506
 
507 507
       "LEFT JOIN {{fleets}} AS FLEET4 ON
508 508
         FLEET4.fleet_mess = 1   AND FLEET0.fleet_mess = 1 AND
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
       " .
513 513
       // Блокировка всех юнитов, принадлежащих этим флотам
514 514
       "LEFT JOIN {{unit}} as UNIT4 ON
515
-        UNIT4.unit_location_type = " . LOC_FLEET . " AND
515
+        UNIT4.unit_location_type = " . LOC_FLEET." AND
516 516
         UNIT4.unit_location_id = FLEET4.fleet_id
517 517
       " .
518 518
       // Lock fleet owner
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
       " .
535 535
       // Блокировка всех юнитов, принадлежащих этой планете
536 536
       "LEFT JOIN {{unit}} as UNIT5 ON
537
-        UNIT5.unit_location_type = " . LOC_PLANET . " AND
537
+        UNIT5.unit_location_type = " . LOC_PLANET." AND
538 538
         UNIT5.unit_location_id = PLANETS5.id
539 539
       " .
540 540
 
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
       " .
553 553
       // Блокировка всех юнитов, принадлежащих этой планете
554 554
       "LEFT JOIN {{unit}} as UNIT6 ON
555
-        UNIT6.unit_location_type = " . LOC_PLANET . " AND
555
+        UNIT6.unit_location_type = " . LOC_PLANET." AND
556 556
         UNIT6.unit_location_id = PLANETS6.id
557 557
       " .
558 558
       "WHERE FLEET0.fleet_id = {$dbId} GROUP BY 1 FOR UPDATE"
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
       } elseif ($this->isResource($unit_id)) {
672 672
         $this->resource_list[$unit_id] = $unit_count;
673 673
       } else {
674
-        throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), FLIGHT_SHIPS_UNIT_WRONG);
674
+        throw new Exception('Trying to pass to fleet non-resource and non-ship '.var_export($unit_array, true), FLIGHT_SHIPS_UNIT_WRONG);
675 675
       }
676 676
     }
677 677
   }
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
    * @param int $unit_count
806 806
    */
807 807
   public function shipSetCount($unit_id, $unit_count = 0) {
808
-    pdump(__CLASS__ . '->' . __FUNCTION__);
808
+    pdump(__CLASS__.'->'.__FUNCTION__);
809 809
     $this->shipAdjustCount($unit_id, $unit_count, true);
810 810
   }
811 811
 
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
    */
1006 1006
   public function resourcesSet($resource_list) {
1007 1007
     if (!empty($this->propertiesAdjusted['resource_list'])) {
1008
-      throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR);
1008
+      throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in '.get_called_class().'::unitSetResourceList', ERR_ERROR);
1009 1009
     }
1010 1010
     $this->resourcesAdjust($resource_list, true);
1011 1011
   }
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
       // Check for negative unit value
1040 1040
       if ($this->resource_list[$resource_id] < 0) {
1041 1041
         // TODO
1042
-        throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR);
1042
+        throw new Exception('Resource '.$resource_id.' will become negative in '.get_called_class().'::unitAdjustResourceList', ERR_ERROR);
1043 1043
       }
1044 1044
     }
1045 1045
   }
@@ -1220,7 +1220,7 @@  discard block
 block discarded – undo
1220 1220
 
1221 1221
   protected function printErrorIfNoShips() {
1222 1222
     if ($this->unitList->unitsCount() <= 0) {
1223
-      message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5);
1223
+      message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet'.DOT_PHP_EX, 5);
1224 1224
     }
1225 1225
   }
1226 1226
 
@@ -1608,14 +1608,14 @@  discard block
 block discarded – undo
1608 1608
       if (FLIGHT_ALLOWED == $validateResult[$missionType]) {
1609 1609
         $this->allowed_missions[$missionType] = $mission;
1610 1610
       } else {
1611
-        if($missionType == $this->mission_type) {
1611
+        if ($missionType == $this->mission_type) {
1612 1612
         }
1613 1613
         unset($this->allowed_missions[$missionType]);
1614 1614
       }
1615 1615
     }
1616 1616
 
1617
-    if(empty($this->allowed_missions)) {
1618
-      if($this->mission_type != MT_NONE && isset($validateResult[$this->mission_type])) {
1617
+    if (empty($this->allowed_missions)) {
1618
+      if ($this->mission_type != MT_NONE && isset($validateResult[$this->mission_type])) {
1619 1619
         throw new ExceptionFleetInvalid($validateResult[$this->mission_type], $validateResult[$this->mission_type]);
1620 1620
       } else {
1621 1621
         throw new ExceptionFleetInvalid(FLIGHT_MISSION_IMPOSSIBLE, FLIGHT_MISSION_IMPOSSIBLE);
@@ -1844,7 +1844,7 @@  discard block
 block discarded – undo
1844 1844
     $template_result['.']['fleets'][] = $this->renderFleet(SN_TIME_NOW, $timeMissionJob);
1845 1845
 
1846 1846
     $template_result += array(
1847
-      'mission'         => classLocale::$lang['type_mission'][$this->_mission_type] . ($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' ' . pretty_time($timeMissionJob) : ''),
1847
+      'mission'         => classLocale::$lang['type_mission'][$this->_mission_type].($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' '.pretty_time($timeMissionJob) : ''),
1848 1848
       'dist'            => pretty_number($this->travelData['distance']),
1849 1849
       'speed'           => pretty_number($this->travelData['fleet_speed']),
1850 1850
       'deute_need'      => pretty_number($this->travelData['consumption']),
Please login to merge, or discard this patch.
includes/db.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -42,15 +42,15 @@  discard block
 block discarded – undo
42 42
 
43 43
   $group = sn_get_groups('resources_loot');
44 44
 
45
-  foreach($unit_list as $unit_id => $unit_amount) {
46
-    if(!in_array($unit_id, $group)) {
45
+  foreach ($unit_list as $unit_id => $unit_amount) {
46
+    if (!in_array($unit_id, $group)) {
47 47
       // TODO - remove later
48 48
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: db_change_units() вызван для не-ресурсов!</h1>');
49 49
       pdump(debug_backtrace());
50 50
       die('db_change_units() вызван для не-ресурсов!');
51 51
     }
52 52
 
53
-    if(empty($unit_amount)) {
53
+    if (empty($unit_amount)) {
54 54
       continue;
55 55
     }
56 56
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     $unit_location = sys_get_unit_location($user, $planet, $unit_id);
60 60
 
61 61
     // Changing value in object
62
-    switch($unit_location) {
62
+    switch ($unit_location) {
63 63
       case LOC_USER:
64 64
         $user[$unit_db_name] += $unit_amount;
65 65
         break;
@@ -77,30 +77,30 @@  discard block
 block discarded – undo
77 77
 function sn_db_perform($table, $values, $type = 'insert', $options = false) {
78 78
   $field_set = '';
79 79
 
80
-  switch($type) {
80
+  switch ($type) {
81 81
     case 'delete':
82 82
       $query = 'DELETE FROM';
83 83
       break;
84 84
 
85 85
     case 'insert':
86 86
       $query = 'INSERT INTO';
87
-      if(isset($options['__multi'])) {
87
+      if (isset($options['__multi'])) {
88 88
         // Here we generate mass-insert set
89 89
         break;
90 90
       }
91 91
     case 'update':
92
-      if(!$query) {
92
+      if (!$query) {
93 93
         $query = 'UPDATE';
94 94
       }
95 95
 
96
-      foreach($values as $field => &$value) {
96
+      foreach ($values as $field => &$value) {
97 97
         $value_type = gettype($value);
98 98
         if ($value_type == TYPE_STRING) {
99
-          $value = "'" . db_escape($value) . "'";
99
+          $value = "'".db_escape($value)."'";
100 100
         }
101 101
         $value = "`{$field}` = {$value}";
102 102
       }
103
-      $field_set = 'SET ' . implode(', ', $values);
103
+      $field_set = 'SET '.implode(', ', $values);
104 104
       break;
105 105
 
106 106
   };
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
   $field_set['__IS_SAFE'] = true;
122 122
 }
123 123
 function sn_db_field_set_make_safe($field_set, $serialize = false) {
124
-  if(!is_array($field_set)) {
124
+  if (!is_array($field_set)) {
125 125
     die('$field_set is not an array!');
126 126
   }
127 127
 
128 128
   $result = array();
129
-  foreach($field_set as $field => $value) {
129
+  foreach ($field_set as $field => $value) {
130 130
     $field = db_escape(trim($field));
131 131
     switch (true) {
132 132
       case is_int($value):
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
         $serialize ? $value = serialize($value) : die('$value is object or array with no $serialize');
143 143
 
144 144
       case is_string($value):
145
-        $value = '"' . db_escape($value) . '"';
145
+        $value = '"'.db_escape($value).'"';
146 146
         break;
147 147
 
148 148
       case is_null($value):
Please login to merge, or discard this patch.