Passed
Push — work-fleets ( 6f822b...6dcfe4 )
by SuperNova.WS
06:31 queued 16s
created
includes/alliance/ali_external_create_ally.inc 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use DBStatic\DBStaticAlly;
6 6
 use DBStatic\DBStaticUser;
7 7
 
8
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
8
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
9 9
   classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
10 10
 }
11 11
 
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 $ally_name_unsafe = sys_get_param_str_unsafe('name');
15 15
 $ally_name = db_escape($ally_name_unsafe);
16 16
 
17
-if($ally_tag) {
18
-  if(!$ally_name_unsafe || !$ally_tag_unsafe) {
17
+if ($ally_tag) {
18
+  if (!$ally_name_unsafe || !$ally_tag_unsafe) {
19 19
     message(classLocale::$lang['have_not_name'], classLocale::$lang['make_alliance']);
20 20
   }
21 21
 
22 22
   $query = DBStaticAlly::db_ally_get_by_name_or_tag($ally_tag, $ally_name);
23
-  if($query) {
23
+  if ($query) {
24 24
     message(str_replace('%s', $query['ally_tag'] == $ally_tag_unsafe ? $ally_tag_unsafe : $ally_name_unsafe, classLocale::$lang['always_exist']), classLocale::$lang['make_alliance']);
25 25
   }
26 26
 
Please login to merge, or discard this patch.
includes/alliance/ali_internal_admin_mail.inc 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@
 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) {
13
+if ($internalAliSendTextUnsafe) {
14 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 17
 $r_list = "<option value=\"-1\">" . classLocale::$lang['All_players'] . "</option>";
18
-if($ranks) {
19
-  foreach($ranks as $id => $array) {
18
+if ($ranks) {
19
+  foreach ($ranks as $id => $array) {
20 20
     $r_list .= "<option value=\"" . $id . "\">" . $array['name'] . "</option>";
21 21
   }
22 22
 }
Please login to merge, or discard this patch.
includes/alliance/ali_internal_admin.inc 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
 use DBStatic\DBStaticAlly;
4 4
 use DBStatic\DBStaticUser;
5 5
 
6
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
6
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
7 7
   classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
8 8
 }
9 9
 
10
-if(!$user_admin) {
10
+if (!$user_admin) {
11 11
   message(classLocale::$lang['Denied_access'], classLocale::$lang['ally_admin']);
12 12
 }
13 13
 
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
 $allyTextID = ($allyTextID < 1 || $allyTextID > 3) ? 1 : $allyTextID;
24 24
 
25 25
 
26
-if(sys_get_param_str('isSaveOptions')) {
26
+if (sys_get_param_str('isSaveOptions')) {
27 27
   require_once('includes/includes/sys_avatar.php');
28 28
 
29 29
   $fieldChange = array();
30
-  if(($new_tag = sys_get_param_str_unsafe('tag', $ally['ally_tag'])) != $ally['ally_tag']) {
30
+  if (($new_tag = sys_get_param_str_unsafe('tag', $ally['ally_tag'])) != $ally['ally_tag']) {
31 31
     $fieldChange['ally_tag'] = $new_tag;
32 32
     DBStaticUser::db_user_set_by_id(
33 33
       $ally['ally_user_id'],
@@ -36,19 +36,19 @@  discard block
 block discarded – undo
36 36
       )
37 37
     );
38 38
   }
39
-  if(($new_name = sys_get_param_str_unsafe('name', $ally['ally_name'])) != $ally['ally_name']) {
39
+  if (($new_name = sys_get_param_str_unsafe('name', $ally['ally_name'])) != $ally['ally_name']) {
40 40
     $fieldChange['ally_name'] = $new_name;
41 41
   }
42 42
 
43
-  if(($new_owner_rank = sys_get_param_str_unsafe('owner_range', $ally['ally_owner_range'])) != $ally['ally_owner_range']) {
43
+  if (($new_owner_rank = sys_get_param_str_unsafe('owner_range', $ally['ally_owner_range'])) != $ally['ally_owner_range']) {
44 44
     $fieldChange['ally_owner_range'] = $new_owner_rank;
45 45
   }
46 46
 
47
-  if(($new_web = sys_get_param_str_unsafe('web', $ally['ally_web'])) != $ally['ally_web']) {
47
+  if (($new_web = sys_get_param_str_unsafe('web', $ally['ally_web'])) != $ally['ally_web']) {
48 48
     $fieldChange['ally_web'] = $new_web;
49 49
   }
50 50
 
51
-  if(($new_request = sys_get_param_int('request_notallow', $ally['ally_request_notallow'])) != $ally['ally_request_notallow']) {
51
+  if (($new_request = sys_get_param_int('request_notallow', $ally['ally_request_notallow'])) != $ally['ally_request_notallow']) {
52 52
     $fieldChange['ally_request_notallow'] = sys_get_param_int('request_notallow', $ally['ally_request_notallow']);
53 53
   }
54 54
 
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
     'AVATAR_UPLOAD_STATUS'  => $avatar_upload_result['STATUS'],
59 59
     'AVATAR_UPLOAD_MESSAGE' => $avatar_upload_result['MESSAGE'],
60 60
   ));
61
-  if($new_image != $ally['ally_image']) {
61
+  if ($new_image != $ally['ally_image']) {
62 62
     $fieldChange['ally_image'] = $new_image;
63 63
   }
64 64
 
65
-  if(!empty($fieldChange)) {
65
+  if (!empty($fieldChange)) {
66 66
     classSupernova::$db->doUpdateRowSet(
67 67
       TABLE_ALLIANCE,
68 68
       $fieldChange,
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
 
74 74
     sys_redirect('alliance.php?mode=admin&edit=ally');
75 75
   }
76
-} elseif(sys_get_param_str('isSaveText')) {
76
+} elseif (sys_get_param_str('isSaveText')) {
77 77
   $text_unsafe = sys_get_param_str_unsafe('text');
78 78
   DBStaticAlly::db_ally_update_texts($text_unsafe, $ally['id'], $text_list[$allyTextID]['db_field']);
79 79
   $ally[$text_list[$allyTextID]['db_field']] = db_escape($text_unsafe);
80
-} elseif(sys_get_param_str('isTransfer') && $idNewLeader = sys_get_param_id('idNewLeader')) {
81
-  if(!$isAllyOwner) {
80
+} elseif (sys_get_param_str('isTransfer') && $idNewLeader = sys_get_param_id('idNewLeader')) {
81
+  if (!$isAllyOwner) {
82 82
     message(classLocale::$lang['Denied_access'], classLocale::$lang['ally_admin']);
83 83
   }
84 84
 
85 85
   $newLeader = DBStaticUser::db_user_by_id($idNewLeader, false, `ally_id`);
86
-  if($newLeader['ally_id'] == $user['ally_id']) {
86
+  if ($newLeader['ally_id'] == $user['ally_id']) {
87 87
     sn_db_transaction_start();
88 88
     DBStaticUser::db_user_set_by_id(
89 89
       $user['id'],
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
     sn_db_transaction_commit();
103 103
     sys_redirect('alliance.php');
104 104
   }
105
-} elseif(sys_get_param_str('isDisband') && sys_get_param_str('isConfirmDisband')) {
106
-  if(!$isAllyOwner) {
105
+} elseif (sys_get_param_str('isDisband') && sys_get_param_str('isConfirmDisband')) {
106
+  if (!$isAllyOwner) {
107 107
     message(classLocale::$lang['Denied_access'], classLocale::$lang['ally_admin']);
108 108
   }
109 109
   sn_db_transaction_start();
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
   $userAllyAdmins = DBStaticUser::db_user_list("`ally_id`= {$ally['id']}", false, '`id`, `username`');
160 160
   unset($tmp);
161 161
   // while ($userAllyAdmin = db_fetch($userAllyAdmins))
162
-  foreach($userAllyAdmins as $userAllyAdmin) {
162
+  foreach ($userAllyAdmins as $userAllyAdmin) {
163 163
 // pdump($userAllyAdmin);
164 164
     $tmp .= "<option value={$userAllyAdmin['id']}>{$userAllyAdmin['username']}</option>";
165 165
   }
@@ -167,8 +167,8 @@  discard block
 block discarded – undo
167 167
   $template->assign_var('adminMembers', $tmp);
168 168
 }
169 169
 
170
-foreach($sn_ali_admin_internal as $sn_ali_admin_action => $sn_ali_admin_action_locale) {
171
-  if(!$sn_ali_admin_action_locale['title']) {
170
+foreach ($sn_ali_admin_internal as $sn_ali_admin_action => $sn_ali_admin_action_locale) {
171
+  if (!$sn_ali_admin_action_locale['title']) {
172 172
     continue;
173 173
   }
174 174
   $template->assign_block_vars('admin_actions', array(
Please login to merge, or discard this patch.
includes/db/db_queries.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 
145 145
 
146 146
 function db_stat_list_update_ally_stats() {
147
-  return ;
147
+  return;
148 148
 }
149 149
 
150 150
 function db_stat_list_delete_ally_player() {
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 // Log Online *************************************************************************************************************
424 424
 function db_log_online_insert() {
425 425
   classSupernova::$db->doInsertSet(TABLE_LOG_USERS_ONLINE, array(
426
-    'online_count' => (int)classSupernova::$config->var_online_user_count,
426
+    'online_count' => (int) classSupernova::$config->var_online_user_count,
427 427
   ), array(), DB_INSERT_IGNORE);
428 428
 }
429 429
 
@@ -519,10 +519,10 @@  discard block
 block discarded – undo
519 519
 function db_log_dark_matter_insert($user_id, $change_type, $dark_matter, $comment_unsafe, $rowUserNameUnsafe, $page_url_unsafe) {
520 520
   return classSupernova::$db->doInsertSet(TABLE_LOG_DARK_MATTER, array(
521 521
     'log_dark_matter_username' => $rowUserNameUnsafe,
522
-    'log_dark_matter_reason'   => (int)$change_type,
523
-    'log_dark_matter_amount'   => (float)$dark_matter,
524
-    'log_dark_matter_comment'  => (string)$comment_unsafe,
525
-    'log_dark_matter_page'     => (string)$page_url_unsafe,
522
+    'log_dark_matter_reason'   => (int) $change_type,
523
+    'log_dark_matter_amount'   => (float) $dark_matter,
524
+    'log_dark_matter_comment'  => (string) $comment_unsafe,
525
+    'log_dark_matter_page'     => (string) $page_url_unsafe,
526 526
     'log_dark_matter_sender'   => $user_id,
527 527
   ), array());
528 528
 }
Please login to merge, or discard this patch.
Doc Comments   +15 added lines, -10 removed lines patch added patch discarded remove patch
@@ -176,6 +176,11 @@  discard block
 block discarded – undo
176 176
  */
177 177
 // OK v4
178 178
 // TODO - вынести в отдельный класс
179
+/**
180
+ * @param string $db_id_field_name
181
+ * @param string $db_table_name
182
+ * @param string $db_value_field_name
183
+ */
179 184
 function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) {
180 185
   $current_value_safe = db_escape($current_value_unsafe);
181 186
   $value_id = classSupernova::$db->doSelectFetchArray("SELECT `{$db_id_field_name}` FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE");
@@ -509,8 +514,8 @@  discard block
 block discarded – undo
509 514
 
510 515
 
511 516
 /**
512
- * @param $user_id
513
- * @param $change_type
517
+ * @param integer $user_id
518
+ * @param integer $change_type
514 519
  * @param $dark_matter
515 520
  * @param $comment_unsafe
516 521
  * @param $rowUserNameUnsafe
@@ -531,7 +536,7 @@  discard block
 block discarded – undo
531 536
 /**
532 537
  * @param $user_id_safe
533 538
  *
534
- * @return array|bool|mysqli_result|null
539
+ * @return integer
535 540
  */
536 541
 function db_referral_get_by_id($user_id_safe) {
537 542
   $old_referral = classSupernova::$db->doSelectFetchArray("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;");
@@ -571,9 +576,9 @@  discard block
 block discarded – undo
571 576
 
572 577
 // Quests ***********************************************************************************************************
573 578
 /**
574
- * @param $query_add_select
579
+ * @param string $query_add_select
575 580
  * @param $query_add_from
576
- * @param $query_add_where
581
+ * @param string $query_add_where
577 582
  *
578 583
  * @return array|bool|mysqli_result|null
579 584
  */
@@ -617,11 +622,11 @@  discard block
 block discarded – undo
617 622
 }
618 623
 
619 624
 /**
620
- * @param $quest_name_unsafe
621
- * @param $quest_type
622
- * @param $quest_description_unsafe
625
+ * @param string $quest_name_unsafe
626
+ * @param integer $quest_type
627
+ * @param string $quest_description_unsafe
623 628
  * @param $quest_conditions
624
- * @param $quest_rewards
629
+ * @param string $quest_rewards
625 630
  * @param $quest_id
626 631
  */
627 632
 function db_quest_update($quest_name_unsafe, $quest_type, $quest_description_unsafe, $quest_conditions, $quest_rewards, $quest_id) {
@@ -705,7 +710,7 @@  discard block
 block discarded – undo
705 710
 
706 711
 /**
707 712
  * @param $payment_id
708
- * @param $payment_status
713
+ * @param integer $payment_status
709 714
  * @param $comment_unsafe
710 715
  */
711 716
 function db_payment_update($payment_id, $payment_status, $comment_unsafe) {
Please login to merge, or discard this patch.
includes/init.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Защита от двойного инита
4
-if(defined('INIT')) {
4
+if (defined('INIT')) {
5 5
   return;
6 6
 }
7 7
 
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 define('SN_DEBUG_PDUMP_CALLER', true);
20 20
 
21 21
 // Бенчмарк
22
-register_shutdown_function(function () {
23
-  if(defined('IN_AJAX')) {
22
+register_shutdown_function(function() {
23
+  if (defined('IN_AJAX')) {
24 24
     return;
25 25
   }
26 26
 
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
     (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : '') .
31 31
     (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: ' . classSupernova::$db->time_mysql_total . 'ms' : '') .
32 32
     '</div>');
33
-  if($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) {
33
+  if ($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) {
34 34
     echo '<a href="badqrys.txt" target="_blank" style="color:red">', 'HACK ALERT!', '</a>';
35 35
   }
36 36
 
37
-  if(!empty($locale_cache_statistic['misses'])) {
37
+  if (!empty($locale_cache_statistic['misses'])) {
38 38
     print('<!--');
39 39
     pdump($locale_cache_statistic);
40 40
     print('-->');
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 define('SN_TIME_NOW_GMT_STRING', gmdate(DATE_ATOM, SN_TIME_NOW));
56 56
 
57
-if(strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) {
57
+if (strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) {
58 58
   define('SN_GOOGLE', true);
59 59
 }
60 60
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 ini_set('error_reporting', E_ALL ^ E_NOTICE);
83 83
 
84 84
 empty($classRoot) ? $classRoot = SN_ROOT_PHYSICAL . 'classes/' : false;
85
-spl_autoload_register(function ($class) use ($classRoot) {
85
+spl_autoload_register(function($class) use ($classRoot) {
86 86
   $class = str_replace('\\', '/', $class);
87 87
   if (file_exists($classRoot . $class . '.php')) {
88 88
     require_once $classRoot . $class . '.php';
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 // Но нужно, пока у нас есть не MVC-страницы
162 162
 $sn_page_data = $sn_data['pages'][$sn_page_name];
163 163
 $sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX;
164
-if($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) {
164
+if ($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) {
165 165
   require_once($sn_page_name_file);
166
-  if(is_array($sn_page_data['options'])) {
166
+  if (is_array($sn_page_data['options'])) {
167 167
     classSupernova::$options = array_merge(classSupernova::$options, $sn_page_data['options']);
168 168
   }
169 169
 }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
 
175 175
 // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу
176
-if(!isset($sn_data['pages'][$sn_page_name])) {
176
+if (!isset($sn_data['pages'][$sn_page_name])) {
177 177
   $sn_page_name = '';
178 178
 }
179 179
 
@@ -181,6 +181,6 @@  discard block
 block discarded – undo
181 181
 classLocale::$lang = $lang = classSupernova::$gc->localePlayer;
182 182
 classLocale::$lang->lng_switch(sys_get_param_str('lang'));
183 183
 
184
-if(!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) {
184
+if (!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) {
185 185
   require_once "init_secondary.php";
186 186
 }
Please login to merge, or discard this patch.
includes/update.php 2 patches
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
 use Vector\Vector;
25 25
 
26
-if(!defined('INIT')) {
26
+if (!defined('INIT')) {
27 27
 //  include_once('init.php');
28 28
   die('Unauthorized access');
29 29
 }
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 classSupernova::$config->debug = 0;
42 42
 
43 43
 
44
-if(classSupernova::$config->db_version == DB_VERSION) {
45
-} elseif(classSupernova::$config->db_version > DB_VERSION) {
44
+if (classSupernova::$config->db_version == DB_VERSION) {
45
+} elseif (classSupernova::$config->db_version > DB_VERSION) {
46 46
   classSupernova::$config->db_saveItem('var_db_update_end', SN_TIME_NOW);
47 47
   die(
48 48
   'Internal error! Auotupdater detects DB version greater then can be handled!<br />
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
   );
52 52
 }
53 53
 
54
-if(classSupernova::$config->db_version < 26) {
54
+if (classSupernova::$config->db_version < 26) {
55 55
   $sys_log_disabled = true;
56 56
 }
57 57
 
@@ -70,20 +70,20 @@  discard block
 block discarded – undo
70 70
 $update_tables = array();
71 71
 $update_indexes = array();
72 72
 $query = upd_do_query('SHOW TABLES;', true);
73
-while($row = classSupernova::$db->db_fetch_row($query)) {
73
+while ($row = classSupernova::$db->db_fetch_row($query)) {
74 74
   upd_load_table_info($row[0]);
75 75
 }
76 76
 upd_log_message('Table info loaded. Now looking DB for upgrades...');
77 77
 
78 78
 upd_do_query('SET FOREIGN_KEY_CHECKS=0;', true);
79 79
 
80
-if($new_version < 37) {
80
+if ($new_version < 37) {
81 81
   die('Upgrade from SN versions below 37 are not supported. Use SN version 39 to upgrade old DB then use V40+ for further upgrade');
82 82
 }
83 83
 
84 84
 ini_set('memory_limit', '1024M');
85 85
 
86
-switch($new_version) {
86
+switch ($new_version) {
87 87
   case 37:
88 88
     upd_log_version_update();
89 89
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
     upd_check_key('payment_currency_exchange_mm_', 2500, !classSupernova::$config->payment_currency_exchange_mm_);
100 100
 
101
-    if(!$update_tables['log_metamatter']) {
101
+    if (!$update_tables['log_metamatter']) {
102 102
       upd_create_table('log_metamatter',
103 103
         "(
104 104
           `id` SERIAL,
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
       "ADD `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'",
124 124
     ), !$update_tables['payment']['payment_test']);
125 125
 
126
-    if($update_tables['payment']['payment_test']['Default'] == 1) {
126
+    if ($update_tables['payment']['payment_test']['Default'] == 1) {
127 127
       upd_alter_table('payment', array(
128 128
         "MODIFY COLUMN `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'",
129 129
       ));
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     ), $update_tables['users']['metamatter']['Type'] == 'int(20)');
141 141
 
142 142
     $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = " . QUE_RESEARCH . " AND que_unit_id IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") FOR UPDATE");
143
-    while($row = db_fetch($query)) {
143
+    while ($row = db_fetch($query)) {
144 144
       $planet_id = ($row['que_planet_id_origin'] ? $row['que_planet_id_origin'] : $row['que_planet_id']);
145 145
       upd_do_query("SELECT id FROM {{planets}} WHERE id = {$planet_id} FOR UPDATE");
146 146
       $price = sys_unit_str2arr($row['que_unit_price']);
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
     LEFT JOIN {{planets}} AS p ON p.id = u.id_planet
159 159
     WHERE unit_snid IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ")
160 160
     FOR UPDATE");
161
-    while($row = db_fetch($query)) {
162
-      if(!$row['id_planet']) {
161
+    while ($row = db_fetch($query)) {
162
+      if (!$row['id_planet']) {
163 163
         continue;
164 164
       }
165 165
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
       $unit_level = $row['unit_level'];
168 168
       $price = get_unit_param($unit_id, P_COST);
169 169
       $factor = $price['factor'];
170
-      foreach($price as $resource_id => &$resource_amount) {
170
+      foreach ($price as $resource_id => &$resource_amount) {
171 171
         $resource_amount = $resource_amount * (pow($factor, $unit_level) - 1) / ($factor - 1);
172 172
       }
173 173
       // upd_do_query
@@ -186,14 +186,14 @@  discard block
 block discarded – undo
186 186
     // Вернуть ресы за уже исследованную Экспедиционную технологию
187 187
     upd_check_key('player_max_colonies', -1, classSupernova::$config->player_max_colonies >= 0);
188 188
 
189
-    if(!isset($update_tables['users']['player_rpg_explore_xp'])) {
189
+    if (!isset($update_tables['users']['player_rpg_explore_xp'])) {
190 190
       upd_alter_table('users', array(
191 191
         "ADD COLUMN `player_rpg_explore_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`",
192 192
         "ADD COLUMN `player_rpg_explore_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`",
193 193
       ), !isset($update_tables['users']['player_rpg_explore_xp']));
194 194
     }
195 195
 
196
-    if(!$update_tables['log_users_online']) {
196
+    if (!$update_tables['log_users_online']) {
197 197
       upd_create_table('log_users_online', "(
198 198
         `online_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Measure time',
199 199
         `online_count` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Users online',
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
       "ADD `user_time_measured` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'When was time diff measured last time' AFTER `onlinetime`",
209 209
     ), !$update_tables['users']['user_time_measured']);
210 210
 
211
-    if($update_tables['rw']) {
211
+    if ($update_tables['rw']) {
212 212
       upd_do_query("DROP TABLE IF EXISTS {{rw}};");
213 213
     }
214 214
 
215
-    if(!$update_tables['player_award']) {
215
+    if (!$update_tables['player_award']) {
216 216
       upd_create_table('player_award', "(
217 217
         `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
218 218
         `award_type_id` int(11) DEFAULT NULL COMMENT 'Award type i.e. order, medal, pennant, rank etc',
@@ -254,14 +254,14 @@  discard block
 block discarded – undo
254 254
     upd_log_version_update();
255 255
 
256 256
 
257
-    if(!isset($update_tables['planets']['que_processed'])) {
257
+    if (!isset($update_tables['planets']['que_processed'])) {
258 258
       upd_alter_table('planets', array(
259 259
         "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `last_update`",
260 260
       ), true);
261 261
       upd_do_query("UPDATE {{planets}} SET que_processed = last_update;");
262 262
     }
263 263
 
264
-    if(!isset($update_tables['users']['que_processed'])) {
264
+    if (!isset($update_tables['users']['que_processed'])) {
265 265
       upd_alter_table('users', array(
266 266
         "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `onlinetime`",
267 267
       ), true);
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
     }
270 270
 
271 271
 
272
-    if(isset($update_tables['planets']['que'])) {
272
+    if (isset($update_tables['planets']['que'])) {
273 273
       $sn_data_aux = array(
274 274
         SHIP_SMALL_FIGHTER_WRATH    => array(
275 275
           'name' => 'ship_fighter_wrath',
@@ -354,20 +354,20 @@  discard block
 block discarded – undo
354 354
       $unit_data = array();
355 355
       $planets = array();
356 356
 
357
-      foreach($planet_unit_list as $unit_id) {
358
-        if(!($unit_name = get_unit_param($unit_id, P_NAME))) {
357
+      foreach ($planet_unit_list as $unit_id) {
358
+        if (!($unit_name = get_unit_param($unit_id, P_NAME))) {
359 359
           $unit_name = $sn_data_aux[$unit_id][P_NAME];
360 360
         }
361
-        if(isset($update_tables['planets'][$unit_name])) {
361
+        if (isset($update_tables['planets'][$unit_name])) {
362 362
           $drop[] = "DROP COLUMN `{$unit_name}`";
363 363
 
364
-          if(isset($aux_group[$unit_id])) {
364
+          if (isset($aux_group[$unit_id])) {
365 365
             $units_info[$unit_id] = $sn_data_aux[$unit_id];
366 366
             $units_info[$unit_id]['que'] = QUE_HANGAR;
367 367
           } else {
368 368
             $units_info[$unit_id] = get_unit_param($unit_id);
369
-            foreach($ques_info as $que_id => $que_data1) {
370
-              if(in_array($unit_id, $que_data1['unit_list'])) {
369
+            foreach ($ques_info as $que_id => $que_data1) {
370
+              if (in_array($unit_id, $que_data1['unit_list'])) {
371 371
                 $units_info[$unit_id]['que'] = $que_id;
372 372
                 break;
373 373
               }
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
       }
378 378
 
379 379
       $query = upd_do_query("SELECT * FROM {{planets}} FOR UPDATE");
380
-      while($row = db_fetch($query)) {
380
+      while ($row = db_fetch($query)) {
381 381
         $user_id = $row['id_owner'];
382 382
         $planet_id = $row['id'];
383 383
 
@@ -385,14 +385,14 @@  discard block
 block discarded – undo
385 385
 
386 386
         // Конвертируем юниты
387 387
         $units_levels = array();
388
-        foreach($planet_unit_list as $unit_id) {
388
+        foreach ($planet_unit_list as $unit_id) {
389 389
           $unit_name = &$units_info[$unit_id][P_NAME];
390
-          if(!isset($row[$unit_name]) || !$row[$unit_name]) {
390
+          if (!isset($row[$unit_name]) || !$row[$unit_name]) {
391 391
             continue;
392 392
           }
393 393
           $units_levels[$unit_id] = $row[$unit_name];
394 394
           $unit_data[] = "({$user_id}," . LOC_PLANET . ",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})";
395
-          if(count($unit_data) > 30) {
395
+          if (count($unit_data) > 30) {
396 396
             $unit_data_max = strlen(implode(',', $unit_data)) > $unit_data_max ? strlen(implode(',', $unit_data)) : $unit_data_max;
397 397
             upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';');
398 398
             $unit_data = array();
@@ -400,10 +400,10 @@  discard block
 block discarded – undo
400 400
         }
401 401
 
402 402
         // Конвертируем очередь построек
403
-        if($row['que']) {
403
+        if ($row['que']) {
404 404
           $que = explode(';', $row['que']);
405
-          foreach($que as $que_item) {
406
-            if(!$que_item) {
405
+          foreach ($que as $que_item) {
406
+            if (!$que_item) {
407 407
               continue;
408 408
             }
409 409
 
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
             $unit_factor = $unit_cost[P_FACTOR] ? $unit_cost[P_FACTOR] : 1;
419 419
             $price_increase = pow($unit_factor, $unit_level);
420 420
             // $unit_time = 0;
421
-            foreach($unit_cost as $resource_id => &$resource_amount) {
422
-              if(!in_array($resource_id, $group_resource_loot)) {
421
+            foreach ($unit_cost as $resource_id => &$resource_amount) {
422
+              if (!in_array($resource_id, $group_resource_loot)) {
423 423
                 unset($unit_cost[$resource_id]);
424 424
                 continue;
425 425
               }
@@ -433,38 +433,38 @@  discard block
 block discarded – undo
433 433
         }
434 434
 
435 435
         // Конвертируем очередь верфи
436
-        if($row['b_hangar_id']) {
436
+        if ($row['b_hangar_id']) {
437 437
           $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0,);
438 438
           $hangar_units = sys_unit_str2arr($row['b_hangar_id']);
439
-          foreach($hangar_units as $unit_id => $unit_count) {
440
-            if($unit_count <= 0) {
439
+          foreach ($hangar_units as $unit_id => $unit_count) {
440
+            if ($unit_count <= 0) {
441 441
               continue;
442 442
             }
443
-            foreach($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) {
444
-              if(!in_array($resource_id, $group_resource_loot)) {
443
+            foreach ($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) {
444
+              if (!in_array($resource_id, $group_resource_loot)) {
445 445
                 continue;
446 446
               }
447 447
               $return_resources[$resource_id] += $unit_count * $resource_amount;
448 448
             }
449 449
           }
450
-          if(array_sum($return_resources) > 0) {
450
+          if (array_sum($return_resources) > 0) {
451 451
             upd_do_query("UPDATE {{planets}} SET `metal` = `metal` + {$return_resources[RES_METAL]}, `crystal` = `crystal` + {$return_resources[RES_CRYSTAL]}, `deuterium` = `deuterium` + {$return_resources[RES_DEUTERIUM]} WHERE `id` = {$planet_id} LIMIT 1");
452 452
           }
453 453
         }
454 454
 
455 455
 
456
-        if(count($que_data) > 10) {
456
+        if (count($que_data) > 10) {
457 457
           $que_data_max = strlen(implode(',', $que_data)) > $que_data_max ? strlen(implode(',', $que_data)) : $que_data_max;
458 458
           upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_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_data) . ';');
459 459
           $que_data = array();
460 460
         }
461 461
       }
462 462
 
463
-      if(!empty($unit_data)) {
463
+      if (!empty($unit_data)) {
464 464
         upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';');
465 465
       }
466 466
 
467
-      if(!empty($que_data)) {
467
+      if (!empty($que_data)) {
468 468
         upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_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_data) . ';');
469 469
       }
470 470
 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
       JOIN `{{users}}` AS u ON a.`id` = u.`user_as_ally` AND `user_as_ally` IS NOT NULL AND `username` = ''
476 476
       SET u.`username` = CONCAT('[', a.`ally_tag`, ']');");
477 477
 
478
-    if($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') {
478
+    if ($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') {
479 479
       upd_do_query("SET FOREIGN_KEY_CHECKS=0;");
480 480
       upd_alter_table('statpoints', "DROP FOREIGN KEY `FK_stats_id_ally`", $update_foreigns['statpoints']['FK_stats_id_ally']);
481 481
       upd_alter_table('statpoints', "DROP KEY `I_stats_id_ally`", $update_indexes['statpoints']['I_stats_id_ally']);
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
       "ADD CONSTRAINT `FK_users_browser_id` FOREIGN KEY (`user_last_browser_id`) REFERENCES `{{security_browser}}` (`browser_id`) ON DELETE SET NULL ON UPDATE CASCADE",
572 572
     ), !isset($update_tables['users']['user_last_proxy']));
573 573
 
574
-    if(!isset($update_tables['notes']['planet_type'])) {
574
+    if (!isset($update_tables['notes']['planet_type'])) {
575 575
       upd_alter_table('notes', array(
576 576
         "ADD COLUMN `galaxy` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `title`",
577 577
         "ADD COLUMN `system` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `galaxy`",
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
     upd_alter_table('users', "ADD COLUMN `user_bot` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['users']['user_bot']));
590 590
     upd_alter_table('unit', "ADD KEY `I_unit_type_snid` (unit_type, unit_snid) USING BTREE", !$update_indexes['unit']['I_unit_type_snid']);
591 591
 
592
-    if($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') {
592
+    if ($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') {
593 593
       upd_alter_table('users', array(
594 594
         "MODIFY COLUMN `settings_tooltiptime` smallint(5) unsigned NOT NULL DEFAULT '500'",
595 595
       ), $update_tables['users']['settings_tooltiptime']['Type'] != 'smallint');
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
       upd_do_query("UPDATE `{{users}}` SET settings_tooltiptime = 500;");
598 598
     }
599 599
 
600
-    if(!isset($update_tables['log_users_online']['online_aggregated'])) {
600
+    if (!isset($update_tables['log_users_online']['online_aggregated'])) {
601 601
       upd_alter_table('log_users_online', "ADD COLUMN `online_aggregated` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['log_users_online']['online_aggregated']));
602 602
       upd_alter_table('log_users_online', array(
603 603
         "DROP PRIMARY KEY",
@@ -605,13 +605,13 @@  discard block
 block discarded – undo
605 605
       ), $update_indexes['log_users_online']['PRIMARY'] != 'online_timestamp,online_aggregated,');
606 606
     }
607 607
 
608
-    if(!isset($update_tables['users']['gender'])) {
608
+    if (!isset($update_tables['users']['gender'])) {
609 609
       upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT " . GENDER_UNKNOWN, !isset($update_tables['users']['gender']));
610 610
       upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE . ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));");
611 611
     }
612 612
     upd_alter_table('users', "DROP COLUMN `sex`", isset($update_tables['users']['sex']));
613 613
 
614
-    if(!$update_tables['users']['dark_matter_total']) {
614
+    if (!$update_tables['users']['dark_matter_total']) {
615 615
       upd_alter_table('users', "ADD `dark_matter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Dark Matter amount ever gained' AFTER `dark_matter`", !$update_tables['users']['dark_matter_total']);
616 616
       upd_do_query(
617 617
         "UPDATE `{{users}}` AS u
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
     }
625 625
 
626 626
     upd_check_key('player_metamatter_immortal', 100000, !isset(classSupernova::$config->player_metamatter_immortal));
627
-    if(!$update_tables['users']['metamatter_total']) {
627
+    if (!$update_tables['users']['metamatter_total']) {
628 628
       upd_alter_table('users', "ADD `metamatter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Metamatter amount ever bought'", !$update_tables['users']['metamatter_total']);
629 629
 
630 630
       upd_do_query(
@@ -636,11 +636,11 @@  discard block
 block discarded – undo
636 636
             (SELECT IF(sum(amount) IS NULL, 0, sum(amount)) FROM {{log_metamatter}} AS mm WHERE mm.user_id = u.id AND mm.amount > 0)
637 637
           );");
638 638
     }
639
-    if(!isset($update_tables['users']['immortal'])) {
639
+    if (!isset($update_tables['users']['immortal'])) {
640 640
       upd_alter_table('users', "ADD COLUMN `immortal` TIMESTAMP NULL", !isset($update_tables['users']['immortal']));
641 641
       upd_do_query("UPDATE {{users}} SET `immortal` = NOW() WHERE `metamatter_total` > 0;");
642 642
     }
643
-    if(isset($update_tables['player_award'])) {
643
+    if (isset($update_tables['player_award'])) {
644 644
       upd_do_query(
645 645
         "UPDATE {{users}} AS u JOIN {{player_award}} AS pa ON u.id = pa.player_id
646 646
           SET metamatter_total = 1, immortal = NOW()
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
       CONSTRAINT `FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
668 668
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
669 669
 
670
-    if(empty($update_tables['blitz_statpoints'])) {
670
+    if (empty($update_tables['blitz_statpoints'])) {
671 671
       upd_create_table('blitz_statpoints', " (
672 672
         `stat_date` int(11) NOT NULL DEFAULT '0',
673 673
         `id_owner` bigint(20) unsigned DEFAULT NULL,
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
       CONSTRAINT `FK_survey_votes_survey_parent_id` FOREIGN KEY (`survey_parent_id`) REFERENCES `{{survey}}` (`survey_id`) ON DELETE CASCADE ON UPDATE CASCADE
736 736
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
737 737
 
738
-    if(empty($update_tables['security_url'])) {
738
+    if (empty($update_tables['security_url'])) {
739 739
       upd_create_table('security_url', " (
740 740
         `url_id` int unsigned NOT NULL AUTO_INCREMENT,
741 741
         `url_string` VARCHAR(250) NOT NULL DEFAULT '',
@@ -748,9 +748,9 @@  discard block
 block discarded – undo
748 748
 
749 749
         $strings = array();
750 750
         $query = classSupernova::$db->doSql($query);
751
-        while($row = db_fetch($query)) {
751
+        while ($row = db_fetch($query)) {
752 752
           $strings[] = '("' . db_escape($row['url']) . '")';
753
-          if(count($strings) > 100) {
753
+          if (count($strings) > 100) {
754 754
             classSupernova::$db->doSql($query_string . implode(',', $strings));
755 755
             $strings = array();
756 756
           }
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
         !empty($strings) ? classSupernova::$db->doSql($query_string . implode(',', $strings)) : false;
759 759
       }
760 760
 
761
-      if(isset($update_tables['counter']['page'])) // TODO REMOVE
761
+      if (isset($update_tables['counter']['page'])) // TODO REMOVE
762 762
       {
763 763
         update_security_url("SELECT DISTINCT `page` AS url FROM {{counter}}");
764 764
         update_security_url("SELECT DISTINCT `url` AS url FROM {{counter}}");
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
       "ADD CONSTRAINT `FK_counter_page_url_id` FOREIGN KEY (`page_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE",
784 784
       "ADD CONSTRAINT `FK_counter_plain_url_id` FOREIGN KEY (`plain_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE",
785 785
     ), !isset($update_tables['counter']['device_id']));
786
-    if(isset($update_tables['counter']['ip'])) {
786
+    if (isset($update_tables['counter']['ip'])) {
787 787
       // upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `user_proxy` = `proxy`, `visit_time` = FROM_UNIXTIME(`time`)');
788 788
       upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `visit_time` = FROM_UNIXTIME(`time`)');
789 789
       upd_do_query('UPDATE `{{counter}}` AS c JOIN {{security_url}} AS u ON u.url_string = c.page SET c.page_url_id = u.url_id');
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 
835 835
     upd_check_key('stats_history_days', 14, !classSupernova::$config->stats_history_days);
836 836
 
837
-    if(classSupernova::$config->payment_currency_default != 'USD') {
837
+    if (classSupernova::$config->payment_currency_default != 'USD') {
838 838
       upd_check_key('payment_currency_default', 'USD', true);
839 839
       upd_check_key('payment_currency_exchange_dm_', 20000, true);
840 840
       upd_check_key('payment_currency_exchange_mm_', 20000, true);
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
     function propagade_player_options($old_option_name, $new_option_id) {
918 918
       global $update_tables;
919 919
 
920
-      if(!empty($update_tables['users'][$old_option_name])) {
920
+      if (!empty($update_tables['users'][$old_option_name])) {
921 921
         upd_do_query(
922 922
           "REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`)
923 923
           SELECT `id`, {$new_option_id}, `{$old_option_name}`
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
 
952 952
 
953 953
     // 2015-08-03 15:05:26 40a6.0
954
-    if(empty($update_tables['planets']['position_original'])) {
954
+    if (empty($update_tables['planets']['position_original'])) {
955 955
       upd_alter_table('planets', array(
956 956
         "ADD COLUMN `position_original` smallint NOT NULL DEFAULT 0",
957 957
         "ADD COLUMN `field_max_original` smallint NOT NULL DEFAULT 0",
@@ -979,12 +979,12 @@  discard block
 block discarded – undo
979 979
 
980 980
     // 2015-08-27 19:14:05 40a10.0
981 981
     // Старая версия таблицы
982
-    if(!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) {
982
+    if (!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) {
983 983
       upd_drop_table('account');
984 984
       upd_drop_table('account_translate');
985 985
     }
986 986
 
987
-    if(empty($update_tables['account'])) {
987
+    if (empty($update_tables['account'])) {
988 988
       upd_create_table('account', " (
989 989
           `account_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
990 990
           `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '',
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 
1047 1047
 
1048 1048
     // 2015-09-24 11:39:37 40a10.25
1049
-    if(empty($update_tables['log_metamatter']['provider_id'])) {
1049
+    if (empty($update_tables['log_metamatter']['provider_id'])) {
1050 1050
       upd_alter_table('log_metamatter', array(
1051 1051
         "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider'",
1052 1052
         "ADD COLUMN `account_id` bigint(20) unsigned NOT NULL DEFAULT 0",
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
     upd_check_key('event_halloween_2015_code', '', !isset(classSupernova::$config->event_halloween_2015_code));
1099 1099
     upd_check_key('event_halloween_2015_timestamp', SN_TIME_SQL, !isset(classSupernova::$config->event_halloween_2015_timestamp));
1100 1100
     upd_check_key('event_halloween_2015_units_used', serialize(array()), !isset(classSupernova::$config->event_halloween_2015_units_used));
1101
-    if(empty($update_tables['log_halloween_2015'])) {
1101
+    if (empty($update_tables['log_halloween_2015'])) {
1102 1102
       upd_create_table('log_halloween_2015', " (
1103 1103
       `log_hw2015_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1104 1104
       `player_id` bigint(20) unsigned NOT NULL COMMENT 'User ID',
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 
1114 1114
 
1115 1115
     // 2015-11-28 06:30:27 40a19.21
1116
-    if(!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) {
1116
+    if (!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) {
1117 1117
       upd_alter_table('ube_report', array(
1118 1118
         "ADD COLUMN `ube_report_debris_total_in_metal` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Total debris in metal'",
1119 1119
         "ADD KEY `I_ube_report_time_debris_id` (`ube_report_time_process` DESC, `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC)", // For Best Battles module
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 
1129 1129
 
1130 1130
     // 2015-12-06 15:10:58 40b1.0
1131
-    if(!empty($update_indexes['planets']['I_metal_mine'])) {
1131
+    if (!empty($update_indexes['planets']['I_metal_mine'])) {
1132 1132
       upd_alter_table('planets', "DROP KEY `I_metal`", $update_indexes['planets']['I_metal']);
1133 1133
       upd_alter_table('planets', "DROP KEY `I_ship_sattelite_sloth`", $update_indexes['planets']['I_ship_sattelite_sloth']);
1134 1134
       upd_alter_table('planets', "DROP KEY `I_ship_bomber_envy`", $update_indexes['planets']['I_ship_bomber_envy']);
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
   case 40:
1192 1192
     upd_log_version_update();
1193 1193
 
1194
-    if(empty($update_tables['festival'])) {
1194
+    if (empty($update_tables['festival'])) {
1195 1195
       upd_create_table('festival', " (
1196 1196
           `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
1197 1197
           `start` datetime NOT NULL COMMENT 'Festival start datetime',
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
       );
1233 1233
     }
1234 1234
 
1235
-    if(empty($update_tables['festival_unit'])) {
1235
+    if (empty($update_tables['festival_unit'])) {
1236 1236
       upd_create_table('festival_unit', " (
1237 1237
           `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1238 1238
           `highspot_id` int(10) unsigned DEFAULT NULL,
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
     }
1250 1250
 
1251 1251
     // 2015-12-21 06:06:09 41a0.12
1252
-    if(empty($update_tables['festival_unit_log'])) {
1252
+    if (empty($update_tables['festival_unit_log'])) {
1253 1253
       upd_create_table('festival_unit_log', " (
1254 1254
           `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1255 1255
           `highspot_id` int(10) unsigned DEFAULT NULL,
@@ -1279,16 +1279,16 @@  discard block
 block discarded – undo
1279 1279
       $update_tables['security_browser']['browser_user_agent']['Collation'] == 'latin1_bin'
1280 1280
     );
1281 1281
 
1282
-    if($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') {
1282
+    if ($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') {
1283 1283
       upd_alter_table('security_browser', "DROP KEY `I_browser_user_agent`", true);
1284 1284
       upd_alter_table('security_browser', "ADD KEY `I_browser_user_agent` (`browser_user_agent`) USING HASH", true);
1285 1285
     }
1286 1286
 
1287
-    if(!empty($update_tables['fleets']['fleet_array'])) {
1287
+    if (!empty($update_tables['fleets']['fleet_array'])) {
1288 1288
       $query = upd_do_query("SELECT * FROM {{fleets}}");
1289
-      while($row = db_fetch($query)) {
1289
+      while ($row = db_fetch($query)) {
1290 1290
         $unit_list = sys_unit_str2arr($row['fleet_array']);
1291
-        foreach($unit_list as $unit_id => $unit_count) {
1291
+        foreach ($unit_list as $unit_id => $unit_count) {
1292 1292
           upd_do_query(
1293 1293
             "REPLACE INTO {{unit}} (`unit_player_id`,`unit_location_type`,`unit_location_id`,`unit_type`,`unit_snid`,`unit_level`) VALUES
1294 1294
               ({$row['fleet_owner']}, " . LOC_FLEET . ", {$row['fleet_id']}, 200, {$unit_id}, {$unit_count});",
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
 
1326 1326
 classSupernova::$cache->unset_by_prefix('lng_');
1327 1327
 
1328
-if($new_version) {
1328
+if ($new_version) {
1329 1329
   classSupernova::$config->db_saveItem('db_version', $new_version);
1330 1330
   upd_log_message("<font color=green>DB version is now {$new_version}</font>");
1331 1331
 } else {
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -758,9 +758,11 @@
 block discarded – undo
758 758
         !empty($strings) ? classSupernova::$db->doSql($query_string . implode(',', $strings)) : false;
759 759
       }
760 760
 
761
-      if(isset($update_tables['counter']['page'])) // TODO REMOVE
761
+      if(isset($update_tables['counter']['page'])) {
762
+        // TODO REMOVE
762 763
       {
763 764
         update_security_url("SELECT DISTINCT `page` AS url FROM {{counter}}");
765
+      }
764 766
         update_security_url("SELECT DISTINCT `url` AS url FROM {{counter}}");
765 767
       }
766 768
     }
Please login to merge, or discard this patch.
includes/general_pname.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,8 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 // Эти функции будут переписаны по добавлению инфы в БД
4 4
 
5
-function pname_factory_production_field_name($factory_unit_id)
6
-{
5
+function pname_factory_production_field_name($factory_unit_id) {
7 6
   return get_unit_param($factory_unit_id, P_NAME) . '_porcent';
8 7
 }
9 8
 
@@ -14,7 +13,6 @@  discard block
 block discarded – undo
14 13
  *
15 14
  * @return mixed
16 15
  */
17
-function pname_resource_name($resource_id)
18
-{
16
+function pname_resource_name($resource_id) {
19 17
   return get_unit_param($resource_id, P_NAME);
20 18
 }
21 19
\ No newline at end of file
Please login to merge, or discard this patch.
includes/includes/flt_page4.inc 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,28 +7,28 @@  discard block
 block discarded – undo
7 7
 
8 8
 $classLocale = classLocale::$lang;
9 9
 
10
-if(SN_IN_FLEET !== true) {
10
+if (SN_IN_FLEET !== true) {
11 11
   classSupernova::$debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
12 12
 }
13 13
 
14 14
 $fleetid = sys_get_param_id('fleetid');
15 15
 
16
-if(!is_numeric($fleetid) || empty($fleetid)) {
16
+if (!is_numeric($fleetid) || empty($fleetid)) {
17 17
   header("Location: fleet.php");
18 18
   exit();
19 19
 }
20 20
 
21 21
 $objFleet = new Fleet();
22 22
 $objFleet->dbLoad($fleetid);
23
-if(!$objFleet->dbId) {
23
+if (!$objFleet->dbId) {
24 24
   message(classLocale::$lang['fl_fleet_not_exists'], classLocale::$lang['fl_error']);
25 25
 }
26 26
 
27
-if($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) {
27
+if ($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) {
28 28
   message(classLocale::$lang['fl_isback'], classLocale::$lang['fl_error']);
29 29
 }
30 30
 
31
-if($objFleet->playerOwnerId != $user['id']) {
31
+if ($objFleet->playerOwnerId != $user['id']) {
32 32
   classSupernova::$debug->warning(classLocale::$lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301);
33 33
   message(classLocale::$lang['fl_aks_hack_wrong_fleet'], classLocale::$lang['fl_error']);
34 34
 }
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
 
40 40
 !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false;
41 41
 
42
-if($userToAdd_unsafe) {
42
+if ($userToAdd_unsafe) {
43 43
   $userToAdd = db_escape($userToAdd_unsafe);
44 44
   $userToAddID = DBStaticUser::db_user_by_username($userToAdd_unsafe, false, 'id', true, true);
45 45
   $userToAddID = $userToAddID['id'];
46 46
 
47
-  if($objFleet->target_owner_id == $userToAddID) {
47
+  if ($objFleet->target_owner_id == $userToAddID) {
48 48
     message(classLocale::$lang['flt_aks_player_same'], classLocale::$lang['fl_error']);
49 49
   }
50 50
 
51
-  if($userToAddID) {
52
-    if(!$aks) {
51
+  if ($userToAddID) {
52
+    if (!$aks) {
53 53
       // No AСS exists - making one
54
-      if(!$objFleet->group_id) {
54
+      if (!$objFleet->group_id) {
55 55
         DBStaticFleetACS::db_acs_insert($fleetid, $user['id'], $objFleet);
56 56
 
57 57
         $aks = DBStaticFleetACS::db_acs_get_by_fleet($fleetid);
@@ -66,21 +66,21 @@  discard block
 block discarded – undo
66 66
 
67 67
     $isUserExists = false;
68 68
     $invited_ar = explode(",", $aks['eingeladen']);
69
-    foreach($invited_ar as $inv) {
70
-      if($userToAddID == $inv) {
69
+    foreach ($invited_ar as $inv) {
70
+      if ($userToAddID == $inv) {
71 71
         $isUserExists = true;
72 72
       }
73 73
     }
74 74
 
75
-    if(count($invited_ar) >= 5) {
75
+    if (count($invited_ar) >= 5) {
76 76
       message(classLocale::$lang['flt_aks_error_too_much_players'], classLocale::$lang['fl_error']);
77 77
     }
78 78
 
79
-    if($isUserExists) {
79
+    if ($isUserExists) {
80 80
       $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited_already'], $userToAdd) : false;
81 81
     } else {
82 82
       $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited'], $userToAdd);
83
-      if(!(DBStaticFleetACS::db_acs_update($userToAddID, $fleetid))) {
83
+      if (!(DBStaticFleetACS::db_acs_update($userToAddID, $fleetid))) {
84 84
         die(sprintf(classLocale::$lang['fl_aks_adding_error'], classSupernova::$db->db_error()));
85 85
       }
86 86
       $aks['eingeladen'] .= ',' . $userToAddID;
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
   'MISSION_NAME' => classLocale::$lang['type_mission'][MT_ACS],
100 100
 ));
101 101
 
102
-if($aks['eingeladen'] && is_array($members = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
103
-  foreach($members as $row) {
102
+if ($aks['eingeladen'] && is_array($members = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
103
+  foreach ($members as $row) {
104 104
     $template->assign_block_vars('invited', array(
105 105
       'NAME' => $row['username'],
106 106
     ));
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 $fleet_data = tplParseFleetObject($objFleet, $i, $user);
126 126
 
127 127
 $template->assign_block_vars('fleets', $fleet_data['fleet']);
128
-foreach($fleet_data['ships'] as $ship_data) {
128
+foreach ($fleet_data['ships'] as $ship_data) {
129 129
   $template->assign_block_vars('fleets.ships', $ship_data);
130 130
 }
131 131
 
Please login to merge, or discard this patch.
includes/includes/market_fleeter.inc 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 
6 6
 $classLocale = classLocale::$lang;
7 7
 
8
-if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) {
8
+if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) {
9 9
   classSupernova::$debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403);
10 10
 }
11 11
 
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
   'rpg_cost' => $rpg_cost,
18 18
 ));
19 19
 
20
-if(is_array($shipList)) {
21
-  if(mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) {
20
+if (is_array($shipList)) {
21
+  if (mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) {
22 22
     $intError = MARKET_NO_DM;
23 23
   }
24 24
 
@@ -33,30 +33,30 @@  discard block
 block discarded – undo
33 33
 
34 34
   $message .= classLocale::$lang["eco_mrk_{$submode}_ships"] . '<ul>';
35 35
   $total = array();
36
-  foreach($shipList as $shipID => &$shipCount) {
36
+  foreach ($shipList as $shipID => &$shipCount) {
37 37
     $shipCount = ceil(floatval($shipCount));
38
-    if(!$shipCount) {
38
+    if (!$shipCount) {
39 39
       continue;
40 40
     }
41 41
 
42
-    if($shipCount < 0) {
42
+    if ($shipCount < 0) {
43 43
       classSupernova::$debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307);
44 44
       $intError = MARKET_NEGATIVE_SHIPS;
45 45
       break;
46 46
     }
47 47
 
48
-    if($mode == MARKET_SCRAPPER) {
48
+    if ($mode == MARKET_SCRAPPER) {
49 49
       $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)];
50
-    } elseif($mode == MARKET_STOCKMAN) {
50
+    } elseif ($mode == MARKET_STOCKMAN) {
51 51
       $amount = $stock[$shipID];
52 52
     }
53 53
 
54
-    if($amount < $shipCount) {
54
+    if ($amount < $shipCount) {
55 55
       $intError = $error_no_stock;
56 56
       break;
57 57
     }
58 58
 
59
-    if(!in_array($shipID, classSupernova::$gc->groupFleet)) {
59
+    if (!in_array($shipID, classSupernova::$gc->groupFleet)) {
60 60
       classSupernova::$debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306);
61 61
       $intError = MARKET_NOT_A_SHIP;
62 62
       break;
@@ -72,16 +72,16 @@  discard block
 block discarded – undo
72 72
     $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier));
73 73
     $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier));
74 74
 
75
-    foreach($resTemp as $resID => $resCount) {
75
+    foreach ($resTemp as $resID => $resCount) {
76 76
       $total[$resID] += $resCount;
77 77
     }
78 78
 
79 79
     $message .= "<li>{$classLocale['tech'][$shipID]}: " . pretty_number($shipCount);
80 80
   }
81 81
 
82
-  if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) {
83
-    foreach($total as $resID => $resCount) {
84
-      if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) {
82
+  if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) {
83
+    foreach ($total as $resID => $resCount) {
84
+      if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) {
85 85
         $intError = MARKET_NO_RESOURCES;
86 86
         classSupernova::$debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301);
87 87
         break;
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
   $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError;
93 93
 
94 94
   $qry = array();
95
-  if($intError == MARKET_DEAL) {
95
+  if ($intError == MARKET_DEAL) {
96 96
     $message .= '</ul>' . classLocale::$lang["eco_mrk_{$submode}_res"] . '<ul>';
97
-    foreach($total as $resID => $resCount) {
98
-      if(!$resCount) {
97
+    foreach ($total as $resID => $resCount) {
98
+      if (!$resCount) {
99 99
         continue;
100 100
       }
101 101
 
@@ -128,38 +128,38 @@  discard block
 block discarded – undo
128 128
       'MESSAGE' => classLocale::$lang['eco_mrk_errors'][$intError],
129 129
     ));
130 130
 
131
-    foreach($shipList as $shipID => $shipCount) {
131
+    foreach ($shipList as $shipID => $shipCount) {
132 132
       $data['ships'][$shipID] = max(0, intval($shipCount));
133 133
     }
134 134
   }
135 135
 }
136 136
 $message = '';
137 137
 
138
-if(!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) {
139
-  classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, classSupernova::$gc->groupFleet)));
138
+if (!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) {
139
+  classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, classSupernova::$gc->groupFleet)));
140 140
 }
141 141
 
142 142
 tpl_set_resource_info($template, $planetrow, array());
143 143
 
144
-if(!$array) {
144
+if (!$array) {
145 145
   $array = array();
146 146
 }
147 147
 
148 148
 $group_fleet = classSupernova::$gc->groupFleet;
149
-foreach($array as $key => $value) {
150
-  if($mode == MARKET_SCRAPPER) {
149
+foreach ($array as $key => $value) {
150
+  if ($mode == MARKET_SCRAPPER) {
151 151
     $shipID = $value;
152 152
     $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)];
153
-  } elseif($mode == MARKET_STOCKMAN) {
153
+  } elseif ($mode == MARKET_STOCKMAN) {
154 154
     $shipID = $key;
155 155
     $amount = $value;
156 156
   }
157 157
 
158
-  if(!in_array($shipID, $group_fleet)) {
158
+  if (!in_array($shipID, $group_fleet)) {
159 159
     continue;
160 160
   }
161 161
 
162
-  if($amount > 0) {
162
+  if ($amount > 0) {
163 163
     $build_data = eco_get_build_data($user, $planetrow, $shipID);
164 164
     $template->assign_block_vars('ships', array(
165 165
       'ID'        => $shipID,
Please login to merge, or discard this patch.