Completed
Push — work-fleets ( ab257a...4117d7 )
by SuperNova.WS
05:11
created
includes/classes/sn_module_payment.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
   public function compile_request($request) {
451 451
     global $config, $user;
452 452
 
453
-    if(!(classSupernova::$auth->account instanceof Account)) {
453
+    if (!(classSupernova::$auth->account instanceof Account)) {
454 454
       // TODO - throw new Exception($lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT);
455 455
     }
456 456
     $this->account = classSupernova::$auth->account;
@@ -471,15 +471,15 @@  discard block
 block discarded – undo
471 471
     $this->payment_currency = $config->payment_currency_default;
472 472
     $this->payment_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_currency);
473 473
 
474
-    if(empty($this->payment_external_currency) && !empty($this->config['currency'])) {
474
+    if (empty($this->payment_external_currency) && !empty($this->config['currency'])) {
475 475
       $this->payment_external_currency = $this->config['currency'];
476 476
     }
477
-    if(empty($this->payment_external_currency)) {
477
+    if (empty($this->payment_external_currency)) {
478 478
       throw new Exception(classLocale::$lang['pay_error_internal_no_external_currency_set'], SN_PAYMENT_ERROR_INTERNAL_NO_EXTERNAL_CURRENCY_SET);
479 479
     }
480 480
 
481 481
     $this->payment_external_amount = self::currency_convert($this->payment_dark_matter_paid, 'MM_', $this->payment_external_currency);
482
-    if($this->payment_external_amount < 0.01) {
482
+    if ($this->payment_external_amount < 0.01) {
483 483
       throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'], SN_PAYMENT_REQUEST_ERROR_UNIT_AMOUNT);
484 484
     }
485 485
 
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
     $this->generate_description();
489 489
 
490 490
     $this->db_insert();
491
-    if(!$this->is_exists) {
491
+    if (!$this->is_exists) {
492 492
       throw new Exception(classLocale::$lang['pay_msg_request_error_db_payment_create'], SN_PAYMENT_REQUEST_DB_ERROR_PAYMENT_CREATE);
493 493
     }
494 494
   }
@@ -503,24 +503,24 @@  discard block
 block discarded – undo
503 503
   protected function payment_request_process($options = array()) {
504 504
     global $lang, $config;
505 505
 
506
-    if(!$this->manifest['active']) {
506
+    if (!$this->manifest['active']) {
507 507
       throw new Exception(classLocale::$lang['pay_msg_module_disabled'], SN_MODULE_DISABLED);
508 508
     }
509 509
 
510 510
     // Если есть payment_id - загружаем под него данные
511
-    if(!empty($this->payment_params['payment_id'])) {
511
+    if (!empty($this->payment_params['payment_id'])) {
512 512
       $this->request_payment_id = sys_get_param_id($this->payment_params['payment_id']);
513
-      if(!$this->request_payment_id) {
513
+      if (!$this->request_payment_id) {
514 514
         throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG);
515 515
       }
516 516
 
517
-      if(!$this->db_get_by_id($this->request_payment_id)) {
517
+      if (!$this->db_get_by_id($this->request_payment_id)) {
518 518
         throw new Exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_INTERNAL_ID_WRONG);
519 519
       }
520 520
 
521 521
       // Проверяем - был ли этот платеж обработан?
522 522
       // TODO - Статусы бывают разные. Нужен спецфлаг payment_processed
523
-      if($this->payment_status != PAYMENT_STATUS_NONE) {
523
+      if ($this->payment_status != PAYMENT_STATUS_NONE) {
524 524
         sn_db_transaction_rollback();
525 525
         sys_redirect(SN_ROOT_VIRTUAL . 'metamatter.php?payment_id=' . $this->payment_id);
526 526
         die();
@@ -530,89 +530,89 @@  discard block
 block discarded – undo
530 530
     // Пытаемся получить из запроса ИД аккаунта
531 531
     $request_account_id = !empty($this->payment_params['account_id']) ? sys_get_param_id($this->payment_params['account_id']) : 0;
532 532
     // Если в запросе нет ИД аккаунта - пытаемся использовать payment_account_id
533
-    if(empty($request_account_id) && !empty($this->payment_account_id)) {
533
+    if (empty($request_account_id) && !empty($this->payment_account_id)) {
534 534
       $request_account_id = $this->payment_account_id;
535 535
     }
536 536
     // Если теперь у нас нету ИД аккаунта ни в запросе, ни в записи таблицы - можно паниковать
537
-    if(empty($request_account_id)) {
537
+    if (empty($request_account_id)) {
538 538
       // TODO - аккаунт
539 539
       throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
540 540
     }
541 541
     // Если нет записи в таблице - тогда берем payment_account_id из запроса
542
-    if(empty($this->payment_account_id)) {
542
+    if (empty($this->payment_account_id)) {
543 543
       $this->payment_account_id = $request_account_id;
544 544
     }
545 545
     // Если у нас отличаются ИД аккаунта в запросе и ИД аккаунта в записи - тоже можно паниковать
546
-    if($this->payment_account_id != $request_account_id) {
546
+    if ($this->payment_account_id != $request_account_id) {
547 547
       // TODO - Поменять сообщение об ошибке
548 548
       throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'], $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
549 549
     }
550 550
     // Проверяем существование аккаунта с данным ИД
551
-    if(!$this->account->db_get_by_id($this->payment_account_id)) {
551
+    if (!$this->account->db_get_by_id($this->payment_account_id)) {
552 552
       throw new Exception(classLocale::$lang['pay_msg_request_user_invalid'] . ' ID ' . $this->payment_account_id, $this->retranslate_error(SN_PAYMENT_REQUEST_USER_NOT_FOUND, $options));
553 553
     }
554 554
 
555 555
     // TODO Проверка на сервер_ид - как бы и не нужна, наверное?
556
-    if(!empty($this->payment_params['server_id'])) {
556
+    if (!empty($this->payment_params['server_id'])) {
557 557
       $this->request_server_id = sys_get_param_str($this->payment_params['server_id']);
558
-      if(SN_ROOT_VIRTUAL != $this->request_server_id) {
558
+      if (SN_ROOT_VIRTUAL != $this->request_server_id) {
559 559
         throw new Exception(classLocale::$lang['pay_msg_request_server_wrong'] . " {$this->request_server_id} вместо " . SN_ROOT_VIRTUAL, SN_PAYMENT_REQUEST_SERVER_WRONG);
560 560
       }
561 561
     }
562 562
 
563 563
     // Сверка количества оплаченной ММ с учётом бонусов
564
-    if(!empty($this->payment_params['payment_dark_matter_gained'])) {
564
+    if (!empty($this->payment_params['payment_dark_matter_gained'])) {
565 565
       $request_mm_amount = sys_get_param_id($this->payment_params['payment_dark_matter_gained']);
566
-      if($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) {
566
+      if ($request_mm_amount != $this->payment_dark_matter_gained && $this->is_loaded) {
567 567
         throw new Exception(classLocale::$lang['pay_msg_mm_request_amount_invalid'] . " пришло {$request_mm_amount} ММ вместо {$this->payment_dark_matter_gained} ММ", SN_PAYMENT_REQUEST_MM_AMOUNT_INVALID);
568 568
       }
569 569
       empty($this->payment_dark_matter_gained) ? $this->payment_dark_matter_gained = $request_mm_amount : false;
570 570
     }
571
-    if(empty($this->payment_dark_matter_paid)) {
571
+    if (empty($this->payment_dark_matter_paid)) {
572 572
       // TODO - обратный расчёт из gained
573 573
     }
574 574
 
575 575
     // Проверка наличия внешнего ИД платежа
576
-    if(!empty($this->payment_params['payment_external_id'])) {
576
+    if (!empty($this->payment_params['payment_external_id'])) {
577 577
       $request_payment_external_id = sys_get_param_id($this->payment_params['payment_external_id']);
578
-      if(empty($request_payment_external_id)) {
578
+      if (empty($request_payment_external_id)) {
579 579
         throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG);
580
-      } elseif(!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) {
580
+      } elseif (!empty($this->payment_external_id) && $this->payment_external_id != $request_payment_external_id) {
581 581
         // TODO - Может быть поменять сообщение
582 582
         throw new exception(classLocale::$lang['pay_msg_request_payment_id_invalid'], SN_PAYMENT_REQUEST_EXTERNAL_ID_WRONG);
583 583
       }
584 584
       $this->payment_external_id = $request_payment_external_id;
585 585
     }
586 586
     // Сверка суммы, запрошенной СН к оплате
587
-    if(!empty($this->payment_params['payment_external_money'])) {
587
+    if (!empty($this->payment_params['payment_external_money'])) {
588 588
       $request_money_out = sys_get_param_float($this->payment_params['payment_external_money']);
589
-      if($request_money_out != $this->payment_external_amount && $this->is_loaded) {
589
+      if ($request_money_out != $this->payment_external_amount && $this->is_loaded) {
590 590
         throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " пришло {$request_money_out} денег вместо {$this->payment_external_amount} денег", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID);
591 591
       }
592 592
       empty($this->payment_external_amount) ? $this->payment_external_amount = $request_money_out : false;
593 593
     }
594 594
     // Заполняем поле валюты платёжной системы
595
-    if(!empty($this->payment_params['payment_external_currency'])) {
595
+    if (!empty($this->payment_params['payment_external_currency'])) {
596 596
       $this->payment_external_currency = sys_get_param_str($this->payment_params['payment_external_currency']);
597
-      if(empty($this->payment_external_currency)) {
597
+      if (empty($this->payment_external_currency)) {
598 598
         // TODO - поменять сообщение
599 599
         throw new Exception(classLocale::$lang['pay_msg_request_payment_amount_invalid'] . " {$this->payment_external_currency}", SN_PAYMENT_REQUEST_CURRENCY_AMOUNT_INVALID);
600 600
       }
601 601
     }
602
-    if(empty($this->payment_external_currency)) {
602
+    if (empty($this->payment_external_currency)) {
603 603
       $this->payment_external_currency = $this->config['currency'];
604 604
     }
605 605
 
606 606
     // Заполнение внутренней суммы и валюты из внешних данных
607
-    if(empty($this->payment_currency)) {
607
+    if (empty($this->payment_currency)) {
608 608
       $this->payment_currency = $config->payment_currency_default;
609 609
     }
610
-    if(empty($this->payment_amount) && !empty($this->payment_external_currency)) {
610
+    if (empty($this->payment_amount) && !empty($this->payment_external_currency)) {
611 611
       $this->payment_amount = self::currency_convert($this->payment_external_amount, $this->payment_external_currency, $this->payment_currency);
612 612
     }
613 613
 
614 614
     // TODO - Тестовый режим
615
-    if(!empty($this->payment_params['test'])) {
615
+    if (!empty($this->payment_params['test'])) {
616 616
       $this->payment_test = $this->config['test'] || sys_get_param_int($this->payment_params['test']);
617 617
     }
618 618
 
@@ -641,12 +641,12 @@  discard block
 block discarded – undo
641 641
     sn_db_transaction_start();
642 642
     try {
643 643
       $response = $this->payment_request_process();
644
-    } catch(Exception $e) {
644
+    } catch (Exception $e) {
645 645
       $response['result'] = $e->getCode();
646 646
       $response['message'] = $e->getMessage();
647 647
     }
648 648
 
649
-    if($response['result'] == SN_PAYMENT_REQUEST_OK) {
649
+    if ($response['result'] == SN_PAYMENT_REQUEST_OK) {
650 650
       sn_db_transaction_commit();
651 651
       $debug->warning('Результат операции: код ' . $response['result'] . ' сообщение "' . $response['message'] . '"', 'Успешный платёж', LOG_INFO_PAYMENT);
652 652
     } else {
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
     }
656 656
 
657 657
     // Переводим код результата из СН в код платежной системы
658
-    if(is_array($this->result_translations) && !empty($this->result_translations)) {
658
+    if (is_array($this->result_translations) && !empty($this->result_translations)) {
659 659
       $response['result'] = isset($this->result_translations[$response['result']]) ? $this->result_translations[$response['result']] : $this->result_translations[SN_PAYMENT_REQUEST_UNDEFINED_ERROR];
660 660
     }
661 661
 
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
     $currency_from = strtolower($currency_from);
681 681
     $currency_to = strtolower($currency_to);
682 682
 
683
-    if($currency_from != $currency_to) {
683
+    if ($currency_from != $currency_to) {
684 684
 //      $config_currency_from_name = 'payment_currency_exchange_' . $currency_from;
685 685
 //      $config_currency_to_name = 'payment_currency_exchange_' . $currency_to;
686 686
 
@@ -710,10 +710,10 @@  discard block
 block discarded – undo
710 710
   public static function bonus_calculate($dark_matter, $direct = true, $return_bonus = false) {
711 711
     $bonus = 0;
712 712
     $dark_matter_new = $dark_matter;
713
-    if(!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) {
714
-      if($direct) {
715
-        foreach(self::$bonus_table as $dm_for_bonus => $multiplier) {
716
-          if($dm_for_bonus <= $dark_matter) {
713
+    if (!empty(self::$bonus_table) && $dark_matter >= self::$bonus_table[0]) {
714
+      if ($direct) {
715
+        foreach (self::$bonus_table as $dm_for_bonus => $multiplier) {
716
+          if ($dm_for_bonus <= $dark_matter) {
717 717
             $dark_matter_new = $dark_matter * (1 + $multiplier);
718 718
             $bonus = $multiplier;
719 719
           } else {
@@ -721,9 +721,9 @@  discard block
 block discarded – undo
721 721
           }
722 722
         }
723 723
       } else {
724
-        foreach(self::$bonus_table as $dm_for_bonus => $multiplier) {
724
+        foreach (self::$bonus_table as $dm_for_bonus => $multiplier) {
725 725
           $temp = $dm_for_bonus * (1 + $multiplier);
726
-          if($dark_matter >= $temp) {
726
+          if ($dark_matter >= $temp) {
727 727
             $dark_matter_new = round($dark_matter / (1 + $multiplier));
728 728
             $bonus = $multiplier;
729 729
           } else {
@@ -779,13 +779,13 @@  discard block
 block discarded – undo
779 779
     );
780 780
 
781 781
     $replace = false;
782
-    if($this->payment_id) {
782
+    if ($this->payment_id) {
783 783
       $payment['payment_id'] = $this->payment_id;
784 784
       $replace = true;
785 785
     }
786 786
 
787 787
     $query = array();
788
-    foreach($payment as $key => $value) {
788
+    foreach ($payment as $key => $value) {
789 789
       $value = is_string($value) ? '"' . db_escape($value) . '"' : $value;
790 790
       $query[] = "`{$key}` = {$value}";
791 791
     }
@@ -797,12 +797,12 @@  discard block
 block discarded – undo
797 797
 
798 798
 
799 799
   function payment_adjust_mm_new() {
800
-    if(!$this->payment_test) {
800
+    if (!$this->payment_test) {
801 801
       // Not a test payment. Adding DM to account
802 802
       $this->account = new Account($this->db);
803 803
       $this->account->db_get_by_id($this->payment_account_id);
804 804
       $result = $this->account->metamatter_change(RPG_PURCHASE, $this->payment_dark_matter_gained, $this->payment_comment);
805
-      if(!$result) {
805
+      if (!$result) {
806 806
         throw new Exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST);
807 807
       }
808 808
     }
@@ -812,25 +812,25 @@  discard block
 block discarded – undo
812 812
     die('{НЕ РАБОТАЕТ! СООБЩИТЕ АДМИНИСТРАЦИИ!}');
813 813
     global $lang;
814 814
 
815
-    if(!isset($payment['payment_status'])) {
815
+    if (!isset($payment['payment_status'])) {
816 816
       throw new exception(classLocale::$lang['pay_msg_request_payment_not_found'], SN_PAYMENT_REQUEST_ORDER_NOT_FOUND);
817 817
     }
818 818
 
819
-    if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
820
-      $safe_comment = db_escape($payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] .' ' . $payment['payment_comment']);
819
+    if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
820
+      $safe_comment = db_escape($payment['payment_comment'] = classLocale::$lang['pay_msg_request_payment_cancelled'] . ' ' . $payment['payment_comment']);
821 821
 
822
-      if(!$payment['payment_test']) {
822
+      if (!$payment['payment_test']) {
823 823
         $result = $this->account->metamatter_change(RPG_PURCHASE_CANCEL, -$payment['payment_dark_matter_gained'], $payment['payment_comment']);
824
-        if(!$result) {
824
+        if (!$result) {
825 825
           throw new exception('Ошибка начисления ММ', SN_METAMATTER_ERROR_ADJUST);
826 826
         }
827 827
       }
828 828
       $payment['payment_status'] = PAYMENT_STATUS_CANCELED;
829 829
       db_payment_update($payment, $safe_comment);
830 830
       throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_complete'], SN_PAYMENT_REQUEST_OK);
831
-    } elseif($payment['payment_status'] == PAYMENT_STATUS_CANCELED) {
831
+    } elseif ($payment['payment_status'] == PAYMENT_STATUS_CANCELED) {
832 832
       throw new exception(classLocale::$lang['pay_msg_request_payment_cancelled_already'], SN_PAYMENT_REQUEST_OK);
833
-    } elseif($payment['payment_status'] == PAYMENT_STATUS_NONE) {
833
+    } elseif ($payment['payment_status'] == PAYMENT_STATUS_NONE) {
834 834
       throw new exception(classLocale::$lang['pay_msg_request_payment_cancel_not_complete'], SN_PAYMENT_REQUEST_PAYMENT_NOT_COMPLETE);
835 835
     }
836 836
   }
@@ -844,8 +844,8 @@  discard block
 block discarded – undo
844 844
 
845 845
   protected function db_complete_payment() {
846 846
     // TODO - поле payment_processed
847
-    if($this->payment_status == PAYMENT_STATUS_NONE) {
848
-      if(!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) {
847
+    if ($this->payment_status == PAYMENT_STATUS_NONE) {
848
+      if (!defined('PAYMENT_EXPIRE_TIME') || PAYMENT_EXPIRE_TIME == 0 || empty($this->payment_date) || strtotime($this->payment_date) + PAYMENT_EXPIRE_TIME <= SN_TIME_NOW) {
849 849
         $this->payment_adjust_mm_new();
850 850
         $this->payment_status = PAYMENT_STATUS_COMPLETE;
851 851
       } else {
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
   protected function db_assign_payment($payment = null) {
893 893
     $this->payment_reset();
894 894
 
895
-    if(is_array($payment) && isset($payment['payment_id'])) {
895
+    if (is_array($payment) && isset($payment['payment_id'])) {
896 896
       $this->payment_id = $payment['payment_id'];
897 897
       $this->payment_status = $payment['payment_status'];
898 898
       $this->payment_date = $payment['payment_date'];
Please login to merge, or discard this patch.
admin/adm_planet_list.php 1 patch
Spacing   +5 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-define('INSIDE'  , true);
4
-define('INSTALL' , false);
3
+define('INSIDE', true);
4
+define('INSTALL', false);
5 5
 define('IN_ADMIN', true);
6 6
 
7 7
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
@@ -9,12 +9,12 @@  discard block
 block discarded – undo
9 9
 global $config, $lang, $user;
10 10
 
11 11
 // if($user['authlevel'] < 1)
12
-if($user['authlevel'] < 3) {
12
+if ($user['authlevel'] < 3) {
13 13
   AdminMessage(classLocale::$lang['adm_err_denied']);
14 14
 }
15 15
 
16 16
 $planet_active = sys_get_param_int('planet_active');
17
-if(!$planet_active) {
17
+if (!$planet_active) {
18 18
   $planet_type = sys_get_param_int('planet_type', 1);
19 19
   $planet_type = $planet_type == 3 ? 3 : 1;
20 20
 } else {
@@ -43,8 +43,7 @@  discard block
 block discarded – undo
43 43
 
44 44
 $page_title =
45 45
   classLocale::$lang['adm_planet_list_title'] . ': ' .
46
-  ($planet_active ? classLocale::$lang['adm_planet_active'] :
47
-    ($planet_type ? ($planet_type == 3 ? classLocale::$lang['sys_moons'] : classLocale::$lang['sys_planets']) : '')
46
+  ($planet_active ? classLocale::$lang['adm_planet_active'] : ($planet_type ? ($planet_type == 3 ? classLocale::$lang['sys_moons'] : classLocale::$lang['sys_planets']) : '')
48 47
   );
49 48
 $template->assign_vars(array(
50 49
   'PAGE_TITLE' => $page_title,
Please login to merge, or discard this patch.
notes.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -15,34 +15,34 @@  discard block
 block discarded – undo
15 15
 $template = gettemplate('notes', true);
16 16
 
17 17
 $result = array();
18
-if(($result_message = sys_get_param_str('MESSAGE')) && isset(classLocale::$lang[$result_message])) {
18
+if (($result_message = sys_get_param_str('MESSAGE')) && isset(classLocale::$lang[$result_message])) {
19 19
   $result[] = array('STATUS' => sys_get_param_int('STATUS'), 'MESSAGE' => classLocale::$lang[$result_message]);
20 20
 }
21 21
 
22 22
 $note_id_edit = sys_get_param_id('note_id_edit');
23
-if(sys_get_param('note_delete')) {
23
+if (sys_get_param('note_delete')) {
24 24
   try {
25 25
     $not = '';
26 26
     $query_where = '';
27
-    switch(sys_get_param_str('note_delete_range')) {
27
+    switch (sys_get_param_str('note_delete_range')) {
28 28
       case 'all':
29 29
       break;
30 30
 
31 31
       case 'marked_not':
32 32
         $not = 'NOT';
33 33
       case 'marked':
34
-        if(!is_array($notes_marked = sys_get_param('note'))) {
34
+        if (!is_array($notes_marked = sys_get_param('note'))) {
35 35
           throw new Exception('note_err_none_selected', ERR_WARNING);
36 36
         }
37 37
 
38 38
         $notes_marked_filtered = array();
39
-        foreach($notes_marked as $note_id => $note_select) {
40
-          if($note_select == 'on' && $note_id = idval($note_id)) {
39
+        foreach ($notes_marked as $note_id => $note_select) {
40
+          if ($note_select == 'on' && $note_id = idval($note_id)) {
41 41
             $notes_marked_filtered[] = $note_id;
42 42
           }
43 43
         }
44 44
 
45
-        if(empty($notes_marked_filtered)) {
45
+        if (empty($notes_marked_filtered)) {
46 46
           throw new Exception('note_err_none_selected', ERR_WARNING);
47 47
         }
48 48
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     db_note_list_delete($user, $query_where);
60 60
     sn_db_transaction_commit();
61 61
     throw new Exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE);
62
-  } catch(Exception $e) {
62
+  } catch (Exception $e) {
63 63
     $note_id_edit = 0;
64 64
     sn_db_transaction_rollback();
65 65
     $result[] = array(
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
       'MESSAGE' => classLocale::$lang[$e->getMessage()],
68 68
     );
69 69
   }
70
-} elseif(($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) {
70
+} elseif (($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) {
71 71
   $note_title == db_escape(classLocale::$lang['note_new_title']) ? $note_title = '' : false;
72 72
   ($note_text = sys_get_param_str('note_text')) == db_escape(classLocale::$lang['note_new_text']) ? $note_text = '' : false;
73 73
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     $note_system = max(0, min(sys_get_param_id('note_system'), $config->game_maxSystem));
77 77
     $note_planet = max(0, min(sys_get_param_id('note_planet'), $config->game_maxPlanet + 1));
78 78
 
79
-    if(!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) {
79
+    if (!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) {
80 80
       throw new exception('note_err_note_empty', ERR_WARNING);
81 81
     }
82 82
 
@@ -85,15 +85,15 @@  discard block
 block discarded – undo
85 85
     $note_sticky = intval(sys_get_param_id('note_sticky')) ? 1 : 0;
86 86
 
87 87
     sn_db_transaction_start();
88
-    if($note_id_edit) {
88
+    if ($note_id_edit) {
89 89
       $check_note_id = db_note_get_id_and_owner($note_id_edit);
90
-      if(!$check_note_id) {
90
+      if (!$check_note_id) {
91 91
         throw new Exception('note_err_note_not_found', ERR_ERROR);
92 92
       }
93 93
     }
94 94
 
95
-    if($note_id_edit) {
96
-      if($check_note_id['owner'] != $user['id']) {
95
+    if ($note_id_edit) {
96
+      if ($check_note_id['owner'] != $user['id']) {
97 97
         throw new Exception('note_err_owner_wrong', ERR_ERROR);
98 98
       }
99 99
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     sn_db_transaction_commit();
106 106
     sys_redirect('notes.php?STATUS=' . ERR_NONE . '&MESSAGE=' . ($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added'));
107 107
 //    throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE);
108
-  } catch(Exception $e) {
108
+  } catch (Exception $e) {
109 109
     $note_id_edit = 0;
110 110
     sn_db_transaction_rollback();
111 111
     $result[] = array(
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
   }
116 116
 }
117 117
 
118
-if(!$note_id_edit) {
118
+if (!$note_id_edit) {
119 119
   note_assign($template, array(
120 120
     'id'          => 0,
121 121
     'time'        => SN_TIME_NOW,
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
 
129 129
 $note_exist = false;
130 130
 $notes_query = db_note_list_by_owner($user['id']);
131
-while($note_row = db_fetch($notes_query)) {
131
+while ($note_row = db_fetch($notes_query)) {
132 132
   note_assign($template, $note_row);
133 133
   $note_exist = $note_exist || $note_row['id'] == $note_id_edit;
134 134
 }
135 135
 $note_id_edit = $note_exist ? $note_id_edit : 0;
136 136
 
137
-foreach($note_priority_classes as $note_priority_id => $note_priority_class) {
137
+foreach ($note_priority_classes as $note_priority_id => $note_priority_class) {
138 138
   $template->assign_block_vars('note_priority', array(
139 139
     'ID'    => $note_priority_id,
140 140
     'CLASS' => $note_priority_classes[$note_priority_id],
@@ -142,14 +142,14 @@  discard block
 block discarded – undo
142 142
   ));
143 143
 }
144 144
 
145
-foreach(classLocale::$lang['sys_planet_type'] as $planet_type_id => $planet_type_string) {
145
+foreach (classLocale::$lang['sys_planet_type'] as $planet_type_id => $planet_type_string) {
146 146
   $template->assign_block_vars('planet_type', array(
147 147
     'ID'   => $planet_type_id,
148 148
     'TEXT' => $planet_type_string,
149 149
   ));
150 150
 }
151 151
 
152
-foreach($result as $result_data) {
152
+foreach ($result as $result_data) {
153 153
   $template->assign_block_vars('result', $result_data);
154 154
 }
155 155
 
Please login to merge, or discard this patch.
metamatter.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 
9 9
 include_once('common.' . substr(strrchr(__FILE__, '.'), 1));
10 10
 
11
-if(!sn_module_get_active_count('payment')) {
11
+if (!sn_module_get_active_count('payment')) {
12 12
   sys_redirect('dark_matter.php');
13 13
   die();
14 14
 }
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
 
66 66
 // Таблица скидок
67 67
 $prev_discount = 0;
68
-if(isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) {
69
-  foreach(sn_module_payment::$bonus_table as $sum => $discount) {
70
-    if($discount && $discount != $prev_discount) {
68
+if (isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) {
69
+  foreach (sn_module_payment::$bonus_table as $sum => $discount) {
70
+    if ($discount && $discount != $prev_discount) {
71 71
       $template->assign_block_vars('discount', array(
72 72
         'SUM'          => $sum,
73 73
         'DISCOUNT'     => $discount * 100,
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
 }
81 81
 
82 82
 // Результат платежа
83
-if($payment_id = sys_get_param_id('payment_id')) {
83
+if ($payment_id = sys_get_param_id('payment_id')) {
84 84
   $payment = db_payment_get($payment_id);
85
-  if($payment && $payment['payment_user_id'] == $user['id']) {
86
-    if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
85
+  if ($payment && $payment['payment_user_id'] == $user['id']) {
86
+    if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
87 87
       $template->assign_block_vars('result', array('MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_complete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name'], $payment['payment_dark_matter_gained'])));
88 88
     }
89
-    if($payment['payment_status'] == PAYMENT_STATUS_NONE) {
89
+    if ($payment['payment_status'] == PAYMENT_STATUS_NONE) {
90 90
       $template->assign_block_vars('result', array(
91 91
         'MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_incomplete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name']),
92 92
         'STATUS'  => 1,
93 93
       ));
94 94
     }
95
-    if($payment['payment_test']) {
95
+    if ($payment['payment_test']) {
96 96
       $template->assign_block_vars('result', array(
97 97
         'MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_test']),
98 98
         'STATUS'  => -1,
@@ -107,28 +107,28 @@  discard block
 block discarded – undo
107 107
   'metamatter' => sys_get_param_float('metamatter'),
108 108
 );
109 109
 
110
-if(!$request['metamatter']) {
110
+if (!$request['metamatter']) {
111 111
   unset($_POST);
112 112
 }
113 113
 
114 114
 $payment_methods_available = array_combine(array_keys(sn_module_payment::$payment_methods), array_fill(0, count(sn_module_payment::$payment_methods), null));
115
-array_walk($payment_methods_available, function (&$value, $index) {
115
+array_walk($payment_methods_available, function(&$value, $index) {
116 116
   $value = !empty(sn_module_payment::$payment_methods[$index]) ? array_combine(array_keys(sn_module_payment::$payment_methods[$index]), array_fill(0, count(sn_module_payment::$payment_methods[$index]), null)) : $value;
117 117
 });
118 118
 
119 119
 // pdump($payment_methods_available);
120 120
 $payment_module_valid = false;
121 121
 $payment_module = sys_get_param_str('payment_module');
122
-foreach(sn_module::$sn_module_list['payment'] as $module_name => $module) {
123
-  if(!is_object($module) || !$module->manifest['active']) {
122
+foreach (sn_module::$sn_module_list['payment'] as $module_name => $module) {
123
+  if (!is_object($module) || !$module->manifest['active']) {
124 124
     continue;
125 125
   }
126 126
 
127 127
   lng_include($module_name, $module->manifest['root_relative']);
128 128
 
129
-  foreach(sn_module_payment::$payment_methods as $payment_type_id => $available_methods) {
130
-    foreach($available_methods as $payment_method => $payment_currency) {
131
-      if(isset($module->manifest['payment_method'][$payment_method])) {
129
+  foreach (sn_module_payment::$payment_methods as $payment_type_id => $available_methods) {
130
+    foreach ($available_methods as $payment_method => $payment_currency) {
131
+      if (isset($module->manifest['payment_method'][$payment_method])) {
132 132
         $payment_methods_available[$payment_type_id][$payment_method][$module_name] = $module->manifest['payment_method'][$payment_method];
133 133
       }
134 134
     }
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 
140 140
 global $template_result;
141 141
 // Доступные платежные методы
142
-foreach($payment_methods_available as $payment_type_id => $payment_methods) {
143
-  if(empty($payment_methods)) {
142
+foreach ($payment_methods_available as $payment_type_id => $payment_methods) {
143
+  if (empty($payment_methods)) {
144 144
     continue;
145 145
   }
146 146
 
@@ -148,8 +148,8 @@  discard block
 block discarded – undo
148 148
     'ID'   => $payment_type_id,
149 149
     'NAME' => classLocale::$lang['pay_methods'][$payment_type_id],
150 150
   );
151
-  foreach($payment_methods as $payment_method_id => $module_list) {
152
-    if(empty($module_list)) {
151
+  foreach ($payment_methods as $payment_method_id => $module_list) {
152
+    if (empty($module_list)) {
153 153
       continue;
154 154
     }
155 155
     $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id] = array(
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
       'NAME_FORCE' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['name']),
161 161
       'BUTTON'     => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['button']),
162 162
     );
163
-    foreach($module_list as $payment_module_name => $payment_module_method_details) {
163
+    foreach ($module_list as $payment_module_name => $payment_module_method_details) {
164 164
       $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id]['.']['module'][] = array(
165 165
         'MODULE' => $payment_module_name,
166 166
       );
167 167
     }
168 168
   }
169 169
 
170
-  if(empty($template_result['.']['payment'][$payment_type_id]['.'])) {
170
+  if (empty($template_result['.']['payment'][$payment_type_id]['.'])) {
171 171
     unset($template_result['.']['payment'][$payment_type_id]);
172 172
   }
173 173
 }
@@ -180,19 +180,19 @@  discard block
 block discarded – undo
180 180
 $payment_module_valid = $payment_module_valid && (!$payment_method_selected || isset($payment_methods_available[$payment_type_selected][$payment_method_selected][$module_name]));
181 181
 
182 182
 // If payment_module invalid - making it empty OR if there is only one payment_module - selecting it
183
-if($payment_module_valid) {
183
+if ($payment_module_valid) {
184 184
   // $payment_module = $payment_module; // Really - do nothing
185
-} elseif($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) {
185
+} elseif ($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) {
186 186
   reset($payment_methods_available[$payment_type_selected][$payment_method_selected]);
187 187
   $payment_module = key($payment_methods_available[$payment_type_selected][$payment_method_selected]);
188
-} elseif(count(sn_module::$sn_module_list['payment']) == 1) {
188
+} elseif (count(sn_module::$sn_module_list['payment']) == 1) {
189 189
   $payment_module = $module_name;
190 190
 } else {
191 191
   $payment_module = '';
192 192
 }
193 193
 
194
-if($payment_type_selected && $payment_method_selected) {
195
-  foreach($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) {
194
+if ($payment_type_selected && $payment_method_selected) {
195
+  foreach ($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) {
196 196
     $template->assign_block_vars('payment_module', array(
197 197
       'ID'          => $module_name,
198 198
       'NAME'        => classLocale::$lang["module_{$module_name}_name"],
@@ -201,10 +201,10 @@  discard block
 block discarded – undo
201 201
   }
202 202
 }
203 203
 
204
-foreach(classLocale::$lang['pay_currency_list'] as $key => $value) {
204
+foreach (classLocale::$lang['pay_currency_list'] as $key => $value) {
205 205
   $course = get_exchange_rate($key);
206 206
 //  if(!$course || $key == $config->payment_currency_default) {
207
-  if(!$course) {
207
+  if (!$course) {
208 208
     continue;
209 209
   }
210 210
   $template->assign_block_vars('exchange', array(
@@ -219,17 +219,17 @@  discard block
 block discarded – undo
219 219
   ));
220 220
 }
221 221
 
222
-if($request['metamatter'] && $payment_module) {
222
+if ($request['metamatter'] && $payment_module) {
223 223
   try {
224 224
     // Any possible errors about generating paylink should be raised in module!
225 225
     $pay_link = sn_module::$sn_module[$payment_module]->compile_request($request);
226 226
 
227 227
     // Поддержка дополнительной информации
228
-    if(is_array($pay_link['RENDER'])) {
229
-      foreach($pay_link['RENDER'] as $html_data) {
228
+    if (is_array($pay_link['RENDER'])) {
229
+      foreach ($pay_link['RENDER'] as $html_data) {
230 230
         $template->assign_block_vars('render', $html_data);
231
-        if(isset($html_data['VALUE']) && is_array($html_data['VALUE'])) {
232
-          foreach($html_data['VALUE'] as $value_id => $value_value) {
231
+        if (isset($html_data['VALUE']) && is_array($html_data['VALUE'])) {
232
+          foreach ($html_data['VALUE'] as $value_id => $value_value) {
233 233
             $template->assign_block_vars('render.value', array(
234 234
               'FIELD' => $value_id,
235 235
               'VALUE' => $value_value,
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
     }
241 241
 
242 242
     // Поддержка передачи данных для многошаговых платежных систем
243
-    if(is_array($pay_link['DATA'])) {
244
-      foreach($pay_link['DATA'] as $key => $value) {
243
+    if (is_array($pay_link['DATA'])) {
244
+      foreach ($pay_link['DATA'] as $key => $value) {
245 245
         $template->assign_block_vars('pay_link_data', array(
246 246
           'FIELD' => $key,
247 247
           'VALUE' => $value,
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
       }
250 250
     }
251 251
 
252
-    if(is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) {
252
+    if (is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) {
253 253
       // TODO Переделать это под assign_vars_recursive и возвращать пустые строки если нет платежного метода - для унификации формы в темплейте
254 254
       $template->assign_vars(array(
255 255
         'PAY_LINK_METHOD' => $pay_link['PAY_LINK_METHOD'],
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
     } else {
259 259
       throw new exception(classLocale::$lang['pay_msg_request_paylink_unsupported'], ERR_ERROR);
260 260
     }
261
-  } catch(exception $e) {
261
+  } catch (exception $e) {
262 262
     $template->assign_block_vars('result', $response = array(
263 263
       'STATUS'  => $e->getCode(),
264 264
       'MESSAGE' => $e->getMessage(),
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
 }
269 269
 
270 270
 // Прегенерированные пакеты
271
-foreach($unit_available_amount_list as $unit_amount => $discount) {
271
+foreach ($unit_available_amount_list as $unit_amount => $discount) {
272 272
   $temp = sn_module_payment::currency_convert($unit_amount, 'MM_', $player_currency);
273 273
   $template->assign_block_vars('mm_amount', array(
274 274
     'VALUE'            => $unit_amount,
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
   'PLAYER_CURRENCY'              => $player_currency,
304 304
   'PLAYER_CURRENCY_PRICE_PER_MM' => sn_module_payment::currency_convert(1, $player_currency, 'MM_', 10),
305 305
 
306
-  'UNIT_AMOUNT'                 => (float)$request['metamatter'],
306
+  'UNIT_AMOUNT'                 => (float) $request['metamatter'],
307 307
   'UNIT_AMOUNT_TEXT'            => pretty_number($request['metamatter']),
308 308
   'UNIT_AMOUNT_BONUS_PERCENT'   => $bonus_percent,
309 309
   'UNIT_AMOUNT_TEXT_DISCOUNTED' => $income_metamatter_text,
Please login to merge, or discard this patch.
jumpgate.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -14,39 +14,39 @@  discard block
 block discarded – undo
14 14
 
15 15
 lng_include('fleet');
16 16
 
17
-if($TargetPlanet = sys_get_param_id('jmpto'))
17
+if ($TargetPlanet = sys_get_param_id('jmpto'))
18 18
 {
19 19
   sn_db_transaction_start();
20 20
   db_user_by_id($user['id'], true, 'id');
21 21
   $planetrow = db_planet_by_id($planetrow['id'], true);
22
-  if(!($NextJumpTime = uni_get_time_to_jump($planetrow)))
22
+  if (!($NextJumpTime = uni_get_time_to_jump($planetrow)))
23 23
   {
24 24
     $TargetGate = db_planet_by_id($TargetPlanet, true, '`id`, `last_jump_time`');
25
-    if(mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0)
25
+    if (mrc_get_level($user, $TargetGate, STRUC_MOON_GATE) > 0)
26 26
     {
27
-      $NextDestTime = uni_get_time_to_jump ( $TargetGate );
28
-      if(!$NextDestTime)
27
+      $NextDestTime = uni_get_time_to_jump($TargetGate);
28
+      if (!$NextDestTime)
29 29
       {
30 30
         // $SubQueryOri = "";
31 31
         // $SubQueryDes = "";
32 32
         $ship_list = sys_get_param('ships');
33 33
         $db_changeset = array();
34
-        foreach($ship_list as $ship_id => $ship_count)
34
+        foreach ($ship_list as $ship_id => $ship_count)
35 35
         {
36
-          if(!in_array($ship_id, sn_get_groups('fleet')))
36
+          if (!in_array($ship_id, sn_get_groups('fleet')))
37 37
           {
38 38
             continue;
39 39
           }
40 40
 
41 41
           $ship_count = max(0, min(floor($ship_count), mrc_get_level($user, $planetrow, $ship_id)));
42
-          if($ship_count)
42
+          if ($ship_count)
43 43
           {
44 44
             $db_changeset['unit'][] = sn_db_unit_changeset_prepare($ship_id, -$ship_count, $user, $planetrow['id']);
45 45
             $db_changeset['unit'][] = sn_db_unit_changeset_prepare($ship_id, $ship_count, $user, $TargetGate['id']);
46 46
           }
47 47
         }
48 48
         // Dit monsieur, y avait quelque chose a envoyer ???
49
-        if(!empty($db_changeset))
49
+        if (!empty($db_changeset))
50 50
         {
51 51
           db_planet_set_by_id($TargetGate['id'], "`last_jump_time` = " . SN_TIME_NOW . "");
52 52
           db_planet_set_by_id($planetrow['id'], "`last_jump_time` = " . SN_TIME_NOW . "");
@@ -55,31 +55,31 @@  discard block
 block discarded – undo
55 55
           db_user_set_by_id($user['id'], "`current_planet` = '{$TargetGate['id']}'");
56 56
 
57 57
           $planetrow['last_jump_time'] = SN_TIME_NOW;
58
-          $RetMessage = classLocale::$lang['gate_jump_done'] ." - ". pretty_time(uni_get_time_to_jump($planetrow));
58
+          $RetMessage = classLocale::$lang['gate_jump_done'] . " - " . pretty_time(uni_get_time_to_jump($planetrow));
59 59
         } else {
60 60
           $RetMessage = classLocale::$lang['gate_wait_data'];
61 61
         }
62 62
       } else {
63
-        $RetMessage = classLocale::$lang['gate_wait_dest'] ." - ". pretty_time($NextDestTime);
63
+        $RetMessage = classLocale::$lang['gate_wait_dest'] . " - " . pretty_time($NextDestTime);
64 64
       }
65 65
     } else {
66 66
       $RetMessage = classLocale::$lang['gate_no_dest_g'];
67 67
     }
68 68
   } else {
69
-    $RetMessage = classLocale::$lang['gate_wait_star'] ." - ". pretty_time($NextJumpTime);
69
+    $RetMessage = classLocale::$lang['gate_wait_star'] . " - " . pretty_time($NextJumpTime);
70 70
   }
71 71
   sn_db_transaction_commit();
72 72
   message($RetMessage, classLocale::$lang['tech'][STRUC_MOON_GATE], "jumpgate.php", 10);
73 73
 } else {
74 74
   $template = gettemplate('jumpgate', true);
75
-  if(mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0)
75
+  if (mrc_get_level($user, $planetrow, STRUC_MOON_GATE) > 0)
76 76
   {
77 77
     $Combo = '';
78 78
     $MoonList = db_planet_list_moon_other($user['id'], $planetrow['id']);
79 79
     // while($CurMoon = db_fetch($MoonList))
80
-    foreach($MoonList as $CurMoon)
80
+    foreach ($MoonList as $CurMoon)
81 81
     {
82
-      if(mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1)
82
+      if (mrc_get_level($user, $CurMoon, STRUC_MOON_GATE) >= 1)
83 83
       {
84 84
         $NextJumpTime = uni_get_time_to_jump($CurMoon);
85 85
         $template->assign_block_vars('moon', array(
@@ -93,9 +93,9 @@  discard block
 block discarded – undo
93 93
       }
94 94
     }
95 95
 
96
-    foreach(sn_get_groups('fleet') as $Ship)
96
+    foreach (sn_get_groups('fleet') as $Ship)
97 97
     {
98
-      if(($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0)
98
+      if (($ship_count = mrc_get_level($user, $planetrow, $Ship)) <= 0)
99 99
       {
100 100
         continue;
101 101
       }
Please login to merge, or discard this patch.
messages.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -42,59 +42,59 @@  discard block
 block discarded – undo
42 42
 
43 43
 $mode = sys_get_param_str('msg_delete') ? 'delete' : sys_get_param_str('mode');
44 44
 $current_class = sys_get_param_int('message_class');
45
-if(!isset($sn_message_class_list[$current_class])) {
45
+if (!isset($sn_message_class_list[$current_class])) {
46 46
   $current_class = 0;
47 47
   $mode = '';
48 48
 }
49 49
 
50
-switch($mode) {
50
+switch ($mode) {
51 51
   case 'write':
52 52
     $error_list = array();
53 53
     $template = gettemplate('msg_message_compose', true);
54 54
 
55 55
     $recipient_name = sys_get_param_str_unsafe('recipient_name');
56
-    if($recipient_name) {
56
+    if ($recipient_name) {
57 57
       $recipient_row = db_user_by_username($recipient_name);
58 58
     }
59 59
 
60
-    if(!$recipient_row) {
60
+    if (!$recipient_row) {
61 61
       $recipient_id = sys_get_param_id('id');
62 62
       $recipient_row = db_user_by_id($recipient_id);
63
-      if(!$recipient_row) {
63
+      if (!$recipient_row) {
64 64
         $recipient_id = 0;
65 65
       }
66 66
     }
67 67
 
68
-    if($recipient_row) {
68
+    if ($recipient_row) {
69 69
       $recipient_id = $recipient_row['id'];
70 70
       $recipient_name = $recipient_row['username'];
71 71
     }
72 72
 
73
-    if($recipient_id == $user['id']) {
73
+    if ($recipient_id == $user['id']) {
74 74
       $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_self_send'], 'STATUS' => ERR_ERROR);
75 75
     }
76 76
 
77 77
     $re = 0;
78 78
     $subject = sys_get_param_str('subject');
79
-    while(strpos($subject, classLocale::$lang['msg_answer_prefix']) !== false) {
79
+    while (strpos($subject, classLocale::$lang['msg_answer_prefix']) !== false) {
80 80
       $subject = substr($subject, strlen(classLocale::$lang['msg_answer_prefix']));
81 81
       $re++;
82 82
     }
83 83
     $re ? $subject = classLocale::$lang['msg_answer_prefix'] . $subject : false;
84 84
 
85
-    if(sys_get_param_str('msg_send')) {
85
+    if (sys_get_param_str('msg_send')) {
86 86
       $subject = $subject ? $subject : classLocale::$lang['msg_subject_default'];
87 87
 
88
-      if(!$recipient_id) {
88
+      if (!$recipient_id) {
89 89
         $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_player_not_found'], 'STATUS' => ERR_ERROR);
90 90
       }
91 91
 
92 92
       $text = sys_get_param_str('text');
93
-      if(!$text) {
93
+      if (!$text) {
94 94
         $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_no_text'], 'STATUS' => ERR_ERROR);
95 95
       }
96 96
 
97
-      if(empty($error_list)) {
97
+      if (empty($error_list)) {
98 98
         $error_list[] = array('MESSAGE' => classLocale::$lang['msg_not_message_sent'], 'STATUS' => ERR_NONE);
99 99
 
100 100
         $user_safe_name = db_escape($user['username']);
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
       'TEXT'           => htmlspecialchars($text),
124 124
     ));
125 125
 
126
-    foreach($error_list as $error_message) {
126
+    foreach ($error_list as $error_message) {
127 127
       $template->assign_block_vars('result', $error_message);
128 128
     }
129 129
 
130 130
     $message_query = db_message_list_get_last_20($user, $recipient_id);
131
-    while($message_row = db_fetch($message_query)) {
131
+    while ($message_row = db_fetch($message_query)) {
132 132
       $template->assign_block_vars('messages', array(
133 133
         'ID'   => $message_row['message_id'],
134 134
         'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF),
@@ -147,25 +147,25 @@  discard block
 block discarded – undo
147 147
 
148 148
     $message_range = sys_get_param_str('message_range');
149 149
 
150
-    switch($message_range) {
150
+    switch ($message_range) {
151 151
       case 'unchecked':
152 152
       case 'checked':
153 153
         $marked_message_list = sys_get_param('mark', array());
154
-        if($message_range == 'checked' && empty($marked_message_list)) {
154
+        if ($message_range == 'checked' && empty($marked_message_list)) {
155 155
           break;
156 156
         }
157 157
 
158 158
         $query_add = implode(',', $marked_message_list);
159
-        if($query_add) {
159
+        if ($query_add) {
160 160
           $query_add = "IN ({$query_add})";
161
-          if($message_range == 'unchecked') {
161
+          if ($message_range == 'unchecked') {
162 162
             $query_add = "NOT {$query_add}";
163 163
           }
164 164
           $query_add = " AND `message_id` {$query_add}";
165 165
         }
166 166
 
167 167
       case 'class':
168
-        if($current_class != MSG_TYPE_OUTBOX && $current_class != MSG_TYPE_NEW) {
168
+        if ($current_class != MSG_TYPE_OUTBOX && $current_class != MSG_TYPE_NEW) {
169 169
           $query_add .= " AND `message_type` = {$current_class}";
170 170
         }
171 171
       case 'all':
@@ -173,19 +173,19 @@  discard block
 block discarded – undo
173 173
       break;
174 174
     }
175 175
 
176
-    if($query_add) {
176
+    if ($query_add) {
177 177
       $query_add = $query_add === true ? '' : $query_add;
178 178
       db_message_list_delete($user, $query_add);
179 179
     }
180 180
 
181 181
   case 'show':
182
-    if($current_class == MSG_TYPE_OUTBOX) {
182
+    if ($current_class == MSG_TYPE_OUTBOX) {
183 183
       $message_query = db_message_list_outbox_by_user_id($user['id']);
184 184
     } else {
185
-      if($current_class == MSG_TYPE_NEW) {
185
+      if ($current_class == MSG_TYPE_NEW) {
186 186
         $SubUpdateQry = array();
187
-        foreach($sn_message_class_list as $message_class_id => $message_class) {
188
-          if($message_class_id != MSG_TYPE_OUTBOX) {
187
+        foreach ($sn_message_class_list as $message_class_id => $message_class) {
188
+          if ($message_class_id != MSG_TYPE_OUTBOX) {
189 189
             $SubUpdateQry[] = "`{$message_class['name']}` = '0'";
190 190
             $user[$message_class['name']] = 0;
191 191
           }
@@ -203,13 +203,13 @@  discard block
 block discarded – undo
203 203
       $message_query = db_message_list_by_owner_and_string($user, $SubSelectQry);
204 204
     }
205 205
 
206
-    if(sys_get_param_int('return')) {
206
+    if (sys_get_param_int('return')) {
207 207
       header('Location: messages.php');
208 208
       die();
209 209
     }
210 210
 
211 211
     $template = gettemplate('msg_message_list', true);
212
-    while($message_row = db_fetch($message_query)) {
212
+    while ($message_row = db_fetch($message_query)) {
213 213
       $template->assign_block_vars('messages', array(
214 214
         'ID'   => $message_row['message_id'],
215 215
         'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF),
@@ -232,18 +232,18 @@  discard block
 block discarded – undo
232 232
   break;
233 233
 }
234 234
 
235
-if(!$template) {
235
+if (!$template) {
236 236
   $template = gettemplate('msg_message_class', true);
237 237
 
238 238
   $query = db_message_count_by_owner_and_type($user);
239
-  while($message_row = db_fetch($query)) {
239
+  while ($message_row = db_fetch($query)) {
240 240
     $messages_total[$message_row['message_type']] = $message_row['message_count'];
241 241
     $messages_total[MSG_TYPE_NEW] += $message_row['message_count'];
242 242
   }
243 243
 
244 244
   $messages_total[MSG_TYPE_OUTBOX] = db_message_count_outbox($user);
245 245
 
246
-  foreach($sn_message_class_list as $message_class_id => $message_class) {
246
+  foreach ($sn_message_class_list as $message_class_id => $message_class) {
247 247
     $template->assign_block_vars('message_class', array(
248 248
       'ID'     => $message_class_id,
249 249
       'STYLE'  => $message_class['name'],
Please login to merge, or discard this patch.
buildings.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@
 block discarded – undo
21 21
 $mode = sys_get_param_escaped('mode');
22 22
 $mode = (!$mode || $mode == 'buildings') ? QUE_STRUCTURES : ($mode == 'fleet' ? SUBQUE_FLEET : ($mode == 'defense' ? SUBQUE_DEFENSE : ($mode == 'research' ? QUE_RESEARCH : $mode)));
23 23
 
24
-if($building_sort = sys_get_param_id('sort_elements')) {
25
-  if(!empty(classLocale::$lang['player_option_building_sort'][$building_sort])) {
24
+if ($building_sort = sys_get_param_id('sort_elements')) {
25
+  if (!empty(classLocale::$lang['player_option_building_sort'][$building_sort])) {
26 26
     classSupernova::$user_options[array(PLAYER_OPTION_BUILDING_SORT, $mode)] = $building_sort;
27 27
     classSupernova::$user_options[array(PLAYER_OPTION_BUILDING_SORT_INVERSE, $mode)] = sys_get_param_id('sort_elements_inverse', 0);
28 28
   }
Please login to merge, or discard this patch.
includes/classes/UBE/UBE.php 1 patch
Spacing   +44 added lines, -45 removed lines patch added patch discarded remove patch
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
     $this->players->db_load_player_by_id($player_id, UBE_PLAYER_IS_DEFENDER);
148 148
 
149 149
     $player_db_row = $this->players[$player_id]->getDbRow();
150
-    if($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) {
150
+    if ($fortifier_level = mrc_get_level($player_db_row, $this->combatMission->dst_planet, MRC_FORTIFIER)) {
151 151
       $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $fortifier_level);
152 152
     }
153 153
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     $this->rounds[0] = new UBERound(0);
180 180
     $this->rounds[0]->make_snapshot($this->fleet_list);
181 181
 
182
-    for($round = 1; $round <= 10; $round++) {
182
+    for ($round = 1; $round <= 10; $round++) {
183 183
       // Проводим раунд
184 184
       defined('DEBUG_UBE') ? print("Round {$round}<br>") : false;
185 185
 
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
 
193 193
       // Анализируем итоги текущего раунда и готовим данные для следующего
194 194
       $this->combat_result = $this->fleet_list->ubeAnalyzeFleetOutcome($round);
195
-      if($this->combat_result != UBE_COMBAT_RESULT_DRAW) {
195
+      if ($this->combat_result != UBE_COMBAT_RESULT_DRAW) {
196 196
         break;
197 197
       }
198 198
 
@@ -221,11 +221,11 @@  discard block
 block discarded – undo
221 221
     // Генерируем результат боя
222 222
     $this->fleet_list->ube_analyze_fleets($this->is_simulator, $this->debris, $this->resource_exchange_rates);
223 223
 
224
-    if(!$this->is_ube_loaded) {
224
+    if (!$this->is_ube_loaded) {
225 225
       $this->moon_calculator->calculate_moon($this);
226 226
 
227 227
       // Лутаем ресурсы - если аттакер выиграл
228
-      if($this->combat_result == UBE_COMBAT_RESULT_WIN) {
228
+      if ($this->combat_result == UBE_COMBAT_RESULT_WIN) {
229 229
         $this->sn_ube_combat_analyze_loot();
230 230
       }
231 231
     }
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
       RES_DEUTERIUM => 0,
246 246
     );
247 247
 
248
-    if(
248
+    if (
249 249
       (($planet_resource_total = $this->fleet_list[0]->get_resources_amount()) > 0)
250 250
       &&
251 251
       (($total_capacity = $this->fleet_list->ube_get_capacity_attackers()) > 0)
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
       $planet_lootable_percent = $planet_lootable / $planet_resource_total;
258 258
 
259 259
       // Вычисляем сколько ресурсов вывезено
260
-      foreach($this->fleet_list->_container as $fleet_id => $fleet) {
260
+      foreach ($this->fleet_list->_container as $fleet_id => $fleet) {
261 261
         $looted_in_metal = 0;
262
-        foreach($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) {
262
+        foreach ($this->fleet_list[0]->resource_list as $resource_id => $resource_amount) {
263 263
           // Вычисляем какой процент общей емкости трюмов атакующих будет задействован
264 264
           $fleet_lootable_percent = $fleet->fleet_capacity / $total_capacity;
265 265
           $looted = floor($resource_amount * $planet_lootable_percent * $fleet_lootable_percent);
@@ -325,16 +325,16 @@  discard block
 block discarded – undo
325 325
     $destination_user_id = $this->fleet_list[0]->owner_id;
326 326
 
327 327
     // Обновляем поле обломков на планете
328
-    if(!$this->is_admin_in_combat && $this->debris->debris_total() > 0) {
328
+    if (!$this->is_admin_in_combat && $this->debris->debris_total() > 0) {
329 329
       db_planet_set_by_gspt($this->ube_planet_info[PLANET_GALAXY], $this->ube_planet_info[PLANET_SYSTEM], $this->ube_planet_info[PLANET_PLANET], PT_PLANET,
330 330
         "`debris_metal` = `debris_metal` + " . $this->debris->debris_get_resource(RES_METAL) . ", `debris_crystal` = `debris_crystal` + " . $this->debris->debris_get_resource(RES_CRYSTAL)
331 331
       );
332 332
     }
333 333
 
334
-    foreach($this->fleet_list->_container as $fleet_id => $UBEFleet) {
334
+    foreach ($this->fleet_list->_container as $fleet_id => $UBEFleet) {
335 335
       $ship_count_lost = $UBEFleet->unit_list->unitCountLost();
336 336
 
337
-      if($fleet_id) {
337
+      if ($fleet_id) {
338 338
         // Флот
339 339
         $UBEFleet->db_save_combat_result_fleet($this->is_small_fleet_recce, $this->moon_calculator->get_reapers_status());
340 340
       } else {
@@ -342,19 +342,19 @@  discard block
 block discarded – undo
342 342
 
343 343
         // Сохраняем изменения ресурсов - если они есть
344 344
         $resource_delta = $UBEFleet->ube_combat_result_calculate_resources();
345
-        if(!empty($resource_delta)) {
345
+        if (!empty($resource_delta)) {
346 346
           $temp = array();
347
-          foreach($resource_delta as $resource_id => $resource_amount) {
347
+          foreach ($resource_delta as $resource_id => $resource_amount) {
348 348
             $resource_db_name = pname_resource_name($resource_id);
349 349
             $temp[] = "`{$resource_db_name}` = `{$resource_db_name}` + ({$resource_amount})";
350 350
           }
351 351
           db_planet_set_by_id($this->ube_planet_info[PLANET_ID], implode(',', $temp));
352 352
         }
353 353
 
354
-        if($ship_count_lost) {
354
+        if ($ship_count_lost) {
355 355
           $db_changeset = array();
356 356
           $planet_row_cache = $this->players[$destination_user_id]->getDbRow();
357
-          foreach($UBEFleet->unit_list->_container as $UBEUnit) {
357
+          foreach ($UBEFleet->unit_list->_container as $UBEUnit) {
358 358
             $db_changeset['unit'][] = sn_db_unit_changeset_prepare($UBEUnit->unitId, -$UBEUnit->units_lost, $planet_row_cache, $this->ube_planet_info[PLANET_ID]);
359 359
           }
360 360
           db_changeset_apply($db_changeset);
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
     // TODO: Связать сабы с флотами констраинтами ON DELETE SET NULL
366 366
     // Для САБов
367 367
     $fleet_group_id_list = $this->fleet_list->ube_get_groups();
368
-    if(!empty($fleet_group_id_list)) {
368
+    if (!empty($fleet_group_id_list)) {
369 369
       $fleet_group_id_list = implode(',', $fleet_group_id_list);
370 370
       db_acs_delete_by_list($fleet_group_id_list);
371 371
     }
@@ -374,19 +374,19 @@  discard block
 block discarded – undo
374 374
 
375 375
     $bashing_list = array();
376 376
     $players_sides = $this->players->get_player_sides();
377
-    foreach($players_sides as $player_id => $player_side) {
378
-      if($player_side != UBE_PLAYER_IS_ATTACKER) {
377
+    foreach ($players_sides as $player_id => $player_side) {
378
+      if ($player_side != UBE_PLAYER_IS_ATTACKER) {
379 379
         continue;
380 380
       }
381
-      if($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) {
381
+      if ($this->moon_calculator->get_status() != UBE_MOON_DESTROY_SUCCESS) {
382 382
         $bashing_list[] = "({$player_id}, {$this->ube_planet_info[PLANET_ID]}, {$this->combat_timestamp})";
383 383
       }
384
-      if($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) {
384
+      if ($this->mission_type_id == MT_ATTACK && $this->is_defender_active_player) {
385 385
         $str_loose_or_win = $this->combat_result == UBE_COMBAT_RESULT_WIN ? 'raidswin' : 'raidsloose';
386 386
         db_user_set_by_id($player_id, "`xpraid` = `xpraid` + 1, `raids` = `raids` + 1, `{$str_loose_or_win}` = `{$str_loose_or_win}` + 1");
387 387
       }
388 388
     }
389
-    if(!empty($bashing_list)) {
389
+    if (!empty($bashing_list)) {
390 390
       $bashing_list = implode(',', $bashing_list);
391 391
       db_bashing_insert($bashing_list);
392 392
     }
@@ -413,20 +413,19 @@  discard block
 block discarded – undo
413 413
       $planet_info[PLANET_SYSTEM],
414 414
       $planet_info[PLANET_PLANET],
415 415
       htmlentities($planet_info[PLANET_NAME], ENT_COMPAT, 'UTF-8'),
416
-      classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' :
417
-        ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')]
416
+      classLocale::$lang[$this->combat_result == UBE_COMBAT_RESULT_WIN ? 'ube_report_info_outcome_win' : ($this->combat_result == UBE_COMBAT_RESULT_DRAW ? 'ube_report_info_outcome_draw' : 'ube_report_info_outcome_loss')]
418 417
     );
419 418
 
420 419
     $text_defender = '';
421 420
     $debris = $this->debris->get_debris();
422
-    foreach($debris as $resource_id => $resource_amount) {
423
-      if($resource_id == RES_DEUTERIUM) {
421
+    foreach ($debris as $resource_id => $resource_amount) {
422
+      if ($resource_id == RES_DEUTERIUM) {
424 423
         continue;
425 424
       }
426 425
 
427 426
       $text_defender .= "{$lang['tech'][$resource_id]}: " . pretty_number($resource_amount) . '<br />';
428 427
     }
429
-    if($text_defender) {
428
+    if ($text_defender) {
430 429
       $text_defender = "{$lang['ube_report_msg_body_debris']}{$text_defender}<br />";
431 430
     }
432 431
 
@@ -436,7 +435,7 @@  discard block
 block discarded – undo
436 435
 
437 436
     // TODO: Оптимизировать отсылку сообщений - отсылать пакетами
438 437
     $player_sides = $this->players->get_player_sides();
439
-    foreach($player_sides as $player_id => $player_side) {
438
+    foreach ($player_sides as $player_id => $player_side) {
440 439
       $message = $text_common . ($this->is_small_fleet_recce && ($player_side == UBE_PLAYER_IS_ATTACKER) ? classLocale::$lang['ube_report_msg_body_sfr'] : $text_defender);
441 440
       msg_send_simple_message($player_id, '', $this->combat_timestamp, MSG_TYPE_COMBAT, classLocale::$lang['sys_mess_tower'], classLocale::$lang['sys_mess_attack_report'], $message);
442 441
     }
@@ -473,11 +472,11 @@  discard block
 block discarded – undo
473 472
     $player_id = $player_id == -1 ? $this->players->count() : $player_id;
474 473
     $fleet_id = $player_id; // FOR SIMULATOR!
475 474
 
476
-    if(empty($this->players[$player_id])) {
475
+    if (empty($this->players[$player_id])) {
477 476
       $this->players[$player_id] = new UBEPlayer();
478 477
     }
479 478
 
480
-    foreach($side_info as $fleet_data) {
479
+    foreach ($side_info as $fleet_data) {
481 480
       $this->players[$player_id]->name = $player_id;
482 481
       $this->players[$player_id]->setSide($attacker);
483 482
 
@@ -485,32 +484,32 @@  discard block
 block discarded – undo
485 484
       $this->fleet_list[$fleet_id] = $objFleet;
486 485
 
487 486
       $this->fleet_list[$fleet_id]->owner_id = $player_id;
488
-      foreach($fleet_data as $unit_id => $unit_count) {
489
-        if(!$unit_count) {
487
+      foreach ($fleet_data as $unit_id => $unit_count) {
488
+        if (!$unit_count) {
490 489
           continue;
491 490
         }
492 491
 
493 492
         $unit_type = get_unit_param($unit_id, P_UNIT_TYPE);
494 493
 
495
-        if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
494
+        if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
496 495
           $this->fleet_list[$fleet_id]->unit_list->unitAdjustCount($unit_id, $unit_count);
497
-        } elseif($unit_type == UNIT_RESOURCES) {
496
+        } elseif ($unit_type == UNIT_RESOURCES) {
498 497
           $this->fleet_list[$fleet_id]->resource_list[$unit_id] = $unit_count;
499
-        } elseif($unit_type == UNIT_TECHNOLOGIES) {
500
-          if($unit_id == TECH_WEAPON) {
498
+        } elseif ($unit_type == UNIT_TECHNOLOGIES) {
499
+          if ($unit_id == TECH_WEAPON) {
501 500
             $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_WEAPON, $unit_count);
502
-          } elseif($unit_id == TECH_SHIELD) {
501
+          } elseif ($unit_id == TECH_SHIELD) {
503 502
             $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_SHIELD, $unit_count);
504
-          } elseif($unit_id == TECH_ARMOR) {
503
+          } elseif ($unit_id == TECH_ARMOR) {
505 504
             $this->players[$player_id]->player_bonus->add_unit_by_snid(TECH_ARMOR, $unit_count);
506 505
           }
507
-        } elseif($unit_type == UNIT_GOVERNORS) {
508
-          if($unit_id == MRC_FORTIFIER) {
506
+        } elseif ($unit_type == UNIT_GOVERNORS) {
507
+          if ($unit_id == MRC_FORTIFIER) {
509 508
             // Фортифаер даёт бонус ко всему
510 509
             $this->planet_bonus->add_unit_by_snid(MRC_FORTIFIER, $unit_count);
511 510
           }
512
-        } elseif($unit_type == UNIT_MERCENARIES) {
513
-          if($unit_id == MRC_ADMIRAL) {
511
+        } elseif ($unit_type == UNIT_MERCENARIES) {
512
+          if ($unit_id == MRC_ADMIRAL) {
514 513
             $this->players[$player_id]->player_bonus->add_unit_by_snid(MRC_ADMIRAL, $unit_count);
515 514
           }
516 515
         }
@@ -581,7 +580,7 @@  discard block
 block discarded – undo
581 580
 
582 581
     $ube_report = new UBEReport();
583 582
     $ube = $ube_report->sn_ube_report_load(sys_get_param_str('cypher'));
584
-    if($ube != UBE_REPORT_NOT_FOUND) {
583
+    if ($ube != UBE_REPORT_NOT_FOUND) {
585 584
       $ube_report->sn_ube_report_generate($ube, $template_result);
586 585
 
587 586
       $template = gettemplate('ube_combat_report', $template);
@@ -614,9 +613,9 @@  discard block
 block discarded – undo
614 613
 //    sn_ube_report_save($combat_data);
615 614
 //  }
616 615
 
617
-    if(sys_get_param_str('reload')) {
616
+    if (sys_get_param_str('reload')) {
618 617
       $ube_new = $ube_report->sn_ube_report_load($ube->get_cypher()); // $combat_data = sn_ube_report_load($combat_data[UBE_REPORT_CYPHER]);
619
-      if($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) {
618
+      if ($ube_new != UBE_REPORT_NOT_FOUND && is_object($ube_new)) {
620 619
         $ube = $ube_new;
621 620
       }
622 621
     }
@@ -664,7 +663,7 @@  discard block
 block discarded – undo
664 663
     $this->debris->load_from_report_row($report_row);
665 664
 
666 665
     $query = doquery("SELECT * FROM {{ube_report_player}} WHERE `ube_report_id` = {$report_row['ube_report_id']}");
667
-    while($player_row = db_fetch($query)) {
666
+    while ($player_row = db_fetch($query)) {
668 667
       $this->players->init_player_from_report_info($player_row);
669 668
     }
670 669
 
Please login to merge, or discard this patch.
includes/functions/flt_mission_missile.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
   $mip_data = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET);
15 15
   $MIPDamage = floor(mrc_modify_value($attackerTech, false, TECH_WEAPON, $MIPs * $mip_data[P_ATTACK] * mt_rand(80, 120) / 100));
16
-  foreach($structures as $key => $structure)
16
+  foreach ($structures as $key => $structure)
17 17
   {
18 18
     $unit_info = get_unit_param($key);
19 19
     $amplify = isset($mip_data[P_AMPLIFY][$key]) ? $mip_data[P_AMPLIFY][$key] : 1;
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
   {
32 32
     //attacking only selected structure
33 33
     $damageDone = $structures[$targetedStructure][$damageTo];
34
-    $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] );
34
+    $structsDestroyed = min(floor($MIPDamage / $damageDone), $structures[$targetedStructure][0]);
35 35
     $structures[$targetedStructure][0] -= $structsDestroyed;
36
-    $MIPDamage -= $structsDestroyed*$damageDone;
36
+    $MIPDamage -= $structsDestroyed * $damageDone;
37 37
   }
38 38
   else
39 39
   {
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
     do
45 45
     {
46 46
       // finding is there any structure that can be damaged with leftovers of $MIPDamage
47
-      foreach($can_be_damaged as $key => $unit_id)
47
+      foreach ($can_be_damaged as $key => $unit_id)
48 48
       {
49 49
 //debug($structures[$unit_id][0]);
50 50
 //debug($structures[$unit_id][$damageTo], $MIPDamage);
51
-        if($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage)
51
+        if ($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage)
52 52
         {
53 53
           unset($can_be_damaged[$key]);
54 54
         }
55 55
       }
56
-      if(empty($can_be_damaged))
56
+      if (empty($can_be_damaged))
57 57
       {
58 58
         break;
59 59
       }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 //debug($destroyed, 'Actually destroyed');
73 73
 
74 74
 //print('<hr>');
75
-    } while($MIPDamage > 0 && !empty($can_be_damaged));
75
+    } while ($MIPDamage > 0 && !empty($can_be_damaged));
76 76
 //debug($MIPDamage, 'MIPDamage left');
77 77
   }
78 78
 //debug($structures);//die();
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
     $crystal += $destroyed * $unit_info[P_COST][RES_CRYSTAL] / 4;
88 88
   }
89 89
 
90
-  $return['structures'] = $structures;     // Structures left after attack
91
-  $return['metal']      = floor($metal);   // Metal scraps
90
+  $return['structures'] = $structures; // Structures left after attack
91
+  $return['metal']      = floor($metal); // Metal scraps
92 92
   $return['crystal']    = floor($crystal); // Crystal scraps
93 93
 
94 94
   return $return;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
   $iraks = db_missile_list_by_arrival();
114 114
 
115
-  while($fleetRow = db_fetch($iraks)) {
115
+  while ($fleetRow = db_fetch($iraks)) {
116 116
     set_time_limit(15);
117 117
     $db_changeset = array();
118 118
 
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 
129 129
     $rowAttacker = db_user_by_id($fleetRow['fleet_owner'], true);
130 130
 
131
-    if($target_planet_row['id']) {
131
+    if ($target_planet_row['id']) {
132 132
       $planetDefense = array();
133
-      foreach(sn_get_groups('defense_active') as $unit_id) {
133
+      foreach (sn_get_groups('defense_active') as $unit_id) {
134 134
         $planetDefense[$unit_id] = array(mrc_get_level($targetUser, $target_planet_row, $unit_id, true, true));
135 135
       }
136 136
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         $message = classLocale::$lang['mip_all_destroyed'];
142 142
         $db_changeset['unit'][] = sn_db_unit_changeset_prepare(UNIT_DEF_MISSILE_INTERCEPTOR, -$missiles, $targetUser, $target_planet_row['id']);
143 143
       } else {
144
-        if($interceptors) {
144
+        if ($interceptors) {
145 145
           $message = sprintf(classLocale::$lang['mip_destroyed'], $interceptors);
146 146
           $db_changeset['unit'][] = sn_db_unit_changeset_prepare(UNIT_DEF_MISSILE_INTERCEPTOR, -$interceptors, $targetUser, $target_planet_row['id']);
147 147
         }
@@ -149,16 +149,16 @@  discard block
 block discarded – undo
149 149
 
150 150
         $attackResult = COE_missileAttack($targetUser, $rowAttacker, $missiles - $interceptors, $planetDefense, $fleetRow['primaer']);
151 151
 
152
-        foreach($attackResult['structures'] as $key => $structure) {
152
+        foreach ($attackResult['structures'] as $key => $structure) {
153 153
           $destroyed = $planetDefense[$key][0] - $structure[0];
154
-          if($destroyed) {
154
+          if ($destroyed) {
155 155
             $db_changeset['unit'][] = sn_db_unit_changeset_prepare($key, -$destroyed, $targetUser, $target_planet_row['id']);
156 156
 
157 157
             $message .= "&nbsp;&nbsp;{$lang['tech'][$key]} - {$destroyed} {$lang['quantity']}<br>";
158 158
           }
159 159
         }
160 160
 
161
-        if(!empty($message)) {
161
+        if (!empty($message)) {
162 162
           $message = $lang['mip_defense_destroyed'] . $message . "{$lang['mip_recycled']}{$lang['Metal']}: {$attackResult['metal']}, {$lang['Crystal']}: {$attackResult['crystal']}<br>";
163 163
 
164 164
           db_planet_set_by_id($target_planet_row['id'], "`metal` = `metal` + {$attackResult['metal']}, `crystal` = `crystal` + {$attackResult['crystal']}");
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
       empty($message) ? $message = classLocale::$lang['mip_no_defense'] : false;
179 179
       // empty($message) && ($message = $lang['mip_no_defense']);
180 180
 
181
-      msg_send_simple_message ( $fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage . $message );
182
-      msg_send_simple_message ( $fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage . $message );
181
+      msg_send_simple_message($fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage . $message);
182
+      msg_send_simple_message($fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, classLocale::$lang['mip_sender_amd'], classLocale::$lang['mip_subject_amd'], $message_vorlage . $message);
183 183
     }
184 184
     db_missile_delete($fleetRow);
185 185
   }
Please login to merge, or discard this patch.