Completed
Push — work-fleets ( 71ccb1...0d1d7f )
by SuperNova.WS
06:04
created
includes/update.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -756,9 +756,11 @@
 block discarded – undo
756 756
         !empty($strings) ? doquery($query_string . implode(',', $strings)) : false;
757 757
       }
758 758
 
759
-      if(isset($update_tables['counter']['page'])) // TODO REMOVE
759
+      if(isset($update_tables['counter']['page'])) {
760
+        // TODO REMOVE
760 761
       {
761 762
         update_security_url("SELECT DISTINCT `page` AS url FROM {{counter}}");
763
+      }
762 764
         update_security_url("SELECT DISTINCT `url` AS url FROM {{counter}}");
763 765
       }
764 766
     }
Please login to merge, or discard this patch.
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
    [!] DB code updates
22 22
 */
23 23
 
24
-if(!defined('INIT')) {
24
+if (!defined('INIT')) {
25 25
 //  include_once('init.php');
26 26
   die('Unauthorized access');
27 27
 }
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 classSupernova::$config->debug = 0;
40 40
 
41 41
 
42
-if(classSupernova::$config->db_version == DB_VERSION) {
43
-} elseif(classSupernova::$config->db_version > DB_VERSION) {
42
+if (classSupernova::$config->db_version == DB_VERSION) {
43
+} elseif (classSupernova::$config->db_version > DB_VERSION) {
44 44
   classSupernova::$config->db_saveItem('var_db_update_end', SN_TIME_NOW);
45 45
   die(
46 46
   'Internal error! Auotupdater detects DB version greater then can be handled!<br />
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
   );
50 50
 }
51 51
 
52
-if(classSupernova::$config->db_version < 26) {
52
+if (classSupernova::$config->db_version < 26) {
53 53
   $sys_log_disabled = true;
54 54
 }
55 55
 
@@ -68,20 +68,20 @@  discard block
 block discarded – undo
68 68
 $update_tables = array();
69 69
 $update_indexes = array();
70 70
 $query = upd_do_query('SHOW TABLES;', true);
71
-while($row = db_fetch_row($query)) {
71
+while ($row = db_fetch_row($query)) {
72 72
   upd_load_table_info($row[0]);
73 73
 }
74 74
 upd_log_message('Table info loaded. Now looking DB for upgrades...');
75 75
 
76 76
 upd_do_query('SET FOREIGN_KEY_CHECKS=0;', true);
77 77
 
78
-if($new_version < 37) {
78
+if ($new_version < 37) {
79 79
   require_once('update_old.php');
80 80
 }
81 81
 
82 82
 ini_set('memory_limit', '1024M');
83 83
 
84
-switch($new_version) {
84
+switch ($new_version) {
85 85
   case 37:
86 86
     upd_log_version_update();
87 87
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 
97 97
     upd_check_key('payment_currency_exchange_mm_', 2500, !classSupernova::$config->payment_currency_exchange_mm_);
98 98
 
99
-    if(!$update_tables['log_metamatter']) {
99
+    if (!$update_tables['log_metamatter']) {
100 100
       upd_create_table('log_metamatter',
101 101
         "(
102 102
           `id` SERIAL,
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
       "ADD `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'",
122 122
     ), !$update_tables['payment']['payment_test']);
123 123
 
124
-    if($update_tables['payment']['payment_test']['Default'] == 1) {
124
+    if ($update_tables['payment']['payment_test']['Default'] == 1) {
125 125
       upd_alter_table('payment', array(
126 126
         "MODIFY COLUMN `payment_test` TINYINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Is this a test payment?'",
127 127
       ));
@@ -137,15 +137,15 @@  discard block
 block discarded – undo
137 137
       "MODIFY COLUMN `metamatter` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Metamatter amount'",
138 138
     ), $update_tables['users']['metamatter']['Type'] == 'int(20)');
139 139
 
140
-    $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = " . QUE_RESEARCH . " AND que_unit_id IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ") FOR UPDATE");
141
-    while($row = db_fetch($query)) {
140
+    $query = upd_do_query("SELECT * FROM {{que}} WHERE `que_type` = ".QUE_RESEARCH." AND que_unit_id IN (".TECH_EXPEDITION.",".TECH_COLONIZATION.") FOR UPDATE");
141
+    while ($row = db_fetch($query)) {
142 142
       $planet_id = ($row['que_planet_id_origin'] ? $row['que_planet_id_origin'] : $row['que_planet_id']);
143 143
       upd_do_query("SELECT id FROM {{planets}} WHERE id = {$planet_id} FOR UPDATE");
144 144
       $price = sys_unit_str2arr($row['que_unit_price']);
145
-      upd_do_query("UPDATE {{planets}} SET " .
146
-        "`metal` = `metal` + " . ($price[RES_METAL] ? $price[RES_METAL] : 0) . "," .
147
-        "`crystal` = `crystal` + " . ($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0) . "," .
148
-        "`deuterium` = `deuterium` + " . ($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0) .
145
+      upd_do_query("UPDATE {{planets}} SET ".
146
+        "`metal` = `metal` + ".($price[RES_METAL] ? $price[RES_METAL] : 0).",".
147
+        "`crystal` = `crystal` + ".($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0).",".
148
+        "`deuterium` = `deuterium` + ".($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0).
149 149
         " WHERE id = {$planet_id}"
150 150
       );
151 151
       upd_do_query("DELETE FROM {{que}} WHERE que_id = {$row['que_id']}");
@@ -154,10 +154,10 @@  discard block
 block discarded – undo
154 154
     $query = upd_do_query("SELECT unit_id, unit_snid, unit_level, id_planet FROM {{unit}} AS un
155 155
     LEFT JOIN {{users}} AS u ON u.id = un.unit_player_id
156 156
     LEFT JOIN {{planets}} AS p ON p.id = u.id_planet
157
-    WHERE unit_snid IN (" . TECH_EXPEDITION . "," . TECH_COLONIZATION . ")
157
+    WHERE unit_snid IN (" . TECH_EXPEDITION.",".TECH_COLONIZATION.")
158 158
     FOR UPDATE");
159
-    while($row = db_fetch($query)) {
160
-      if(!$row['id_planet']) {
159
+    while ($row = db_fetch($query)) {
160
+      if (!$row['id_planet']) {
161 161
         continue;
162 162
       }
163 163
 
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
       $unit_level = $row['unit_level'];
166 166
       $price = get_unit_param($unit_id, P_COST);
167 167
       $factor = $price['factor'];
168
-      foreach($price as $resource_id => &$resource_amount) {
168
+      foreach ($price as $resource_id => &$resource_amount) {
169 169
         $resource_amount = $resource_amount * (pow($factor, $unit_level) - 1) / ($factor - 1);
170 170
       }
171 171
       // upd_do_query
172
-      upd_do_query($q = "UPDATE {{planets}} SET " .
173
-        "`metal` = `metal` + " . ($price[RES_METAL] ? $price[RES_METAL] : 0) . "," .
174
-        "`crystal` = `crystal` + " . ($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0) . "," .
175
-        "`deuterium` = `deuterium` + " . ($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0) .
172
+      upd_do_query($q = "UPDATE {{planets}} SET ".
173
+        "`metal` = `metal` + ".($price[RES_METAL] ? $price[RES_METAL] : 0).",".
174
+        "`crystal` = `crystal` + ".($price[RES_CRYSTAL] ? $price[RES_CRYSTAL] : 0).",".
175
+        "`deuterium` = `deuterium` + ".($price[RES_DEUTERIUM] ? $price[RES_DEUTERIUM] : 0).
176 176
         " WHERE id = {$row['id_planet']}"
177 177
       );
178 178
       upd_do_query("DELETE FROM {{unit}} WHERE unit_id = {$row['unit_id']}");
@@ -184,14 +184,14 @@  discard block
 block discarded – undo
184 184
     // Вернуть ресы за уже исследованную Экспедиционную технологию
185 185
     upd_check_key('player_max_colonies', -1, classSupernova::$config->player_max_colonies >= 0);
186 186
 
187
-    if(!isset($update_tables['users']['player_rpg_explore_xp'])) {
187
+    if (!isset($update_tables['users']['player_rpg_explore_xp'])) {
188 188
       upd_alter_table('users', array(
189 189
         "ADD COLUMN `player_rpg_explore_level` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`",
190 190
         "ADD COLUMN `player_rpg_explore_xp` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0 AFTER `dark_matter`",
191 191
       ), !isset($update_tables['users']['player_rpg_explore_xp']));
192 192
     }
193 193
 
194
-    if(!$update_tables['log_users_online']) {
194
+    if (!$update_tables['log_users_online']) {
195 195
       upd_create_table('log_users_online', "(
196 196
         `online_timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Measure time',
197 197
         `online_count` SMALLINT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Users online',
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
       "ADD `user_time_measured` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'When was time diff measured last time' AFTER `onlinetime`",
207 207
     ), !$update_tables['users']['user_time_measured']);
208 208
 
209
-    if($update_tables['rw']) {
209
+    if ($update_tables['rw']) {
210 210
       upd_do_query("DROP TABLE IF EXISTS {{rw}};");
211 211
     }
212 212
 
213
-    if(!$update_tables['player_award']) {
213
+    if (!$update_tables['player_award']) {
214 214
       upd_create_table('player_award', "(
215 215
         `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
216 216
         `award_type_id` int(11) DEFAULT NULL COMMENT 'Award type i.e. order, medal, pennant, rank etc',
@@ -252,14 +252,14 @@  discard block
 block discarded – undo
252 252
     upd_log_version_update();
253 253
 
254 254
 
255
-    if(!isset($update_tables['planets']['que_processed'])) {
255
+    if (!isset($update_tables['planets']['que_processed'])) {
256 256
       upd_alter_table('planets', array(
257 257
         "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `last_update`",
258 258
       ), true);
259 259
       upd_do_query("UPDATE {{planets}} SET que_processed = last_update;");
260 260
     }
261 261
 
262
-    if(!isset($update_tables['users']['que_processed'])) {
262
+    if (!isset($update_tables['users']['que_processed'])) {
263 263
       upd_alter_table('users', array(
264 264
         "ADD COLUMN `que_processed` INT(11) UNSIGNED NOT NULL DEFAULT 0 AFTER `onlinetime`",
265 265
       ), true);
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
     }
268 268
 
269 269
 
270
-    if(isset($update_tables['planets']['que'])) {
270
+    if (isset($update_tables['planets']['que'])) {
271 271
       $sn_data_aux = array(
272 272
         SHIP_SMALL_FIGHTER_WRATH    => array(
273 273
           'name' => 'ship_fighter_wrath',
@@ -352,20 +352,20 @@  discard block
 block discarded – undo
352 352
       $unit_data = array();
353 353
       $planets = array();
354 354
 
355
-      foreach($planet_unit_list as $unit_id) {
356
-        if(!($unit_name = get_unit_param($unit_id, P_NAME))) {
355
+      foreach ($planet_unit_list as $unit_id) {
356
+        if (!($unit_name = get_unit_param($unit_id, P_NAME))) {
357 357
           $unit_name = $sn_data_aux[$unit_id][P_NAME];
358 358
         }
359
-        if(isset($update_tables['planets'][$unit_name])) {
359
+        if (isset($update_tables['planets'][$unit_name])) {
360 360
           $drop[] = "DROP COLUMN `{$unit_name}`";
361 361
 
362
-          if(isset($aux_group[$unit_id])) {
362
+          if (isset($aux_group[$unit_id])) {
363 363
             $units_info[$unit_id] = $sn_data_aux[$unit_id];
364 364
             $units_info[$unit_id]['que'] = QUE_HANGAR;
365 365
           } else {
366 366
             $units_info[$unit_id] = get_unit_param($unit_id);
367
-            foreach($ques_info as $que_id => $que_data1) {
368
-              if(in_array($unit_id, $que_data1['unit_list'])) {
367
+            foreach ($ques_info as $que_id => $que_data1) {
368
+              if (in_array($unit_id, $que_data1['unit_list'])) {
369 369
                 $units_info[$unit_id]['que'] = $que_id;
370 370
                 break;
371 371
               }
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
       }
376 376
 
377 377
       $query = upd_do_query("SELECT * FROM {{planets}} FOR UPDATE");
378
-      while($row = db_fetch($query)) {
378
+      while ($row = db_fetch($query)) {
379 379
         $user_id = $row['id_owner'];
380 380
         $planet_id = $row['id'];
381 381
 
@@ -383,25 +383,25 @@  discard block
 block discarded – undo
383 383
 
384 384
         // Конвертируем юниты
385 385
         $units_levels = array();
386
-        foreach($planet_unit_list as $unit_id) {
386
+        foreach ($planet_unit_list as $unit_id) {
387 387
           $unit_name = &$units_info[$unit_id][P_NAME];
388
-          if(!isset($row[$unit_name]) || !$row[$unit_name]) {
388
+          if (!isset($row[$unit_name]) || !$row[$unit_name]) {
389 389
             continue;
390 390
           }
391 391
           $units_levels[$unit_id] = $row[$unit_name];
392
-          $unit_data[] = "({$user_id}," . LOC_PLANET . ",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})";
393
-          if(count($unit_data) > 30) {
392
+          $unit_data[] = "({$user_id},".LOC_PLANET.",{$planet_id},{$units_info[$unit_id][P_UNIT_TYPE]},{$unit_id},{$units_levels[$unit_id]})";
393
+          if (count($unit_data) > 30) {
394 394
             $unit_data_max = strlen(implode(',', $unit_data)) > $unit_data_max ? strlen(implode(',', $unit_data)) : $unit_data_max;
395
-            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) . ';');
395
+            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).';');
396 396
             $unit_data = array();
397 397
           }
398 398
         }
399 399
 
400 400
         // Конвертируем очередь построек
401
-        if($row['que']) {
401
+        if ($row['que']) {
402 402
           $que = explode(';', $row['que']);
403
-          foreach($que as $que_item) {
404
-            if(!$que_item) {
403
+          foreach ($que as $que_item) {
404
+            if (!$que_item) {
405 405
               continue;
406 406
             }
407 407
 
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
             $unit_factor = $unit_cost[P_FACTOR] ? $unit_cost[P_FACTOR] : 1;
417 417
             $price_increase = pow($unit_factor, $unit_level);
418 418
             // $unit_time = 0;
419
-            foreach($unit_cost as $resource_id => &$resource_amount) {
420
-              if(!in_array($resource_id, $group_resource_loot)) {
419
+            foreach ($unit_cost as $resource_id => &$resource_amount) {
420
+              if (!in_array($resource_id, $group_resource_loot)) {
421 421
                 unset($unit_cost[$resource_id]);
422 422
                 continue;
423 423
               }
@@ -431,39 +431,39 @@  discard block
 block discarded – undo
431 431
         }
432 432
 
433 433
         // Конвертируем очередь верфи
434
-        if($row['b_hangar_id']) {
434
+        if ($row['b_hangar_id']) {
435 435
           $return_resources = array(RES_METAL => 0, RES_CRYSTAL => 0, RES_DEUTERIUM => 0,);
436 436
           $hangar_units = sys_unit_str2arr($row['b_hangar_id']);
437
-          foreach($hangar_units as $unit_id => $unit_count) {
438
-            if($unit_count <= 0) {
437
+          foreach ($hangar_units as $unit_id => $unit_count) {
438
+            if ($unit_count <= 0) {
439 439
               continue;
440 440
             }
441
-            foreach($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) {
442
-              if(!in_array($resource_id, $group_resource_loot)) {
441
+            foreach ($units_info[$unit_id][P_COST] as $resource_id => $resource_amount) {
442
+              if (!in_array($resource_id, $group_resource_loot)) {
443 443
                 continue;
444 444
               }
445 445
               $return_resources[$resource_id] += $unit_count * $resource_amount;
446 446
             }
447 447
           }
448
-          if(array_sum($return_resources) > 0) {
448
+          if (array_sum($return_resources) > 0) {
449 449
             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");
450 450
           }
451 451
         }
452 452
 
453 453
 
454
-        if(count($que_data) > 10) {
454
+        if (count($que_data) > 10) {
455 455
           $que_data_max = strlen(implode(',', $que_data)) > $que_data_max ? strlen(implode(',', $que_data)) : $que_data_max;
456
-          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) . ';');
456
+          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).';');
457 457
           $que_data = array();
458 458
         }
459 459
       }
460 460
 
461
-      if(!empty($unit_data)) {
462
-        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) . ';');
461
+      if (!empty($unit_data)) {
462
+        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).';');
463 463
       }
464 464
 
465
-      if(!empty($que_data)) {
466
-        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) . ';');
465
+      if (!empty($que_data)) {
466
+        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).';');
467 467
       }
468 468
 
469 469
       upd_alter_table('planets', $drop, true);
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
       JOIN `{{users}}` AS u ON a.`id` = u.`user_as_ally` AND `user_as_ally` IS NOT NULL AND `username` = ''
474 474
       SET u.`username` = CONCAT('[', a.`ally_tag`, ']');");
475 475
 
476
-    if($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') {
476
+    if ($update_indexes['statpoints']['I_stats_id_ally'] != 'id_ally,stat_type,stat_code,') {
477 477
       upd_do_query("SET FOREIGN_KEY_CHECKS=0;");
478 478
       upd_alter_table('statpoints', "DROP FOREIGN KEY `FK_stats_id_ally`", $update_foreigns['statpoints']['FK_stats_id_ally']);
479 479
       upd_alter_table('statpoints', "DROP KEY `I_stats_id_ally`", $update_indexes['statpoints']['I_stats_id_ally']);
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
       "ADD CONSTRAINT `FK_users_browser_id` FOREIGN KEY (`user_last_browser_id`) REFERENCES `{{security_browser}}` (`browser_id`) ON DELETE SET NULL ON UPDATE CASCADE",
570 570
     ), !isset($update_tables['users']['user_last_proxy']));
571 571
 
572
-    if(!isset($update_tables['notes']['planet_type'])) {
572
+    if (!isset($update_tables['notes']['planet_type'])) {
573 573
       upd_alter_table('notes', array(
574 574
         "ADD COLUMN `galaxy` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `title`",
575 575
         "ADD COLUMN `system` SMALLINT(6) UNSIGNED NOT NULL DEFAULT 0 AFTER `galaxy`",
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
     upd_alter_table('users', "ADD COLUMN `user_bot` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0", !isset($update_tables['users']['user_bot']));
588 588
     upd_alter_table('unit', "ADD KEY `I_unit_type_snid` (unit_type, unit_snid) USING BTREE", !$update_indexes['unit']['I_unit_type_snid']);
589 589
 
590
-    if($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') {
590
+    if ($update_tables['users']['settings_tooltiptime']['Type'] != 'smallint(5) unsigned') {
591 591
       upd_alter_table('users', array(
592 592
         "MODIFY COLUMN `settings_tooltiptime` smallint(5) unsigned NOT NULL DEFAULT '500'",
593 593
       ), $update_tables['users']['settings_tooltiptime']['Type'] != 'smallint');
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
       upd_do_query("UPDATE `{{users}}` SET settings_tooltiptime = 500;");
596 596
     }
597 597
 
598
-    if(!isset($update_tables['log_users_online']['online_aggregated'])) {
598
+    if (!isset($update_tables['log_users_online']['online_aggregated'])) {
599 599
       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']));
600 600
       upd_alter_table('log_users_online', array(
601 601
         "DROP PRIMARY KEY",
@@ -603,13 +603,13 @@  discard block
 block discarded – undo
603 603
       ), $update_indexes['log_users_online']['PRIMARY'] != 'online_timestamp,online_aggregated,');
604 604
     }
605 605
 
606
-    if(!isset($update_tables['users']['gender'])) {
607
-      upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT " . GENDER_UNKNOWN, !isset($update_tables['users']['gender']));
608
-      upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', " . GENDER_FEMALE . ", IF(UPPER(`sex`) = 'M', " . GENDER_MALE . ", " . GENDER_UNKNOWN . "));");
606
+    if (!isset($update_tables['users']['gender'])) {
607
+      upd_alter_table('users', "ADD COLUMN `gender` TINYINT(1) UNSIGNED NOT NULL DEFAULT ".GENDER_UNKNOWN, !isset($update_tables['users']['gender']));
608
+      upd_do_query("UPDATE {{users}} SET `gender` = IF(UPPER(`sex`) = 'F', ".GENDER_FEMALE.", IF(UPPER(`sex`) = 'M', ".GENDER_MALE.", ".GENDER_UNKNOWN."));");
609 609
     }
610 610
     upd_alter_table('users', "DROP COLUMN `sex`", isset($update_tables['users']['sex']));
611 611
 
612
-    if(!$update_tables['users']['dark_matter_total']) {
612
+    if (!$update_tables['users']['dark_matter_total']) {
613 613
       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']);
614 614
       upd_do_query(
615 615
         "UPDATE `{{users}}` AS u
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
     }
623 623
 
624 624
     upd_check_key('player_metamatter_immortal', 100000, !isset(classSupernova::$config->player_metamatter_immortal));
625
-    if(!$update_tables['users']['metamatter_total']) {
625
+    if (!$update_tables['users']['metamatter_total']) {
626 626
       upd_alter_table('users', "ADD `metamatter_total` BIGINT(20) NOT NULL DEFAULT 0 COMMENT 'Total Metamatter amount ever bought'", !$update_tables['users']['metamatter_total']);
627 627
 
628 628
       upd_do_query(
@@ -634,11 +634,11 @@  discard block
 block discarded – undo
634 634
             (SELECT IF(sum(amount) IS NULL, 0, sum(amount)) FROM {{log_metamatter}} AS mm WHERE mm.user_id = u.id AND mm.amount > 0)
635 635
           );");
636 636
     }
637
-    if(!isset($update_tables['users']['immortal'])) {
637
+    if (!isset($update_tables['users']['immortal'])) {
638 638
       upd_alter_table('users', "ADD COLUMN `immortal` TIMESTAMP NULL", !isset($update_tables['users']['immortal']));
639 639
       upd_do_query("UPDATE {{users}} SET `immortal` = NOW() WHERE `metamatter_total` > 0;");
640 640
     }
641
-    if(isset($update_tables['player_award'])) {
641
+    if (isset($update_tables['player_award'])) {
642 642
       upd_do_query(
643 643
         "UPDATE {{users}} AS u JOIN {{player_award}} AS pa ON u.id = pa.player_id
644 644
           SET metamatter_total = 1, immortal = NOW()
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
       CONSTRAINT `FK_user_id` FOREIGN KEY (`user_id`) REFERENCES `{{users}}` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
666 666
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
667 667
 
668
-    if(empty($update_tables['blitz_statpoints'])) {
668
+    if (empty($update_tables['blitz_statpoints'])) {
669 669
       upd_create_table('blitz_statpoints', " (
670 670
         `stat_date` int(11) NOT NULL DEFAULT '0',
671 671
         `id_owner` bigint(20) unsigned DEFAULT NULL,
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
       CONSTRAINT `FK_survey_votes_survey_parent_id` FOREIGN KEY (`survey_parent_id`) REFERENCES `{{survey}}` (`survey_id`) ON DELETE CASCADE ON UPDATE CASCADE
734 734
     ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
735 735
 
736
-    if(empty($update_tables['security_url'])) {
736
+    if (empty($update_tables['security_url'])) {
737 737
       upd_create_table('security_url', " (
738 738
         `url_id` int unsigned NOT NULL AUTO_INCREMENT,
739 739
         `url_string` VARCHAR(250) NOT NULL DEFAULT '',
@@ -746,17 +746,17 @@  discard block
 block discarded – undo
746 746
 
747 747
         $strings = array();
748 748
         $query = doquery($query);
749
-        while($row = db_fetch($query)) {
750
-          $strings[] = '("' . db_escape($row['url']) . '")';
751
-          if(count($strings) > 100) {
752
-            doquery($query_string . implode(',', $strings));
749
+        while ($row = db_fetch($query)) {
750
+          $strings[] = '("'.db_escape($row['url']).'")';
751
+          if (count($strings) > 100) {
752
+            doquery($query_string.implode(',', $strings));
753 753
             $strings = array();
754 754
           }
755 755
         }
756
-        !empty($strings) ? doquery($query_string . implode(',', $strings)) : false;
756
+        !empty($strings) ? doquery($query_string.implode(',', $strings)) : false;
757 757
       }
758 758
 
759
-      if(isset($update_tables['counter']['page'])) // TODO REMOVE
759
+      if (isset($update_tables['counter']['page'])) // TODO REMOVE
760 760
       {
761 761
         update_security_url("SELECT DISTINCT `page` AS url FROM {{counter}}");
762 762
         update_security_url("SELECT DISTINCT `url` AS url FROM {{counter}}");
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
       "ADD CONSTRAINT `FK_counter_page_url_id` FOREIGN KEY (`page_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE",
782 782
       "ADD CONSTRAINT `FK_counter_plain_url_id` FOREIGN KEY (`plain_url_id`) REFERENCES `{{security_url}}` (`url_id`) ON DELETE CASCADE ON UPDATE CASCADE",
783 783
     ), !isset($update_tables['counter']['device_id']));
784
-    if(isset($update_tables['counter']['ip'])) {
784
+    if (isset($update_tables['counter']['ip'])) {
785 785
       // upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `user_proxy` = `proxy`, `visit_time` = FROM_UNIXTIME(`time`)');
786 786
       upd_do_query('UPDATE `{{counter}}` SET `user_ip` = INET_ATON(`ip`), `visit_time` = FROM_UNIXTIME(`time`)');
787 787
       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');
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
 
833 833
     upd_check_key('stats_history_days', 14, !classSupernova::$config->stats_history_days);
834 834
 
835
-    if(classSupernova::$config->payment_currency_default != 'USD') {
835
+    if (classSupernova::$config->payment_currency_default != 'USD') {
836 836
       upd_check_key('payment_currency_default', 'USD', true);
837 837
       upd_check_key('payment_currency_exchange_dm_', 20000, true);
838 838
       upd_check_key('payment_currency_exchange_mm_', 20000, true);
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 
890 890
     $virtual_exploded = explode('/', SN_ROOT_VIRTUAL_PARENT);
891 891
     // TODO - переделать всё на db_loadItem... НАВЕРНОЕ
892
-    upd_check_key('server_email', 'root@' . $virtual_exploded[2], !classSupernova::$config->db_loadItem('server_email'));
892
+    upd_check_key('server_email', 'root@'.$virtual_exploded[2], !classSupernova::$config->db_loadItem('server_email'));
893 893
 
894 894
     upd_alter_table('survey_votes', array(
895 895
       "DROP FOREIGN KEY `FK_survey_votes_user`",
@@ -915,12 +915,12 @@  discard block
 block discarded – undo
915 915
     function propagade_player_options($old_option_name, $new_option_id) {
916 916
       global $update_tables;
917 917
 
918
-      if(!empty($update_tables['users'][$old_option_name])) {
918
+      if (!empty($update_tables['users'][$old_option_name])) {
919 919
         upd_do_query(
920 920
           "REPLACE INTO {{player_options}} (`player_id`, `option_id`, `value`)
921 921
           SELECT `id`, {$new_option_id}, `{$old_option_name}`
922 922
           FROM {{users}}
923
-          WHERE `user_as_ally` is null and `user_bot` = " . USER_BOT_PLAYER);
923
+          WHERE `user_as_ally` is null and `user_bot` = ".USER_BOT_PLAYER);
924 924
         // TODO - UNCOMMENT !!!
925 925
         upd_alter_table('users', array("DROP COLUMN `{$old_option_name}`",));
926 926
       }
@@ -949,7 +949,7 @@  discard block
 block discarded – undo
949 949
 
950 950
 
951 951
     // 2015-08-03 15:05:26 40a6.0
952
-    if(empty($update_tables['planets']['position_original'])) {
952
+    if (empty($update_tables['planets']['position_original'])) {
953 953
       upd_alter_table('planets', array(
954 954
         "ADD COLUMN `position_original` smallint NOT NULL DEFAULT 0",
955 955
         "ADD COLUMN `field_max_original` smallint NOT NULL DEFAULT 0",
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
       upd_do_query('UPDATE {{planets}} SET `position_original` = `planet`, `field_max_original` = `field_max`, `temp_min_original` = `temp_min`, `temp_max_original` = `temp_max`;');
965 965
 
966 966
       // Миграция тяжмета в оливин
967
-      upd_do_query('UPDATE {{planets}} SET `density_index` = ' . PLANET_DENSITY_METAL_PERIDOT . ' WHERE `density_index` = 7'); // deprecated define('PLANET_DENSITY_METAL_HEAVY', 7);
967
+      upd_do_query('UPDATE {{planets}} SET `density_index` = '.PLANET_DENSITY_METAL_PERIDOT.' WHERE `density_index` = 7'); // deprecated define('PLANET_DENSITY_METAL_HEAVY', 7);
968 968
 
969 969
       // Добавляем планету-странника
970 970
       upd_check_key('game_maxPlanet', 16, Vector::$knownPlanets == 15);
@@ -977,12 +977,12 @@  discard block
 block discarded – undo
977 977
 
978 978
     // 2015-08-27 19:14:05 40a10.0
979 979
     // Старая версия таблицы
980
-    if(!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) {
980
+    if (!empty($update_tables['account']['account_is_global']) || empty($update_tables['account']['account_immortal'])) {
981 981
       upd_drop_table('account');
982 982
       upd_drop_table('account_translate');
983 983
     }
984 984
 
985
-    if(empty($update_tables['account'])) {
985
+    if (empty($update_tables['account'])) {
986 986
       upd_create_table('account', " (
987 987
           `account_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
988 988
           `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT '',
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
         ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;");
1002 1002
 
1003 1003
       upd_create_table('account_translate', " (
1004
-          `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider',
1004
+          `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL." COMMENT 'Account provider',
1005 1005
           `provider_account_id` bigint(20) unsigned NOT NULL COMMENT 'Account ID on provider',
1006 1006
           `user_id` bigint(20) unsigned NOT NULL COMMENT 'User ID',
1007 1007
           `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -1016,12 +1016,12 @@  discard block
 block discarded – undo
1016 1016
             (`account_id`, `account_name`, `account_password`, `account_salt`, `account_email`, `account_register_time`, `account_language`, `account_metamatter`, `account_metamatter_total`, `account_immortal`)
1017 1017
           SELECT
1018 1018
             `id`, `username`, `password`, `salt`, `email_2`, FROM_UNIXTIME(register_time), `lang`, `metamatter`, `metamatter_total`, `immortal`
1019
-          FROM {{users}} WHERE `user_as_ally` IS NULL AND `user_bot` = " . USER_BOT_PLAYER . ";"
1019
+          FROM {{users}} WHERE `user_as_ally` IS NULL AND `user_bot` = " . USER_BOT_PLAYER.";"
1020 1020
       );
1021 1021
 
1022 1022
       upd_do_query(
1023 1023
         "REPLACE INTO {{account_translate}} (`provider_id`, `provider_account_id`, `user_id`, `timestamp`)
1024
-          SELECT " . ACCOUNT_PROVIDER_LOCAL . ", a.account_id, u.id, a.`account_register_time`
1024
+          SELECT " . ACCOUNT_PROVIDER_LOCAL.", a.account_id, u.id, a.`account_register_time`
1025 1025
             FROM {{users}} AS u
1026 1026
             JOIN {{account}} AS a ON
1027 1027
               a.account_name = u.username
@@ -1036,7 +1036,7 @@  discard block
 block discarded – undo
1036 1036
 
1037 1037
 
1038 1038
     // 2015-09-05 17:07:15 40a10.17
1039
-    upd_alter_table('ube_report', "ADD COLUMN `ube_report_capture_result` tinyint unsigned NOT NULL DEFAULT " . UBE_CAPTURE_DISABLED, empty($update_tables['ube_report']['ube_report_capture_result']));
1039
+    upd_alter_table('ube_report', "ADD COLUMN `ube_report_capture_result` tinyint unsigned NOT NULL DEFAULT ".UBE_CAPTURE_DISABLED, empty($update_tables['ube_report']['ube_report_capture_result']));
1040 1040
 
1041 1041
 
1042 1042
     // 2015-09-07 21:11:48 40a10.19
@@ -1044,18 +1044,18 @@  discard block
 block discarded – undo
1044 1044
 
1045 1045
 
1046 1046
     // 2015-09-24 11:39:37 40a10.25
1047
-    if(empty($update_tables['log_metamatter']['provider_id'])) {
1047
+    if (empty($update_tables['log_metamatter']['provider_id'])) {
1048 1048
       upd_alter_table('log_metamatter', array(
1049
-        "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Account provider'",
1049
+        "ADD COLUMN `provider_id` tinyint unsigned NOT NULL DEFAULT ".ACCOUNT_PROVIDER_LOCAL." COMMENT 'Account provider'",
1050 1050
         "ADD COLUMN `account_id` bigint(20) unsigned NOT NULL DEFAULT 0",
1051 1051
         "ADD COLUMN `account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT ''",
1052
-        "ADD COLUMN `server_name` varchar(128) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT '" . SN_ROOT_VIRTUAL . "'",
1052
+        "ADD COLUMN `server_name` varchar(128) CHARACTER SET latin1 COLLATE latin1_general_ci NOT NULL DEFAULT '".SN_ROOT_VIRTUAL."'",
1053 1053
       ), empty($update_tables['log_metamatter']['provider_id']));
1054 1054
 
1055 1055
       upd_do_query("UPDATE {{log_metamatter}} SET `account_id` = `user_id`, `account_name` = `username`");
1056 1056
 
1057 1057
       upd_alter_table('payment', array(
1058
-        "ADD COLUMN `payment_provider_id` tinyint unsigned NOT NULL DEFAULT " . ACCOUNT_PROVIDER_LOCAL . " COMMENT 'Payment account provider'",
1058
+        "ADD COLUMN `payment_provider_id` tinyint unsigned NOT NULL DEFAULT ".ACCOUNT_PROVIDER_LOCAL." COMMENT 'Payment account provider'",
1059 1059
         "ADD COLUMN `payment_account_id` bigint(20) unsigned NOT NULL",
1060 1060
         "ADD COLUMN `payment_account_name` varchar(32) CHARACTER SET utf8 NOT NULL DEFAULT ''",
1061 1061
       ), !$update_tables['payment']['payment_account_id']);
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
     upd_check_key('event_halloween_2015_code', '', !isset(classSupernova::$config->event_halloween_2015_code));
1097 1097
     upd_check_key('event_halloween_2015_timestamp', SN_TIME_SQL, !isset(classSupernova::$config->event_halloween_2015_timestamp));
1098 1098
     upd_check_key('event_halloween_2015_units_used', serialize(array()), !isset(classSupernova::$config->event_halloween_2015_units_used));
1099
-    if(empty($update_tables['log_halloween_2015'])) {
1099
+    if (empty($update_tables['log_halloween_2015'])) {
1100 1100
       upd_create_table('log_halloween_2015', " (
1101 1101
       `log_hw2015_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1102 1102
       `player_id` bigint(20) unsigned NOT NULL COMMENT 'User ID',
@@ -1111,7 +1111,7 @@  discard block
 block discarded – undo
1111 1111
 
1112 1112
 
1113 1113
     // 2015-11-28 06:30:27 40a19.21
1114
-    if(!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) {
1114
+    if (!isset($update_tables['ube_report']['ube_report_debris_total_in_metal'])) {
1115 1115
       upd_alter_table('ube_report', array(
1116 1116
         "ADD COLUMN `ube_report_debris_total_in_metal` DECIMAL(65,0) UNSIGNED NOT NULL DEFAULT 0 COMMENT 'Total debris in metal'",
1117 1117
         "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
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
 
1127 1127
 
1128 1128
     // 2015-12-06 15:10:58 40b1.0
1129
-    if(!empty($update_indexes['planets']['I_metal_mine'])) {
1129
+    if (!empty($update_indexes['planets']['I_metal_mine'])) {
1130 1130
       upd_alter_table('planets', "DROP KEY `I_metal`", $update_indexes['planets']['I_metal']);
1131 1131
       upd_alter_table('planets', "DROP KEY `I_ship_sattelite_sloth`", $update_indexes['planets']['I_ship_sattelite_sloth']);
1132 1132
       upd_alter_table('planets', "DROP KEY `I_ship_bomber_envy`", $update_indexes['planets']['I_ship_bomber_envy']);
@@ -1189,7 +1189,7 @@  discard block
 block discarded – undo
1189 1189
   case 40:
1190 1190
     upd_log_version_update();
1191 1191
 
1192
-    if(empty($update_tables['festival'])) {
1192
+    if (empty($update_tables['festival'])) {
1193 1193
       upd_create_table('festival', " (
1194 1194
           `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
1195 1195
           `start` datetime NOT NULL COMMENT 'Festival start datetime',
@@ -1230,7 +1230,7 @@  discard block
 block discarded – undo
1230 1230
       );
1231 1231
     }
1232 1232
 
1233
-    if(empty($update_tables['festival_unit'])) {
1233
+    if (empty($update_tables['festival_unit'])) {
1234 1234
       upd_create_table('festival_unit', " (
1235 1235
           `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1236 1236
           `highspot_id` int(10) unsigned DEFAULT NULL,
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
     }
1248 1248
 
1249 1249
     // 2015-12-21 06:06:09 41a0.12
1250
-    if(empty($update_tables['festival_unit_log'])) {
1250
+    if (empty($update_tables['festival_unit_log'])) {
1251 1251
       upd_create_table('festival_unit_log', " (
1252 1252
           `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1253 1253
           `highspot_id` int(10) unsigned DEFAULT NULL,
@@ -1277,19 +1277,19 @@  discard block
 block discarded – undo
1277 1277
       $update_tables['security_browser']['browser_user_agent']['Collation'] == 'latin1_bin'
1278 1278
     );
1279 1279
 
1280
-    if($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') {
1280
+    if ($update_indexes_full['security_browser']['I_browser_user_agent']['browser_user_agent']['Index_type'] == 'BTREE') {
1281 1281
       upd_alter_table('security_browser', "DROP KEY `I_browser_user_agent`", true);
1282 1282
       upd_alter_table('security_browser', "ADD KEY `I_browser_user_agent` (`browser_user_agent`) USING HASH", true);
1283 1283
     }
1284 1284
 
1285
-    if(!empty($update_tables['fleets']['fleet_array'])) {
1285
+    if (!empty($update_tables['fleets']['fleet_array'])) {
1286 1286
       $query = upd_do_query("SELECT * FROM {{fleets}}");
1287
-      while($row = db_fetch($query)) {
1287
+      while ($row = db_fetch($query)) {
1288 1288
         $unit_list = sys_unit_str2arr($row['fleet_array']);
1289
-        foreach($unit_list as $unit_id => $unit_count) {
1289
+        foreach ($unit_list as $unit_id => $unit_count) {
1290 1290
           upd_do_query(
1291 1291
             "REPLACE INTO {{unit}} (`unit_player_id`,`unit_location_type`,`unit_location_id`,`unit_type`,`unit_snid`,`unit_level`) VALUES
1292
-              ({$row['fleet_owner']}, " . LOC_FLEET . ", {$row['fleet_id']}, 200, {$unit_id}, {$unit_count});",
1292
+              ({$row['fleet_owner']}, ".LOC_FLEET.", {$row['fleet_id']}, 200, {$unit_id}, {$unit_count});",
1293 1293
 //              ({$row['fleet_owner']}, " . LOC_FLEET . ", {$row['fleet_id']}, " . get_unit_param($unit_id, P_UNIT_TYPE) . ", {$unit_id}, {$unit_count});",
1294 1294
             true
1295 1295
           );
@@ -1323,11 +1323,11 @@  discard block
 block discarded – undo
1323 1323
 
1324 1324
 classSupernova::$cache->unset_by_prefix('lng_');
1325 1325
 
1326
-if($new_version) {
1326
+if ($new_version) {
1327 1327
   classSupernova::$config->db_saveItem('db_version', $new_version);
1328 1328
   upd_log_message("<font color=green>DB version is now {$new_version}</font>");
1329 1329
 } else {
1330
-  upd_log_message("DB version didn't changed from " . classSupernova::$config->db_version);
1330
+  upd_log_message("DB version didn't changed from ".classSupernova::$config->db_version);
1331 1331
 }
1332 1332
 
1333 1333
 classSupernova::$config->db_loadAll();
Please login to merge, or discard this patch.
ajax_version_check.php 2 patches
Switch Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -13,15 +13,15 @@
 block discarded – undo
13 13
   . '&id=' . urlencode(classSupernova::$config->server_updater_id);
14 14
 
15 15
 switch($mode) {
16
-  case SNC_MODE_REGISTER:
17
-    if(classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) {
18
-      if($ajax) {
19
-        print(SNC_VER_REGISTER_ERROR_REGISTERED);
16
+    case SNC_MODE_REGISTER:
17
+      if(classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) {
18
+        if($ajax) {
19
+          print(SNC_VER_REGISTER_ERROR_REGISTERED);
20
+        }
21
+        die();
20 22
       }
21
-      die();
22
-    }
23
-    $url .= "&name=" . urlencode(classSupernova::$config->game_name) . "&url=" . urlencode(SN_ROOT_VIRTUAL);
24
-  break;
23
+      $url .= "&name=" . urlencode(classSupernova::$config->game_name) . "&url=" . urlencode(SN_ROOT_VIRTUAL);
24
+    break;
25 25
 }
26 26
 
27 27
 $check_result = sn_get_url_contents($url);
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,42 +1,42 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once('includes/init.' . substr(strrchr(__FILE__, '.'), 1));
3
+require_once('includes/init.'.substr(strrchr(__FILE__, '.'), 1));
4 4
 
5 5
 $mode = sys_get_param_int('mode');
6 6
 $ajax = sys_get_param_int('ajax');
7 7
 
8
-$url = 'http://supernova.ws/version_check.php?mode=' . $mode
9
-  . '&db=' . DB_VERSION
10
-  . '&release=' . SN_RELEASE
11
-  . '&version=' . SN_VERSION
12
-  . '&key=' . urlencode(classSupernova::$config->server_updater_key)
13
-  . '&id=' . urlencode(classSupernova::$config->server_updater_id);
8
+$url = 'http://supernova.ws/version_check.php?mode='.$mode
9
+  . '&db='.DB_VERSION
10
+  . '&release='.SN_RELEASE
11
+  . '&version='.SN_VERSION
12
+  . '&key='.urlencode(classSupernova::$config->server_updater_key)
13
+  . '&id='.urlencode(classSupernova::$config->server_updater_id);
14 14
 
15
-switch($mode) {
15
+switch ($mode) {
16 16
   case SNC_MODE_REGISTER:
17
-    if(classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) {
18
-      if($ajax) {
17
+    if (classSupernova::$config->server_updater_key || classSupernova::$config->server_updater_id) {
18
+      if ($ajax) {
19 19
         print(SNC_VER_REGISTER_ERROR_REGISTERED);
20 20
       }
21 21
       die();
22 22
     }
23
-    $url .= "&name=" . urlencode(classSupernova::$config->game_name) . "&url=" . urlencode(SN_ROOT_VIRTUAL);
23
+    $url .= "&name=".urlencode(classSupernova::$config->game_name)."&url=".urlencode(SN_ROOT_VIRTUAL);
24 24
   break;
25 25
 }
26 26
 
27 27
 $check_result = sn_get_url_contents($url);
28
-if(!$check_result) {
28
+if (!$check_result) {
29 29
   $version_check = SNC_VER_ERROR_CONNECT;
30
-} elseif(($version_check = intval($check_result)) && $version_check == $check_result) {
30
+} elseif (($version_check = intval($check_result)) && $version_check == $check_result) {
31 31
   $version_check = $check_result;
32 32
 } else {
33 33
   // JSON decode if string
34 34
   $check_result = json_decode($check_result, true);
35 35
   $version_check = $check_result === null ? SNC_VER_UNKNOWN_RESPONSE : $check_result['version_check'];
36 36
 
37
-  switch($mode) {
37
+  switch ($mode) {
38 38
     case SNC_MODE_REGISTER:
39
-      if($check_result['site']['site_key'] && $check_result['site']['site_id'] && $check_result['site']['result'] == SNC_VER_REGISTER_REGISTERED) {
39
+      if ($check_result['site']['site_key'] && $check_result['site']['site_id'] && $check_result['site']['result'] == SNC_VER_REGISTER_REGISTERED) {
40 40
         classSupernova::$config->db_saveItem('server_updater_key', $check_result['site']['site_key']);
41 41
         classSupernova::$config->db_saveItem('server_updater_id', $check_result['site']['site_id']);
42 42
       }
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 classSupernova::$config->db_saveItem('server_updater_check_last', SN_TIME_NOW);
50 50
 classSupernova::$config->db_saveItem('server_updater_check_result', $version_check);
51 51
 
52
-if($ajax) {
52
+if ($ajax) {
53 53
   define('IN_AJAX', true);
54 54
   print($version_check);
55 55
 }
Please login to merge, or discard this patch.
admin/tools.php 2 patches
Switch Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -34,69 +34,69 @@
 block discarded – undo
34 34
 }
35 35
 
36 36
 switch($mode) {
37
-  case ADM_TOOL_CONFIG_RELOAD:
38
-    classSupernova::$config->db_loadAll();
39
-    sys_refresh_tablelist();
40
-
41
-    classSupernova::$config->db_loadItem('game_watchlist');
42
-    if(classSupernova::$config->game_watchlist) {
43
-      classSupernova::$config->game_watchlist_array = explode(';', classSupernova::$config->game_watchlist);
44
-    } else {
45
-      unset(classSupernova::$config->game_watchlist_array);
46
-    }
47
-  break;
48
-
49
-  case ADM_TOOL_MD5:
50
-    $template = gettemplate("admin/md5enc", true);
51
-    $password_seed = sys_get_param_str_unsafe('seed', SN_SYS_SEC_CHARS_ALLOWED);
52
-    $password_length = sys_get_param_int('length', 16);
53
-    $string = ($string = sys_get_param_str_unsafe('string')) ? $string : sys_random_string($password_length, $password_seed);
54
-
55
-    $template->assign_vars(array(
56
-      'SEED'   => $password_seed,
57
-      'LENGTH' => $password_length,
58
-      'STRING' => htmlentities($string),
59
-      'MD5'    => md5($string),
60
-    ));
61
-    display($template, classLocale::$lang['adm_tools_md5_header'], false, '', true);
62
-  break;
63
-
64
-  case ADM_TOOL_FORCE_ALL:
65
-    classSupernova::$config->db_saveItem('db_version', 0);
66
-    require_once('../includes/update.php');
67
-  break;
68
-
69
-  case ADM_TOOL_FORCE_LAST:
70
-    classSupernova::$config->db_saveItem('db_version', floor(classSupernova::$config->db_version - 1));
71
-    require_once('../includes/update.php');
72
-  break;
73
-
74
-  case ADM_TOOL_INFO_PHP:
75
-    phpinfo();
76
-  break;
77
-
78
-  case ADM_TOOL_INFO_SQL:
79
-    $template = gettemplate("simple_table", true);
80
-
81
-    $status = array(
82
-      classLocale::$lang['adm_tool_sql_server_version'] => classSupernova::$db->db_get_server_info(),
83
-      classLocale::$lang['adm_tool_sql_client_version'] => classSupernova::$db->db_get_client_info(),
84
-      classLocale::$lang['adm_tool_sql_host_info']      => classSupernova::$db->db_get_host_info(),
85
-    );
86
-    templateAssignTable($template, 'server', $status);
87
-
88
-    templateAssignTable($template, 'status', classSupernova::$db->db_get_server_stat());
89
-    templateAssignTable($template, 'params', classSupernova::$db->db_core_show_status());
90
-
91
-    $template->assign_vars(array(
92
-      'PAGE_HEADER'   => classLocale::$lang['adm_tool_sql_page_header'],
93
-      'COLUMN_NAME_1' => classLocale::$lang['adm_tool_sql_param_name'],
94
-      'COLUMN_NAME_2' => classLocale::$lang['adm_tool_sql_param_value'],
95
-      'TABLE_FOOTER'  => 'test',
96
-    ));
97
-
98
-    display($template, classLocale::$lang['adm_bn_ttle'], false, '', true);
99
-  break;
37
+    case ADM_TOOL_CONFIG_RELOAD:
38
+      classSupernova::$config->db_loadAll();
39
+      sys_refresh_tablelist();
40
+
41
+      classSupernova::$config->db_loadItem('game_watchlist');
42
+      if(classSupernova::$config->game_watchlist) {
43
+        classSupernova::$config->game_watchlist_array = explode(';', classSupernova::$config->game_watchlist);
44
+      } else {
45
+        unset(classSupernova::$config->game_watchlist_array);
46
+      }
47
+    break;
48
+
49
+    case ADM_TOOL_MD5:
50
+      $template = gettemplate("admin/md5enc", true);
51
+      $password_seed = sys_get_param_str_unsafe('seed', SN_SYS_SEC_CHARS_ALLOWED);
52
+      $password_length = sys_get_param_int('length', 16);
53
+      $string = ($string = sys_get_param_str_unsafe('string')) ? $string : sys_random_string($password_length, $password_seed);
54
+
55
+      $template->assign_vars(array(
56
+        'SEED'   => $password_seed,
57
+        'LENGTH' => $password_length,
58
+        'STRING' => htmlentities($string),
59
+        'MD5'    => md5($string),
60
+      ));
61
+      display($template, classLocale::$lang['adm_tools_md5_header'], false, '', true);
62
+    break;
63
+
64
+    case ADM_TOOL_FORCE_ALL:
65
+      classSupernova::$config->db_saveItem('db_version', 0);
66
+      require_once('../includes/update.php');
67
+    break;
68
+
69
+    case ADM_TOOL_FORCE_LAST:
70
+      classSupernova::$config->db_saveItem('db_version', floor(classSupernova::$config->db_version - 1));
71
+      require_once('../includes/update.php');
72
+    break;
73
+
74
+    case ADM_TOOL_INFO_PHP:
75
+      phpinfo();
76
+    break;
77
+
78
+    case ADM_TOOL_INFO_SQL:
79
+      $template = gettemplate("simple_table", true);
80
+
81
+      $status = array(
82
+        classLocale::$lang['adm_tool_sql_server_version'] => classSupernova::$db->db_get_server_info(),
83
+        classLocale::$lang['adm_tool_sql_client_version'] => classSupernova::$db->db_get_client_info(),
84
+        classLocale::$lang['adm_tool_sql_host_info']      => classSupernova::$db->db_get_host_info(),
85
+      );
86
+      templateAssignTable($template, 'server', $status);
87
+
88
+      templateAssignTable($template, 'status', classSupernova::$db->db_get_server_stat());
89
+      templateAssignTable($template, 'params', classSupernova::$db->db_core_show_status());
90
+
91
+      $template->assign_vars(array(
92
+        'PAGE_HEADER'   => classLocale::$lang['adm_tool_sql_page_header'],
93
+        'COLUMN_NAME_1' => classLocale::$lang['adm_tool_sql_param_name'],
94
+        'COLUMN_NAME_2' => classLocale::$lang['adm_tool_sql_param_value'],
95
+        'TABLE_FOOTER'  => 'test',
96
+      ));
97
+
98
+      display($template, classLocale::$lang['adm_bn_ttle'], false, '', true);
99
+    break;
100 100
 
101 101
 }
102 102
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -9,10 +9,10 @@  discard block
 block discarded – undo
9 9
 define('INSIDE', true);
10 10
 define('INSTALL', false);
11 11
 define('IN_ADMIN', true);
12
-require('../common.' . substr(strrchr(__FILE__, '.'), 1));
12
+require('../common.'.substr(strrchr(__FILE__, '.'), 1));
13 13
 
14 14
 // if($user['authlevel'] < 1)
15
-if($user['authlevel'] < 3) {
15
+if ($user['authlevel'] < 3) {
16 16
   AdminMessage(classLocale::$lang['adm_err_denied']);
17 17
 }
18 18
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function templateAssignTable($template, $str, $status) {
27 27
   $template->assign_block_vars('table', classLocale::$lang['adm_tool_sql_table'][$str]);
28
-  foreach($status as $key => $value) {
28
+  foreach ($status as $key => $value) {
29 29
     $template->assign_block_vars('table.row', array(
30 30
       'VALUE_1' => $key,
31 31
       'VALUE_2' => $value,
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
   }
34 34
 }
35 35
 
36
-switch($mode) {
36
+switch ($mode) {
37 37
   case ADM_TOOL_CONFIG_RELOAD:
38 38
     classSupernova::$config->db_loadAll();
39 39
     sys_refresh_tablelist();
40 40
 
41 41
     classSupernova::$config->db_loadItem('game_watchlist');
42
-    if(classSupernova::$config->game_watchlist) {
42
+    if (classSupernova::$config->game_watchlist) {
43 43
       classSupernova::$config->game_watchlist_array = explode(';', classSupernova::$config->game_watchlist);
44 44
     } else {
45 45
       unset(classSupernova::$config->game_watchlist_array);
Please login to merge, or discard this patch.
includes/classes/Vector.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@
 block discarded – undo
10 10
   /**
11 11
    * UniverseVector constructor.
12 12
    *
13
-   * @param int|string       $galaxy
14
-   * @param int|Vector|array $system
13
+   * @param integer       $galaxy
14
+   * @param integer $system
15 15
    * @param int              $planet
16 16
    * @param int              $type
17 17
    */
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
   public $type = PT_NONE;
14 14
 
15 15
   public static function _staticInit() {
16
-    if(static::$_isStaticInit) {
16
+    if (static::$_isStaticInit) {
17 17
       return;
18 18
     }
19 19
     static::$knownGalaxies = intval(classSupernova::$config->game_maxGalaxy);
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
   public function __construct($galaxy = 0, $system = 0, $planet = 0, $type = PT_NONE) {
34 34
     // static::_staticInit();
35 35
 
36
-    if(is_string($galaxy) && $galaxy == VECTOR_READ_VECTOR && is_object($system) && $system instanceof Vector) {
36
+    if (is_string($galaxy) && $galaxy == VECTOR_READ_VECTOR && is_object($system) && $system instanceof Vector) {
37 37
       $this->readFromVector($system);
38
-    } elseif(is_string($galaxy) && $galaxy == VECTOR_READ_PARAMS && is_array($system)) {
38
+    } elseif (is_string($galaxy) && $galaxy == VECTOR_READ_PARAMS && is_array($system)) {
39 39
       $this->readFromParamFleets($system);
40 40
     } else {
41 41
       $this->galaxy = intval($galaxy);
@@ -74,11 +74,11 @@  discard block
 block discarded – undo
74 74
    * @param Vector $vector
75 75
    */
76 76
   public function distance($vector) {
77
-    if($this->galaxy != $vector->galaxy) {
77
+    if ($this->galaxy != $vector->galaxy) {
78 78
       $distance = abs($this->galaxy - $vector->galaxy) * classSupernova::$config->uni_galaxy_distance;
79
-    } elseif($this->system != $vector->system) {
79
+    } elseif ($this->system != $vector->system) {
80 80
       $distance = abs($this->system - $vector->system) * 5 * 19 + 2700;
81
-    } elseif($this->planet != $vector->planet) {
81
+    } elseif ($this->planet != $vector->planet) {
82 82
       $distance = abs($this->planet - $vector->planet) * 5 + 1000;
83 83
       // TODO - uncomment
84 84
 //    } elseif($this->type != PT_NONE && $vector->type != PT_NONE && $this->type == $vector->type) {
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
    * @param array $coordinates
102 102
    */
103 103
   public static function convertToVector($coordinates, $prefix = '') {
104
-    $galaxy = !empty($coordinates[$prefix . 'galaxy']) ? intval($coordinates[$prefix . 'galaxy']) : 0;
105
-    $system = !empty($coordinates[$prefix . 'system']) ? intval($coordinates[$prefix . 'system']) : 0;
106
-    $planet = !empty($coordinates[$prefix . 'planet']) ? intval($coordinates[$prefix . 'planet']) : 0;
107
-    $type = !empty($coordinates[$prefix . 'type'])
108
-      ? intval($coordinates[$prefix . 'type'])
109
-      : (!empty($coordinates[$prefix . 'planet_type']) ? intval($coordinates[$prefix . 'planet_type']) : 0);
104
+    $galaxy = !empty($coordinates[$prefix.'galaxy']) ? intval($coordinates[$prefix.'galaxy']) : 0;
105
+    $system = !empty($coordinates[$prefix.'system']) ? intval($coordinates[$prefix.'system']) : 0;
106
+    $planet = !empty($coordinates[$prefix.'planet']) ? intval($coordinates[$prefix.'planet']) : 0;
107
+    $type = !empty($coordinates[$prefix.'type'])
108
+      ? intval($coordinates[$prefix.'type'])
109
+      : (!empty($coordinates[$prefix.'planet_type']) ? intval($coordinates[$prefix.'planet_type']) : 0);
110 110
 
111 111
     return new static($galaxy, $system, $planet, $type);
112 112
   }
Please login to merge, or discard this patch.
includes/classes/Player.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
    * @return int|mixed
229 229
    */
230 230
   public function calcColonyMaxCount($astrotech = -1) {
231
-    if($astrotech == -1) {
232
-      if(!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) {
231
+    if ($astrotech == -1) {
232
+      if (!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) {
233 233
 
234 234
         $expeditions = get_player_max_expeditons($this->_dbRow);
235 235
         $astrotech = mrc_get_level($this->_dbRow, null, TECH_ASTROTECH);
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 
303 303
 
304 304
   public function expeditionsMax() {
305
-    if($this->expeditionsMax === null) {
305
+    if ($this->expeditionsMax === null) {
306 306
       $this->expeditionsMax = get_player_max_expeditons($this->_dbRow);
307 307
     }
308 308
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
   }
311 311
 
312 312
   public function expeditionsFlying() {
313
-    if($this->expeditionsFlying === null) {
313
+    if ($this->expeditionsFlying === null) {
314 314
       $this->expeditionsFlying = FleetList::fleet_count_flying($this->_dbId, MT_EXPLORE);
315 315
     }
316 316
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 
320 320
 
321 321
   public function fleetsMax() {
322
-    if($this->fleetMax === null) {
322
+    if ($this->fleetMax === null) {
323 323
       $this->fleetMax = GetMaxFleets($this->_dbRow);
324 324
     }
325 325
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
   }
328 328
 
329 329
   public function fleetsFlying() {
330
-    if($this->fleetFlying === null) {
330
+    if ($this->fleetFlying === null) {
331 331
       $this->fleetFlying = FleetList::fleet_count_flying($this->_dbId);
332 332
     }
333 333
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
 
338 338
   public function coloniesMax() {
339
-    if($this->coloniesMax === null) {
339
+    if ($this->coloniesMax === null) {
340 340
       $this->coloniesMax = get_player_max_colonies($this->_dbRow);
341 341
     }
342 342
 
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
   }
345 345
 
346 346
   public function coloniesCurrent() {
347
-    if($this->coloniesCurrent === null) {
347
+    if ($this->coloniesCurrent === null) {
348 348
       $this->coloniesCurrent = get_player_current_colonies($this->_dbRow);
349 349
     }
350 350
 
Please login to merge, or discard this patch.
includes/includes/flt_page5.inc 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 *
13 13
 **/
14 14
 
15
-if(SN_IN_FLEET !== true) {
15
+if (SN_IN_FLEET !== true) {
16 16
   $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
17 17
 }
18 18
 
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 
26 26
   $planet_list = array();
27 27
 
28
-  if(is_array($resources_taken))
28
+  if (is_array($resources_taken))
29 29
   {
30 30
     $query = implode(',', array_keys($resources_taken));
31 31
     $query = " AND `destruyed` = 0 AND `id` IN ({$query})";
@@ -33,16 +33,16 @@  discard block
 block discarded – undo
33 33
     $query = '';
34 34
   }
35 35
 
36
-  foreach(sn_get_groups('flt_transports') as $transport_id) {
36
+  foreach (sn_get_groups('flt_transports') as $transport_id) {
37 37
     $transports[$transport_id] = get_unit_param($transport_id, P_CAPACITY);
38 38
   }
39 39
   arsort($transports);
40 40
 
41 41
   $planets_db_list = db_planet_list_sorted($user, $planetrow['id'], '*', $query);
42 42
   !is_array($planets_db_list) ? $planets_db_list = array() : false;
43
-  foreach($planets_db_list as $planet_db_data) {
43
+  foreach ($planets_db_list as $planet_db_data) {
44 44
   // begin planet loop
45
-    if(!$query) {
45
+    if (!$query) {
46 46
       $resources_taken[$planet_db_data['id']] = 1;
47 47
     }
48 48
     sn_db_transaction_start();
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
     $planet_id = $planet_db_data['id'];
55 55
 
56 56
     $planet_resources = 0;
57
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
58
-      if($resources_taken[$planet_id] == 1 || $resources_taken[$planet_id][$resource_id]) {
57
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
58
+      if ($resources_taken[$planet_id] == 1 || $resources_taken[$planet_id][$resource_id]) {
59 59
         $planet_resources += floor(mrc_get_level($user, $planet_db_data, $resource_id, true, true)); // $planet_db_data[get_unit_param($resource_id, P_NAME)]);
60 60
       }
61 61
     }
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
     $fleet_capacity = 0;
87 87
     $ship_loadout = array();
88 88
     $fleet = array();
89
-    foreach($transports as $ship_id => $ship_capacity) {
90
-      if($ship_count = mrc_get_level($user, $planet_db_data, $ship_id, true, true)) {
89
+    foreach ($transports as $ship_id => $ship_capacity) {
90
+      if ($ship_count = mrc_get_level($user, $planet_db_data, $ship_id, true, true)) {
91 91
         $ship_loadout[$ship_id]['capacity'] = $ship_count * $ship_capacity;
92 92
         $ship_loadout[$ship_id]['taken'] = 0;
93 93
         $fleet_capacity += $ship_loadout[$ship_id]['capacity'];
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 
99 99
     $will_take = min($planet_resources, $fleet_capacity);
100 100
 
101
-    foreach($ship_loadout as $ship_id => &$planet_ship) {
101
+    foreach ($ship_loadout as $ship_id => &$planet_ship) {
102 102
       $can_take = min($will_take, $planet_ship['capacity']);
103
-      if($can_take <= 0) {
103
+      if ($can_take <= 0) {
104 104
         continue;
105 105
       }
106 106
       $planet_ship['capacity'] -= $can_take;
@@ -108,23 +108,23 @@  discard block
 block discarded – undo
108 108
       $fleet[$ship_id] = ceil($planet_ship['taken'] / $transports[$ship_id]);
109 109
 
110 110
       $will_take -= $can_take;
111
-      if($will_take <= 0) {
111
+      if ($will_take <= 0) {
112 112
         break;
113 113
       }
114 114
     }
115 115
 
116
-    if(!empty($fleet)) {
116
+    if (!empty($fleet)) {
117 117
       $travel_data = flt_travel_data($user, $planetrow, $planet_db_data, $fleet, 10);
118 118
       $planet_data['FLEET_SPEED'] = $travel_data['fleet_speed'];
119 119
       $planet_data['DISTANCE']    = $travel_data['distance'];
120 120
       $planet_data['DURATION']    = $travel_data['duration'];
121 121
       $planet_data['CONSUMPTION'] = $travel_data['consumption'];
122 122
 
123
-      if(floor(mrc_get_level($user, $planet_db_data, RES_DEUTERIUM, true)) >= $planet_data['CONSUMPTION']) {
123
+      if (floor(mrc_get_level($user, $planet_db_data, RES_DEUTERIUM, true)) >= $planet_data['CONSUMPTION']) {
124 124
         $will_take = min($planet_resources, $fleet_capacity) - $planet_data['CONSUMPTION'];
125 125
 
126
-        foreach(sn_get_groups('resources_loot') as $resource_id) {
127
-          if($resources_taken[$planet_id] != 1 && !$resources_taken[$planet_id][$resource_id]) {
126
+        foreach (sn_get_groups('resources_loot') as $resource_id) {
127
+          if ($resources_taken[$planet_id] != 1 && !$resources_taken[$planet_id][$resource_id]) {
128 128
             continue;
129 129
           }
130 130
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
           $fleet[$resource_id] = min($will_take, $resource_amount);
134 134
           $will_take -= $resource_amount;
135 135
 
136
-          if($will_take <= 0) {
136
+          if ($will_take <= 0) {
137 137
             break;
138 138
           }
139 139
         }
@@ -157,19 +157,19 @@  discard block
 block discarded – undo
157 157
 
158 158
 $resources_taken = sys_get_param('resources');
159 159
 
160
-if(!empty($resources_taken))  { // begin processing parameters
160
+if (!empty($resources_taken)) { // begin processing parameters
161 161
   $planet_list = flt_build_gathering($resources_taken);
162 162
 
163
-  foreach($planet_list as $planet_id => $planet_data) {
164
-    if($planet_data['RESULT'] == FLIGHT_ALLOWED) {
163
+  foreach ($planet_list as $planet_id => $planet_data) {
164
+    if ($planet_data['RESULT'] == FLIGHT_ALLOWED) {
165 165
       $planet_data['RESULT'] = flt_t_send_fleet($user, $planet_data['PLANET_DB_DATA'], $planetrow, $planet_data['FLEET'], MT_TRANSPORT);
166 166
     }
167 167
 
168 168
     $planet_data['MESSAGE'] = classLocale::$lang['fl_attack_error'][$planet_data['RESULT']];
169 169
 
170 170
     $template->assign_block_vars('results', $planet_data);
171
-    if(!empty($planet_data['FLEET']) && $planet_data['RESULT'] == FLIGHT_ALLOWED) {
172
-      foreach($planet_data['FLEET'] as $unit_id => $amount) {
171
+    if (!empty($planet_data['FLEET']) && $planet_data['RESULT'] == FLIGHT_ALLOWED) {
172
+      foreach ($planet_data['FLEET'] as $unit_id => $amount) {
173 173
         $template->assign_block_vars('results.units', array(
174 174
           'ID'     => $unit_id,
175 175
           'NAME'   => classLocale::$lang['tech'][$unit_id],
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
 // Building list of own planets & moons
184 184
 $planet_list = flt_build_gathering();
185
-foreach($planet_list as $planet_data) {
185
+foreach ($planet_list as $planet_data) {
186 186
   $planet_data['DURATION'] = $planet_data['DURATION'] ? pretty_time($planet_data['DURATION']) : classLocale::$lang['flt_no_fuel'];
187 187
   $template->assign_block_vars('colonies', $planet_data);
188 188
 }
Please login to merge, or discard this patch.
includes/classes/Fleet.php 2 patches
Doc Comments   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
   /**
973 973
    * Set current resource list from array of units
974 974
    *
975
-   * @param array $resource_list
975
+   * @param integer[] $resource_list
976 976
    */
977 977
   public function resourcesSet($resource_list) {
978 978
     if (!empty($this->propertiesAdjusted['resource_list'])) {
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
   }
1021 1021
 
1022 1022
   /**
1023
-   * @param array $rate
1023
+   * @param integer[] $rate
1024 1024
    *
1025 1025
    * @return float
1026 1026
    */
@@ -1051,7 +1051,6 @@  discard block
 block discarded – undo
1051 1051
    * Restores fleet or resources to planet
1052 1052
    *
1053 1053
    * @param bool $start
1054
-   * @param bool $only_resources
1055 1054
    * @param int  $result
1056 1055
    *
1057 1056
    * @return int
@@ -1205,6 +1204,9 @@  discard block
 block discarded – undo
1205 1204
   }
1206 1205
 
1207 1206
 
1207
+  /**
1208
+   * @param integer $missionStartTimeStamp
1209
+   */
1208 1210
   protected function renderFleetCoordinates($missionStartTimeStamp = SN_TIME_NOW, $timeMissionJob = 0) {
1209 1211
     $timeToReturn = $this->travelData['duration'] * 2 + $timeMissionJob;
1210 1212
 
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -398,31 +398,31 @@  discard block
 block discarded – undo
398 398
 
399 399
     return doquery(
400 400
     // Блокировка самого флота
401
-      "SELECT 1 FROM {{fleets}} AS f " .
401
+      "SELECT 1 FROM {{fleets}} AS f ".
402 402
 
403 403
       // Блокировка всех юнитов, принадлежащих этому флоту
404
-      "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = " . static::$locationType . " AND unit.unit_location_id = f.fleet_id " .
404
+      "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = ".static::$locationType." AND unit.unit_location_id = f.fleet_id ".
405 405
 
406 406
       // Блокировка всех прилетающих и улетающих флотов, если нужно
407 407
       // TODO - lock fleets by COORDINATES
408
-      ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '') .
408
+      ($mission_data['dst_fleets'] ? "LEFT JOIN {{fleets}} AS fd ON fd.fleet_end_planet_id = f.fleet_end_planet_id OR fd.fleet_start_planet_id = f.fleet_end_planet_id " : '').
409 409
       // Блокировка всех юнитов, принадлежащих прилетающим и улетающим флотам - ufd = unit_fleet_destination
410
-      ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = " . static::$locationType . " AND ufd.unit_location_id = fd.fleet_id " : '') .
410
+      ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = ".static::$locationType." AND ufd.unit_location_id = fd.fleet_id " : '').
411 411
 
412
-      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '') .
412
+      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '').
413 413
       // Блокировка всех юнитов, принадлежащих владельцу планеты-цели
414
-      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '') .
414
+      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '').
415 415
       // Блокировка планеты-цели
416
-      ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '') .
416
+      ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '').
417 417
       // Блокировка всех юнитов, принадлежащих планете-цели - НЕ НУЖНО. Уже залочили ранее, как принадлежащие игроку-цели
418 418
 //      ($mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS upd ON upd.unit_location_type = " . LOC_PLANET . " AND upd.unit_location_id = pd.id " : '') .
419 419
 
420 420
 
421
-      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '') .
421
+      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '').
422 422
       // Блокировка всех юнитов, принадлежащих владельцу флота
423
-      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '') .
423
+      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '').
424 424
       // Блокировка планеты отправления
425
-      ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '') .
425
+      ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '').
426 426
       // Блокировка всех юнитов, принадлежащих планете с которой юниты были отправлены - НЕ НУЖНО. Уже залочили ранее, как принадлежащие владельцу флота
427 427
 //      ($mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS ups ON ups.unit_location_type = " . LOC_PLANET . " AND ups.unit_location_id = ps.id " : '') .
428 428
 
@@ -439,11 +439,11 @@  discard block
 block discarded – undo
439 439
   public function dbGetLockById($dbId) {
440 440
     doquery(
441 441
     // Блокировка самого флота
442
-      "SELECT 1 FROM {{fleets}} AS FLEET0 " .
442
+      "SELECT 1 FROM {{fleets}} AS FLEET0 ".
443 443
       // Lock fleet owner
444
-      "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner " .
444
+      "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner ".
445 445
       // Блокировка всех юнитов, принадлежащих этому флоту
446
-      "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = " . LOC_FLEET . " AND UNIT0.unit_location_id = FLEET0.fleet_id " .
446
+      "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = ".LOC_FLEET." AND UNIT0.unit_location_id = FLEET0.fleet_id ".
447 447
 
448 448
       // Без предварительной выборки неизвестно - куда летит этот флот.
449 449
       // Поэтому надо выбирать флоты, чьи координаты прибытия ИЛИ отбытия совпадают с координатами прибытия ИЛИ отбытия текущего флота.
@@ -459,9 +459,9 @@  discard block
 block discarded – undo
459 459
         FLEET1.fleet_end_planet = FLEET0.fleet_end_planet
460 460
       " .
461 461
       // Блокировка всех юнитов, принадлежащих этим флотам
462
-      "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = " . LOC_FLEET . " AND UNIT1.unit_location_id = FLEET1.fleet_id " .
462
+      "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = ".LOC_FLEET." AND UNIT1.unit_location_id = FLEET1.fleet_id ".
463 463
       // Lock fleet owner
464
-      "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner " .
464
+      "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner ".
465 465
 
466 466
       "LEFT JOIN {{fleets}} AS FLEET2 ON
467 467
         FLEET2.fleet_mess = 1   AND FLEET0.fleet_mess = 0 AND
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
       " .
472 472
       // Блокировка всех юнитов, принадлежащих этим флотам
473 473
       "LEFT JOIN {{unit}} as UNIT2 ON
474
-        UNIT2.unit_location_type = " . LOC_FLEET . " AND
474
+        UNIT2.unit_location_type = " . LOC_FLEET." AND
475 475
         UNIT2.unit_location_id = FLEET2.fleet_id
476 476
       " .
477 477
       // Lock fleet owner
@@ -488,11 +488,11 @@  discard block
 block discarded – undo
488 488
       " .
489 489
       // Блокировка всех юнитов, принадлежащих этим флотам
490 490
       "LEFT JOIN {{unit}} as UNIT3 ON
491
-        UNIT3.unit_location_type = " . LOC_FLEET . " AND
491
+        UNIT3.unit_location_type = " . LOC_FLEET." AND
492 492
         UNIT3.unit_location_id = FLEET3.fleet_id
493 493
       " .
494 494
       // Lock fleet owner
495
-      "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner " .
495
+      "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner ".
496 496
 
497 497
       "LEFT JOIN {{fleets}} AS FLEET4 ON
498 498
         FLEET4.fleet_mess = 1   AND FLEET0.fleet_mess = 1 AND
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
       " .
503 503
       // Блокировка всех юнитов, принадлежащих этим флотам
504 504
       "LEFT JOIN {{unit}} as UNIT4 ON
505
-        UNIT4.unit_location_type = " . LOC_FLEET . " AND
505
+        UNIT4.unit_location_type = " . LOC_FLEET." AND
506 506
         UNIT4.unit_location_id = FLEET4.fleet_id
507 507
       " .
508 508
       // Lock fleet owner
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
       " .
525 525
       // Блокировка всех юнитов, принадлежащих этой планете
526 526
       "LEFT JOIN {{unit}} as UNIT5 ON
527
-        UNIT5.unit_location_type = " . LOC_PLANET . " AND
527
+        UNIT5.unit_location_type = " . LOC_PLANET." AND
528 528
         UNIT5.unit_location_id = PLANETS5.id
529 529
       " .
530 530
 
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
       " .
543 543
       // Блокировка всех юнитов, принадлежащих этой планете
544 544
       "LEFT JOIN {{unit}} as UNIT6 ON
545
-        UNIT6.unit_location_type = " . LOC_PLANET . " AND
545
+        UNIT6.unit_location_type = " . LOC_PLANET." AND
546 546
         UNIT6.unit_location_id = PLANETS6.id
547 547
       " .
548 548
       "WHERE FLEET0.fleet_id = {$dbId} GROUP BY 1 FOR UPDATE"
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
       } elseif ($this->isResource($unit_id)) {
662 662
         $this->resource_list[$unit_id] = $unit_count;
663 663
       } else {
664
-        throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR);
664
+        throw new Exception('Trying to pass to fleet non-resource and non-ship '.var_export($unit_array, true), ERR_ERROR);
665 665
       }
666 666
     }
667 667
   }
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
    */
987 987
   public function resourcesSet($resource_list) {
988 988
     if (!empty($this->propertiesAdjusted['resource_list'])) {
989
-      throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR);
989
+      throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in '.get_called_class().'::unitSetResourceList', ERR_ERROR);
990 990
     }
991 991
     $this->resourcesAdjust($resource_list, true);
992 992
   }
@@ -1020,7 +1020,7 @@  discard block
 block discarded – undo
1020 1020
       // Check for negative unit value
1021 1021
       if ($this->resource_list[$resource_id] < 0) {
1022 1022
         // TODO
1023
-        throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR);
1023
+        throw new Exception('Resource '.$resource_id.' will become negative in '.get_called_class().'::unitAdjustResourceList', ERR_ERROR);
1024 1024
       }
1025 1025
     }
1026 1026
   }
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
 
1194 1194
   protected function printErrorIfNoShips() {
1195 1195
     if ($this->unitList->unitsCount() <= 0) {
1196
-      message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5);
1196
+      message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet'.DOT_PHP_EX, 5);
1197 1197
     }
1198 1198
   }
1199 1199
 
@@ -1540,7 +1540,7 @@  discard block
 block discarded – undo
1540 1540
     } catch (Exception $e) {
1541 1541
 
1542 1542
       // TODO - MESSAGE BOX
1543
-      if($e instanceof ExceptionFleetInvalid) {
1543
+      if ($e instanceof ExceptionFleetInvalid) {
1544 1544
         sn_db_transaction_rollback();
1545 1545
         pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]);
1546 1546
       } else {
@@ -1629,7 +1629,7 @@  discard block
 block discarded – undo
1629 1629
       $validator->validate();
1630 1630
     } catch (Exception $e) {
1631 1631
       // TODO - MESSAGE BOX
1632
-      if($e instanceof ExceptionFleetInvalid) {
1632
+      if ($e instanceof ExceptionFleetInvalid) {
1633 1633
         sn_db_transaction_rollback();
1634 1634
         pdie(classLocale::$lang['fl_attack_error'][$e->getCode()]);
1635 1635
       } else {
@@ -1690,7 +1690,7 @@  discard block
 block discarded – undo
1690 1690
 
1691 1691
 
1692 1692
     if (!empty($this->captain['unit_id'])) {
1693
-      DBStaticUnit::db_unit_set_by_id($this->captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$this->_dbId}");
1693
+      DBStaticUnit::db_unit_set_by_id($this->captain['unit_id'], "`unit_location_type` = ".LOC_FLEET.", `unit_location_id` = {$this->_dbId}");
1694 1694
     }
1695 1695
 
1696 1696
 //    return $this->fleet->acs['ankunft'] - $this->fleet->time_launch >= $this->fleet->travelData['duration'];
@@ -1702,7 +1702,7 @@  discard block
 block discarded – undo
1702 1702
     $template_result['.']['fleets'][] = $this->renderFleet(SN_TIME_NOW, $timeMissionJob);
1703 1703
 
1704 1704
     $template_result += array(
1705
-      'mission'         => classLocale::$lang['type_mission'][$this->_mission_type] . ($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' ' . pretty_time($timeMissionJob) : ''),
1705
+      'mission'         => classLocale::$lang['type_mission'][$this->_mission_type].($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' '.pretty_time($timeMissionJob) : ''),
1706 1706
       'dist'            => pretty_number($this->travelData['distance']),
1707 1707
       'speed'           => pretty_number($this->travelData['fleet_speed']),
1708 1708
       'deute_need'      => pretty_number($this->travelData['consumption']),
Please login to merge, or discard this patch.
includes/debug.class.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -70,6 +70,9 @@  discard block
 block discarded – undo
70 70
     $this->numqueries = 0;
71 71
   }
72 72
 
73
+  /**
74
+   * @param string $mes
75
+   */
73 76
   function add($mes) {
74 77
     $this->log .= $mes;
75 78
     $this->numqueries++;
@@ -185,6 +188,9 @@  discard block
 block discarded – undo
185 188
     return $error_backtrace;
186 189
   }
187 190
 
191
+  /**
192
+   * @param string $die_message
193
+   */
188 194
   function error_fatal($die_message, $details = 'There is a fatal error on page') {
189 195
     // TODO - Записывать детали ошибки в лог-файл
190 196
     die($die_message);
Please login to merge, or discard this patch.
Spacing   +74 added lines, -75 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 
31 31
 defined('INSIDE') || die();
32 32
 
33
-if(php_sapi_name() == "cli") {
33
+if (php_sapi_name() == "cli") {
34 34
   // In cli-mode
35 35
   define('__DEBUG_CRLF', "\r\n");
36
-  define('__DEBUG_LINE', '-------------------------------------------------' . __DEBUG_CRLF);
36
+  define('__DEBUG_LINE', '-------------------------------------------------'.__DEBUG_CRLF);
37 37
 } else {
38 38
   // Not in cli-mode
39 39
   define('__DEBUG_CRLF', '<br />');
@@ -50,17 +50,17 @@  discard block
 block discarded – undo
50 50
   function log_file($message, $ident_change = 0) {
51 51
     static $ident = 0;
52 52
 
53
-    if(!defined('SN_DEBUG_LOG')) {
53
+    if (!defined('SN_DEBUG_LOG')) {
54 54
       return;
55 55
     }
56 56
 
57
-    if($this->log_file_handler === null) {
58
-      $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+');
57
+    if ($this->log_file_handler === null) {
58
+      $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL.'/.logs/supernova.log', 'a+');
59 59
       @fwrite($this->log_file_handler, "\r\n\r\n");
60 60
     }
61 61
     $ident_change < 0 ? $ident += $ident_change * 2 : false;
62
-    if($this->log_file_handler) {
63
-      @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n");
62
+    if ($this->log_file_handler) {
63
+      @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()).str_repeat(' ', $ident + 1).$message."\r\n");
64 64
     }
65 65
     $ident_change > 0 ? $ident += $ident_change * 2 : false;
66 66
   }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
   }
81 81
 
82 82
   function echo_log() {
83
-    echo '<br><table><tr><td class=k colspan=4><a href="' . SN_ROOT_PHYSICAL . "admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>";
83
+    echo '<br><table><tr><td class=k colspan=4><a href="'.SN_ROOT_PHYSICAL."admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>";
84 84
     die();
85 85
   }
86 86
 
@@ -90,25 +90,25 @@  discard block
 block discarded – undo
90 90
     $result = array();
91 91
     $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++;
92 92
     $result[] = "tID {$transaction_id}";
93
-    foreach($backtrace as $a_trace) {
94
-      if(in_array($a_trace['function'], $exclude_functions)) {
93
+    foreach ($backtrace as $a_trace) {
94
+      if (in_array($a_trace['function'], $exclude_functions)) {
95 95
         continue;
96 96
       }
97 97
       $function =
98 98
         ($a_trace['type']
99 99
           ? ($a_trace['type'] == '->'
100
-            ? "({$a_trace['class']})" . get_class($a_trace['object'])
100
+            ? "({$a_trace['class']})".get_class($a_trace['object'])
101 101
             : $a_trace['class']
102
-          ) . $a_trace['type']
102
+          ).$a_trace['type']
103 103
           : ''
104
-        ) . $a_trace['function'] . '()';
104
+        ).$a_trace['function'].'()';
105 105
 
106 106
       $file = str_replace(SN_ROOT_PHYSICAL, '', str_replace('\\', '/', $a_trace['file']));
107 107
 
108 108
       // $result[] = "{$function} ({$a_trace['line']})'{$file}'";
109 109
       $result[] = "{$function} - '{$file}' Line {$a_trace['line']}";
110 110
 
111
-      if(!$long_comment) {
111
+      if (!$long_comment) {
112 112
         break;
113 113
       }
114 114
     }
@@ -122,26 +122,26 @@  discard block
 block discarded – undo
122 122
   function dump($dump = false, $force_base = false, $deadlock = false) {
123 123
     global $user, $planetrow;
124 124
 
125
-    if($dump === false) {
125
+    if ($dump === false) {
126 126
       return;
127 127
     }
128 128
 
129 129
     $error_backtrace = array();
130 130
     $base_dump = false;
131 131
 
132
-    if($force_base === true) {
132
+    if ($force_base === true) {
133 133
       $base_dump = true;
134 134
     }
135 135
 
136
-    if($dump === true) {
136
+    if ($dump === true) {
137 137
       $base_dump = true;
138 138
     } else {
139
-      if(!is_array($dump)) {
139
+      if (!is_array($dump)) {
140 140
         $dump = array('var' => $dump);
141 141
       }
142 142
 
143
-      foreach($dump as $dump_var_name => $dump_var) {
144
-        if($dump_var_name == 'base_dump') {
143
+      foreach ($dump as $dump_var_name => $dump_var) {
144
+        if ($dump_var_name == 'base_dump') {
145 145
           $base_dump = $dump_var;
146 146
         } else {
147 147
           $error_backtrace[$dump_var_name] = $dump_var;
@@ -149,22 +149,21 @@  discard block
 block discarded – undo
149 149
       }
150 150
     }
151 151
 
152
-    if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
152
+    if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
153 153
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
154 154
       $error_backtrace['locks'] = classSupernova::$locks;
155 155
       $error_backtrace['cSN_data'] = classSupernova::$data;
156
-      foreach($error_backtrace['cSN_data'] as &$location) {
157
-        foreach($location as $location_id => &$location_data) {
158
-          $location_data = isset($location_data['username']) ? $location_data['username'] :
159
-            (isset($location_data['name']) ? $location_data['name'] : $location_id);
156
+      foreach ($error_backtrace['cSN_data'] as &$location) {
157
+        foreach ($location as $location_id => &$location_data) {
158
+          $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id);
160 159
         }
161 160
       }
162 161
       $error_backtrace['cSN_queries'] = classSupernova::$queries;
163 162
     }
164 163
 
165
-    if($base_dump) {
166
-      if(is_array($this->log_array) && count($this->log_array) > 0) {
167
-        foreach($this->log_array as $log) {
164
+    if ($base_dump) {
165
+      if (is_array($this->log_array) && count($this->log_array) > 0) {
166
+        foreach ($this->log_array as $log) {
168 167
           $error_backtrace['queries'][] = $log;
169 168
         }
170 169
       }
@@ -193,14 +192,14 @@  discard block
 block discarded – undo
193 192
   function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) {
194 193
     global $sys_stop_log_hit, $sys_log_disabled, $user;
195 194
 
196
-    if(empty(classSupernova::$db->connected)) {
195
+    if (empty(classSupernova::$db->connected)) {
197 196
       // TODO - писать ошибку в файл
198 197
       die('SQL server currently unavailable. Please contact Administration...');
199 198
     }
200 199
 
201 200
     sn_db_transaction_rollback();
202 201
 
203
-    if(classSupernova::$config->debug == 1) {
202
+    if (classSupernova::$config->debug == 1) {
204 203
       echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>";
205 204
       echo "<table>{$this->log}</table>";
206 205
     }
@@ -212,16 +211,16 @@  discard block
 block discarded – undo
212 211
 
213 212
     $userId = empty($user['id']) ? 0 : $user['id'];
214 213
 
215
-    if(!$sys_log_disabled) {
214
+    if (!$sys_log_disabled) {
216 215
       $query = "INSERT INTO `{{logs}}` SET
217
-        `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($userId) . "',
218
-        `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
219
-        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" .
216
+        `log_time` = '" . time()."', `log_code` = '".db_escape($error_code)."', `log_sender` = '".db_escape($userId)."',
217
+        `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."',  `log_text` = '".db_escape($message)."',
218
+        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'".
220 219
 //        ($error_backtrace ? ", `log_dump` = '" . db_escape(serialize($error_backtrace)) . "'" : '') . ";";
221
-      ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";";
222
-      doquery($query, '', false, true) or die($fatal_error . db_error());
220
+      ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";";
221
+      doquery($query, '', false, true) or die($fatal_error.db_error());
223 222
 
224
-      $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>" . db_insert_id() . "</b>";
223
+      $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>".db_insert_id()."</b>";
225 224
 
226 225
       $sys_stop_log_hit = true;
227 226
       $sys_log_disabled = true;
@@ -231,7 +230,7 @@  discard block
 block discarded – undo
231 230
       ob_start();
232 231
       print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}");
233 232
 
234
-      foreach($error_backtrace as $name => $value) {
233
+      foreach ($error_backtrace as $name => $value) {
235 234
         print(__DEBUG_LINE);
236 235
         pdump($value, $name);
237 236
       }
@@ -243,7 +242,7 @@  discard block
 block discarded – undo
243 242
   function warning($message, $title = 'System Message', $log_code = 300, $dump = false) {
244 243
     global $user, $sys_log_disabled;
245 244
 
246
-    if(empty(classSupernova::$db->connected)) {
245
+    if (empty(classSupernova::$db->connected)) {
247 246
       // TODO - писать ошибку в файл
248 247
       die('SQL server currently unavailable. Please contact Administration...');
249 248
     }
@@ -252,12 +251,12 @@  discard block
 block discarded – undo
252 251
 
253 252
     $userId = empty($user['id']) ? 0 : $user['id'];
254 253
 
255
-    if(!$sys_log_disabled) {
254
+    if (!$sys_log_disabled) {
256 255
       $query = "INSERT INTO `{{logs}}` SET
257
-        `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($userId) . "',
258
-        `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
259
-        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" .
260
-        ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";";
256
+        `log_time` = '" . time()."', `log_code` = '".db_escape($log_code)."', `log_sender` = '".db_escape($userId)."',
257
+        `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."',  `log_text` = '".db_escape($message)."',
258
+        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'".
259
+        ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";";
261 260
       doquery($query, '', false, true);
262 261
     } else {
263 262
 //        // TODO Здесь надо писать в файло
@@ -270,11 +269,11 @@  discard block
 block discarded – undo
270 269
 // Dump variables nicer then var_dump()
271 270
 
272 271
 function dump($value, $varname = null, $level = 0, $dumper = '') {
273
-  if(isset($varname)) {
272
+  if (isset($varname)) {
274 273
     $varname .= " = ";
275 274
   }
276 275
 
277
-  if($level == -1) {
276
+  if ($level == -1) {
278 277
     $trans[' '] = '&there4;';
279 278
     $trans["\t"] = '&rArr;';
280 279
     $trans["\n"] = '&para;;';
@@ -283,31 +282,31 @@  discard block
 block discarded – undo
283 282
 
284 283
     return strtr(htmlspecialchars($value), $trans);
285 284
   }
286
-  if($level == 0) {
285
+  if ($level == 0) {
287 286
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
288
-    $dumper = mt_rand(10, 99) . '|' . $varname;
287
+    $dumper = mt_rand(10, 99).'|'.$varname;
289 288
   }
290 289
 
291 290
   $type = gettype($value);
292 291
   $dumper .= $type;
293 292
 
294
-  if($type == 'string') {
295
-    $dumper .= '(' . strlen($value) . ')';
293
+  if ($type == 'string') {
294
+    $dumper .= '('.strlen($value).')';
296 295
     $value = dump($value, '', -1);
297
-  } elseif($type == 'boolean') {
296
+  } elseif ($type == 'boolean') {
298 297
     $value = ($value ? 'true' : 'false');
299
-  } elseif($type == 'object') {
298
+  } elseif ($type == 'object') {
300 299
     $props = get_class_vars(get_class($value));
301
-    $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
302
-    foreach($props as $key => $val) {
303
-      $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
300
+    $dumper .= '('.count($props).') <u>'.get_class($value).'</u>';
301
+    foreach ($props as $key => $val) {
302
+      $dumper .= "\n".str_repeat("\t", $level + 1).$key.' => ';
304 303
       $dumper .= dump($value->$key, '', $level + 1);
305 304
     }
306 305
     $value = '';
307
-  } elseif($type == 'array') {
308
-    $dumper .= '(' . count($value) . ')';
309
-    foreach($value as $key => $val) {
310
-      $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
306
+  } elseif ($type == 'array') {
307
+    $dumper .= '('.count($value).')';
308
+    foreach ($value as $key => $val) {
309
+      $dumper .= "\n".str_repeat("\t", $level + 1).dump($key, '', -1).' => ';
311 310
       $dumper .= dump($val, '', $level + 1);
312 311
     }
313 312
     $value = '';
@@ -326,24 +325,24 @@  discard block
 block discarded – undo
326 325
 //  $backtrace = $backtrace[1];
327 326
 
328 327
   $caller = '';
329
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
330
-    $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
331
-      (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
332
-      $backtrace[1]['function'] .
328
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
329
+    $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '').
330
+      (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '').
331
+      $backtrace[1]['function'].
333 332
       (!empty($backtrace[0]['file'])
334 333
         ? (
335
-          ' (' . substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN) .
336
-          (!empty($backtrace[0]['line']) ? ':' . $backtrace[0]['line'] : '') .
334
+          ' ('.substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN).
335
+          (!empty($backtrace[0]['line']) ? ':'.$backtrace[0]['line'] : '').
337 336
           ')'
338 337
         )
339 338
         : ''
340 339
       );
341
-    $caller = "\r\n" . $caller;
340
+    $caller = "\r\n".$caller;
342 341
   }
343 342
 
344
-  print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">' .
345
-    dump($value, $varname) .
346
-    $caller .
343
+  print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">'.
344
+    dump($value, $varname).
345
+    $caller.
347 346
     '</pre>'
348 347
   );
349 348
 }
@@ -353,24 +352,24 @@  discard block
 block discarded – undo
353 352
 }
354 353
 
355 354
 function pr($prePrint = false) {
356
-  if($prePrint) {
355
+  if ($prePrint) {
357 356
     print(__DEBUG_CRLF);
358 357
   }
359
-  print(mt_rand() . __DEBUG_CRLF);
358
+  print(mt_rand().__DEBUG_CRLF);
360 359
 }
361 360
 
362 361
 function pc($prePrint = false) {
363 362
   global $_PRINT_COUNT_VALUE;
364 363
   $_PRINT_COUNT_VALUE++;
365 364
 
366
-  if($prePrint) {
365
+  if ($prePrint) {
367 366
     print(__DEBUG_CRLF);
368 367
   }
369
-  print($_PRINT_COUNT_VALUE . __DEBUG_CRLF);
368
+  print($_PRINT_COUNT_VALUE.__DEBUG_CRLF);
370 369
 }
371 370
 
372 371
 function prep($message) {
373
-  print('<pre>' . $message . '</pre>');
372
+  print('<pre>'.$message.'</pre>');
374 373
 }
375 374
 
376 375
 function backtrace_no_arg() {
@@ -393,5 +392,5 @@  discard block
 block discarded – undo
393 392
  */
394 393
 function pdie($message = '') {
395 394
   $backtrace = debug_backtrace();
396
-  die(__DEBUG_LINE . ($message ? $message . ' @ ' : '') . $backtrace[0]['file'] . ':' . $backtrace[0]['line']);
395
+  die(__DEBUG_LINE.($message ? $message.' @ ' : '').$backtrace[0]['file'].':'.$backtrace[0]['line']);
397 396
 }
Please login to merge, or discard this patch.
metamatter.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -4,9 +4,9 @@  discard block
 block discarded – undo
4 4
 // Может добавить спецстатус "Ответ системы платежа" и парсить дальше getMessage
5 5
 // см constants.php
6 6
 
7
-include_once('common.' . substr(strrchr(__FILE__, '.'), 1));
7
+include_once('common.'.substr(strrchr(__FILE__, '.'), 1));
8 8
 
9
-if(!sn_module_get_active_count('payment')) {
9
+if (!sn_module_get_active_count('payment')) {
10 10
   sys_redirect('dark_matter.php');
11 11
   die();
12 12
 }
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 
24 24
 // Таблица скидок
25 25
 $prev_discount = 0;
26
-if(isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) {
27
-  foreach(sn_module_payment::$bonus_table as $sum => $discount) {
28
-    if($discount && $discount != $prev_discount) {
26
+if (isset(sn_module_payment::$bonus_table) && is_array(sn_module_payment::$bonus_table)) {
27
+  foreach (sn_module_payment::$bonus_table as $sum => $discount) {
28
+    if ($discount && $discount != $prev_discount) {
29 29
       $template->assign_block_vars('discount', array(
30 30
         'SUM'          => $sum,
31 31
         'DISCOUNT'     => $discount * 100,
@@ -38,19 +38,19 @@  discard block
 block discarded – undo
38 38
 }
39 39
 
40 40
 // Результат платежа
41
-if($payment_id = sys_get_param_id('payment_id')) {
41
+if ($payment_id = sys_get_param_id('payment_id')) {
42 42
   $payment = db_payment_get($payment_id);
43
-  if($payment && $payment['payment_user_id'] == $user['id']) {
44
-    if($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
43
+  if ($payment && $payment['payment_user_id'] == $user['id']) {
44
+    if ($payment['payment_status'] == PAYMENT_STATUS_COMPLETE) {
45 45
       $template->assign_block_vars('result', array('MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_complete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name'], $payment['payment_dark_matter_gained'])));
46 46
     }
47
-    if($payment['payment_status'] == PAYMENT_STATUS_NONE) {
47
+    if ($payment['payment_status'] == PAYMENT_STATUS_NONE) {
48 48
       $template->assign_block_vars('result', array(
49 49
         'MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_incomplete'], $payment['payment_dark_matter_paid'], $payment['payment_module_name']),
50 50
         'STATUS'  => 1,
51 51
       ));
52 52
     }
53
-    if($payment['payment_test']) {
53
+    if ($payment['payment_test']) {
54 54
       $template->assign_block_vars('result', array(
55 55
         'MESSAGE' => sprintf(classLocale::$lang['pay_msg_mm_purchase_test']),
56 56
         'STATUS'  => -1,
@@ -65,28 +65,28 @@  discard block
 block discarded – undo
65 65
   'metamatter' => sys_get_param_float('metamatter'),
66 66
 );
67 67
 
68
-if(!$request['metamatter']) {
68
+if (!$request['metamatter']) {
69 69
   unset($_POST);
70 70
 }
71 71
 
72 72
 $payment_methods_available = array_combine(array_keys(sn_module_payment::$payment_methods), array_fill(0, count(sn_module_payment::$payment_methods), null));
73
-array_walk($payment_methods_available, function (&$value, $index) {
73
+array_walk($payment_methods_available, function(&$value, $index) {
74 74
   $value = !empty(sn_module_payment::$payment_methods[$index]) ? array_combine(array_keys(sn_module_payment::$payment_methods[$index]), array_fill(0, count(sn_module_payment::$payment_methods[$index]), null)) : $value;
75 75
 });
76 76
 
77 77
 // pdump($payment_methods_available);
78 78
 $payment_module_valid = false;
79 79
 $payment_module = sys_get_param_str('payment_module');
80
-foreach(sn_module::$sn_module_list['payment'] as $module_name => $module) {
81
-  if(!is_object($module) || !$module->manifest['active']) {
80
+foreach (sn_module::$sn_module_list['payment'] as $module_name => $module) {
81
+  if (!is_object($module) || !$module->manifest['active']) {
82 82
     continue;
83 83
   }
84 84
 
85 85
   lng_include($module_name, $module->manifest['root_relative']);
86 86
 
87
-  foreach(sn_module_payment::$payment_methods as $payment_type_id => $available_methods) {
88
-    foreach($available_methods as $payment_method => $payment_currency) {
89
-      if(isset($module->manifest['payment_method'][$payment_method])) {
87
+  foreach (sn_module_payment::$payment_methods as $payment_type_id => $available_methods) {
88
+    foreach ($available_methods as $payment_method => $payment_currency) {
89
+      if (isset($module->manifest['payment_method'][$payment_method])) {
90 90
         $payment_methods_available[$payment_type_id][$payment_method][$module_name] = $module->manifest['payment_method'][$payment_method];
91 91
       }
92 92
     }
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 
98 98
 global $template_result;
99 99
 // Доступные платежные методы
100
-foreach($payment_methods_available as $payment_type_id => $payment_methods) {
101
-  if(empty($payment_methods)) {
100
+foreach ($payment_methods_available as $payment_type_id => $payment_methods) {
101
+  if (empty($payment_methods)) {
102 102
     continue;
103 103
   }
104 104
 
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
     'ID'   => $payment_type_id,
107 107
     'NAME' => classLocale::$lang['pay_methods'][$payment_type_id],
108 108
   );
109
-  foreach($payment_methods as $payment_method_id => $module_list) {
110
-    if(empty($module_list)) {
109
+  foreach ($payment_methods as $payment_method_id => $module_list) {
110
+    if (empty($module_list)) {
111 111
       continue;
112 112
     }
113 113
     $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id] = array(
@@ -118,14 +118,14 @@  discard block
 block discarded – undo
118 118
       'NAME_FORCE' => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['name']),
119 119
       'BUTTON'     => isset(sn_module_payment::$payment_methods[$payment_type_id][$payment_method_id]['button']),
120 120
     );
121
-    foreach($module_list as $payment_module_name => $payment_module_method_details) {
121
+    foreach ($module_list as $payment_module_name => $payment_module_method_details) {
122 122
       $template_result['.']['payment'][$payment_type_id]['.']['method'][$payment_method_id]['.']['module'][] = array(
123 123
         'MODULE' => $payment_module_name,
124 124
       );
125 125
     }
126 126
   }
127 127
 
128
-  if(empty($template_result['.']['payment'][$payment_type_id]['.'])) {
128
+  if (empty($template_result['.']['payment'][$payment_type_id]['.'])) {
129 129
     unset($template_result['.']['payment'][$payment_type_id]);
130 130
   }
131 131
 }
@@ -138,19 +138,19 @@  discard block
 block discarded – undo
138 138
 $payment_module_valid = $payment_module_valid && (!$payment_method_selected || isset($payment_methods_available[$payment_type_selected][$payment_method_selected][$module_name]));
139 139
 
140 140
 // If payment_module invalid - making it empty OR if there is only one payment_module - selecting it
141
-if($payment_module_valid) {
141
+if ($payment_module_valid) {
142 142
   // $payment_module = $payment_module; // Really - do nothing
143
-} elseif($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) {
143
+} elseif ($payment_type_selected && count($payment_methods_available[$payment_type_selected][$payment_method_selected]) == 1) {
144 144
   reset($payment_methods_available[$payment_type_selected][$payment_method_selected]);
145 145
   $payment_module = key($payment_methods_available[$payment_type_selected][$payment_method_selected]);
146
-} elseif(count(sn_module::$sn_module_list['payment']) == 1) {
146
+} elseif (count(sn_module::$sn_module_list['payment']) == 1) {
147 147
   $payment_module = $module_name;
148 148
 } else {
149 149
   $payment_module = '';
150 150
 }
151 151
 
152
-if($payment_type_selected && $payment_method_selected) {
153
-  foreach($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) {
152
+if ($payment_type_selected && $payment_method_selected) {
153
+  foreach ($payment_methods_available[$payment_type_selected][$payment_method_selected] as $module_name => $temp) {
154 154
     $template->assign_block_vars('payment_module', array(
155 155
       'ID'          => $module_name,
156 156
       'NAME'        => classLocale::$lang["module_{$module_name}_name"],
@@ -159,9 +159,9 @@  discard block
 block discarded – undo
159 159
   }
160 160
 }
161 161
 
162
-foreach(classLocale::$lang['pay_currency_list'] as $key => $value) {
162
+foreach (classLocale::$lang['pay_currency_list'] as $key => $value) {
163 163
   $course = get_exchange_rate($key);
164
-  if(!$course) {
164
+  if (!$course) {
165 165
     continue;
166 166
   }
167 167
   $template->assign_block_vars('exchange', array(
@@ -176,17 +176,17 @@  discard block
 block discarded – undo
176 176
   ));
177 177
 }
178 178
 
179
-if($request['metamatter'] && $payment_module) {
179
+if ($request['metamatter'] && $payment_module) {
180 180
   try {
181 181
     // Any possible errors about generating paylink should be raised in module!
182 182
     $pay_link = sn_module::$sn_module[$payment_module]->compile_request($request);
183 183
 
184 184
     // Поддержка дополнительной информации
185
-    if(is_array($pay_link['RENDER'])) {
186
-      foreach($pay_link['RENDER'] as $html_data) {
185
+    if (is_array($pay_link['RENDER'])) {
186
+      foreach ($pay_link['RENDER'] as $html_data) {
187 187
         $template->assign_block_vars('render', $html_data);
188
-        if(isset($html_data['VALUE']) && is_array($html_data['VALUE'])) {
189
-          foreach($html_data['VALUE'] as $value_id => $value_value) {
188
+        if (isset($html_data['VALUE']) && is_array($html_data['VALUE'])) {
189
+          foreach ($html_data['VALUE'] as $value_id => $value_value) {
190 190
             $template->assign_block_vars('render.value', array(
191 191
               'FIELD' => $value_id,
192 192
               'VALUE' => $value_value,
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
     }
198 198
 
199 199
     // Поддержка передачи данных для многошаговых платежных систем
200
-    if(is_array($pay_link['DATA'])) {
201
-      foreach($pay_link['DATA'] as $key => $value) {
200
+    if (is_array($pay_link['DATA'])) {
201
+      foreach ($pay_link['DATA'] as $key => $value) {
202 202
         $template->assign_block_vars('pay_link_data', array(
203 203
           'FIELD' => $key,
204 204
           'VALUE' => $value,
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
       }
207 207
     }
208 208
 
209
-    if(is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) {
209
+    if (is_array($pay_link) && in_array($pay_link['PAY_LINK_METHOD'], array('POST', 'GET', 'LINK', 'STEP'))) {
210 210
       // TODO Переделать это под assign_vars_recursive и возвращать пустые строки если нет платежного метода - для унификации формы в темплейте
211 211
       $template->assign_vars(array(
212 212
         'PAY_LINK_METHOD' => $pay_link['PAY_LINK_METHOD'],
@@ -215,17 +215,17 @@  discard block
 block discarded – undo
215 215
     } else {
216 216
       throw new exception(classLocale::$lang['pay_msg_request_paylink_unsupported'], ERR_ERROR);
217 217
     }
218
-  } catch(exception $e) {
218
+  } catch (exception $e) {
219 219
     $template->assign_block_vars('result', $response = array(
220 220
       'STATUS'  => $e->getCode(),
221 221
       'MESSAGE' => $e->getMessage(),
222 222
     ));
223
-    classSupernova::$debug->warning('Результат операции: код ' . $e->getCode() . ' сообщение "' . $e->getMessage() . '"', 'Ошибка платежа', LOG_INFO_PAYMENT);
223
+    classSupernova::$debug->warning('Результат операции: код '.$e->getCode().' сообщение "'.$e->getMessage().'"', 'Ошибка платежа', LOG_INFO_PAYMENT);
224 224
   }
225 225
 }
226 226
 
227 227
 // Прегенерированные пакеты
228
-foreach($unit_available_amount_list as $unit_amount => $discount) {
228
+foreach ($unit_available_amount_list as $unit_amount => $discount) {
229 229
   $temp = sn_module_payment::currency_convert($unit_amount, 'MM_', $player_currency);
230 230
   $template->assign_block_vars('mm_amount', array(
231 231
     'VALUE'            => $unit_amount,
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
   'PLAYER_CURRENCY'              => $player_currency,
261 261
   'PLAYER_CURRENCY_PRICE_PER_MM' => sn_module_payment::currency_convert(1, $player_currency, 'MM_', 10),
262 262
 
263
-  'UNIT_AMOUNT'                 => (float)$request['metamatter'],
263
+  'UNIT_AMOUNT'                 => (float) $request['metamatter'],
264 264
   'UNIT_AMOUNT_TEXT'            => pretty_number($request['metamatter']),
265 265
   'UNIT_AMOUNT_BONUS_PERCENT'   => $bonus_percent,
266 266
   'UNIT_AMOUNT_TEXT_DISCOUNTED' => $income_metamatter_text,
Please login to merge, or discard this patch.