Completed
Push — work-fleets ( 03d1ea...77506a )
by SuperNova.WS
05:17
created
includes/vars_structures.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
       'factor' => 1.5,
16 16
     ),
17 17
     P_UNIT_PRODUCTION => array(
18
-      RES_METAL     => function ($level, $production_factor, $user, $planet_row) {return  40 * $level * pow(1.1, $level) * (0.1 * $production_factor);},
19
-      RES_ENERGY    => function ($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor);},
18
+      RES_METAL     => function($level, $production_factor, $user, $planet_row) {return  40 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
19
+      RES_ENERGY    => function($level, $production_factor, $user, $planet_row) {return -13 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
20 20
     ),
21 21
     P_MINING_IS_MANAGED => true,
22 22
   ),
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
       'factor' => 1.6,
34 34
     ),
35 35
     P_UNIT_PRODUCTION => array(
36
-      RES_CRYSTAL   => function ($level, $production_factor, $user, $planet_row) {return  32 * $level * pow(1.1, $level) * (0.1 * $production_factor);},
37
-      RES_ENERGY    => function ($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor);},
36
+      RES_CRYSTAL   => function($level, $production_factor, $user, $planet_row) {return  32 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
37
+      RES_ENERGY    => function($level, $production_factor, $user, $planet_row) {return -16 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
38 38
     ),
39 39
     P_MINING_IS_MANAGED => true,
40 40
   ),
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
       'factor' => 1.5,
52 52
     ),
53 53
     P_UNIT_PRODUCTION => array(
54
-      RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return  10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28);},
55
-      RES_ENERGY    => function ($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor);},
54
+      RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return  10 * $level * pow(1.1, $level) * (0.1 * $production_factor) * (-0.002 * $planet_row["temp_max"] + 1.28); },
55
+      RES_ENERGY    => function($level, $production_factor, $user, $planet_row) {return -20 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
56 56
     ),
57 57
     P_MINING_IS_MANAGED => true,
58 58
   ),
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
       'factor' => 1.5,
70 70
     ),
71 71
     P_UNIT_PRODUCTION => array(
72
-      RES_ENERGY    => function ($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor);},
72
+      RES_ENERGY    => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 5 + 15) * $level * pow(1.1, $level) * (0.1 * $production_factor); },
73 73
     ),
74 74
     P_MINING_IS_MANAGED => true,
75 75
   ),
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
       'factor' => 1.8,
88 88
     ),
89 89
     P_UNIT_PRODUCTION => array(
90
-      RES_DEUTERIUM => function ($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor);},
91
-      RES_ENERGY    => function ($level, $production_factor, $user, $planet_row) {return  30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, null, TECH_ENERGY), $level) * (0.1 * $production_factor);},
90
+      RES_DEUTERIUM => function($level, $production_factor, $user, $planet_row) {return -10 * $level * pow(1.1, $level) * (0.1 * $production_factor); },
91
+      RES_ENERGY    => function($level, $production_factor, $user, $planet_row) {return  30 * $level * pow(1.05 + 0.01 * mrc_get_level($user, null, TECH_ENERGY), $level) * (0.1 * $production_factor); },
92 92
     ),
93 93
     P_MINING_IS_MANAGED => true,
94 94
   ),
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
       'factor' => 2,
106 106
     ),
107 107
     'storage' => array(
108
-      RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);},
108
+      RES_METAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); },
109 109
     ),
110 110
   ),
111 111
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
       'factor' => 2,
122 122
     ),
123 123
     'storage' => array(
124
-      RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);},
124
+      RES_CRYSTAL => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); },
125 125
     ),
126 126
   ),
127 127
 
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
       'factor' => 2,
138 138
     ),
139 139
     'storage' => array(
140
-      RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level);},
140
+      RES_DEUTERIUM => function($level) {return BASE_STORAGE_SIZE * pow(1.5, $level); },
141 141
     ),
142 142
   ),
143 143
 
Please login to merge, or discard this patch.
includes/db/db_queries_planets.php 1 patch
Spacing   +12 added lines, -13 removed lines patch added patch discarded remove patch
@@ -36,8 +36,7 @@  discard block
 block discarded – undo
36 36
   $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0;
37 37
   $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0;
38 38
   $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0;
39
-  $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) :
40
-    (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0);
39
+  $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) : (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0);
41 40
   $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type;
42 41
 
43 42
   return db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields);
@@ -45,7 +44,7 @@  discard block
 block discarded – undo
45 44
 
