Completed
Push — work-fleets ( 9e446e...674b8a )
by SuperNova.WS
12:48 queued 05:50
created
includes/general.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -685,10 +685,10 @@  discard block
 block discarded – undo
685 685
     $rexep = "#" . strtr(preg_quote($format), $masks) . "#";
686 686
     if (preg_match($rexep, $date, $out)) {
687 687
       $ret = array(
688
-        "tm_sec"  => (int)$out['S'],
689
-        "tm_min"  => (int)$out['M'],
690
-        "tm_hour" => (int)$out['H'],
691
-        "tm_mday" => (int)$out['d'],
688
+        "tm_sec"  => (int) $out['S'],
689
+        "tm_min"  => (int) $out['M'],
690
+        "tm_hour" => (int) $out['H'],
691
+        "tm_mday" => (int) $out['d'],
692 692
         "tm_mon"  => $out['m'] ? $out['m'] - 1 : 0,
693 693
         "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0,
694 694
       );
@@ -1339,7 +1339,7 @@  discard block
 block discarded – undo
1339 1339
     $time_left = min(floor($time_left / PERIOD_DAY), $term_original);
1340 1340
     $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0;
1341 1341
 
1342
-    array_walk_recursive($result, function (&$value) use ($cost_left) {
1342
+    array_walk_recursive($result, function(&$value) use ($cost_left) {
1343 1343
       $value -= $cost_left;
1344 1344
     });
1345 1345
   }
@@ -1500,7 +1500,7 @@  discard block
 block discarded – undo
1500 1500
       break;
1501 1501
     }
1502 1502
     $sort_option_inverse_closure = $sort_option_inverse ? -1 : 1;
1503
-    usort($ListToSort, function ($a, $b) use ($sort_option_field, $sort_option_inverse_closure) {
1503
+    usort($ListToSort, function($a, $b) use ($sort_option_field, $sort_option_inverse_closure) {
1504 1504
       return $a[$sort_option_field] < $b[$sort_option_field] ? -1 * $sort_option_inverse_closure : (
1505 1505
       $a[$sort_option_field] > $b[$sort_option_field] ? 1 * $sort_option_inverse_closure : 0
1506 1506
       );
Please login to merge, or discard this patch.
includes/init.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Защита от двойного инита
4
-if(defined('INIT')) {
4
+if (defined('INIT')) {
5 5
   return;
6 6
 }
7 7
 
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 define('SN_DEBUG_PDUMP_CALLER', true);
20 20
 
21 21
 // Бенчмарк
22
-register_shutdown_function(function () {
23
-  if(defined('IN_AJAX')) {
22
+register_shutdown_function(function() {
23
+  if (defined('IN_AJAX')) {
24 24
     return;
25 25
   }
26 26
 
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
     (!empty($locale_cache_statistic['misses']) ? ', LOCALE MISSED' : '') .
31 31
     (class_exists('classSupernova') && is_object(classSupernova::$db) ? ', DB time: ' . classSupernova::$db->time_mysql_total . 'ms' : '') .
32 32
     '</div>');
33
-  if($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) {
33
+  if ($user['authlevel'] >= 2 && file_exists(SN_ROOT_PHYSICAL . 'badqrys.txt') && @filesize(SN_ROOT_PHYSICAL . 'badqrys.txt') > 0) {
34 34
     echo '<a href="badqrys.txt" target="_blank" style="color:red">', 'HACK ALERT!', '</a>';
35 35
   }
36 36
 
37
-  if(!empty($locale_cache_statistic['misses'])) {
37
+  if (!empty($locale_cache_statistic['misses'])) {
38 38
     print('<!--');
39 39
     pdump($locale_cache_statistic);
40 40
     print('-->');
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
 define('SN_TIME_NOW_GMT_STRING', gmdate(DATE_ATOM, SN_TIME_NOW));
56 56
 
57
-if(strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) {
57
+if (strpos(strtolower($_SERVER['SERVER_NAME']), 'google.') !== false) {
58 58
   define('SN_GOOGLE', true);
59 59
 }
60 60
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 ini_set('error_reporting', E_ALL ^ E_NOTICE);
83 83
 
84 84
 empty($classRoot) ? $classRoot = SN_ROOT_PHYSICAL . 'classes/' : false;
85
-spl_autoload_register(function ($class) use ($classRoot) {
85
+spl_autoload_register(function($class) use ($classRoot) {
86 86
   $class = str_replace('\\', '/', $class);
87 87
   if (file_exists($classRoot . $class . '.php')) {
88 88
     require_once $classRoot . $class . '.php';
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 // Но нужно, пока у нас есть не MVC-страницы
162 162
 $sn_page_data = $sn_data['pages'][$sn_page_name];
163 163
 $sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX;
164
-if($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) {
164
+if ($sn_page_name && isset($sn_page_data) && file_exists($sn_page_name_file)) {
165 165
   require_once($sn_page_name_file);
166
-  if(is_array($sn_page_data['options'])) {
166
+  if (is_array($sn_page_data['options'])) {
167 167
     classSupernova::$options = array_merge(classSupernova::$options, $sn_page_data['options']);
168 168
   }
169 169
 }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
 
175 175
 // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу
176
-if(!isset($sn_data['pages'][$sn_page_name])) {
176
+if (!isset($sn_data['pages'][$sn_page_name])) {
177 177
   $sn_page_name = '';
178 178
 }
179 179
 
@@ -181,6 +181,6 @@  discard block
 block discarded – undo
181 181
 classLocale::$lang = $lang = classSupernova::$gc->localePlayer;
182 182
 classLocale::$lang->lng_switch(sys_get_param_str('lang'));
183 183
 
184
-if(!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) {
184
+if (!defined('DEBUG_INIT_SKIP_SECONDARY') || DEBUG_INIT_SKIP_SECONDARY !== true) {
185 185
   require_once "init_secondary.php";
186 186
 }
Please login to merge, or discard this patch.
includes/init/init_functions.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 // ------------------------------------------------------------------------------------------------------------------------------
4 4
 function sn_sys_load_php_files($dir_name, $load_extension = '.php', $modules = false) {
5
-  if(!file_exists($dir_name) || !is_dir($dir_name)) {
5
+  if (!file_exists($dir_name) || !is_dir($dir_name)) {
6 6
     return;
7 7
   }
8 8
 
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function init_update() {
41 41
   $update_file = SN_ROOT_PHYSICAL . "includes/update" . DOT_PHP_EX;
42
-  if(file_exists($update_file)) {
43
-    if(filemtime($update_file) > classSupernova::$config->db_loadItem('var_db_update') || classSupernova::$config->db_loadItem('db_version') < DB_VERSION) {
44
-      if(defined('IN_ADMIN')) {
42
+  if (file_exists($update_file)) {
43
+    if (filemtime($update_file) > classSupernova::$config->db_loadItem('var_db_update') || classSupernova::$config->db_loadItem('db_version') < DB_VERSION) {
44
+      if (defined('IN_ADMIN')) {
45 45
         sn_db_transaction_start(); // Для защиты от двойного запуска апдейта - начинаем транзакцию. Так запись в базе будет блокирована
46
-        if(SN_TIME_NOW >= classSupernova::$config->db_loadItem('var_db_update_end')) {
46
+        if (SN_TIME_NOW >= classSupernova::$config->db_loadItem('var_db_update_end')) {
47 47
           classSupernova::$config->db_saveItem('var_db_update_end', SN_TIME_NOW + (classSupernova::$config->upd_lock_time ? classSupernova::$config->upd_lock_time : 300));
48 48
           sn_db_transaction_commit();
49 49
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
           $current_time = time();
54 54
           classSupernova::$config->db_saveItem('var_db_update', $current_time);
55 55
           classSupernova::$config->db_saveItem('var_db_update_end', $current_time);
56
-        } elseif(filemtime($update_file) > classSupernova::$config->var_db_update) {
56
+        } elseif (filemtime($update_file) > classSupernova::$config->var_db_update) {
57 57
           $timeout = classSupernova::$config->var_db_update_end - SN_TIME_NOW;
58 58
           die(
59 59
             "Обновляется база данных. Рассчетное время окончания - {$timeout} секунд (время обновления может увеличиваться). Пожалуйста, подождите...<br />
Please login to merge, or discard this patch.
includes/update.php 1 patch
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 
24 24
 use Vector\Vector;
25 25
 
26
-if(!defined('INIT')) {
26
+if (!defined('INIT')) {
27 27
 //  include_once('init.php');
28 28
   die('Unauthorized access');
29 29
 }
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 classSupernova::$config->debug = 0;
42 42
 
43 43
 
44
-if(classSupernova::$config->db_version == DB_VERSION) {
45
-} elseif(classSupernova::$config->db_version > DB_VERSION) {
44
+if (classSupernova::$config->db_version == DB_VERSION) {
45
+} elseif (classSupernova::$config->db_version > DB_VERSION) {
46 46
   classSupernova::$config->db_saveItem('var_db_update_end', SN_TIME_NOW);
47 47
   die(
48 48
   'Internal error! Auotupdater detects DB version greater then can be handled!<br />
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
   );
52 52
 }
53 53
 
54
-if(classSupernova::$config->db_version < 26) {
54
+if (classSupernova::$config->db_version < 26) {
55 55
   $sys_log_disabled = true;
56 56
 }
57 57
 
@@ -70,20 +70,20 @@  discard block
 block discarded – undo
70 70
 $update_tables = array();
71 71
 $update_indexes = array();
72 72
 $query = upd_do_query('SHOW TABLES;', true);
73
-while($row = classSupernova::$db->db_fetch_row($query)) {
73
+while ($row = classSupernova::$db->db_fetch_row($query)) {
74 74
   upd_load_table_info($row[0]);
75 75
 }
76 76
 upd_log_message('Table info loaded. Now looking DB for upgrades...');
77 77
 
78 78
 upd_do_query('SET FOREIGN_KEY_CHECKS=0;', true);
79 79
 
80
-if($new_version < 37) {
80
+if ($new_version < 37) {
81 81
   die('Upgrade from SN versions below 37 are not supported. Use SN version 39 to upgrade old DB then use V40+ for further upgrade');
82 82
 }
83 83
 
84 84
 ini_set('memory_limit', '1024M');
85 85
 
86
-switch($new_version) {
86
+switch ($new_version) {
87 87
   case 37:
88 88
     upd_log_version_update();
89 89
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
     upd_check_key('payment_currency_exchange_mm_', 2500, !classSupernova::$config->payment_currency_exchange_mm_);
100 100
 
101
-    if(!$update_tables['log_metamatter']) {
101
+    if (!$update_tables['log_metamatter']) {
102 102
       upd_create_table('log_metamatter',
103 103
         "(
104 104
           `id` SERIAL,
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
       "ADD `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'",
124 124
     ), !$update_tables['payment']['payment_test']);
125 125
 
126
-    if($update_tables['payment']['payment_test']['Default'] == 1) {
126
+    if ($update_tables['payment']['payment_test']['Default'] == 1) {
127 127
       upd_alter_table('payment', array(
128 128
         "MODIFY COLUMN `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'",
129 129
       ));
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     ), $update_tables['users']['metamatter']['Type'] == 'int(20)');
141 141
 
142 142
     $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = " . QUE_RESEARCH . " AND que_unit_id IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") FOR UPDATE");
143
-    while($row = db_fetch($query)) {
143
+    while ($row = db_fetch($query)) {
144 144
       $planet_id = ($row['que_planet_id_origin'] ? $row['que_planet_id_origin'] : $row['que_planet_id']);
145 145
       upd_do_query("SELECT id FROM {{planets}} WHERE id = {$planet_id} FOR UPDATE");
146 146
       $price = sys_unit_str2arr($row['que_unit_price']);
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
     LEFT JOIN {{planets}} AS p ON p.id = u.id_planet
159 159
     WHERE unit_snid IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ")
160 160
     FOR UPDATE");
161
-    while($row = db_fetch($query)) {
162
-      if(!$row['id_planet']) {
161
+    while ($row = db_fetch($query)) {
162
+      if (!$row['id_planet']) {
163 163
         continue;
164 164
       }
165 165
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
       $unit_level = $row['unit_level'];
168 168
       $price = get_unit_param($unit_id, P_COST);
169 169
       $factor = $price['factor'];
170
-      foreach($price as $resource_id => &$resource_amount) {
170
+      foreach ($price as $resource_id => &$resource_amount) {
171 171
         $resource_amount = $resource_amount * (pow($factor, $unit_level) - 1) / ($factor - 1);
172 172
       }
173 173
       // upd_do_query
@@ -186,14 +186,14 @@  discard block
 block discarded – undo
186 186
     // Вернуть ресы за уже исследованную Экспедиционную технологию
187 187
     upd_check_key('player_max_colonies', -1, classSupernova::$config->player_max_colonies >= 0);
188 188
 
189
-    if(!isset($update_tables['users']['player_rpg_explore_xp'])) {
189
+    if (!isset($update_tables['users']['player_rpg_explore_xp'])) {
190 190
       upd_alter_table('users', array(
191 191
         "ADD COLUMN `player_rpg_explore_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`",
192 192
         "ADD COLUMN `player_rpg_explore_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`",
193 193
       ), !isset($update_tables['users']['player_rpg_explore_xp']));
194 194
     }
195 195
 
196
-    if(!$update_tables['log_users_online']) {
196
+    if (!$update_tables['log_users_online']) {
197 197
       upd_create_table('log_users_online', "(
198 198
         `online_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Measure time',
199 199
         `online_count` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Users online',
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
       "ADD `user_time_measured` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'When was time diff measured last time' AFTER `onlinetime`",
209 209
     ), !$update_tables['users']['user_time_measured']);
210 210
 
211
-    if($update_tables['rw']) {
211
+    if ($update_tables['rw']) {
212 212
       upd_do_query("DROP TABLE IF EXISTS {{rw}};");
213 213
     }
214 214
 
215
-    if(!$update_tables['player_award']) {
215
+    if (!$update_tables['player_award']) {
216 216
       upd_create_table('player_award', "(
217 217
         `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
218 218
         `award_type_id` int(11) DEFAULT NULL COMMENT 'Award type i.e. order, medal, pennant, rank etc',
@@ -254,14 +254,14 @@  discard block
 block discarded – undo
254 254
     upd_log_version_update();
255 255
 
256 256
 
257
-    if(!isset($update_tables['planets']['que_processed'])) {
257
+    if (!isset($update_tables['planets']['que_processed'])) {
258 258
       upd_alter_table('planets', array(
259 259
         "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `last_update`",
260 260
       ), true);
261 261
       upd_do_query("UPDATE {{planets}} SET que_processed = last_update;");
262 262
     }
263 263
 
264
-    if(!isset($update_tables['users']['que_processed'])) {
264
+    if (!isset($update_tables['users']['que_processed'])) {
265 265
       upd_alter_table('users', array(
266 266
         "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `onlinetime`",
267 267
       ), true);
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
     }
270 270
 
271 271
 
272
-    if(isset($update_tables['planets']['que'])) {
272
+    if (isset($update_tables['planets']['que'])) {
273 273
       $sn_data_aux = array(
274 274
         SHIP_SMALL_FIGHTER_WRATH    => array(
275 275
           'name' => 'ship_fighter_wrath',
@@ -354,20 +354,20 @@  discard block
 block discarded – undo
354 354
       $unit_data = array();
355 355
       $planets = array();
356 356
 
357
-      foreach($planet_unit_list as $unit_id) {
358
-        if(!($unit_name = get_unit_param($unit_id, P_NAME))) {
357
+      foreach ($planet_unit_list as $unit_id) {
358
+        if (!($unit_name = get_unit_param($unit_id, P_NAME))) {
359 359
           $unit_name = $sn_data_aux[$unit_id][P_NAME];
360 360
         }
361
-        if(isset($update_tables['planets'][$unit_name])) {
361
+        if (isset($update_tables['planets'][$unit_name])) {
362 362
           $drop[] = "DROP COLUMN `{$unit_name}`";
363 363
 
364
-          if(isset($aux_group[$unit_id])) {
364
+          if (isset($aux_group[$unit_id])) {
365 365
             $units_info[$unit_id] = $sn_data_aux[$unit_id];
366 366
             $units_info[$unit_id]['que'] = QUE_HANGAR;
367 367
           } else {
368 368
             $units_info[$unit_id] = get_unit_param($unit_id);
369
-            foreach($ques_info as $que_id => $que_data1) {
370
-              if(in_array($unit_id, $que_data1['unit_list'])) {
369
+            foreach ($ques_info as $que_id => $que_data1) {
370
+              if (in_array($unit_id, $que_data1['unit_list'])) {
371 371
                 $units_info[$unit_id]['que'] = $que_id;
372 372
                 break;
373 373
               }
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
       }
378 378
 
379 379
       $query = upd_do_query("SELECT * FROM {{planets}} FOR UPDATE");
380
-      while($row = db_fetch($query)) {
380
+      while ($row = db_fetch($query)) {
381 381
         $user_id = $row['id_owner'];
382 382
         $planet_id = $row['id'];
383 383
 
@@ -385,14 +385,14 @@  discard block
 block discarded – undo
385 385
 
386 386
         // Конвертируем юниты
387 387
         $units_levels = array();
388
-        foreach($planet_unit_list as $unit_id) {
388
+        foreach ($planet_unit_list as $unit_id) {
389 389
           $unit_name = &$units_info[$unit_id][P_NAME];
390
-          if(!isset($row[$unit_name]) || !$row[$unit_name]) {
390
+          if (!isset($row[$unit_name]) || !$row[$unit_name]) {
391 391
             continue;
392 392
           }
393 393
           $units_levels[$unit_id] = $row[$unit_name];
394 394
           $unit_data[] = "({$user_id}," . LOC_PLANET . ",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})";
395
-          if(count($unit_data) > 30) {
395
+          if (count($unit_data) > 30) {
396 396
             $unit_data_max = strlen(implode(',', $unit_data)) > $unit_data_max ? strlen(implode(',', $unit_data)) : $unit_data_max;
397 397
             upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';');
398 398
             $unit_data = array();
@@ -400,10 +400,10 @@  discard block
 block discarded – undo
400 400
         }
401 401
 
402 402
         // Конвертируем очередь построек
403
-        if($row['que']) {
403
+        if ($row['que']) {
404 404
           $que = explode(';', $row['que']);
405
-          foreach($que as $que_item) {
406
-            if(!$que_item) {
405
+          foreach ($que as $que_item) {
406
+            if (!$que_item) {
407 407
               continue;
408 408
             }
409 409
 
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
             $unit_factor = $unit_cost[P_FACTOR] ? $unit_cost[P_FACTOR] : 1;
419 419
             $price_increase = pow($unit_factor, $unit_level);
420 420
             // $unit_time = 0;
421
-            foreach($unit_cost as $resource_id => &$resource_amount) {
422
-              if(!in_array($resource_id, $group_resource_loot)) {
421
+            foreach ($unit_cost as $resource_id => &$resource_amount) {
422
+              if (!in_array($resource_id, $group_resource_loot)) {
423 423
                 unset($unit_cost[$resource_id]);
424 424
                 continue;
425 425
               }
@@ -433,38 +433,38 @@  discard block
 block discarded – undo
433 433
         }
434 434
 
435 435
         // Конвертируем очередь верфи
436
-        if($row['b_hangar_id']) {
436
+        if ($row['b_hangar_id']) {
437 437
           $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0,);
438 438
           $hangar_units = sys_unit_str2arr($row['b_hangar_id']);
439
-          foreach($hangar_units as $unit_id => $unit_count) {
440
-            if($unit_count <= 0) {
439
+          foreach ($hangar_units as $unit_id => $unit_count) {
440
+            if ($unit_count <= 0) {
441 441
               continue;
442 442
             }
443
-            foreach($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) {
444
-              if(!in_array($resource_id, $group_resource_loot)) {
443
+            foreach ($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) {
444
+              if (!in_array($resource_id, $group_resource_loot)) {
445 445
                 continue;
446 446
               }
447 447
               $return_resources[$resource_id] += $unit_count * $resource_amount;
448 448
             }
449 449
           }
450
-          if(array_sum($return_resources) > 0) {
450
+          if (array_sum($return_resources) > 0) {
451 451
             upd_do_query("UPDATE {{planets}} SET `metal` = `metal` + {$return_resources[RES_METAL]}, `crystal` = `crystal` + {$return_resources[RES_CRYSTAL]}, `deuterium` = `deuterium` + {$return_resources[RES_DEUTERIUM]} WHERE `id` = {$planet_id} LIMIT 1");
452 452
           }
453 453
         }
454 454
 
455 455
 
456
-        if(count($que_data) > 10) {
456
+        if (count($que_data) > 10) {
457 457
           $que_data_max = strlen(implode(',', $que_data)) > $que_data_max ? strlen(implode(',', $que_data)) : $que_data_max;
458 458
           upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';');
459 459
           $que_data = array();
460 460
         }
461 461
       }
462 462
 
463
-      if(!empty($unit_data)) {
463
+      if (!empty($unit_data)) {
464 464
         upd_do_query('REPLACE INTO {{unit}} (`unit_player_id`, `unit_location_type`, `unit_location_id`, `unit_type`, `unit_snid`, `unit_level`) VALUES ' . implode(',', $unit_data) . ';');
465 465
       }
466 466
 
467
-      if(!empty($que_data)) {
467
+      if (!empty($que_data)) {
468 468
         upd_do_query('INSERT INTO {{que}} (`que_player_id`, `que_planet_id`, `que_planet_id_origin`, `que_type`, `que_time_left`, `que_unit_id`, `que_unit_amount`, `que_unit_mode`, `que_unit_level`, `que_unit_time`, `que_unit_price`) VALUES ' . implode(',', $que_data) . ';');
469 469
       }
470 470
 
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
       JOIN `{{users}}` AS u ON a.`id` = u.`user_as_ally` AND `user_as_ally` IS NOT NULL AND `username` = ''
476 476
       SET u.`username` = CONCAT('[', a.`ally_tag`, ']');");
477 477
 
478
-    if($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') {
478
+    if ($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') {
479 479
       upd_do_query("SET FOREIGN_KEY_CHECKS=0;");
480 480
       upd_alter_table('statpoints', "DROP FOREIGN KEY `FK_stats_id_ally`", $update_foreigns['statpoints']['FK_stats_id_ally']);
481 481
       upd_alter_table('statpoints', "DROP KEY `I_stats_id_ally`", $update_indexes['statpoints']['I_stats_id_ally']);
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
       "ADD CONSTRAINT `FK_users_browser_id` FOREIGN KEY (`user_last_browser_id`) REFERENCES `{{security_browser}}` (`browser_id`) ON DELETE SET NULL ON UPDATE CASCADE",
572 572
     ), !isset($update_tables['users']['user_last_proxy']));
573 573
 
574
-    if(!isset($update_tables['notes']['planet_type'])) {
574
+    if (!isset($update_tables['notes']['planet_type'])) {
575 575
       upd_alter_table('notes', array(
576 576
         "ADD COLUMN `galaxy` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `title`",
577 577
         "ADD COLUMN `system` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `galaxy`",
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
     upd_alter_table('users', "ADD COLUMN `user_bot` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['users']['user_bot']));
590 590
     upd_alter_table('unit', "ADD KEY `I_unit_type_snid` (unit_type, unit_snid) USING BTREE", !$update_indexes['unit']['I_unit_type_snid']);
591 591
 
592
-    if($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') {
592
+    if ($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') {
593 593
       upd_alter_table('users', array(
594 594
         "MODIFY COLUMN `settings_tooltiptime` smallint(5) unsigned NOT NULL DEFAULT '500'",
595 595
       ), $update_tables['users']['settings_tooltiptime']['Type'] != 'smallint');
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
       upd_do_query("UPDATE `{{users}}` SET settings_tooltiptime = 500;");
598 598
     }
599 599
 
600
-    if(!isset($update_tables['log_users_online']['online_aggregated'])) {
600
+    if (!isset($update_tables['log_users_online']['online_aggregated'])) {
601 601
       upd_alter_table('log_users_online', "ADD COLUMN `online_aggregated` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['log_users_online']['online_aggregated']));
602 602
       upd_alter_table('log_users_online', array(
603 603
         "DROP PRIMARY KEY",
@@ -605,13 +605,13 @@  discard block
 block discarded – undo
605 605
       ), $update_indexes['log_users_online']['PRIMARY'] != 'online_timestamp,online_aggregated,');
606 606
     }
607 607
 
608
-    if(!isset($update_tables['users']['gender'])) {
608
+    if (!isset($update_tables['users']['gender'])) {
609 609
       upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT " . GENDER_UNKNOWN, !isset($update_tables['users']['gender']));
610 610
       upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE . ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));");
611 611
     }
612 612
     upd_alter_table('users', "DROP COLUMN `sex`", isset($update_tables['users']['sex']));
613 613
 
614
-    if(!$update_tables['users']['dark_matter_total']) {
614
+    if (!$update_tables['users']['dark_matter_total']) {
615 615
       upd_alter_table('users', "ADD `dark_matter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Dark Matter amount ever gained' AFTER `dark_matter`", !$update_tables['users']['dark_matter_total']);
616 616
       upd_do_query(
617 617
         "UPDATE `{{users}}` AS u
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
     }
625 625
 
626 626
     upd_check_key('player_metamatter_immortal', 100000, !isset(classSupernova::$config->player_metamatter_immortal));
627
-    if(!$update_tables['users']['metamatter_total']) {
627
+    if (!$update_tables['users']['metamatter_total']) {
628 628
       upd_alter_table('users', "ADD `metamatter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Metamatter amount ever bought'", !$update_tables['users']['metamatter_total']);
629 629
 
630 630
       upd_do_query(
@@ -636,11 +636,11 @@  discard block
 block discarded – undo
636 636
             (SELECT IF(sum(amount) IS NULL, 0, sum(amount)) FROM {{log_metamatter}} AS mm WHERE mm.user_id = u.id AND mm.amount > 0)
637 637
           );");
638 638
     }
639
-    if(!isset($update_tables['users']['immortal'])) {
639
+    if (!isset($update_tables['users']['immortal'])) {
640 640
       upd_alter_table('users', "ADD COLUMN `immortal` TIMESTAMP NULL", !isset($update_tables['users']['immortal']));
641 641
       upd_do_query("UPDATE {{users}} SET `immortal` = NOW() WHERE `metamatter_total` > 0;");
642 642
     }
643
-    if(isset($update_tables['player_award'])) {
643
+    if (isset($update_tables['player_award'])) {
644 644
       upd_do_query(
645 645
         "UPDATE {{users}} AS u JOIN {{player_award}} AS pa ON u.id = pa.player_id
646 646
           SET metamatter_total = 1, immortal = NOW()
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
       CONSTRAINT `FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
668 668
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
669 669
 
670
-    if(empty($update_tables['blitz_statpoints'])) {
670
+    if (empty($update_tables['blitz_statpoints'])) {
671 671
       upd_create_table('blitz_statpoints', " (
672 672
         `stat_date` int(11) NOT NULL DEFAULT '0',
673 673
         `id_owner` bigint(20) unsigned DEFAULT NULL,
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
       CONSTRAINT `FK_survey_votes_survey_parent_id` FOREIGN KEY (`survey_parent_id`) REFERENCES `{{survey}}` (`survey_id`) ON DELETE CASCADE ON UPDATE CASCADE
736 736
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
737 737
 
738
-    if(empty($update_tables['security_url'])) {
738
+    if (empty($update_tables['security_url'])) {
739 739
       upd_create_table('security_url', " (
740 740
         `url_id` int unsigned NOT NULL AUTO_INCREMENT,
741 741
         `url_string` VARCHAR(250) NOT NULL DEFAULT '',
@@ -748,9 +748,9 @@  discard block
 block discarded – undo
748 748
 
749 749
         $strings = array();
750 750
         $query = classSupernova::$db->doSql($query);
751
-        while($row = db_fetch($query)) {
751
+        while ($row = db_fetch($query)) {
752 752
           $strings[] = '("' . db_escape($row['url']) . '")';
753
-          if(count($strings) > 100) {
753
+          if (count($strings) > 100) {
754 754
             classSupernova::$db->doSql($query_string . implode(',', $strings));
755 755
             $strings = array();
756 756
           }
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
         !empty($strings) ? classSupernova::$db->doSql($query_string . implode(',', $strings)) : false;
759 759
       }
760 760
 
761
-      if(isset($update_tables['counter']['page'])) // TODO REMOVE
761
+      if (isset($update_tables['counter']['page'])) // TODO REMOVE
762 762
       {
763 763
         update_security_url("SELECT DISTINCT `page` AS url FROM {{counter}}");
764 764
         update_security_url("SELECT DISTINCT `url` AS url FROM {{counter}}");
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
       "ADD CONSTRAINT `FK_counter_page_url_id` FOREIGN KEY (`page_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE",
784 784
       "ADD CONSTRAINT `FK_counter_plain_url_id` FOREIGN KEY (`plain_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE",
785 785
     ), !isset($update_tables['counter']['device_id']));
786
-    if(isset($update_tables['counter']['ip'])) {
786
+    if (isset($update_tables['counter']['ip'])) {
787 787
       // upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `user_proxy` = `proxy`, `visit_time` = FROM_UNIXTIME(`time`)');
788 788
       upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `visit_time` = FROM_UNIXTIME(`time`)');
789 789
       upd_do_query('UPDATE `{{counter}}` AS c JOIN {{security_url}} AS u ON u.url_string = c.page SET c.page_url_id = u.url_id');
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
 
835 835
     upd_check_key('stats_history_days', 14, !classSupernova::$config->stats_history_days);
836 836
 
837
-    if(classSupernova::$config->payment_currency_default != 'USD') {
837
+    if (classSupernova::$config->payment_currency_default != 'USD') {
838 838
       upd_check_key('payment_currency_default', 'USD', true);
839 839
       upd_check_key('payment_currency_exchange_dm_', 20000, true);
840 840
       upd_check_key('payment_currency_exchange_mm_', 20000, true);
@@ -917,7 +917,7 @@  discard block
 block discarded – undo
917 917
     function propagade_player_options($old_option_name, $new_option_id) {
918 918
       global $update_tables;
919 919
 
920
-      if(!empty($update_tables['users'][$old_option_name])) {
920
+      if (!empty($update_tables['users'][$old_option_name])) {
921 921
         upd_do_query(
922 922
           "REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`)
923 923
           SELECT `id`, {$new_option_id}, `{$old_option_name}`
@@ -951,7 +951,7 @@  discard block
 block discarded – undo
951 951
 
952 952
 
953 953
     // 2015-08-03 15:05:26 40a6.0
954
-    if(empty($update_tables['planets']['position_original'])) {
954
+    if (empty($update_tables['planets']['position_original'])) {
955 955
       upd_alter_table('planets', array(
956 956
         "ADD COLUMN `position_original` smallint NOT NULL DEFAULT 0",
957 957
         "ADD COLUMN `field_max_original` smallint NOT NULL DEFAULT 0",
@@ -979,12 +979,12 @@  discard block
 block discarded – undo
979 979
 
980 980
     // 2015-08-27 19:14:05 40a10.0
981 981
     // Старая версия таблицы
982
-    if(!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) {
982
+    if (!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) {
983 983
       upd_drop_table('account');
984 984
       upd_drop_table('account_translate');
985 985
     }
986 986
 
987
-    if(empty($update_tables['account'])) {
987
+    if (empty($update_tables['account'])) {
988 988
       upd_create_table('account', " (
989 989
           `account_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
990 990
           `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '',
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
 
1047 1047
 
1048 1048
     // 2015-09-24 11:39:37 40a10.25
1049
-    if(empty($update_tables['log_metamatter']['provider_id'])) {
1049
+    if (empty($update_tables['log_metamatter']['provider_id'])) {
1050 1050
       upd_alter_table('log_metamatter', array(
1051 1051
         "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider'",
1052 1052
         "ADD COLUMN `account_id` bigint(20) unsigned NOT NULL DEFAULT 0",
@@ -1098,7 +1098,7 @@  discard block
 block discarded – undo
1098 1098
     upd_check_key('event_halloween_2015_code', '', !isset(classSupernova::$config->event_halloween_2015_code));
1099 1099
     upd_check_key('event_halloween_2015_timestamp', SN_TIME_SQL, !isset(classSupernova::$config->event_halloween_2015_timestamp));
1100 1100
     upd_check_key('event_halloween_2015_units_used', serialize(array()), !isset(classSupernova::$config->event_halloween_2015_units_used));
1101
-    if(empty($update_tables['log_halloween_2015'])) {
1101
+    if (empty($update_tables['log_halloween_2015'])) {
1102 1102
       upd_create_table('log_halloween_2015', " (
1103 1103
       `log_hw2015_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1104 1104
       `player_id` bigint(20) unsigned NOT NULL COMMENT 'User ID',
@@ -1113,7 +1113,7 @@  discard block
 block discarded – undo
1113 1113
 
1114 1114
 
1115 1115
     // 2015-11-28 06:30:27 40a19.21
1116
-    if(!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) {
1116
+    if (!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) {
1117 1117
       upd_alter_table('ube_report', array(
1118 1118
         "ADD COLUMN `ube_report_debris_total_in_metal` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Total debris in metal'",
1119 1119
         "ADD KEY `I_ube_report_time_debris_id` (`ube_report_time_process` DESC, `ube_report_debris_total_in_metal` DESC, `ube_report_id` ASC)", // For Best Battles module
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 
1129 1129
 
1130 1130
     // 2015-12-06 15:10:58 40b1.0
1131
-    if(!empty($update_indexes['planets']['I_metal_mine'])) {
1131
+    if (!empty($update_indexes['planets']['I_metal_mine'])) {
1132 1132
       upd_alter_table('planets', "DROP KEY `I_metal`", $update_indexes['planets']['I_metal']);
1133 1133
       upd_alter_table('planets', "DROP KEY `I_ship_sattelite_sloth`", $update_indexes['planets']['I_ship_sattelite_sloth']);
1134 1134
       upd_alter_table('planets', "DROP KEY `I_ship_bomber_envy`", $update_indexes['planets']['I_ship_bomber_envy']);
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
   case 40:
1192 1192
     upd_log_version_update();
1193 1193
 
1194
-    if(empty($update_tables['festival'])) {
1194
+    if (empty($update_tables['festival'])) {
1195 1195
       upd_create_table('festival', " (
1196 1196
           `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
1197 1197
           `start` datetime NOT NULL COMMENT 'Festival start datetime',
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
       );
1233 1233
     }
1234 1234
 
1235
-    if(empty($update_tables['festival_unit'])) {
1235
+    if (empty($update_tables['festival_unit'])) {
1236 1236
       upd_create_table('festival_unit', " (
1237 1237
           `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1238 1238
           `highspot_id` int(10) unsigned DEFAULT NULL,
@@ -1249,7 +1249,7 @@  discard block
 block discarded – undo
1249 1249
     }
1250 1250
 
1251 1251
     // 2015-12-21 06:06:09 41a0.12
1252
-    if(empty($update_tables['festival_unit_log'])) {
1252
+    if (empty($update_tables['festival_unit_log'])) {
1253 1253
       upd_create_table('festival_unit_log', " (
1254 1254
           `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1255 1255
           `highspot_id` int(10) unsigned DEFAULT NULL,
@@ -1279,16 +1279,16 @@  discard block
 block discarded – undo
1279 1279
       $update_tables['security_browser']['browser_user_agent']['Collation'] == 'latin1_bin'
1280 1280
     );
1281 1281
 
1282
-    if($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') {
1282
+    if ($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') {
1283 1283
       upd_alter_table('security_browser', "DROP KEY `I_browser_user_agent`", true);
1284 1284
       upd_alter_table('security_browser', "ADD KEY `I_browser_user_agent` (`browser_user_agent`) USING HASH", true);
1285 1285
     }
1286 1286
 
1287
-    if(!empty($update_tables['fleets']['fleet_array'])) {
1287
+    if (!empty($update_tables['fleets']['fleet_array'])) {
1288 1288
       $query = upd_do_query("SELECT * FROM {{fleets}}");
1289
-      while($row = db_fetch($query)) {
1289
+      while ($row = db_fetch($query)) {
1290 1290
         $unit_list = sys_unit_str2arr($row['fleet_array']);
1291
-        foreach($unit_list as $unit_id => $unit_count) {
1291
+        foreach ($unit_list as $unit_id => $unit_count) {
1292 1292
           upd_do_query(
1293 1293
             "REPLACE INTO {{unit}} (`unit_player_id`,`unit_location_type`,`unit_location_id`,`unit_type`,`unit_snid`,`unit_level`) VALUES
1294 1294
               ({$row['fleet_owner']}, " . LOC_FLEET . ", {$row['fleet_id']}, 200, {$unit_id}, {$unit_count});",
@@ -1325,7 +1325,7 @@  discard block
 block discarded – undo
1325 1325
 
1326 1326
 classSupernova::$cache->unset_by_prefix('lng_');
1327 1327
 
1328
-if($new_version) {
1328
+if ($new_version) {
1329 1329
   classSupernova::$config->db_saveItem('db_version', $new_version);
1330 1330
   upd_log_message("<font color=green>DB version is now {$new_version}</font>");
1331 1331
 } else {
Please login to merge, or discard this patch.
includes/includes/flt_page4.inc 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,28 +7,28 @@  discard block
 block discarded – undo
7 7
 
8 8
 $classLocale = classLocale::$lang;
9 9
 
10
-if(SN_IN_FLEET !== true) {
10
+if (SN_IN_FLEET !== true) {
11 11
   classSupernova::$debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
12 12
 }
13 13
 
14 14
 $fleetid = sys_get_param_id('fleetid');
15 15
 
16
-if(!is_numeric($fleetid) || empty($fleetid)) {
16
+if (!is_numeric($fleetid) || empty($fleetid)) {
17 17
   header("Location: fleet.php");
18 18
   exit();
19 19
 }
20 20
 
21 21
 $objFleet = new Fleet();
22 22
 $objFleet->dbLoad($fleetid);
23
-if(!$objFleet->dbId) {
23
+if (!$objFleet->dbId) {
24 24
   message(classLocale::$lang['fl_fleet_not_exists'], classLocale::$lang['fl_error']);
25 25
 }
26 26
 
27
-if($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) {
27
+if ($objFleet->time_arrive_to_target <= SN_TIME_NOW || $objFleet->time_return_to_source < SN_TIME_NOW || $objFleet->isReturning()) {
28 28
   message(classLocale::$lang['fl_isback'], classLocale::$lang['fl_error']);
29 29
 }
30 30
 
31
-if($objFleet->playerOwnerId != $user['id']) {
31
+if ($objFleet->playerOwnerId != $user['id']) {
32 32
   classSupernova::$debug->warning(classLocale::$lang['fl_aks_hack_wrong_fleet'], 'Wrong Fleet Owner', 301);
33 33
   message(classLocale::$lang['fl_aks_hack_wrong_fleet'], classLocale::$lang['fl_error']);
34 34
 }
@@ -39,19 +39,19 @@  discard block
 block discarded – undo
39 39
 
40 40
 !$aks && !$userToAdd_unsafe ? $userToAdd_unsafe = $user['username'] : false;
41 41
 
42
-if($userToAdd_unsafe) {
42
+if ($userToAdd_unsafe) {
43 43
   $userToAdd = db_escape($userToAdd_unsafe);
44 44
   $userToAddID = DBStaticUser::db_user_by_username($userToAdd_unsafe, false, 'id', true, true);
45 45
   $userToAddID = $userToAddID['id'];
46 46
 
47
-  if($objFleet->target_owner_id == $userToAddID) {
47
+  if ($objFleet->target_owner_id == $userToAddID) {
48 48
     message(classLocale::$lang['flt_aks_player_same'], classLocale::$lang['fl_error']);
49 49
   }
50 50
 
51
-  if($userToAddID) {
52
-    if(!$aks) {
51
+  if ($userToAddID) {
52
+    if (!$aks) {
53 53
       // No AСS exists - making one
54
-      if(!$objFleet->group_id) {
54
+      if (!$objFleet->group_id) {
55 55
         DBStaticFleetACS::db_acs_insert($fleetid, $user['id'], $objFleet);
56 56
 
57 57
         $aks = DBStaticFleetACS::db_acs_get_by_fleet($fleetid);
@@ -66,21 +66,21 @@  discard block
 block discarded – undo
66 66
 
67 67
     $isUserExists = false;
68 68
     $invited_ar = explode(",", $aks['eingeladen']);
69
-    foreach($invited_ar as $inv) {
70
-      if($userToAddID == $inv) {
69
+    foreach ($invited_ar as $inv) {
70
+      if ($userToAddID == $inv) {
71 71
         $isUserExists = true;
72 72
       }
73 73
     }
74 74
 
75
-    if(count($invited_ar) >= 5) {
75
+    if (count($invited_ar) >= 5) {
76 76
       message(classLocale::$lang['flt_aks_error_too_much_players'], classLocale::$lang['fl_error']);
77 77
     }
78 78
 
79
-    if($isUserExists) {
79
+    if ($isUserExists) {
80 80
       $userToAdd_unsafe != $user['username'] ? $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited_already'], $userToAdd) : false;
81 81
     } else {
82 82
       $add_user_message_mr = sprintf(classLocale::$lang['fl_aks_player_invited'], $userToAdd);
83
-      if(!(DBStaticFleetACS::db_acs_update($userToAddID, $fleetid))) {
83
+      if (!(DBStaticFleetACS::db_acs_update($userToAddID, $fleetid))) {
84 84
         die(sprintf(classLocale::$lang['fl_aks_adding_error'], classSupernova::$db->db_error()));
85 85
       }
86 86
       $aks['eingeladen'] .= ',' . $userToAddID;
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
   'MISSION_NAME' => classLocale::$lang['type_mission'][MT_ACS],
100 100
 ));
101 101
 
102
-if($aks['eingeladen'] && is_array($members = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
103
-  foreach($members as $row) {
102
+if ($aks['eingeladen'] && is_array($members = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_USER, "`id` in ({$aks['eingeladen']})")) && !empty($members)) {
103
+  foreach ($members as $row) {
104 104
     $template->assign_block_vars('invited', array(
105 105
       'NAME' => $row['username'],
106 106
     ));
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 $fleet_data = tplParseFleetObject($objFleet, $i, $user);
126 126
 
127 127
 $template->assign_block_vars('fleets', $fleet_data['fleet']);
128
-foreach($fleet_data['ships'] as $ship_data) {
128
+foreach ($fleet_data['ships'] as $ship_data) {
129 129
   $template->assign_block_vars('fleets.ships', $ship_data);
130 130
 }
131 131
 
Please login to merge, or discard this patch.
includes/includes/flt_flying_fleet_handler2.php 1 patch
Spacing   +7 added lines, -11 removed lines patch added patch discarded remove patch
@@ -23,15 +23,11 @@  discard block
 block discarded – undo
23 23
 // ------------------------------------------------------------------
24 24
 function flt_flyingFleetsSort($a, $b) {
25 25
   // Сравниваем время флотов - кто раньше, тот и первый обрабатывается
26
-  return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 :
27
-    // Если время - одинаковое, сравниваем события флотов
26
+  return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов
28 27
     // Если события - одинаковые, то флоты равны
29
-    ($a['fleet_event'] == $b['fleet_event'] ? 0 :
30
-      // Если события разные - первыми считаем прибывающие флоты
31
-      ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 :
32
-        // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
33
-        ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 :
34
-          // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
28
+    ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты
29
+      ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
30
+        ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
35 31
           // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска
36 32
           (
37 33
           0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий
@@ -55,7 +51,7 @@  discard block
 block discarded – undo
55 51
 // ------------------------------------------------------------------
56 52
 function flt_flying_fleet_handler($skip_fleet_update = false) {
57 53
   if (true) {
58
-    if(!defined('IN_AJAX')) {
54
+    if (!defined('IN_AJAX')) {
59 55
       print('<div style="color: red; font-size: 300%">Fleet handler is disabled</div>');
60 56
       pdump('Fleet handler is disabled');
61 57
     }
@@ -190,7 +186,7 @@  discard block
 block discarded – undo
190 186
     // Watchdog timer
191 187
     // If flying fleet handler works more then 10 seconds - stopping it
192 188
     // Let next run handle rest of fleets
193
-    if(time() - SN_TIME_NOW > 10) {
189
+    if (time() - SN_TIME_NOW > 10) {
194 190
       $debug->warning('Flying fleet handler standard routine works more then 10 seconds - watchdog unlocked', 'FFH Warning', 504);
195 191
       break;
196 192
     }
@@ -256,7 +252,7 @@  discard block
 block discarded – undo
256 252
     $objMission->fleet_event = $fleet_event['fleet_event'];
257 253
 
258 254
     // Fleet that have planet destination is returned
259
-    if($mission_data['dst_planet'] && empty($objMission->dst_planet['id_owner'])) {
255
+    if ($mission_data['dst_planet'] && empty($objMission->dst_planet['id_owner'])) {
260 256
       $objFleet->markReturnedAndSave();
261 257
       sn_db_transaction_commit();
262 258
       continue;
Please login to merge, or discard this patch.
includes/includes/market_fleeter.inc 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 
6 6
 $classLocale = classLocale::$lang;
7 7
 
8
-if(!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) {
8
+if (!defined('SN_IN_MARKET') || SN_IN_MARKET !== true) {
9 9
   classSupernova::$debug->error("Attempt to call market page mode {$mode} directly - not from market.php", 'Forbidden', 403);
10 10
 }
11 11
 
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
   'rpg_cost' => $rpg_cost,
18 18
 ));
19 19
 
20
-if(is_array($shipList)) {
21
-  if(mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) {
20
+if (is_array($shipList)) {
21
+  if (mrc_get_level($user, null, RES_DARK_MATTER) < $rpg_cost) {
22 22
     $intError = MARKET_NO_DM;
23 23
   }
24 24
 
@@ -33,30 +33,30 @@  discard block
 block discarded – undo
33 33
 
34 34
   $message .= classLocale::$lang["eco_mrk_{$submode}_ships"] . '<ul>';
35 35
   $total = array();
36
-  foreach($shipList as $shipID => &$shipCount) {
36
+  foreach ($shipList as $shipID => &$shipCount) {
37 37
     $shipCount = ceil(floatval($shipCount));
38
-    if(!$shipCount) {
38
+    if (!$shipCount) {
39 39
       continue;
40 40
     }
41 41
 
42
-    if($shipCount < 0) {
42
+    if ($shipCount < 0) {
43 43
       classSupernova::$debug->warning('User supplied negative ship count on Black Market page', 'Hack Attempt', 307);
44 44
       $intError = MARKET_NEGATIVE_SHIPS;
45 45
       break;
46 46
     }
47 47
 
48
-    if($mode == MARKET_SCRAPPER) {
48
+    if ($mode == MARKET_SCRAPPER) {
49 49
       $amount = mrc_get_level($user, $planetrow, $shipID, true, true); // $planetrow[get_unit_param($shipID, P_NAME)];
50
-    } elseif($mode == MARKET_STOCKMAN) {
50
+    } elseif ($mode == MARKET_STOCKMAN) {
51 51
       $amount = $stock[$shipID];
52 52
     }
53 53
 
54
-    if($amount < $shipCount) {
54
+    if ($amount < $shipCount) {
55 55
       $intError = $error_no_stock;
56 56
       break;
57 57
     }
58 58
 
59
-    if(!in_array($shipID, classSupernova::$gc->groupFleet)) {
59
+    if (!in_array($shipID, classSupernova::$gc->groupFleet)) {
60 60
       classSupernova::$debug->warning('Hack Attempt', 'User supplied non-ship unit ID on Black Market page', 306);
61 61
       $intError = MARKET_NOT_A_SHIP;
62 62
       break;
@@ -72,16 +72,16 @@  discard block
 block discarded – undo
72 72
     $resTemp[RES_CRYSTAL] = floor($build_data[BUILD_CREATE][RES_CRYSTAL] * $shipCount * $config_rpg_scrape_crystal * (-$multiplier));
73 73
     $resTemp[RES_DEUTERIUM] = floor($build_data[BUILD_CREATE][RES_DEUTERIUM] * $shipCount * $config_rpg_scrape_deuterium * (-$multiplier));
74 74
 
75
-    foreach($resTemp as $resID => $resCount) {
75
+    foreach ($resTemp as $resID => $resCount) {
76 76
       $total[$resID] += $resCount;
77 77
     }
78 78
 
79 79
     $message .= "<li>{$classLocale['tech'][$shipID]}: " . pretty_number($shipCount);
80 80
   }
81 81
 
82
-  if($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) {
83
-    foreach($total as $resID => $resCount) {
84
-      if(mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) {
82
+  if ($mode == MARKET_STOCKMAN && $intError == MARKET_DEAL) {
83
+    foreach ($total as $resID => $resCount) {
84
+      if (mrc_get_level($user, $planetrow, $resID, true, true) < -$resCount) {
85 85
         $intError = MARKET_NO_RESOURCES;
86 86
         classSupernova::$debug->warning('Trying to use bug in s/h market', 'S/H Ship Market', 301);
87 87
         break;
@@ -92,10 +92,10 @@  discard block
 block discarded – undo
92 92
   $intError = ($intError == MARKET_DEAL) && (array_sum($total) == 0) ? $error_zero_res : $intError;
93 93
 
94 94
   $qry = array();
95
-  if($intError == MARKET_DEAL) {
95
+  if ($intError == MARKET_DEAL) {
96 96
     $message .= '</ul>' . classLocale::$lang["eco_mrk_{$submode}_res"] . '<ul>';
97
-    foreach($total as $resID => $resCount) {
98
-      if(!$resCount) {
97
+    foreach ($total as $resID => $resCount) {
98
+      if (!$resCount) {
99 99
         continue;
100 100
       }
101 101
 
@@ -128,38 +128,38 @@  discard block
 block discarded – undo
128 128
       'MESSAGE' => classLocale::$lang['eco_mrk_errors'][$intError],
129 129
     ));
130 130
 
131
-    foreach($shipList as $shipID => $shipCount) {
131
+    foreach ($shipList as $shipID => $shipCount) {
132 132
       $data['ships'][$shipID] = max(0, intval($shipCount));
133 133
     }
134 134
   }
135 135
 }
136 136
 $message = '';
137 137
 
138
-if(!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) {
139
-  classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item){return mt_rand(1, 1000);}, classSupernova::$gc->groupFleet)));
138
+if (!classSupernova::$config->eco_stockman_fleet && classSupernova::$config->eco_stockman_fleet_populate) {
139
+  classSupernova::$config->db_saveItem('eco_stockman_fleet', sys_unit_arr2str(array_map(function($item) {return mt_rand(1, 1000); }, classSupernova::$gc->groupFleet)));
140 140
 }
141 141
 
142 142
 tpl_set_resource_info($template, $planetrow, array());
143 143
 
144
-if(!$array) {
144
+if (!$array) {
145 145
   $array = array();
146 146
 }
147 147
 
148 148
 $group_fleet = classSupernova::$gc->groupFleet;
149
-foreach($array as $key => $value) {
150
-  if($mode == MARKET_SCRAPPER) {
149
+foreach ($array as $key => $value) {
150
+  if ($mode == MARKET_SCRAPPER) {
151 151
     $shipID = $value;
152 152
     $amount = mrc_get_level($user, $planetrow, $shipID, false, true); // $planetrow[get_unit_param($shipID, P_NAME)];
153
-  } elseif($mode == MARKET_STOCKMAN) {
153
+  } elseif ($mode == MARKET_STOCKMAN) {
154 154
     $shipID = $key;
155 155
     $amount = $value;
156 156
   }
157 157
 
158
-  if(!in_array($shipID, $group_fleet)) {
158
+  if (!in_array($shipID, $group_fleet)) {
159 159
     continue;
160 160
   }
161 161
 
162
-  if($amount > 0) {
162
+  if ($amount > 0) {
163 163
     $build_data = eco_get_build_data($user, $planetrow, $shipID);
164 164
     $template->assign_block_vars('ships', array(
165 165
       'ID'        => $shipID,
Please login to merge, or discard this patch.
includes/includes/sys_stat.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -43,23 +43,23 @@  discard block
 block discarded – undo
43 43
 
44 44
   $sta_update_msg = db_escape($sta_update_msg);
45 45
 
46
-  if($next_step) {
46
+  if ($next_step) {
47 47
     $sta_update_step++;
48 48
   }
49 49
   $sta_update_msg = "Update in progress. Step {$sta_update_step}/14: {$sta_update_msg}.";
50 50
 
51 51
   classSupernova::$config->db_saveItem('var_stat_update_msg', $sta_update_msg);
52
-  if($next_step) {
52
+  if ($next_step) {
53 53
     classSupernova::$debug->warning($sta_update_msg, 'Stat update', LOG_INFO_STAT_PROCESS);
54 54
   }
55 55
 }
56 56
 
57 57
 function sys_stat_calculate_flush(&$data, $force = false) {
58
-  if(count($data) < 25 && !$force) {
58
+  if (count($data) < 25 && !$force) {
59 59
     return;
60 60
   }
61 61
 
62
-  if(!empty($data)) {
62
+  if (!empty($data)) {
63 63
     classSupernova::$gc->db->doInsertBatch(
64 64
       TABLE_STAT_POINTS, $data, array(
65 65
       'id_owner',
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
   classSupernova::$gc->cacheOperator->db_lock_tables('users');
115 115
   $user_list = DBStaticUser::db_user_list('', true, 'id, dark_matter, metal, crystal, deuterium, user_as_ally, ally_id');
116 116
   $row_num = count($user_list);
117
-  foreach($user_list as $player) {
118
-    if($i++ % 100 == 0) {
117
+  foreach ($user_list as $player) {
118
+    if ($i++ % 100 == 0) {
119 119
       sta_set_time_limit("calculating players stats (player {$i}/{$row_num})", false);
120 120
     }
121
-    if(array_key_exists($user_id = $player['id'], $user_skip_list)) {
121
+    if (array_key_exists($user_id = $player['id'], $user_skip_list)) {
122 122
       continue;
123 123
     }
124 124
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     $counts[$user_id][UNIT_RESOURCES] += $resources;
128 128
 
129 129
     // А здесь мы фильтруем пользователей по $user_skip_list - далее не нужно этого делать, потому что
130
-    if(!isset($user_skip_list[$user_id])) {
130
+    if (!isset($user_skip_list[$user_id])) {
131 131
       $user_allies[$user_id] = $player['ally_id'];
132 132
     }
133 133
   }
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
   $i = 0;
140 140
   $query = DBStaticPlanet::db_planet_list_resources_by_owner();
141 141
   $row_num = classSupernova::$db->db_num_rows($query);
142
-  while($planet = db_fetch($query)) {
143
-    if($i++ % 100 == 0) {
142
+  while ($planet = db_fetch($query)) {
143
+    if ($i++ % 100 == 0) {
144 144
       sta_set_time_limit("calculating planets stats (planet {$i}/{$row_num})", false);
145 145
     }
146
-    if(array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) {
146
+    if (array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) {
147 147
       continue;
148 148
     }
149 149
 
@@ -157,22 +157,22 @@  discard block
 block discarded – undo
157 157
   $i = 0;
158 158
   $query = FleetList::dbQueryAllId();
159 159
   $row_num = classSupernova::$db->db_num_rows($query);
160
-  while($fleet_row = db_fetch($query)) {
161
-    if($i++ % 100 == 0) {
160
+  while ($fleet_row = db_fetch($query)) {
161
+    if ($i++ % 100 == 0) {
162 162
       sta_set_time_limit("calculating flying fleets stats (fleet {$i}/{$row_num})", false);
163 163
     }
164 164
     $objFleet = new Fleet();
165 165
     // TODO - без дополнительной инициализации и перераспределений памяти на каждый new Fleet()/unset($fleet)
166 166
     // К тому же при включённом кэшировании это быстро забъёт кэш холодными данными
167 167
     $objFleet->dbRowParse($fleet_row);
168
-    if(array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) {
168
+    if (array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) {
169 169
       continue;
170 170
     }
171 171
 
172
-    foreach($objFleet->shipsIterator() as $unit_id => $unit) {
172
+    foreach ($objFleet->shipsIterator() as $unit_id => $unit) {
173 173
       $counts[$user_id][UNIT_SHIPS] += $unit->count;
174 174
 
175
-      if(!isset($unit_cost_cache[$unit_id][0])) {
175
+      if (!isset($unit_cost_cache[$unit_id][0])) {
176 176
         $unit_cost_cache[$unit_id][0] = get_unit_param($unit_id, P_COST);
177 177
       }
178 178
       $unit_cost_data = &$unit_cost_cache[$unit_id][0];
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
   $i = 0;
192 192
   $query = DBStaticUnit::db_unit_list_stat_calculate();
193 193
   $row_num = classSupernova::$db->db_num_rows($query);
194
-  while($unit = db_fetch($query)) {
195
-    if($i++ % 100 == 0) {
194
+  while ($unit = db_fetch($query)) {
195
+    if ($i++ % 100 == 0) {
196 196
       sta_set_time_limit("calculating unit stats (unit {$i}/{$row_num})", false);
197 197
     }
198
-    if(array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) {
198
+    if (array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) {
199 199
       continue;
200 200
     }
201 201
 
@@ -209,11 +209,11 @@  discard block
 block discarded – undo
209 209
   $i = 0;
210 210
   $query = DBStaticQue::db_que_list_stat();
211 211
   $row_num = classSupernova::$db->db_num_rows($query);
212
-  while($que_item = db_fetch($query)) {
213
-    if($i++ % 100 == 0) {
212
+  while ($que_item = db_fetch($query)) {
213
+    if ($i++ % 100 == 0) {
214 214
       sta_set_time_limit("calculating ques stats (que item {$i}/{$row_num})", false);
215 215
     }
216
-    if(array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) {
216
+    if (array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) {
217 217
       continue;
218 218
     }
219 219
     $que_unit_amount = $que_item['que_unit_amount'];
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
   sta_set_time_limit('posting new user stats to DB');
242 242
   $data = array();
243
-  foreach($user_allies as $user_id => $ally_id) {
243
+  foreach ($user_allies as $user_id => $ally_id) {
244 244
     $points[$user_id][UNIT_RESOURCES] = $counts[$user_id][UNIT_RESOURCES] / 1000;
245 245
     $points[$user_id] = array_map('floor', $points[$user_id]);
246 246
     $counts[$user_id] = array_map('floor', $counts[$user_id]);
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 
315 315
   // Updating player's ranks
316 316
   sta_set_time_limit("updating ranks for players");
317
-  foreach($rankNames as $rankName) {
317
+  foreach ($rankNames as $rankName) {
318 318
     sta_set_time_limit("updating player rank '{$rankName}'", false);
319 319
     classSupernova::$db->doSql($qryResetRowNum);
320 320
     classSupernova::$db->doUpdateReallyComplex(sprintf($qryFormat, $rankName, 1));
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 
323 323
   sta_set_time_limit("updating ranks for Alliances");
324 324
   // Updating Allie's ranks
325
-  foreach($rankNames as $rankName) {
325
+  foreach ($rankNames as $rankName) {
326 326
     sta_set_time_limit("updating Alliances rank '{$rankName}'", false);
327 327
     classSupernova::$db->doSql($qryResetRowNum);
328 328
     classSupernova::$db->doUpdateReallyComplex(sprintf($qryFormat, $rankName, 2));
Please login to merge, or discard this patch.
includes/includes/art_artifact.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 
19 19
   $unit_level = $artifact_level_old = mrc_get_level($user, null, $unit_id, true);
20 20
   if ($unit_level > 0) {
21
-    switch($unit_id) {
21
+    switch ($unit_id) {
22 22
       case ART_LHC:
23 23
       case ART_HOOK_SMALL:
24 24
       case ART_HOOK_MEDIUM:
Please login to merge, or discard this patch.