Passed
Push — master ( bc874f...230097 )
by SuperNova.WS
04:01
created
includes/pages/imperator.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 //    $same_user = false;
54 54
 //  }
55 55
 
56
-  if(!$user_data) {
56
+  if (!$user_data) {
57 57
     message($lang['imp_imperator_none'], $lang['sys_error'], 'index.php', 10);
58 58
     die();
59 59
   }
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
64 64
   $stat_array = array();
65 65
   $query = doquery("SELECT * FROM {{statpoints}} WHERE `stat_type` = 1 AND `id_owner` = {$user_id} ORDER BY `stat_code` DESC;");
66 66
   $stat_count = classSupernova::$db->db_affected_rows();
67
-  while($row = db_fetch($query)) {
68
-    foreach($stat_fields as $field_db_name => $field_template_name) {
67
+  while ($row = db_fetch($query)) {
68
+    foreach ($stat_fields as $field_db_name => $field_template_name) {
69 69
       // $stat_count - $row['stat_code'] - для реверсирования ID статы в JS
70 70
       $stat_array[$field_template_name]['DATA'][$stat_count - $row['stat_code']] = $row[$field_db_name];
71 71
     }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 
74 74
   $stat_array_date = $stat_array['STAT_DATE'];
75 75
   empty($stat_array_date['DATA']) ? $stat_array_date['DATA'] = array() : false;
76
-  foreach($stat_array_date['DATA'] as $key => $value) {
76
+  foreach ($stat_array_date['DATA'] as $key => $value) {
77 77
     $template->assign_block_vars('stat_date', array(
78 78
       'ID' => $key,
79 79
       'VALUE' => $value,
@@ -83,21 +83,21 @@  discard block
 block discarded – undo
83 83
 
84 84
   unset($stat_array['STAT_DATE']);
85 85
   $template_data = array();
86
-  foreach($stat_array as $stat_type => &$stat_type_data) {
86
+  foreach ($stat_array as $stat_type => &$stat_type_data) {
87 87
     $reverse_min_max = strpos($stat_type, '_RANK') !== false;
88 88
     $stat_type_data['MIN'] = $reverse_min_max ? max($stat_type_data['DATA']) : min($stat_type_data['DATA']);
89 89
     $stat_type_data['MAX'] = $reverse_min_max ? min($stat_type_data['DATA']) : max($stat_type_data['DATA']);
90 90
     $stat_type_data['AVG'] = average($stat_type_data['DATA']);
91
-    foreach($stat_type_data['DATA'] as $key => $value) {
91
+    foreach ($stat_type_data['DATA'] as $key => $value) {
92 92
       $stat_type_data['PERCENT'][$key] = ($stat_type_data['MAX'] - $value ? ($value - $stat_type_data['MIN']) / ($stat_type_data['MAX'] - $stat_type_data['MIN']) : 1) * 100;
93 93
       $template_data[$stat_type][$key]['ID'] = $key;
94 94
       $template_data[$stat_type][$key]['VALUE'] = $value;
95
-      $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN']  - $value : $value - $stat_type_data['MAX']);
95
+      $template_data[$stat_type][$key]['DELTA'] = ($reverse_min_max ? $stat_type_data['MIN'] - $value : $value - $stat_type_data['MAX']);
96 96
       $template_data[$stat_type][$key]['PERCENT'] = $stat_type_data['PERCENT'][$key];
97 97
     }
98 98
   }
99 99
 
100
-  foreach($template_data as $stat_type => $stat_type_data) {
100
+  foreach ($template_data as $stat_type => $stat_type_data) {
101 101
     $template->assign_block_vars('stat', array(
102 102
       'TYPE' => $stat_type,
103 103
       'TEXT' => $lang['imp_stat_types'][$stat_type],
@@ -105,13 +105,13 @@  discard block
 block discarded – undo
105 105
       'MAX' => $stat_array[$stat_type]['MAX'],
106 106
       'AVG' => $stat_array[$stat_type]['AVG'],
107 107
     ));
108
-    foreach($stat_type_data as $stat_entry) {
108
+    foreach ($stat_type_data as $stat_entry) {
109 109
       $template->assign_block_vars('stat.entry', $stat_entry);
110 110
     }
111 111
   }
112 112
 
113 113
 
114
-  if($same_user) {
114
+  if ($same_user) {
115 115
     rpg_level_up($user, RPG_STRUCTURE);
116 116
     rpg_level_up($user, RPG_RAID);
117 117
     rpg_level_up($user, RPG_TECH);
@@ -145,29 +145,29 @@  discard block
 block discarded – undo
145 145
     'builder_xp'           => pretty_number($user_data['xpminier']),
146 146
     'builder_lvl'          => pretty_number($user_data['lvl_minier']),
147 147
     'builder_lvl_st'       => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'])),
148
-    'builder_lvl_up'       => pretty_number(rpg_get_miner_xp($user_data['lvl_minier']+1)),
148
+    'builder_lvl_up'       => pretty_number(rpg_get_miner_xp($user_data['lvl_minier'] + 1)),
149 149
     'raid_xp'              => pretty_number($user_data['xpraid']),
150 150
     'raid_lvl'             => pretty_number($user_data['lvl_raid']),
151
-    'raid_lvl_up'          => pretty_number(rpg_get_raider_xp($user_data['lvl_raid']+1)),
151
+    'raid_lvl_up'          => pretty_number(rpg_get_raider_xp($user_data['lvl_raid'] + 1)),
152 152
     'raids'                => pretty_number($user_data['raids']),
153 153
     'raidswin'             => pretty_number($user_data['raidswin']),
154 154
     'raidsloose'           => pretty_number($user_data['raidsloose']),
155 155
     'tech_xp'              => pretty_number($user_data['player_rpg_tech_xp']),
156 156
     'tech_lvl'             => pretty_number($user_data['player_rpg_tech_level']),
157 157
     'tech_lvl_st'          => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'])),
158
-    'tech_lvl_up'          => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level']+1)),
158
+    'tech_lvl_up'          => pretty_number(rpg_get_tech_xp($user_data['player_rpg_tech_level'] + 1)),
159 159
 
160 160
     'explore_xp'           => pretty_number($user_data['player_rpg_explore_xp']),
161 161
     'explore_lvl'          => pretty_number($user_data['player_rpg_explore_level']),
162 162
     'explore_lvl_st'       => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'])),
163
-    'explore_lvl_up'       => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level']+1)),
164
-
165
-    'build_points'         => pretty_number( $StatRecord['build_points'] ),
166
-    'tech_points'          => pretty_number( $StatRecord['tech_points'] ),
167
-    'fleet_points'         => pretty_number( $StatRecord['fleet_points'] ),
168
-    'defs_points'          => pretty_number( $StatRecord['defs_points'] ),
169
-    'res_points'           => pretty_number( $StatRecord['res_points'] ),
170
-    'total_points'         => pretty_number( $StatRecord['total_points'] ),
163
+    'explore_lvl_up'       => pretty_number(rpg_get_explore_xp($user_data['player_rpg_explore_level'] + 1)),
164
+
165
+    'build_points'         => pretty_number($StatRecord['build_points']),
166
+    'tech_points'          => pretty_number($StatRecord['tech_points']),
167
+    'fleet_points'         => pretty_number($StatRecord['fleet_points']),
168
+    'defs_points'          => pretty_number($StatRecord['defs_points']),
169
+    'res_points'           => pretty_number($StatRecord['res_points']),
170
+    'total_points'         => pretty_number($StatRecord['total_points']),
171 171
     'user_rank'            => $StatRecord['total_rank'],
172 172
     'RANK_DIFF'            => $StatRecord['total_old_rank'] - $StatRecord['total_rank'],
173 173
 
Please login to merge, or discard this patch.
includes/pages/options.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
   $language_new = sys_get_param_str('langer', $user['lang']);
24 24
 
25
-  if($language_new != $user['lang']) {
25
+  if ($language_new != $user['lang']) {
26 26
     $lang->lng_switch($language_new);
27 27
   }
28 28
 
@@ -31,18 +31,18 @@  discard block
 block discarded – undo
31 31
 
32 32
   $FMT_DATE = preg_replace(array('/d/', '/m/', '/Y/'), array('DD', 'MM', 'YYYY'), FMT_DATE);
33 33
 
34
-  if(sys_get_param_str('mode') == 'change') {
35
-    if($user['authlevel'] > 0) {
34
+  if (sys_get_param_str('mode') == 'change') {
35
+    if ($user['authlevel'] > 0) {
36 36
       $planet_protection = sys_get_param_int('adm_pl_prot') ? $user['authlevel'] : 0;
37 37
       DBStaticPlanet::db_planet_set_by_owner($user['id'], "`id_level` = '{$planet_protection}'");
38 38
       db_user_set_by_id($user['id'], "`admin_protection` = '{$planet_protection}'");
39 39
       $user['admin_protection'] = $planet_protection;
40 40
     }
41 41
 
42
-    if(sys_get_param_int('vacation') && !$config->user_vacation_disable) {
42
+    if (sys_get_param_int('vacation') && !$config->user_vacation_disable) {
43 43
       sn_db_transaction_start();
44
-      if($user['authlevel'] < 3) {
45
-        if($user['vacation_next'] > SN_TIME_NOW) {
44
+      if ($user['authlevel'] < 3) {
45
+        if ($user['vacation_next'] > SN_TIME_NOW) {
46 46
           message($lang['opt_vacation_err_timeout'], $lang['Error'], 'index.php?page=options', 5);
47 47
           die();
48 48
         }
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
 //          message($lang['opt_vacation_err_your_fleet'], $lang['Error'], 'index.php?page=options', 5);
53 53
 //          die();
54 54
 //        }
55
-        if(fleet_count_flying($user['id'])) {
55
+        if (fleet_count_flying($user['id'])) {
56 56
           message($lang['opt_vacation_err_your_fleet'], $lang['Error'], 'index.php?page=options', 5);
57 57
           die();
58 58
         }
59 59
 
60 60
         $que = que_get($user['id'], false);
61
-        if(!empty($que)) {
61
+        if (!empty($que)) {
62 62
           message($lang['opt_vacation_err_que'], $lang['Error'], 'index.php?page=options', 5);
63 63
           die();
64 64
         }
65 65
 
66 66
         $query = classSupernova::db_get_record_list(LOC_PLANET, "`id_owner` = {$user['id']}");
67
-        foreach($query as $planet) {
67
+        foreach ($query as $planet) {
68 68
           // $planet = sys_o_get_updated($user, $planet, SN_TIME_NOW);
69 69
           // $planet = $planet['planet'];
70 70
 
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
       sn_db_transaction_commit();
83 83
     }
84 84
 
85
-    foreach($user_option_list as $option_group_id => $option_group) {
86
-      foreach($option_group as $option_name => $option_value) {
87
-        if($user[$option_name] !== null) {
85
+    foreach ($user_option_list as $option_group_id => $option_group) {
86
+      foreach ($option_group as $option_name => $option_value) {
87
+        if ($user[$option_name] !== null) {
88 88
           $user[$option_name] = sys_get_param_str($option_name);
89 89
         } else {
90 90
           $user[$option_name] = $option_value;
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
 
96 96
 
97 97
     $player_options = sys_get_param('options');
98
-    if(!empty($player_options)) {
99
-      array_walk($player_options, function (&$value) {
98
+    if (!empty($player_options)) {
99
+      array_walk($player_options, function(&$value) {
100 100
         // TODO - Когда будет больше параметров - сделать больше проверок
101 101
         $value = intval($value);
102 102
       });
@@ -105,15 +105,15 @@  discard block
 block discarded – undo
105 105
 
106 106
     $username = substr(sys_get_param_str_unsafe('username'), 0, 32);
107 107
     $username_safe = db_escape($username);
108
-    if($username && $user['username'] != $username && $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
108
+    if ($username && $user['username'] != $username && $config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
109 109
       // проверка на корректность
110 110
       sn_db_transaction_start();
111 111
       $name_check = doquery("SELECT * FROM {{player_name_history}} WHERE `player_name` LIKE \"{$username_safe}\" LIMIT 1 FOR UPDATE;", true);
112
-      if(!$name_check || $name_check['player_id'] == $user['id']) {
112
+      if (!$name_check || $name_check['player_id'] == $user['id']) {
113 113
         $user = db_user_by_id($user['id'], true);
114
-        switch($config->game_user_changename) {
114
+        switch ($config->game_user_changename) {
115 115
           case SERVER_PLAYER_NAME_CHANGE_PAY:
116
-            if(mrc_get_level($user, $planetrow, RES_DARK_MATTER) < $config->game_user_changename_cost) {
116
+            if (mrc_get_level($user, $planetrow, RES_DARK_MATTER) < $config->game_user_changename_cost) {
117 117
               $template_result['.']['result'][] = array(
118 118
                 'STATUS'  => ERR_ERROR,
119 119
                 'MESSAGE' => $lang['opt_msg_name_change_err_no_dm'],
@@ -143,18 +143,18 @@  discard block
 block discarded – undo
143 143
       sn_db_transaction_commit();
144 144
     }
145 145
 
146
-    if($new_password = sys_get_param('newpass1')) {
146
+    if ($new_password = sys_get_param('newpass1')) {
147 147
       try {
148
-        if($new_password != sys_get_param('newpass2')) {
148
+        if ($new_password != sys_get_param('newpass2')) {
149 149
           throw new Exception($lang['opt_err_pass_unmatched'], ERR_WARNING);
150 150
         }
151 151
 
152
-        if(!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) {
152
+        if (!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) {
153 153
           throw new Exception($lang['opt_err_pass_wrong'], ERR_WARNING);
154 154
         }
155 155
 
156 156
         throw new Exception($lang['opt_msg_pass_changed'], ERR_NONE);
157
-      } catch(Exception $e) {
157
+      } catch (Exception $e) {
158 158
         $template_result['.']['result'][] = array(
159 159
           'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
160 160
           'MESSAGE' => $e->getMessage()
@@ -195,12 +195,12 @@  discard block
 block discarded – undo
195 195
     $user['gender'] = $user['gender'] == GENDER_UNKNOWN ? $gender : $user['gender'];
196 196
 
197 197
     try {
198
-      if($user['birthday']) {
198
+      if ($user['birthday']) {
199 199
         throw new exception();
200 200
       }
201 201
 
202 202
       $user_birthday = sys_get_param_str_unsafe('user_birthday');
203
-      if(!$user_birthday || $user_birthday == $FMT_DATE) {
203
+      if (!$user_birthday || $user_birthday == $FMT_DATE) {
204 204
         throw new exception();
205 205
       }
206 206
 
@@ -210,16 +210,16 @@  discard block
 block discarded – undo
210 210
       $pos['Y'] = strpos(FMT_DATE, 'Y');
211 211
       asort($pos);
212 212
       $i = 0;
213
-      foreach($pos as &$position) {
213
+      foreach ($pos as &$position) {
214 214
         $position = ++$i;
215 215
       }
216 216
 
217 217
       $regexp = "/" . preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE) . "/";
218
-      if(!preg_match($regexp, $user_birthday, $match)) {
218
+      if (!preg_match($regexp, $user_birthday, $match)) {
219 219
         throw new exception();
220 220
       }
221 221
 
222
-      if(!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) {
222
+      if (!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) {
223 223
         throw new exception();
224 224
       }
225 225
 
@@ -227,13 +227,13 @@  discard block
 block discarded – undo
227 227
       // EOF black magic! Now we have valid SQL date in $user['user_birthday'] - independent of date format
228 228
 
229 229
       $year = date('Y', SN_TIME_NOW);
230
-      if(mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) {
230
+      if (mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) {
231 231
         $year--;
232 232
       }
233 233
       $user['user_birthday_celebrated'] = db_escape("{$year}-{$match[$pos['m']]}-{$match[$pos['d']]}");
234 234
 
235 235
       $user_birthday = ", `user_birthday` = '{$user['user_birthday']}', `user_birthday_celebrated` = '{$user['user_birthday_celebrated']}'";
236
-    } catch(exception $e) {
236
+    } catch (exception $e) {
237 237
       $user_birthday = '';
238 238
     }
239 239
 
@@ -243,14 +243,14 @@  discard block
 block discarded – undo
243 243
     $template_result['.']['result'][] = $avatar_upload_result;
244 244
 
245 245
     $user_time_diff = playerTimeDiff::user_time_diff_get();
246
-    if(sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) {
246
+    if (sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) {
247 247
       playerTimeDiff::user_time_diff_set(array(
248 248
         PLAYER_OPTION_TIME_DIFF              => sys_get_param_int('PLAYER_OPTION_TIME_DIFF'),
249 249
         PLAYER_OPTION_TIME_DIFF_UTC_OFFSET   => 0,
250 250
         PLAYER_OPTION_TIME_DIFF_FORCED       => 1,
251 251
         PLAYER_OPTION_TIME_DIFF_MEASURE_TIME => SN_TIME_SQL,
252 252
       ));
253
-    } elseif(sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) {
253
+    } elseif (sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) {
254 254
       playerTimeDiff::user_time_diff_set(array(
255 255
         PLAYER_OPTION_TIME_DIFF              => '',
256 256
         PLAYER_OPTION_TIME_DIFF_UTC_OFFSET   => 0,
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
       'STATUS'  => ERR_NONE,
271 271
       'MESSAGE' => $lang['opt_msg_saved']
272 272
     );
273
-  } elseif(sys_get_param_str('result') == 'ok') {
273
+  } elseif (sys_get_param_str('result') == 'ok') {
274 274
     $template_result['.']['result'][] = array(
275 275
       'STATUS'  => ERR_NONE,
276 276
       'MESSAGE' => $lang['opt_msg_saved']
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
 //  );
299 299
 
300 300
   $dir = dir(SN_ROOT_PHYSICAL . 'skins');
301
-  while(($entry = $dir->read()) !== false) {
302
-    if(is_dir("skins/{$entry}") && $entry[0] != '.') {
301
+  while (($entry = $dir->read()) !== false) {
302
+    if (is_dir("skins/{$entry}") && $entry[0] != '.') {
303 303
       $template_result['.']['skin_list'][] = array(
304 304
         'VALUE'    => $entry,
305 305
         'NAME'     => $entry,
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
   }
310 310
   $dir->close();
311 311
 
312
-  foreach($lang['opt_planet_sort_options'] as $key => &$value) {
312
+  foreach ($lang['opt_planet_sort_options'] as $key => &$value) {
313 313
     $template_result['.']['planet_sort_options'][] = array(
314 314
       'VALUE'    => $key,
315 315
       'NAME'     => $value,
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
       );
326 326
     }
327 327
   */
328
-  foreach($lang['sys_gender_list'] as $key => $value) {
328
+  foreach ($lang['sys_gender_list'] as $key => $value) {
329 329
     $template_result['.']['gender_list'][] = array(
330 330
       'VALUE'    => $key,
331 331
       'NAME'     => $value,
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
   }
335 335
 
336 336
   $lang_list = lng_get_list();
337
-  foreach($lang_list as $lang_id => $lang_data) {
337
+  foreach ($lang_list as $lang_id => $lang_data) {
338 338
     $template_result['.']['languages'][] = array(
339 339
       'VALUE'    => $lang_id,
340 340
       'NAME'     => $lang_data['LANG_NAME_NATIVE'],
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
   }
344 344
 
345 345
 
346
-  if(isset($lang['menu_customize_show_hide_button_state'])) {
347
-    foreach($lang['menu_customize_show_hide_button_state'] as $key => $value) {
346
+  if (isset($lang['menu_customize_show_hide_button_state'])) {
347
+    foreach ($lang['menu_customize_show_hide_button_state'] as $key => $value) {
348 348
       $template->assign_block_vars('menu_customize_show_hide_button_state', array(
349 349
         'ID'   => $key,
350 350
         'NAME' => $value,
@@ -454,10 +454,10 @@  discard block
 block discarded – undo
454 454
     'PAGE_HEADER' => $lang['opt_header'],
455 455
   ));
456 456
 
457
-  foreach($user_option_list as $option_group_id => $option_group) {
458
-    if($option_group_id == OPT_MESSAGE) {
459
-      foreach($sn_message_class_list as $message_class_id => $message_class_data) {
460
-        if($message_class_data['switchable'] || ($message_class_data['email'] && $config->game_email_pm)) {
457
+  foreach ($user_option_list as $option_group_id => $option_group) {
458
+    if ($option_group_id == OPT_MESSAGE) {
459
+      foreach ($sn_message_class_list as $message_class_id => $message_class_data) {
460
+        if ($message_class_data['switchable'] || ($message_class_data['email'] && $config->game_email_pm)) {
461 461
           $option_name = $message_class_data['name'];
462 462
 
463 463
           $template->assign_block_vars("options_{$option_group_id}", array(
@@ -469,8 +469,8 @@  discard block
 block discarded – undo
469 469
         }
470 470
       }
471 471
     } else {
472
-      foreach($option_group as $option_name => $option_value) {
473
-        if(array_key_exists($option_name, $user_option_types)) {
472
+      foreach ($option_group as $option_name => $option_value) {
473
+        if (array_key_exists($option_name, $user_option_types)) {
474 474
           $option_type = $user_option_types[$option_name];
475 475
         } else {
476 476
           $option_type = 'switch';
Please login to merge, or discard this patch.
includes/db/db_helpers.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@  discard block
 block discarded – undo
27 27
  */
28 28
 function db_set_make_safe_string($set, $delta = false) {
29 29
   $set_safe = array();
30
-  foreach($set as $field => $value) {
31
-    if(empty($field)) {
30
+  foreach ($set as $field => $value) {
31
+    if (empty($field)) {
32 32
       continue;
33 33
     }
34 34
 
35 35
     $field = '`' . db_escape($field) . '`';
36 36
     $new_value = $value;
37
-    if($value === null) {
37
+    if ($value === null) {
38 38
       $new_value = 'NULL';
39
-    } elseif(is_string($value) && (string)($new_value = floatval($value)) != (string)$value) {
39
+    } elseif (is_string($value) && (string) ($new_value = floatval($value)) != (string) $value) {
40 40
       // non-float
41 41
       $new_value = '"' . db_escape($value) . '"';
42
-    } elseif($delta) {
42
+    } elseif ($delta) {
43 43
       // float and DELTA-set
44 44
       $new_value = "{$field} + ({$new_value})";
45 45
     }
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function missile_list_convert_to_fleet(&$missile_db_list, &$fleet_db_list) {
61 61
   // Missile attack
62
-  foreach($missile_db_list as $irak) {
63
-    if($irak['fleet_end_time'] >= SN_TIME_NOW) {
62
+  foreach ($missile_db_list as $irak) {
63
+    if ($irak['fleet_end_time'] >= SN_TIME_NOW) {
64 64
       $irak['fleet_start_type'] = PT_PLANET;
65 65
       $planet_start = DBStaticPlanet::db_planet_by_vector($irak, 'fleet_start_', false, 'name');
66 66
       $irak['fleet_id'] = -$irak['id'];
Please login to merge, or discard this patch.
includes/general_pname.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,12 +2,10 @@
 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
 
10
-function pname_resource_name($resource_id)
11
-{
9
+function pname_resource_name($resource_id) {
12 10
   return get_unit_param($resource_id, P_NAME);
13 11
 }
14 12
\ No newline at end of file
Please login to merge, or discard this patch.
includes/functions/uni_functions.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 
8 8
   $possible_cores = array();
9 9
   $probability = 0;
10
-  foreach($density_list as $possible_core_id => $core_data) {
11
-    if(!$core_data[UNIT_PLANET_DENSITY_RARITY]) {
10
+  foreach ($density_list as $possible_core_id => $core_data) {
11
+    if (!$core_data[UNIT_PLANET_DENSITY_RARITY]) {
12 12
       continue;
13 13
     }
14 14
 
15
-    if(
15
+    if (
16 16
       // Core type exists
17 17
       in_array($possible_core_id, $position_data['core_types'])
18 18
       // Limit core type with planet sector count
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 
34 34
   $random = mt_rand(1, $probability);
35 35
   $selected_core = null;
36
-  foreach($possible_cores as $core_type => $core_info) {
37
-    if($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) {
36
+  foreach ($possible_cores as $core_type => $core_info) {
37
+    if ($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) {
38 38
       $selected_core = $core_info;
39 39
       break;
40 40
     }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
   $Position = intval($Position);
61 61
 
62
-  if(!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) {
62
+  if (!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) {
63 63
     return false;
64 64
   }
65 65
 
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 
69 69
   $planet_generator = sn_get_groups('planet_generator');
70 70
 
71
-  if($HomeWorld) {
71
+  if ($HomeWorld) {
72 72
     $position_data = $planet_generator[0];
73 73
   } else {
74 74
     $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position];
75
-    if($Position >= UNIVERSE_RANDOM_PLANET_START) {
75
+    if ($Position >= UNIVERSE_RANDOM_PLANET_START) {
76 76
       // Корректируем температуру для планеты-странника
77 77
       $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START);
78 78
     }
@@ -172,15 +172,15 @@  discard block
 block discarded – undo
172 172
   $moon_name = '';
173 173
   $moon_row = array();
174 174
   $moon = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id');
175
-  if(!$moon['id']) {
175
+  if (!$moon['id']) {
176 176
     $moon_planet = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_PLANET, true, '`id`, `temp_min`, `temp_max`, `name`, `debris_metal`, `debris_crystal`');
177 177
 
178
-    if($moon_planet['id']) {
178
+    if ($moon_planet['id']) {
179 179
       $base_storage_size = BASE_STORAGE_SIZE;
180 180
 
181
-      if(!$moon_chance) {
181
+      if (!$moon_chance) {
182 182
         $size = mt_rand(1100, 8999);
183
-      } elseif($moon_chance <= 100) {
183
+      } elseif ($moon_chance <= 100) {
184 184
         $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999);
185 185
       } else {
186 186
         $size = $moon_chance;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
       $field_max = ceil($size / 1000);
198 198
 
199
-      if(isset($options['image']) && $options['image']) {
199
+      if (isset($options['image']) && $options['image']) {
200 200
         $moon_image = $options['image'];
201 201
       } else {
202 202
         $moon_image = 'mond';
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
           `deuterium` = '0', `deuterium_perhour` = '0', `deuterium_max` = '{$base_storage_size}'"
212 212
       );
213 213
 
214
-      if($update_debris) {
214
+      if ($update_debris) {
215 215
         $debris_spent = $moon_chance * 1000000;
216 216
         $metal_spent  = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100));
217 217
         $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent);
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
   $planet_row['id'] = $user['current_planet'];
248 248
 
249 249
   // Пытаемся переключить на новую планету
250
-  if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet'])
250
+  if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet'])
251 251
   {
252 252
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id');
253 253
   }
@@ -257,15 +257,15 @@  discard block
 block discarded – undo
257 257
   }
258 258
 
259 259
   // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету
260
-  if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
260
+  if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
261 261
   {
262 262
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id');
263 263
     // Если текущей планеты не существует - выставляем Столицу
264
-    if(!isset($planet_row['id']))
264
+    if (!isset($planet_row['id']))
265 265
     {
266 266
       $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id');
267 267
       // Если и столицы не существует - значит что-то очень не так с записью пользователя
268
-      if(!isset($planet_row['id']))
268
+      if (!isset($planet_row['id']))
269 269
       {
270 270
         global $debug;
271 271
         $debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502);
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
   }
275 275
 
276 276
   // Если производилось переключение планеты - делаем запись в юзере
277
-  if($user['current_planet'] != $planet_row['id'])
277
+  if ($user['current_planet'] != $planet_row['id'])
278 278
   {
279 279
     db_user_set_by_id($user['id'], "`current_planet` = '{$planet_row['id']}'");
280 280
     $user['current_planet'] = $planet_row['id'];
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 {
299 299
   global $lang;
300 300
 
301
-  if(!$from['id'])
301
+  if (!$from['id'])
302 302
   {
303 303
     $result = $lang['sys_planet_expedition'];
304 304
   }
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 function uni_calculate_moon_chance($FleetDebris)
338 338
 {
339 339
   $MoonChance = $FleetDebris / 1000000;
340
-  return ($MoonChance < 1) ? 0 : ($MoonChance>30 ? 30 : $MoonChance);
340
+  return ($MoonChance < 1) ? 0 : ($MoonChance > 30 ? 30 : $MoonChance);
341 341
 }
342 342
 
343 343
 function uni_coordinates_valid($coordinates, $prefix = '')
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
   global $lang, $config;
360 360
 
361 361
   try {
362
-    if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) {
362
+    if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) {
363 363
       throw new exception($lang['ov_teleport_err_cooldown'], ERR_ERROR);
364 364
     }
365 365
 
366
-    if(mrc_get_level($user, false, RES_DARK_MATTER) < $config->planet_teleport_cost) {
366
+    if (mrc_get_level($user, false, RES_DARK_MATTER) < $config->planet_teleport_cost) {
367 367
       throw new exception($lang['ov_teleport_err_no_dark_matter'], ERR_ERROR);
368 368
     }
369 369
 
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 //    if(!empty($incoming['incoming'])) {
376 376
 //      throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR);
377 377
 //    }
378
-    if(fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) {
378
+    if (fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) {
379 379
       throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR);
380 380
     }
381 381
 
@@ -384,10 +384,10 @@  discard block
 block discarded – undo
384 384
     //  throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR);
385 385
     //}
386 386
 
387
-    if(is_array($new_coordinates)) {
387
+    if (is_array($new_coordinates)) {
388 388
       $new_coordinates['planet_type'] = PT_PLANET;
389 389
       $incoming = DBStaticPlanet::db_planet_by_vector($new_coordinates, '', true, 'id');
390
-      if($incoming['id']) {
390
+      if ($incoming['id']) {
391 391
         throw new exception($lang['ov_teleport_err_destination_busy'], ERR_ERROR);
392 392
       }
393 393
     }
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
       'result'  => ERR_NONE,
397 397
       'message' => '',
398 398
     );
399
-  } catch(exception $e) {
399
+  } catch (exception $e) {
400 400
     $response = array(
401 401
       'result'  => $e->getCode(),
402 402
       'message' => $e->getMessage(),
Please login to merge, or discard this patch.
Braces   +14 added lines, -23 removed lines patch added patch discarded remove patch
@@ -242,24 +242,24 @@  discard block
 block discarded – undo
242 242
  * 1 - copyright 2008 By Chlorel for XNova
243 243
  *
244 244
  */
245
-function SetSelectedPlanet(&$user)
246
-{
245
+function SetSelectedPlanet(&$user) {
247 246
   $planet_row['id'] = $user['current_planet'];
248 247
 
249 248
   // Пытаемся переключить на новую планету
250 249
   if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet'])
251 250
   {
252 251
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id');
253
-  }
254
-  else
252
+  } else
255 253
   {
256 254
     $planet_row = DBStaticPlanet::db_planet_by_id($planet_row['id']);
257 255
   }
258 256
 
259 257
   // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету
260
-  if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
258
+  if(!isset($planet_row['id'])) {
259
+    // || $planet_row['id'] != $user['current_planet']
261 260
   {
262 261
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id');
262
+  }
263 263
     // Если текущей планеты не существует - выставляем Столицу
264 264
     if(!isset($planet_row['id']))
265 265
     {
@@ -284,25 +284,21 @@  discard block
 block discarded – undo
284 284
 }
285 285
 
286 286
 // ----------------------------------------------------------------------------------------------------------------
287
-function uni_render_coordinates($from, $prefix = '')
288
-{
287
+function uni_render_coordinates($from, $prefix = '') {
289 288
   return "[{$from[$prefix . 'galaxy']}:{$from[$prefix . 'system']}:{$from[$prefix . 'planet']}]";
290 289
 }
291 290
 
292
-function uni_render_planet($from)
293
-{
291
+function uni_render_planet($from) {
294 292
   return "{$from['name']} [{$from['galaxy']}:{$from['system']}:{$from['planet']}]";
295 293
 }
296 294
 
297
-function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false)
298
-{
295
+function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) {
299 296
   global $lang;
300 297
 
301 298
   if(!$from['id'])
302 299
   {
303 300
     $result = $lang['sys_planet_expedition'];
304
-  }
305
-  else
301
+  } else
306 302
   {
307 303
     $from_planet_id = $include_id ? (
308 304
       'ID {' . ($from['id'] ? $from['id'] : ($from[$prefix . 'planet_id'] ? $from[$prefix . 'planet_id'] : 0)) . '} '
@@ -318,30 +314,25 @@  discard block
 block discarded – undo
318 314
   return $result;
319 315
 }
320 316
 
321
-function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php')
322
-{
317
+function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php') {
323 318
   return $page . (strpos($page, '?') === false ? '?' : '&') . "galaxy={$from[$prefix . 'galaxy']}&system={$from[$prefix . 'system']}&planet={$from[$prefix . 'planet']}";
324 319
 }
325 320
 
326
-function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '')
327
-{
321
+function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '') {
328 322
   return '<a href="' . uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}") . '"' . ($fleet_type ? " {$fleet_type}" : '') . '>' . uni_render_coordinates($from, $prefix) . '</a>';
329 323
 }
330 324
 
331
-function uni_get_time_to_jump($moon_row)
332
-{
325
+function uni_get_time_to_jump($moon_row) {
333 326
   $jump_gate_level = mrc_get_level($user, $moon_row, STRUC_MOON_GATE);
334 327
   return $jump_gate_level ? max(0, $moon_row['last_jump_time'] + abs(60 * 60 / $jump_gate_level) - SN_TIME_NOW) : 0;
335 328
 }
336 329
 
337
-function uni_calculate_moon_chance($FleetDebris)
338
-{
330
+function uni_calculate_moon_chance($FleetDebris) {
339 331
   $MoonChance = $FleetDebris / 1000000;
340 332
   return ($MoonChance < 1) ? 0 : ($MoonChance>30 ? 30 : $MoonChance);
341 333
 }
342 334
 
343
-function uni_coordinates_valid($coordinates, $prefix = '')
344
-{
335
+function uni_coordinates_valid($coordinates, $prefix = '') {
345 336
   global $config;
346 337
 
347 338
   // array_walk($coordinates, 'intval');
Please login to merge, or discard this patch.
includes/functions/flt_mission_missile.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
   $mip_data = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET);
15 15
   $MIPDamage = floor(mrc_modify_value($attackerTech, false, TECH_WEAPON, $MIPs * $mip_data[P_ATTACK] * mt_rand(80, 120) / 100));
16
-  foreach($structures as $key => $structure)
16
+  foreach ($structures as $key => $structure)
17 17
   {
18 18
     $unit_info = get_unit_param($key);
19 19
     $amplify = isset($mip_data[P_AMPLIFY][$key]) ? $mip_data[P_AMPLIFY][$key] : 1;
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
   {
32 32
     //attacking only selected structure
33 33
     $damageDone = $structures[$targetedStructure][$damageTo];
34
-    $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] );
34
+    $structsDestroyed = min(floor($MIPDamage / $damageDone), $structures[$targetedStructure][0]);
35 35
     $structures[$targetedStructure][0] -= $structsDestroyed;
36
-    $MIPDamage -= $structsDestroyed*$damageDone;
36
+    $MIPDamage -= $structsDestroyed * $damageDone;
37 37
   }
38 38
   else
39 39
   {
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
     do
45 45
     {
46 46
       // finding is there any structure that can be damaged with leftovers of $MIPDamage
47
-      foreach($can_be_damaged as $key => $unit_id)
47
+      foreach ($can_be_damaged as $key => $unit_id)
48 48
       {
49 49
 //debug($structures[$unit_id][0]);
50 50
 //debug($structures[$unit_id][$damageTo], $MIPDamage);
51
-        if($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage)
51
+        if ($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage)
52 52
         {
53 53
           unset($can_be_damaged[$key]);
54 54
         }
55 55
       }
56
-      if(empty($can_be_damaged))
56
+      if (empty($can_be_damaged))
57 57
       {
58 58
         break;
59 59
       }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 //debug($destroyed, 'Actually destroyed');
73 73
 
74 74
 //print('<hr>');
75
-    } while($MIPDamage > 0 && !empty($can_be_damaged));
75
+    } while ($MIPDamage > 0 && !empty($can_be_damaged));
76 76
 //debug($MIPDamage, 'MIPDamage left');
77 77
   }
78 78
 //debug($structures);//die();
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
     $crystal += $destroyed * $unit_info[P_COST][RES_CRYSTAL] / 4;
88 88
   }
89 89
 
90
-  $return['structures'] = $structures;     // Structures left after attack
91
-  $return['metal']      = floor($metal);   // Metal scraps
90
+  $return['structures'] = $structures; // Structures left after attack
91
+  $return['metal']      = floor($metal); // Metal scraps
92 92
   $return['crystal']    = floor($crystal); // Crystal scraps
93 93
 
94 94
   return $return;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
   $iraks = doquery("SELECT * FROM {{iraks}} WHERE `fleet_end_time` <= " . SN_TIME_NOW . " FOR UPDATE;");
114 114
 
115
-  while($fleetRow = db_fetch($iraks)) {
115
+  while ($fleetRow = db_fetch($iraks)) {
116 116
     set_time_limit(15);
117 117
     $db_changeset = array();
118 118
 
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 
129 129
     $rowAttacker = db_user_by_id($fleetRow['fleet_owner'], true);
130 130
 
131
-    if($target_planet_row['id']) {
131
+    if ($target_planet_row['id']) {
132 132
       $planetDefense = array();
133
-      foreach(sn_get_groups('defense_active') as $unit_id) {
133
+      foreach (sn_get_groups('defense_active') as $unit_id) {
134 134
         $planetDefense[$unit_id] = array(mrc_get_level($targetUser, $target_planet_row, $unit_id, true, true));
135 135
       }
136 136
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
         $message = $lang['mip_all_destroyed'];
142 142
         $db_changeset['unit'][] = sn_db_unit_changeset_prepare(UNIT_DEF_MISSILE_INTERCEPTOR, -$missiles, $targetUser, $target_planet_row['id']);
143 143
       } else {
144
-        if($interceptors) {
144
+        if ($interceptors) {
145 145
           $message = sprintf($lang['mip_destroyed'], $interceptors);
146 146
           $db_changeset['unit'][] = sn_db_unit_changeset_prepare(UNIT_DEF_MISSILE_INTERCEPTOR, -$interceptors, $targetUser, $target_planet_row['id']);
147 147
         }
@@ -149,16 +149,16 @@  discard block
 block discarded – undo
149 149
 
150 150
         $attackResult = COE_missileAttack($targetUser, $rowAttacker, $missiles - $interceptors, $planetDefense, $fleetRow['primaer']);
151 151
 
152
-        foreach($attackResult['structures'] as $key => $structure) {
152
+        foreach ($attackResult['structures'] as $key => $structure) {
153 153
           $destroyed = $planetDefense[$key][0] - $structure[0];
154
-          if($destroyed) {
154
+          if ($destroyed) {
155 155
             $db_changeset['unit'][] = sn_db_unit_changeset_prepare($key, -$destroyed, $targetUser, $target_planet_row['id']);
156 156
 
157 157
             $message .= "&nbsp;&nbsp;{$lang['tech'][$key]} - {$destroyed} {$lang['quantity']}<br>";
158 158
           }
159 159
         }
160 160
 
161
-        if(!empty($message)) {
161
+        if (!empty($message)) {
162 162
           $message = $lang['mip_defense_destroyed'] . $message . "{$lang['mip_recycled']}{$lang['Metal']}: {$attackResult['metal']}, {$lang['Crystal']}: {$attackResult['crystal']}<br>";
163 163
 
164 164
           DBStaticPlanet::db_planet_set_by_id($target_planet_row['id'], "`metal` = `metal` + {$attackResult['metal']}, `crystal` = `crystal` + {$attackResult['crystal']}");
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
       empty($message) ? $message = $lang['mip_no_defense'] : false;
179 179
       // empty($message) && ($message = $lang['mip_no_defense']);
180 180
 
181
-      msg_send_simple_message ( $fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message );
182
-      msg_send_simple_message ( $fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message );
181
+      msg_send_simple_message($fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message);
182
+      msg_send_simple_message($fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message);
183 183
     }
184 184
     doquery("DELETE FROM {{iraks}} WHERE id = '{$fleetRow['id']}';");
185 185
   }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@  discard block
 block discarded – undo
4 4
 // Open Source
5 5
 // V1
6 6
 //
7
-function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0')
8
-{
7
+function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0') {
9 8
   // Here we select which part of defense should take damage: structure or shield
10 9
   // $damageTo = P_SHIELD;
11 10
   // $damageTo = P_STRUCTURE;
@@ -34,8 +33,7 @@  discard block
 block discarded – undo
34 33
     $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] );
35 34
     $structures[$targetedStructure][0] -= $structsDestroyed;
36 35
     $MIPDamage -= $structsDestroyed*$damageDone;
37
-  }
38
-  else
36
+  } else
39 37
   {
40 38
     // REALLY random attack
41 39
     $can_be_damaged = sn_get_groups('defense_active');
Please login to merge, or discard this patch.
includes/functions/sys_maintenance.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
     array('query' => 'DELETE FROM {{aks}} WHERE `id` NOT IN (SELECT DISTINCT `fleet_group` FROM {{fleets}});', 'result' => false, 'error' => '', 'affected_rows' => 0),
16 16
   );
17 17
 
18
-  foreach($queries as &$query)
18
+  foreach ($queries as &$query)
19 19
   {
20 20
     $query['result'] = doquery($query['query']);
21 21
     $query['error']  = classSupernova::$db->db_error();
22
-    $query['affected_rows']  = classSupernova::$db->db_affected_rows();
22
+    $query['affected_rows'] = classSupernova::$db->db_affected_rows();
23 23
   }
24 24
 
25 25
   return $queries;
@@ -51,30 +51,30 @@  discard block
 block discarded – undo
51 51
   $recorded_run = strtotime($recorded_run);
52 52
 
53 53
   $prev_run_array = getdate($recorded_run);
54
-  $prev_run_array = array($prev_run_array['seconds'],$prev_run_array['minutes'],$prev_run_array['hours'],$prev_run_array['mday'],$prev_run_array['mon'],$prev_run_array['year']);
54
+  $prev_run_array = array($prev_run_array['seconds'], $prev_run_array['minutes'], $prev_run_array['hours'], $prev_run_array['mday'], $prev_run_array['mon'], $prev_run_array['year']);
55 55
   $today_array = getdate(SN_TIME_NOW);
56
-  $today_array = array($today_array['seconds'],$today_array['minutes'],$today_array['hours'],$today_array['mday'],$today_array['mon'],$today_array['year']);
56
+  $today_array = array($today_array['seconds'], $today_array['minutes'], $today_array['hours'], $today_array['mday'], $today_array['mon'], $today_array['year']);
57 57
   $scheduleList = explode(',', $scheduleList);
58 58
   array_walk($scheduleList, function(&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) {
59 59
     $schedule = array('schedule_array' => array_reverse(explode(':', trim($schedule))));
60 60
 
61 61
     $interval = $date_part_names_reverse[count($schedule['schedule_array'])];
62 62
 
63
-    foreach($prev_run_array as $index => $date_part) {
63
+    foreach ($prev_run_array as $index => $date_part) {
64 64
       $schedule['array']['recorded'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $date_part;
65 65
       $schedule['array']['now'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $today_array[$index];
66 66
     }
67
-    if($schedule['array']['recorded'] == $schedule['array']['now']) {
67
+    if ($schedule['array']['recorded'] == $schedule['array']['now']) {
68 68
       unset($schedule['array']['now']);
69 69
     }
70 70
 
71
-    foreach($schedule['array'] as $name => $array) {
71
+    foreach ($schedule['array'] as $name => $array) {
72 72
       $schedule['string'][$name] = "{$array[5]}-{$array[4]}-{$array[3]} {$array[2]}:{$array[1]}:{$array[0]}";
73 73
       $schedule['string'][$name . '_next'] = $schedule['string'][$name] . ' +1 ' . $interval;
74 74
       $schedule['string'][$name . '_prev'] = $schedule['string'][$name] . ' -1 ' . $interval;
75 75
     }
76 76
 
77
-    foreach($schedule['string'] as $string) {
77
+    foreach ($schedule['string'] as $string) {
78 78
       $timestamp = strtotime($string);
79 79
       $schedule['timestamp'][$timestamp] = $possible_schedules[$timestamp] = date(FMT_DATE_TIME_SQL, strtotime($string));
80 80
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
   $prev_run = 0;
86 86
   $next_run = 0;
87
-  foreach($possible_schedules as $timestamp => $string_date) {
87
+  foreach ($possible_schedules as $timestamp => $string_date) {
88 88
     $prev_run = SN_TIME_NOW >= $timestamp ? $timestamp : $prev_run;
89 89
     $next_run = SN_TIME_NOW < $timestamp && !$next_run ? $timestamp : $next_run;
90 90
   }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-function sys_maintenance()
4
-{
3
+function sys_maintenance() {
5 4
   global $config;
6 5
 
7 6
   $bashing_time_limit = SN_TIME_NOW - $config->fleet_bashing_scope;
@@ -42,8 +41,7 @@  discard block
 block discarded – undo
42 41
  * TODO: 2. [<m|w|d|h|m|s>@]<time>
43 42
  */
44 43
 
45
-function sys_schedule_get_prev_run($scheduleList, $recorded_run = SN_TIME_NOW, $return_next_run = false)
46
-{
44
+function sys_schedule_get_prev_run($scheduleList, $recorded_run = SN_TIME_NOW, $return_next_run = false) {
47 45
   static $date_part_names_reverse = array('seconds', 'minutes', 'hours', 'days', 'months', 'years',);
48 46
 
49 47
   $possible_schedules = array();
Please login to merge, or discard this patch.
includes/functions/lng_language.php 1 patch
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -1,14 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // ----------------------------------------------------------------------------------------------------------------
4
-function lng_try_filepath($path, $file_path_relative)
5
-{
4
+function lng_try_filepath($path, $file_path_relative) {
6 5
   $file_path = SN_ROOT_PHYSICAL . ($path && file_exists(SN_ROOT_PHYSICAL . $path . $file_path_relative) ? $path : '') . $file_path_relative;
7 6
   return file_exists($file_path) ? $file_path : false;
8 7
 }
9 8
 
10
-function lng_die_not_an_object()
11
-{
9
+function lng_die_not_an_object() {
12 10
   print('Ошибка - $lang не объект! Сообщите Администратору сервера и приложите содержимое страницы');
13 11
   $trace = debug_backtrace();
14 12
   unset($trace[0]);
@@ -17,32 +15,27 @@  discard block
 block discarded – undo
17 15
 }
18 16
 
19 17
 // ----------------------------------------------------------------------------------------------------------------
20
-function lng_include($filename, $path = '', $ext = '.mo.php')
21
-{
18
+function lng_include($filename, $path = '', $ext = '.mo.php') {
22 19
   global $lang;
23 20
   return is_object($lang) ? $lang->lng_include($filename, $path, $ext) : lng_die_not_an_object();
24 21
 }
25 22
 
26
-function lng_get_list()
27
-{
23
+function lng_get_list() {
28 24
   global $lang;
29 25
   return is_object($lang) ? $lang->lng_get_list() : lng_die_not_an_object();
30 26
 }
31 27
 
32
-function lng_get_info($entry)
33
-{
28
+function lng_get_info($entry) {
34 29
   global $lang;
35 30
   return is_object($lang) ? $lang->lng_get_info($entry) : lng_die_not_an_object();
36 31
 }
37 32
 
38
-function lng_switch($language_new)
39
-{
33
+function lng_switch($language_new) {
40 34
   global $lang;
41 35
   return is_object($lang) ? $lang->lng_switch($language_new) : lng_die_not_an_object();
42 36
 }
43 37
 
44
-function lng_load_i18n($i18n)
45
-{
38
+function lng_load_i18n($i18n) {
46 39
   global $lang;
47 40
   return is_object($lang) ? $lang->lng_load_i18n($i18n) : lng_die_not_an_object();
48 41
 }
Please login to merge, or discard this patch.
includes/functions/eco_planet_update.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -14,13 +14,13 @@  discard block
 block discarded – undo
14 14
 
15 15
   $no_data = array('user' => false, 'planet' => false, 'que' => false);
16 16
 
17
-  if(!$planet) {
17
+  if (!$planet) {
18 18
     return $no_data;
19 19
   }
20 20
 
21
-  if(!$no_user_update) {
21
+  if (!$no_user_update) {
22 22
     $user = intval(is_array($user) && $user['id'] ? $user['id'] : $user);
23
-    if(!$user) {
23
+    if (!$user) {
24 24
       // TODO - Убрать позже
25 25
       print('<h1>СООБЩИТЕ ЭТО АДМИНУ: sys_o_get_updated() - USER пустой!</h1>');
26 26
       $backtrace = debug_backtrace();
@@ -32,17 +32,17 @@  discard block
 block discarded – undo
32 32
     $user = db_user_by_id($user, !$simulation, '*', true);
33 33
   }
34 34
 
35
-  if(empty($user['id'])) {
35
+  if (empty($user['id'])) {
36 36
     return $no_data;
37 37
   }
38 38
 
39
-  if(is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) {
39
+  if (is_array($planet) && isset($planet['galaxy']) && $planet['galaxy']) {
40 40
     $planet = DBStaticPlanet::db_planet_by_vector($planet, '', !$simulation);
41 41
   } else {
42 42
     $planet = intval(is_array($planet) && isset($planet['id']) ? $planet['id'] : $planet);
43 43
     $planet = DBStaticPlanet::db_planet_by_id($planet, !$simulation);
44 44
   }
45
-  if(!is_array($planet) || !isset($planet['id'])) {
45
+  if (!is_array($planet) || !isset($planet['id'])) {
46 46
     return $no_data;
47 47
   }
48 48
 
@@ -65,15 +65,15 @@  discard block
 block discarded – undo
65 65
     RES_DEUTERIUM => 0,
66 66
   );
67 67
 
68
-  switch($planet['planet_type']) {
68
+  switch ($planet['planet_type']) {
69 69
     case PT_PLANET:
70
-      foreach($resources_increase as $resource_id => &$increment) {
70
+      foreach ($resources_increase as $resource_id => &$increment) {
71 71
         $resource_name = pname_resource_name($resource_id);
72 72
         $increment = $caps_real['total'][$resource_id] * $ProductionTime / 3600;
73 73
         $store_free = $caps_real['total_storage'][$resource_id] - $planet[$resource_name];
74 74
         $increment = min($increment, max(0, $store_free));
75 75
 
76
-        if($planet[$resource_name] + $increment < 0 && !$simulation) {
76
+        if ($planet[$resource_name] + $increment < 0 && !$simulation) {
77 77
           global $debug;
78 78
           $debug->warning("Player ID {$user['id']} have negative resources on ID {$planet['id']}.{$planet['planet_type']} [{$planet['galaxy']}:{$planet['system']}:{$planet['planet']}]. Difference {$planet[$resource_name]} of {$resource_name}", 'Negative Resources', 501);
79 79
         }
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
   // TODO пересчитывать размер планеты только при постройке чего-нибудь и при покупке сектора
96 96
   $planet['field_current'] = 0;
97 97
   $sn_group_build_allow = sn_get_groups('build_allow');
98
-  if(is_array($sn_group_build_allow[$planet['planet_type']])) {
99
-    foreach($sn_group_build_allow[$planet['planet_type']] as $building_id) {
98
+  if (is_array($sn_group_build_allow[$planet['planet_type']])) {
99
+    foreach ($sn_group_build_allow[$planet['planet_type']] as $building_id) {
100 100
       $planet['field_current'] += mrc_get_level($user, $planet, $building_id, !$simulation, true);
101 101
     }
102 102
   }
103 103
 
104
-  if($simulation) {
104
+  if ($simulation) {
105 105
     return array('user' => $user, 'planet' => $planet, 'que' => $que);
106 106
   }
107 107
 
Please login to merge, or discard this patch.