46 45
 function db_planet_by_parent($parent_id, $for_update = false, $fields = '*') {
47 46
   //if(!($parent_id = intval($parent_id))) return false;
48
-  if(!($parent_id = idval($parent_id))) {
47
+  if (!($parent_id = idval($parent_id))) {
49 48
     return false;
50 49
   }
51 50
 
@@ -55,7 +54,7 @@  discard block
 block discarded – undo
55 54
 
56 55
 function db_planet_by_id_and_owner($planet_id, $owner_id, $for_update = false, $fields = '*') {
57 56
   //if(!($planet_id = intval($planet_id)) || !($owner_id = intval($owner_id))) return false;
58
-  if(!($planet_id = idval($planet_id)) || !($owner_id = idval($owner_id))) {
57
+  if (!($planet_id = idval($planet_id)) || !($owner_id = idval($owner_id))) {
59 58
     return false;
60 59
   }
61 60
 
@@ -66,7 +65,7 @@  discard block
 block discarded – undo
66 65
 
67 66
 function db_planet_list_moon_other($user_id, $this_moon_id) {
68 67
   // if(!($user_id = intval($user_id)) || !($this_moon_id = intval($this_moon_id))) return false;
69
-  if(!($user_id = idval($user_id)) || !($this_moon_id = idval($this_moon_id))) {
68
+  if (!($user_id = idval($user_id)) || !($this_moon_id = idval($this_moon_id))) {
70 69
     return false;
71 70
   }
72 71
 
@@ -83,7 +82,7 @@  discard block
 block discarded – undo
83 82
 }
84 83
 
85 84
 function db_planet_list_sorted($user_row, $skip_planet_id = false, $field_list = '', $conditions = '') {
86
-  if(!is_array($user_row)) {
85
+  if (!is_array($user_row)) {
87 86
     return false;
88 87
   }
89 88
   // $field_list = $field_list != '*' ? "{{planets}}.`id`, `name`, `image`, {{planets}}.`galaxy`, {{planets}}.`system`, {{planets}}.`planet`, `planet_type`{$field_list}" : $field_list;
@@ -105,7 +104,7 @@  discard block
 block discarded – undo
105 104
 }
106 105
 
107 106
 function db_planet_list_by_user_or_planet($user_id, $planet_id) {
108
-  if(!($user_id = idval($user_id)) && !($planet_id = idval($planet_id))) {
107
+  if (!($user_id = idval($user_id)) && !($planet_id = idval($planet_id))) {
109 108
     return false;
110 109
   }
111 110
 
@@ -115,7 +114,7 @@  discard block
 block discarded – undo
115 114
 
116 115
 function db_planet_set_by_id($planet_id, $set) {
117 116
   // if(!($planet_id = intval($planet_id))) return false;
118
-  if(!($planet_id = idval($planet_id))) {
117
+  if (!($planet_id = idval($planet_id))) {
119 118
     return false;
120 119
   }
121 120
 
@@ -123,7 +122,7 @@  discard block
 block discarded – undo
123 122
 }
124 123
 
125 124
 function db_planet_set_by_gspt($ui_galaxy, $ui_system, $ui_planet, $ui_planet_type = PT_ALL, $set) {
126
-  if(!($set = trim($set))) {
125
+  if (!($set = trim($set))) {
127 126
     return false;
128 127
   }
129 128
 
@@ -137,7 +136,7 @@  discard block
 block discarded – undo
137 136
 
138 137
 function db_planet_set_by_parent($ui_parent_id, $ss_set) {
139 138
   //if(!($si_parent_id = intval($ui_parent_id)) || !($ss_set = trim($ss_set))) return false;
140
-  if(!($si_parent_id = idval($ui_parent_id)) || !($ss_set = trim($ss_set))) {
139
+  if (!($si_parent_id = idval($ui_parent_id)) || !($ss_set = trim($ss_set))) {
141 140
     return false;
142 141
   }
143 142
 
@@ -146,7 +145,7 @@  discard block
 block discarded – undo
146 145
 
147 146
 function db_planet_set_by_owner($ui_owner_id, $ss_set) {
148 147
   //if(!($si_owner_id = intval($ui_owner_id)) || !($ss_set = trim($ss_set))) return false;
149
-  if(!($si_owner_id = idval($ui_owner_id)) || !($ss_set = trim($ss_set))) {
148
+  if (!($si_owner_id = idval($ui_owner_id)) || !($ss_set = trim($ss_set))) {
150 149
     return false;
151 150
   }
152 151
 
@@ -156,7 +155,7 @@  discard block
 block discarded – undo
156 155
 
157 156
 function db_planet_delete_by_id($planet_id) {
158 157
   // if(!($planet_id = intval($planet_id))) return false;
159
-  if(!($planet_id = idval($planet_id))) {
158
+  if (!($planet_id = idval($planet_id))) {
160 159
     return false;
161 160
   }
162 161
   classSupernova::db_del_record_by_id(LOC_PLANET, $planet_id);
@@ -168,7 +167,7 @@  discard block
 block discarded – undo
168 167
 
169 168
 function db_planet_list_delete_by_owner($ui_owner_id) {
170 169
   // if(!($si_owner_id = intval($ui_owner_id))) return false;
171
-  if(!($si_owner_id = idval($ui_owner_id))) {
170
+  if (!($si_owner_id = idval($ui_owner_id))) {
172 171
     return false;
173 172
   }
174 173
   classSupernova::db_del_record_list(LOC_PLANET, "`id_owner` = {$si_owner_id}");
Please login to merge, or discard this patch.
search.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 include('common.' . substr(strrchr(__FILE__, '.'), 1));
14 14
 
15
-if(classSupernova::$config->game_mode == GAME_BLITZ) {
15
+if (classSupernova::$config->game_mode == GAME_BLITZ) {
16 16
   message(classLocale::$lang['sys_blitz_page_disabled'], classLocale::$lang['sys_error'], 'overview.php', 10);
17 17
   die();
18 18
 }
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 
26 26
 $template = gettemplate('search', true);
27 27
 
28
-if($searchtext && $type) {
29
-  switch($type) {
28
+if ($searchtext && $type) {
29
+  switch ($type) {
30 30
     case "planetname":
31 31
       // $search = db_planet_list_search($searchtext);
32 32
     break;
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
     break;
42 42
   }
43 43
 
44
-  while($row = db_fetch($search)) {
45
-    if($type == 'playername' || $type == 'planetname') {
44
+  while ($row = db_fetch($search)) {
45
+    if ($type == 'playername' || $type == 'planetname') {
46 46
       $template->assign_block_vars('search_result', array(
47 47
         'PLAYER_ID'       => $row['uid'],
48 48
         'PLAYER_NAME'     => htmlentities($row['username'], ENT_COMPAT, 'UTF-8'),
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         'ALLY_NAME'       => htmlentities($row['ally_name'], ENT_COMPAT, 'UTF-8'),
58 58
         'ALLY_TAG'        => htmlentities($row['ally_tag'], ENT_COMPAT, 'UTF-8'),
59 59
       ));
60
-    } elseif($type == 'ally') {
60
+    } elseif ($type == 'ally') {
61 61
       $template->assign_block_vars('search_result', array(
62 62
         'ALLY_NAME'     => htmlentities($row['ally_name'], ENT_COMPAT, 'UTF-8'),
63 63
         'ALLY_TAG'      => htmlentities($row['ally_tag'], ENT_COMPAT, 'UTF-8'),
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
   'ally'       => 'sys_alliance',
76 76
 );
77 77
 
78
-foreach($search_type as $type_id => $type_lang) {
78
+foreach ($search_type as $type_id => $type_lang) {
79 79
   $template->assign_block_vars('type', array(
80 80
     'ID'       => $type_id,
81 81
     'TEXT'     => classLocale::$lang[$type_lang],
Please login to merge, or discard this patch.
includes/includes/user_birthday_celebrate.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
     'GROUP BY `unit_snid`'
27 27
   );
28 28
   $result = array();
29
-  while($row = db_fetch($query)) {
29
+  while ($row = db_fetch($query)) {
30 30
     $result[$row['unit_snid']] = $row;
31 31
   }
32 32
 
Please login to merge, or discard this patch.
includes/includes/upd_helpers.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('IN_UPDATE')) {
3
+if (!defined('IN_UPDATE')) {
4 4
   die('Trying to call update helpers externally!');
5 5
 }
6 6
 
@@ -8,13 +8,13 @@  discard block
 block discarded – undo
8 8
   global $update_tables;
9 9
 
10 10
   upd_add_more_time();
11
-  if(!$no_log) {
11
+  if (!$no_log) {
12 12
     upd_log_message("Performing query '{$query}'");
13 13
   }
14 14
 
15 15
   // classSupernova::$db->sn_db_connect();
16
-  if(!(strpos($query, '{{') === false)) {
17
-    foreach($update_tables as $tableName => $cork) {
16
+  if (!(strpos($query, '{{') === false)) {
17
+    foreach ($update_tables as $tableName => $cork) {
18 18
       $query = str_replace("{{{$tableName}}}", classSupernova::$db->db_prefix . $tableName, $query);
19 19
     }
20 20
   }
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
   global $sys_log_disabled;
28 28
 
29 29
   classSupernova::$config->db_loadItem($key);
30
-  if($condition || !isset(classSupernova::$config->$key)) {
30
+  if ($condition || !isset(classSupernova::$config->$key)) {
31 31
     upd_add_more_time();
32
-    if(!$sys_log_disabled) {
32
+    if (!$sys_log_disabled) {
33 33
       upd_log_message("Updating config key '{$key}' with value '{$default_value}'");
34 34
     }
35 35
     classSupernova::$config->db_saveItem($key, $default_value);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 function upd_log_message($message) {
58 58
   global $sys_log_disabled, $upd_log, $debug;
59 59
 
60
-  if($sys_log_disabled) {
60
+  if ($sys_log_disabled) {
61 61
 //    print("{$message}<br />");
62 62
   } else {
63 63
     $upd_log .= "{$message}\r\n";
@@ -68,15 +68,15 @@  discard block
 block discarded – undo
68 68
 function upd_unset_table_info($table_name) {
69 69
   global $update_tables, $update_indexes, $update_foreigns;
70 70
 
71
-  if(isset($update_tables[$table_name])) {
71
+  if (isset($update_tables[$table_name])) {
72 72
     unset($update_tables[$table_name]);
73 73
   }
74 74
 
75
-  if(isset($update_indexes[$table_name])) {
75
+  if (isset($update_indexes[$table_name])) {
76 76
     unset($update_indexes[$table_name]);
77 77
   }
78 78
 
79
-  if(isset($update_foreigns[$table_name])) {
79
+  if (isset($update_foreigns[$table_name])) {
80 80
     unset($update_foreigns[$table_name]);
81 81
   }
82 82
 }
@@ -90,18 +90,18 @@  discard block
 block discarded – undo
90 90
   upd_unset_table_info($tableName);
91 91
 
92 92
   $q1 = upd_do_query("SHOW FULL COLUMNS FROM {$prefix_table_name};", true);
93
-  while($r1 = db_fetch($q1)) {
93
+  while ($r1 = db_fetch($q1)) {
94 94
     $update_tables[$tableName][$r1['Field']] = $r1;
95 95
   }
96 96
 
97 97
   $q1 = upd_do_query("SHOW INDEX FROM {$prefix_table_name};", true);
98
-  while($r1 = db_fetch($q1)) {
98
+  while ($r1 = db_fetch($q1)) {
99 99
     $update_indexes[$tableName][$r1['Key_name']] .= "{$r1['Column_name']},";
100 100
     $update_indexes_full[$tableName][$r1['Key_name']][$r1['Column_name']] = $r1;
101 101
   }
102 102
 
103 103
   $q1 = upd_do_query("SELECT * FROM `information_schema`.`KEY_COLUMN_USAGE` WHERE `TABLE_SCHEMA` = '" . db_escape(classSupernova::$db_name) . "' AND TABLE_NAME = '{$prefix_table_name}' AND REFERENCED_TABLE_NAME is not null;", true);
104
-  while($r1 = db_fetch($q1)) {
104
+  while ($r1 = db_fetch($q1)) {
105 105
     $table_referenced = str_replace(classSupernova::$config->db_prefix, '', $r1['REFERENCED_TABLE_NAME']);
106 106
 
107 107
     $update_foreigns[$tableName][$r1['CONSTRAINT_NAME']] .= "{$r1['COLUMN_NAME']},{$table_referenced},{$r1['REFERENCED_COLUMN_NAME']};";
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
  * @return bool|mysqli_result|void
117 117
  */
118 118
 function upd_alter_table($table, $alters, $condition = true) {
119
-  if(!$condition) {
119
+  if (!$condition) {
120 120
     return;
121 121
   }
122 122
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
   $alters_print = is_array($alters) ? dump($alters) : $alters;
125 125
   upd_log_message("Altering table '{$table}' with alterations {$alters_print}");
126 126
 
127
-  if(!is_array($alters)) {
127
+  if (!is_array($alters)) {
128 128
     $alters = array($alters);
129 129
   }
130 130
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
   $result = upd_do_query($qry);
135 135
   $error = db_error();
136
-  if($error) {
136
+  if ($error) {
137 137
     die("Altering error for table `{$table}`: {$error}<br />{$alters_print}");
138 138
   }
139 139
 
@@ -152,12 +152,12 @@  discard block
 block discarded – undo
152 152
 function upd_create_table($table_name, $declaration) {
153 153
   global $update_tables;
154 154
 
155
-  if(!$update_tables[$table_name]) {
155
+  if (!$update_tables[$table_name]) {
156 156
     upd_do_query('set foreign_key_checks = 0;', true);
157 157
     $db_prefix = classSupernova::$config->db_prefix;
158 158
     $result = upd_do_query("CREATE TABLE IF NOT EXISTS `{$db_prefix}{$table_name}` {$declaration}");
159 159
     $error = db_error();
160
-    if($error) {
160
+    if ($error) {
161 161
       die("Creating error for table `{$table_name}`: {$error}<br />" . dump($declaration));
162 162
     }
163 163
     upd_do_query('set foreign_key_checks = 1;', true);
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
 
184 184
 
185 185
 function upd_db_unit_changeset_prepare($unit_id, $unit_value, $user, $planet_id = null) {
186
-  if(!is_array($user)) {
186
+  if (!is_array($user)) {
187 187
     // TODO - remove later
188 188
     print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER is not ARRAY</h1>');
189 189
     pdump(debug_backtrace());
190 190
     die('USER is not ARRAY');
191 191
   }
192 192
 
193
-  if(!isset($user['id']) || !$user['id']) {
193
+  if (!isset($user['id']) || !$user['id']) {
194 194
     // TODO - remove later
195 195
     print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sn_db_unit_changeset_prepare() - USER[id] пустой</h1>');
196 196
     pdump($user);
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 
206 206
   $db_changeset = array();
207 207
   $temp = upd_db_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id');
208
-  if($temp['unit_id']) {
208
+  if ($temp['unit_id']) {
209 209
     // update
210 210
     $db_changeset = array(
211 211
       'action' => SQL_OP_UPDATE,
@@ -250,41 +250,41 @@  discard block
 block discarded – undo
250 250
 
251 251
 
252 252
 function upd_db_changeset_apply($db_changeset) {
253
-  if(!is_array($db_changeset) || empty($db_changeset)) {
253
+  if (!is_array($db_changeset) || empty($db_changeset)) {
254 254
     return;
255 255
   }
256 256
 
257
-  foreach($db_changeset as $table_name => $table_data) {
258
-    foreach($table_data as $record_id => $conditions) {
257
+  foreach ($db_changeset as $table_name => $table_data) {
258
+    foreach ($table_data as $record_id => $conditions) {
259 259
       $where = '';
260
-      if(!empty($conditions['where'])) {
260
+      if (!empty($conditions['where'])) {
261 261
         $where = 'WHERE ' . implode(' AND ', $conditions['where']);
262 262
       }
263 263
 
264 264
       $fields = array();
265
-      if($conditions['fields']) {
266
-        foreach($conditions['fields'] as $field_name => $field_data) {
265
+      if ($conditions['fields']) {
266
+        foreach ($conditions['fields'] as $field_name => $field_data) {
267 267
           $condition = "`{$field_name}` = ";
268 268
           $value = '';
269
-          if($field_data['delta']) {
269
+          if ($field_data['delta']) {
270 270
             $value = "`{$field_name}`" . ($field_data['delta'] >= 0 ? '+' : '') . $field_data['delta'];
271
-          } elseif($field_data['set']) {
271
+          } elseif ($field_data['set']) {
272 272
             $value = (is_string($field_data['set']) ? "'{$field_data['set']}'" : $field_data['set']);
273 273
           }
274
-          if($value) {
274
+          if ($value) {
275 275
             $fields[] = $condition . $value;
276 276
           }
277 277
         }
278 278
       }
279 279
       $fields = implode(',', $fields);
280 280
 
281
-      switch($conditions['action']) {
281
+      switch ($conditions['action']) {
282 282
         case SQL_OP_DELETE:
283 283
           upd_do_query("DELETE FROM {{{$table_name}}} {$where}");
284 284
         break;
285 285
 
286 286
         case SQL_OP_UPDATE:
287
-          if($fields) {
287
+          if ($fields) {
288 288
             /*if($table_name == 'unit')
289 289
             {
290 290
               pdump("UPDATE {{{$table_name}}} SET {$fields} {$where}");
@@ -295,13 +295,13 @@  discard block
 block discarded – undo
295 295
         break;
296 296
 
297 297
         case SQL_OP_INSERT:
298
-          if($fields) {
298
+          if ($fields) {
299 299
             upd_do_query("INSERT INTO {{{$table_name}}} SET {$fields}");
300 300
           }
301 301
         break;
302 302
 
303 303
         case SQL_OP_REPLACE:
304
-          if($fields) {
304
+          if ($fields) {
305 305
             upd_do_query("REPLACE INTO {{{$table_name}}} SET {$fields}");
306 306
           }
307 307
         break;
Please login to merge, or discard this patch.
includes/includes/market_info.inc 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 $classLocale = classLocale::$lang;
4 4
 
5
-if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true)
5
+if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true)
6 6
 {
7 7
   $debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403);
8 8
 }
@@ -17,50 +17,50 @@  discard block
 block discarded – undo
17 17
 ));
18 18
 
19 19
 $info_action = sys_get_param_int('action');
20
-if($info_action)
20
+if ($info_action)
21 21
 {
22 22
   try
23 23
   {
24 24
     sn_db_transaction_start();
25 25
 
26 26
     $user = db_user_by_id($user['id'], true);
27
-    if(mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->rpg_cost_info)
27
+    if (mrc_get_level($user, null, RES_DARK_MATTER) < classSupernova::$config->rpg_cost_info)
28 28
     {
29 29
       throw new Exception(MARKET_NO_DM, ERR_ERROR);
30 30
     }
31 31
 
32
-    switch($info_action)
32
+    switch ($info_action)
33 33
     {
34 34
       case MARKET_INFO_PLAYER:
35 35
         $user_info_name_unsafe = sys_get_param_str_unsafe('user_info_name');
36
-        if(!$user_info_name_unsafe)
36
+        if (!$user_info_name_unsafe)
37 37
         {
38 38
           throw new Exception(MARKET_INFO_PLAYER_WRONG, ERR_ERROR);
39 39
         }
40 40
 
41
-        if(is_id($user_info_name_unsafe))
41
+        if (is_id($user_info_name_unsafe))
42 42
         {
43 43
           $user_info = db_user_by_id($user_info_name_unsafe, true, '`id`, `username`', true);
44 44
         }
45
-        if(!is_array($user_info))
45
+        if (!is_array($user_info))
46 46
         {
47 47
           $user_info = db_user_by_username($user_info_name_unsafe, true, '`id`, `username`', true, true);
48 48
         }
49
-        if(!is_array($user_info))
49
+        if (!is_array($user_info))
50 50
         {
51 51
           throw new Exception(MARKET_INFO_PLAYER_NOT_FOUND, ERR_ERROR);
52 52
         }
53
-        if($user_info['id'] == $user['id'])
53
+        if ($user_info['id'] == $user['id'])
54 54
         {
55 55
           throw new Exception(MARKET_INFO_PLAYER_SAME, ERR_ERROR);
56 56
         }
57 57
 
58 58
         $msg_text = array();
59
-        foreach(sn_get_groups('mercenaries') as $mercenary_id)
59
+        foreach (sn_get_groups('mercenaries') as $mercenary_id)
60 60
         {
61 61
           $msg_text[] = "{$classLocale['tech'][$mercenary_id]} - " . (($mercenary_level = mrc_get_level($user_info, null, $mercenary_id)) ? "{$classLocale['sys_level']} {$mercenary_level}" : classLocale::$lang['eco_mrk_info_not_hired']);
62 62
         }
63
-        if($mercenary_level = mrc_get_level($user_info, null, UNIT_PREMIUM))
63
+        if ($mercenary_level = mrc_get_level($user_info, null, UNIT_PREMIUM))
64 64
         {
65 65
           $msg_text[] = "{$classLocale['tech'][UNIT_PREMIUM]} - {$mercenary_level} {$classLocale['sys_level']}";
66 66
         }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
       break;
75 75
     }
76 76
 
77
-    if(!rpg_points_change($user['id'], RPG_MARKET_INFO_MERCENARY, -classSupernova::$config->rpg_cost_info, "Using Black Market page {$classLocale['eco_mrk_info']} - getting info about user ID {$user_info['id']}"))
77
+    if (!rpg_points_change($user['id'], RPG_MARKET_INFO_MERCENARY, -classSupernova::$config->rpg_cost_info, "Using Black Market page {$classLocale['eco_mrk_info']} - getting info about user ID {$user_info['id']}"))
78 78
     {
79 79
       // TODO: throw new Exception(MARKET_INFO_PLAYER_SAME, ERR_ERROR);
80 80
     }
Please login to merge, or discard this patch.
includes/includes/sys_avatar.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,29 +5,29 @@  discard block
 block discarded – undo
5 5
     $avatar_filename = $fullsize_filename = SN_ROOT_PHYSICAL . 'images/avatar/' . $prefix . '_' . $subject_id;
6 6
     $avatar_filename .= '.png';
7 7
     $fullsize_filename .= '_full.png';
8
-    if(sys_get_param_int('avatar_remove')) {
9
-      if(file_exists($avatar_filename) && !unlink($avatar_filename)) {
8
+    if (sys_get_param_int('avatar_remove')) {
9
+      if (file_exists($avatar_filename) && !unlink($avatar_filename)) {
10 10
         throw new Exception(classLocale::$lang['opt_msg_avatar_error_delete'], ERR_ERROR);
11 11
       }
12 12
       $avatar_field = 0;
13 13
       throw new Exception(classLocale::$lang['opt_msg_avatar_removed'], ERR_NONE);
14
-    } elseif($_FILES['avatar']['size']) {
15
-      if(!in_array($_FILES['avatar']['type'], array('image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png')) || $_FILES['avatar']['size'] > 204800) {
14
+    } elseif ($_FILES['avatar']['size']) {
15
+      if (!in_array($_FILES['avatar']['type'], array('image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg', 'image/png')) || $_FILES['avatar']['size'] > 204800) {
16 16
         throw new Exception(classLocale::$lang['opt_msg_avatar_error_unsupported'], ERR_WARNING);
17 17
       }
18 18
 
19
-      if($_FILES['avatar']['error']) {
19
+      if ($_FILES['avatar']['error']) {
20 20
         throw new Exception(sprintf(classLocale::$lang['opt_msg_avatar_error_upload'], $_FILES['avatar']['error']), ERR_ERROR);
21 21
       }
22 22
 
23
-      if(!($avatar_image = imagecreatefromstring(file_get_contents($_FILES['avatar']['tmp_name'])))) {
23
+      if (!($avatar_image = imagecreatefromstring(file_get_contents($_FILES['avatar']['tmp_name'])))) {
24 24
         throw new Exception(classLocale::$lang['opt_msg_avatar_error_unsupported'], ERR_WARNING);
25 25
       }
26 26
 
27 27
       $avatar_size = getimagesize($_FILES['avatar']['tmp_name']);
28 28
       $avatar_max_width = classSupernova::$config->avatar_max_width;
29 29
       $avatar_max_height = classSupernova::$config->avatar_max_height;
30
-      if($avatar_size[0] > $avatar_max_width || $avatar_size[1] > $avatar_max_height) {
30
+      if ($avatar_size[0] > $avatar_max_width || $avatar_size[1] > $avatar_max_height) {
31 31
         $aspect_ratio = min($avatar_max_width / $avatar_size[0], $avatar_max_height / $avatar_size[1]);
32 32
         $avatar_image_new = imagecreatetruecolor($avatar_size[0] * $aspect_ratio, $avatar_size[0] * $aspect_ratio);
33 33
         $result = imagecopyresized($avatar_image_new, $avatar_image, 0, 0, 0, 0, $avatar_size[0] * $aspect_ratio, $avatar_size[0] * $aspect_ratio, $avatar_size[0], $avatar_size[1]);
@@ -35,11 +35,11 @@  discard block
 block discarded – undo
35 35
         $avatar_image = $avatar_image_new;
36 36
       }
37 37
 
38
-      if(file_exists($avatar_filename) && !unlink($avatar_filename)) {
38
+      if (file_exists($avatar_filename) && !unlink($avatar_filename)) {
39 39
         throw new Exception(classLocale::$lang['opt_msg_avatar_error_delete'], ERR_ERROR);
40 40
       }
41 41
 
42
-      if(!imagepng($avatar_image, $avatar_filename, 9)) {
42
+      if (!imagepng($avatar_image, $avatar_filename, 9)) {
43 43
         throw new Exception(classLocale::$lang['opt_msg_avatar_error_writing'], ERR_ERROR);
44 44
       }
45 45
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
       imagedestroy($avatar_image);
48 48
       throw new Exception(classLocale::$lang['opt_msg_avatar_uploaded'], ERR_NONE);
49 49
     }
50
-  } catch(Exception $e) {
50
+  } catch (Exception $e) {
51 51
     return array(
52 52
       'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
53 53
       'MESSAGE' => $e->getMessage()
Please login to merge, or discard this patch.
includes/includes/mrc_mercenary.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -4,13 +4,13 @@  discard block
 block discarded – undo
4 4
 
5 5
 function mrc_officer_accessible(&$user, $mercenary_id) {
6 6
   $mercenary_info = get_unit_param($mercenary_id);
7
-  if(classSupernova::$config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) {
7
+  if (classSupernova::$config->empire_mercenary_temporary || $mercenary_info[P_UNIT_TYPE] == UNIT_PLANS) {
8 8
     return true;
9 9
   }
10 10
 
11
-  if(isset($mercenary_info[P_REQUIRE])) {
12
-    foreach($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) {
13
-      if(mrc_get_level($user, null, $unit_id) < $unit_level) {
11
+  if (isset($mercenary_info[P_REQUIRE])) {
12
+    foreach ($mercenary_info[P_REQUIRE] as $unit_id => $unit_level) {
13
+      if (mrc_get_level($user, null, $unit_id) < $unit_level) {
14 14
         return false;
15 15
       }
16 16
     }
@@ -26,35 +26,35 @@  discard block
 block discarded – undo
26 26
     $is_permanent = $mode == UNIT_PLANS || !classSupernova::$config->empire_mercenary_temporary;
27 27
     $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? classSupernova::$config->ali_bonus_members : 1);
28 28
     $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1;
29
-    if(!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) {
29
+    if (!in_array($mercenary_id, sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries'))) {
30 30
       throw new Exception(classLocale::$lang['mrc_msg_error_wrong_mercenary'], ERR_ERROR);
31 31
     }
32 32
 
33
-    if(!mrc_officer_accessible($user, $mercenary_id)) {
33
+    if (!mrc_officer_accessible($user, $mercenary_id)) {
34 34
       throw new Exception(classLocale::$lang['mrc_msg_error_requirements'], ERR_ERROR);
35 35
     }
36 36
 
37 37
     $mercenary_level = sys_get_param_int('mercenary_level');
38
-    if($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) {
38
+    if ($mercenary_level < 0 || $mercenary_level > get_unit_param($mercenary_id, P_MAX_STACK)) {
39 39
       throw new Exception(classLocale::$lang['mrc_msg_error_wrong_level'], ERR_ERROR);
40 40
     }
41 41
 
42
-    if($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) {
42
+    if ($mercenary_level && !array_key_exists($mercenary_period = sys_get_param_int('mercenary_period'), $sn_powerup_buy_discounts)) {
43 43
       throw new Exception(classLocale::$lang['mrc_msg_error_wrong_period'], ERR_ERROR);
44 44
     }
45 45
 
46 46
     sn_db_transaction_start();
47 47
 
48 48
     $mercenary_level_old = mrc_get_level($user, $planetrow, $mercenary_id, true, true);
49
-    if(classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) {
49
+    if (classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old && $mercenary_level) {
50 50
       throw new Exception(classLocale::$lang['mrc_msg_error_already_hired'], ERR_ERROR); // Can't hire already hired temp mercenary - dismiss first
51
-    } elseif(classSupernova::$config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) {
51
+    } elseif (classSupernova::$config->empire_mercenary_temporary && !$mercenary_level_old && !$mercenary_level) {
52 52
       throw new Exception('', ERR_NONE); // Can't dismiss (!$mercenary_level) not hired (!$mercenary_level_old) temp mercenary. But no error
53 53
     }
54 54
 
55
-    if($mercenary_level) {
55
+    if ($mercenary_level) {
56 56
       $darkmater_cost = eco_get_total_cost($mercenary_id, $mercenary_level);
57
-      if(!classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old) {
57
+      if (!classSupernova::$config->empire_mercenary_temporary && $mercenary_level_old) {
58 58
         $darkmater_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level_old);
59 59
         $darkmater_cost[BUILD_CREATE][RES_DARK_MATTER] -= $darkmater_cost_old[BUILD_CREATE][RES_DARK_MATTER];
60 60
       }
@@ -64,13 +64,13 @@  discard block
 block discarded – undo
64 64
     }
65 65
     $darkmater_cost *= $cost_alliance_multiplyer;
66 66
 
67
-    if(mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) {
67
+    if (mrc_get_level($user, null, RES_DARK_MATTER) < $darkmater_cost) {
68 68
       throw new Exception(classLocale::$lang['mrc_msg_error_no_resource'], ERR_ERROR);
69 69
     }
70 70
 
71
-    if(($darkmater_cost && $mercenary_level) || !$is_permanent) {
71
+    if (($darkmater_cost && $mercenary_level) || !$is_permanent) {
72 72
       $unit_row = db_unit_by_location($user['id'], LOC_USER, $user['id'], $mercenary_id);
73
-      if(is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) {
73
+      if (is_array($unit_row) && ($dismiss_left_days = floor((strtotime($unit_row['unit_time_finish']) - SN_TIME_NOW) / PERIOD_DAY))) {
74 74
         $dismiss_full_cost = eco_get_total_cost($mercenary_id, $unit_row['unit_level']);
75 75
         $dismiss_full_cost = $dismiss_full_cost[BUILD_CREATE][RES_DARK_MATTER];
76 76
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
       db_unit_list_delete($user['id'], LOC_USER, $user['id'], $mercenary_id);
84 84
     }
85 85
 
86
-    if($darkmater_cost && $mercenary_level) {
86
+    if ($darkmater_cost && $mercenary_level) {
87 87
       db_unit_set_insert(
88 88
         "unit_player_id = {$user['id']},
89 89
         unit_location_type = " . LOC_USER . ",
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
     }
101 101
     sn_db_transaction_commit();
102 102
     sys_redirect($_SERVER['REQUEST_URI']);
103
-  } catch(Exception $e) {
103
+  } catch (Exception $e) {
104 104
     sn_db_transaction_rollback();
105 105
     $operation_result = array(
106 106
       'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
   $mode = in_array($mode, array(UNIT_MERCENARIES, UNIT_PLANS)) ? $mode : UNIT_MERCENARIES;
119 119
   $is_permanent = $mode == UNIT_PLANS || !classSupernova::$config->empire_mercenary_temporary;
120 120
 
121
-  if($mercenary_id = sys_get_param_int('mercenary_id')) {
121
+  if ($mercenary_id = sys_get_param_int('mercenary_id')) {
122 122
     $operation_result = mrc_mercenary_hire($mode, $user, $mercenary_id);
123 123
   }
124 124
 
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 
127 127
   $template = gettemplate('mrc_mercenary_hire', true);
128 128
 
129
-  if(!empty($operation_result)) {
129
+  if (!empty($operation_result)) {
130 130
     $template->assign_block_vars('result', $operation_result);
131 131
   }
132 132
 
133
-  foreach($sn_powerup_buy_discounts as $hire_period => $hire_discount) {
133
+  foreach ($sn_powerup_buy_discounts as $hire_period => $hire_discount) {
134 134
     $template->assign_block_vars('period', array(
135 135
       'LENGTH'   => $hire_period,
136 136
       'TEXT'     => classLocale::$lang['mrc_period_list'][$hire_period],
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
   $user_dark_matter = mrc_get_level($user, null, RES_DARK_MATTER);
143 143
   $cost_alliance_multiplyer = (SN_IN_ALLY === true && $mode == UNIT_PLANS ? classSupernova::$config->ali_bonus_members : 1);
144 144
   $cost_alliance_multiplyer = $cost_alliance_multiplyer >= 1 ? $cost_alliance_multiplyer : 1;
145
-  foreach(sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) {
145
+  foreach (sn_get_groups($mode == UNIT_PLANS ? 'plans' : 'mercenaries') as $mercenary_id) {
146 146
     {
147 147
       $mercenary = get_unit_param($mercenary_id);
148 148
       $mercenary_bonus = $mercenary['bonus'];
149 149
       $mercenary_bonus = $mercenary_bonus >= 0 ? "+{$mercenary_bonus}" : "{$mercenary_bonus}";
150
-      switch($mercenary['bonus_type']) {
150
+      switch ($mercenary['bonus_type']) {
151 151
         case BONUS_PERCENT:
152 152
           $mercenary_bonus = "{$mercenary_bonus}% ";
153 153
         break;
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
       $mercenary_level = mrc_get_level($user, null, $mercenary_id, false, true);
165 165
       $mercenary_level_bonus = max(0, mrc_get_level($user, null, $mercenary_id) - $mercenary_level);
166 166
       $total_cost_old = 0;
167
-      if($is_permanent) {
167
+      if ($is_permanent) {
168 168
         $total_cost_old = eco_get_total_cost($mercenary_id, $mercenary_level);
169 169
         $total_cost_old = $total_cost_old[BUILD_CREATE][RES_DARK_MATTER] * $cost_alliance_multiplyer;
170 170
       }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
       ));
194 194
 
195 195
       $upgrade_cost = 1;
196
-      for($i = classSupernova::$config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) {
196
+      for ($i = classSupernova::$config->empire_mercenary_temporary ? 1 : $mercenary_level + 1; $mercenary['max'] ? ($i <= $mercenary['max']) : $upgrade_cost <= $user_dark_matter; $i++) {
197 197
         $total_cost = eco_get_total_cost($mercenary_id, $i);
198 198
         $total_cost[BUILD_CREATE][RES_DARK_MATTER] *= $cost_alliance_multiplyer;
199 199
         $upgrade_cost = $total_cost[BUILD_CREATE][RES_DARK_MATTER] - $total_cost_old;
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
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 $classLocale = classLocale::$lang;
4 4
 
5
-if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) {
5
+if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) {
6 6
   $debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403);
7 7
 }
8 8
 
@@ -14,8 +14,8 @@  discard block
 block discarded – undo
14 14
   'rpg_cost' => $rpg_cost,
15 15
 ));
16 16
 
17
-if(is_array($shipList)) {
18
-  if(mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) {
17
+if (is_array($shipList)) {
18
+  if (mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) {
19 19
     $intError = MARKET_NO_DM;
20 20
   }
21 21
 
@@ -32,30 +32,30 @@  discard block
 block discarded – undo
32 32
   $qry = array();
33 33
   $total = array();
34 34
   $db_changeset = array();
35
-  foreach($shipList as $shipID => &$shipCount) {
35
+  foreach ($shipList as $shipID => &$shipCount) {
36 36
     $shipCount = ceil(floatval($shipCount));
37
-    if(!$shipCount) {
37
+    if (!$shipCount) {
38 38
       continue;
39 39
     }
40 40
 
41
-    if($shipCount < 0) {
41
+    if ($shipCount < 0) {
42 42
       $debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307);
43 43
       $intError = MARKET_NEGATIVE_SHIPS;
44 44
       break;
45 45
     }
46 46
 
47
-    if($mode == MARKET_SCRAPPER) {
47
+    if ($mode == MARKET_SCRAPPER) {
48 48
       $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)];
49
-    } elseif($mode == MARKET_STOCKMAN) {
49
+    } elseif ($mode == MARKET_STOCKMAN) {
50 50
       $amount = $stock[$shipID];
51 51
     }
52 52
 
53
-    if($amount < $shipCount) {
53
+    if ($amount < $shipCount) {
54 54
       $intError = $error_no_stock;
55 55
       break;
56 56
     }
57 57
 
58
-    if(!in_array($shipID, sn_get_groups('fleet'))) {
58
+    if (!in_array($shipID, sn_get_groups('fleet'))) {
59 59
       $debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306);
60 60
       $intError = MARKET_NOT_A_SHIP;
61 61
       break;
@@ -71,16 +71,16 @@  discard block
 block discarded – undo
71 71
     $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier));
72 72
     $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier));
73 73
 
74
-    foreach($resTemp as $resID => $resCount) {
74
+    foreach ($resTemp as $resID => $resCount) {
75 75
       $total[$resID] += $resCount;
76 76
     }
77 77
 
78 78
     $message .= "<li>{$classLocale['tech'][$shipID]}: " . pretty_number($shipCount);
79 79
   }
80 80
 
81
-  if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) {
82
-    foreach($total as $resID => $resCount) {
83
-      if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) {
81
+  if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) {
82
+    foreach ($total as $resID => $resCount) {
83
+      if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) {
84 84
         $intError = MARKET_NO_RESOURCES;
85 85
         $debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301);
86 86
         break;
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 
91 91
   $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError;
92 92
 
93
-  if($intError == MARKET_DEAL) {
93
+  if ($intError == MARKET_DEAL) {
94 94
     $message .= '</ul>' . classLocale::$lang["eco_mrk_{$submode}_res"] . '<ul>';
95
-    foreach($total as $resID => $resCount) {
96
-      if(!$resCount) {
95
+    foreach ($total as $resID => $resCount) {
96
+      if (!$resCount) {
97 97
         continue;
98 98
       }
99 99
 
@@ -127,38 +127,38 @@  discard block
 block discarded – undo
127 127
       'MESSAGE' => classLocale::$lang['eco_mrk_errors'][$intError],
128 128
     ));
129 129
 
130
-    foreach($shipList as $shipID => $shipCount) {
130
+    foreach ($shipList as $shipID => $shipCount) {
131 131
       $data['ships'][$shipID] = max(0, intval($shipCount));
132 132
     }
133 133
   }
134 134
 }
135 135
 $message = '';
136 136
 
137
-if(!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) {
138
-  classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, sn_get_groups('fleet'))));
137
+if (!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) {
138
+  classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, sn_get_groups('fleet'))));
139 139
 }
140 140
 
141 141
 tpl_set_resource_info($template, $planetrow, array());
142 142
 
143
-if(!$array) {
143
+if (!$array) {
144 144
   $array = array();
145 145
 }
146 146
 
147 147
 $group_fleet = sn_get_groups('fleet');
148
-foreach($array as $key => $value) {
149
-  if($mode == MARKET_SCRAPPER) {
148
+foreach ($array as $key => $value) {
149
+  if ($mode == MARKET_SCRAPPER) {
150 150
     $shipID = $value;
151 151
     $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)];
152
-  } elseif($mode == MARKET_STOCKMAN) {
152
+  } elseif ($mode == MARKET_STOCKMAN) {
153 153
     $shipID = $key;
154 154
     $amount = $value;
155 155
   }
156 156
 
157
-  if(!in_array($shipID, $group_fleet)) {
157
+  if (!in_array($shipID, $group_fleet)) {
158 158
     continue;
159 159
   }
160 160
 
161
-  if($amount > 0) {
161
+  if ($amount > 0) {
162 162
     $build_data = eco_get_build_data($user, $planetrow, $shipID);
163 163
     $template->assign_block_vars('ships', array(
164 164
       'ID'        => $shipID,
Please login to merge, or discard this patch.