Completed
Push — work-fleets ( 006942...3604bd )
by SuperNova.WS
06:54
created
includes/includes/flt_mission_recycle.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
   $RecyclerCapacity = 0;
17 17
   $OtherFleetCapacity = 0;
18 18
 
19
-  foreach($objFleet->shipsIterator() as $unit_id => $unit) {
20
-    if(in_array($unit_id, classSupernova::$gc->groupFleet)) {
19
+  foreach ($objFleet->shipsIterator() as $unit_id => $unit) {
20
+    if (in_array($unit_id, classSupernova::$gc->groupFleet)) {
21 21
       $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit->count;
22
-      if(in_array($unit_id, classSupernova::$gc->groupRecyclers)) {
22
+      if (in_array($unit_id, classSupernova::$gc->groupRecyclers)) {
23 23
         $RecyclerCapacity += $capacity;
24 24
       } else {
25 25
         $OtherFleetCapacity += $capacity;
@@ -28,33 +28,33 @@  discard block
 block discarded – undo
28 28
   }
29 29
 
30 30
   $fleet_resources_amount = $objFleet->resourcesGetTotal();
31
-  if($fleet_resources_amount > $OtherFleetCapacity) {
31
+  if ($fleet_resources_amount > $OtherFleetCapacity) {
32 32
     // Если во флоте есть другие корабли И количество ресурсов больше, чем их ёмкость трюмов - значит часть этих ресурсов лежит в трюмах переработчиков
33 33
     // Уменьшаем ёмкость переработчиков на указанную величину
34 34
     $RecyclerCapacity -= ($fleet_resources_amount - $OtherFleetCapacity);
35 35
   }
36 36
 
37 37
   $resources_recycled = array();
38
-  if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) {
38
+  if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) {
39 39
     $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
40 40
     $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
41 41
   } else {
42
-    if(($destination_planet["debris_metal"] > $RecyclerCapacity / 2) &&
42
+    if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) &&
43 43
       ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2)
44 44
     ) {
45 45
       $resources_recycled[RES_METAL] = $RecyclerCapacity / 2;
46 46
       $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity / 2;
47 47
     } else {
48
-      if($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) {
48
+      if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) {
49 49
         $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
50
-        if($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) {
50
+        if ($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) {
51 51
           $resources_recycled[RES_METAL] = $RecyclerCapacity - $resources_recycled[RES_CRYSTAL];
52 52
         } else {
53 53
           $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
54 54
         }
55 55
       } else {
56 56
         $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
57
-        if($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) {
57
+        if ($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) {
58 58
           $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity - $resources_recycled[RES_METAL];
59 59
         } else {
60 60
           $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
Please login to merge, or discard this patch.
classes/Fleet.php 3 patches
Doc Comments   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
   /**
980 980
    * Set current resource list from array of units
981 981
    *
982
-   * @param array $resource_list
982
+   * @param integer[] $resource_list
983 983
    */
984 984
   public function resourcesSet($resource_list) {
985 985
     if (!empty($this->propertiesAdjusted['resource_list'])) {
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
   }
1028 1028
 
1029 1029
   /**
1030
-   * @param array $rate
1030
+   * @param integer[] $rate
1031 1031
    *
1032 1032
    * @return float
1033 1033
    */
@@ -1058,8 +1058,6 @@  discard block
 block discarded – undo
1058 1058
    * Restores fleet or resources to planet
1059 1059
    *
1060 1060
    * @param bool $start
1061
-   * @param bool $only_resources
1062
-   * @param int  $result
1063 1061
    */
1064 1062
   public function resourcesUnload($start = true) {
1065 1063
     sn_db_transaction_check(true);
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 use DBStatic\DBStaticFleetACS;
3
-use DBStatic\DBStaticNote;
4 3
 use DBStatic\DBStaticPlanet;
5 4
 use DBStatic\DBStaticUnit;
6 5
 use DBStatic\DBStaticUser;
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -401,31 +401,31 @@  discard block
 block discarded – undo
401 401
 
402 402
     return classSupernova::$db->doSelect(
403 403
     // Блокировка самого флота
404
-      "SELECT 1 FROM {{fleets}} AS f " .
404
+      "SELECT 1 FROM {{fleets}} AS f ".
405 405
 
406 406
       // Блокировка всех юнитов, принадлежащих этому флоту
407
-      "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = " . static::$locationType . " AND unit.unit_location_id = f.fleet_id " .
407
+      "LEFT JOIN {{unit}} as unit ON unit.unit_location_type = ".static::$locationType." AND unit.unit_location_id = f.fleet_id ".
408 408
 
409 409
       // Блокировка всех прилетающих и улетающих флотов, если нужно
410 410
       // TODO - lock fleets by COORDINATES
411
-      ($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 " : '') .
411
+      ($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 " : '').
412 412
       // Блокировка всех юнитов, принадлежащих прилетающим и улетающим флотам - ufd = unit_fleet_destination
413
-      ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = " . static::$locationType . " AND ufd.unit_location_id = fd.fleet_id " : '') .
413
+      ($mission_data['dst_fleets'] ? "LEFT JOIN {{unit}} AS ufd ON ufd.unit_location_type = ".static::$locationType." AND ufd.unit_location_id = fd.fleet_id " : '').
414 414
 
415
-      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '') .
415
+      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{users}} AS ud ON ud.id = f.fleet_target_owner " : '').
416 416
       // Блокировка всех юнитов, принадлежащих владельцу планеты-цели
417
-      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '') .
417
+      ($mission_data['dst_user'] || $mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS unit_player_dest ON unit_player_dest.unit_player_id = ud.id " : '').
418 418
       // Блокировка планеты-цели
419
-      ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '') .
419
+      ($mission_data['dst_planet'] ? "LEFT JOIN {{planets}} AS pd ON pd.id = f.fleet_end_planet_id " : '').
420 420
       // Блокировка всех юнитов, принадлежащих планете-цели - НЕ НУЖНО. Уже залочили ранее, как принадлежащие игроку-цели
421 421
 //      ($mission_data['dst_planet'] ? "LEFT JOIN {{unit}} AS upd ON upd.unit_location_type = " . LOC_PLANET . " AND upd.unit_location_id = pd.id " : '') .
422 422
 
423 423
 
424
-      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '') .
424
+      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{users}} AS us ON us.id = f.fleet_owner " : '').
425 425
       // Блокировка всех юнитов, принадлежащих владельцу флота
426
-      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '') .
426
+      ($mission_data['src_user'] || $mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS unit_player_src ON unit_player_src.unit_player_id = us.id " : '').
427 427
       // Блокировка планеты отправления
428
-      ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '') .
428
+      ($mission_data['src_planet'] ? "LEFT JOIN {{planets}} AS ps ON ps.id = f.fleet_start_planet_id " : '').
429 429
       // Блокировка всех юнитов, принадлежащих планете с которой юниты были отправлены - НЕ НУЖНО. Уже залочили ранее, как принадлежащие владельцу флота
430 430
 //      ($mission_data['src_planet'] ? "LEFT JOIN {{unit}} AS ups ON ups.unit_location_type = " . LOC_PLANET . " AND ups.unit_location_id = ps.id " : '') .
431 431
 
@@ -442,11 +442,11 @@  discard block
 block discarded – undo
442 442
   public function dbGetLockById($dbId) {
443 443
     classSupernova::$db->doSelect(
444 444
     // Блокировка самого флота
445
-      "SELECT 1 FROM {{fleets}} AS FLEET0 " .
445
+      "SELECT 1 FROM {{fleets}} AS FLEET0 ".
446 446
       // Lock fleet owner
447
-      "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner " .
447
+      "LEFT JOIN {{users}} as USER0 on USER0.id = FLEET0.fleet_owner ".
448 448
       // Блокировка всех юнитов, принадлежащих этому флоту
449
-      "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = " . LOC_FLEET . " AND UNIT0.unit_location_id = FLEET0.fleet_id " .
449
+      "LEFT JOIN {{unit}} as UNIT0 ON UNIT0.unit_location_type = ".LOC_FLEET." AND UNIT0.unit_location_id = FLEET0.fleet_id ".
450 450
 
451 451
       // Без предварительной выборки неизвестно - куда летит этот флот.
452 452
       // Поэтому надо выбирать флоты, чьи координаты прибытия ИЛИ отбытия совпадают с координатами прибытия ИЛИ отбытия текущего флота.
@@ -462,9 +462,9 @@  discard block
 block discarded – undo
462 462
         FLEET1.fleet_end_planet = FLEET0.fleet_end_planet
463 463
       " .
464 464
       // Блокировка всех юнитов, принадлежащих этим флотам
465
-      "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = " . LOC_FLEET . " AND UNIT1.unit_location_id = FLEET1.fleet_id " .
465
+      "LEFT JOIN {{unit}} as UNIT1 ON UNIT1.unit_location_type = ".LOC_FLEET." AND UNIT1.unit_location_id = FLEET1.fleet_id ".
466 466
       // Lock fleet owner
467
-      "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner " .
467
+      "LEFT JOIN {{users}} as USER1 on USER1.id = FLEET1.fleet_owner ".
468 468
 
469 469
       "LEFT JOIN {{fleets}} AS FLEET2 ON
470 470
         FLEET2.fleet_mess = 1   AND FLEET0.fleet_mess = 0 AND
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
       " .
475 475
       // Блокировка всех юнитов, принадлежащих этим флотам
476 476
       "LEFT JOIN {{unit}} as UNIT2 ON
477
-        UNIT2.unit_location_type = " . LOC_FLEET . " AND
477
+        UNIT2.unit_location_type = " . LOC_FLEET." AND
478 478
         UNIT2.unit_location_id = FLEET2.fleet_id
479 479
       " .
480 480
       // Lock fleet owner
@@ -491,11 +491,11 @@  discard block
 block discarded – undo
491 491
       " .
492 492
       // Блокировка всех юнитов, принадлежащих этим флотам
493 493
       "LEFT JOIN {{unit}} as UNIT3 ON
494
-        UNIT3.unit_location_type = " . LOC_FLEET . " AND
494
+        UNIT3.unit_location_type = " . LOC_FLEET." AND
495 495
         UNIT3.unit_location_id = FLEET3.fleet_id
496 496
       " .
497 497
       // Lock fleet owner
498
-      "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner " .
498
+      "LEFT JOIN {{users}} as USER3 on USER3.id = FLEET3.fleet_owner ".
499 499
 
500 500
       "LEFT JOIN {{fleets}} AS FLEET4 ON
501 501
         FLEET4.fleet_mess = 1   AND FLEET0.fleet_mess = 1 AND
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
       " .
506 506
       // Блокировка всех юнитов, принадлежащих этим флотам
507 507
       "LEFT JOIN {{unit}} as UNIT4 ON
508
-        UNIT4.unit_location_type = " . LOC_FLEET . " AND
508
+        UNIT4.unit_location_type = " . LOC_FLEET." AND
509 509
         UNIT4.unit_location_id = FLEET4.fleet_id
510 510
       " .
511 511
       // Lock fleet owner
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
       " .
528 528
       // Блокировка всех юнитов, принадлежащих этой планете
529 529
       "LEFT JOIN {{unit}} as UNIT5 ON
530
-        UNIT5.unit_location_type = " . LOC_PLANET . " AND
530
+        UNIT5.unit_location_type = " . LOC_PLANET." AND
531 531
         UNIT5.unit_location_id = PLANETS5.id
532 532
       " .
533 533
 
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
       " .
546 546
       // Блокировка всех юнитов, принадлежащих этой планете
547 547
       "LEFT JOIN {{unit}} as UNIT6 ON
548
-        UNIT6.unit_location_type = " . LOC_PLANET . " AND
548
+        UNIT6.unit_location_type = " . LOC_PLANET." AND
549 549
         UNIT6.unit_location_id = PLANETS6.id
550 550
       " .
551 551
       "WHERE FLEET0.fleet_id = {$dbId} GROUP BY 1 FOR UPDATE"
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
       } elseif ($this->isResource($unit_id)) {
658 658
         $this->resource_list[$unit_id] = $unit_count;
659 659
       } else {
660
-        throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), FLIGHT_SHIPS_UNIT_WRONG);
660
+        throw new Exception('Trying to pass to fleet non-resource and non-ship '.var_export($unit_array, true), FLIGHT_SHIPS_UNIT_WRONG);
661 661
       }
662 662
     }
663 663
   }
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
    * @param int $unit_count
792 792
    */
793 793
   public function shipSetCount($unit_id, $unit_count = 0) {
794
-    pdump(__CLASS__ . '->' . __FUNCTION__);
794
+    pdump(__CLASS__.'->'.__FUNCTION__);
795 795
     $this->shipAdjustCount($unit_id, $unit_count, true);
796 796
   }
797 797
 
@@ -983,7 +983,7 @@  discard block
 block discarded – undo
983 983
    */
984 984
   public function resourcesSet($resource_list) {
985 985
     if (!empty($this->propertiesAdjusted['resource_list'])) {
986
-      throw new ExceptionPropertyAccess('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR);
986
+      throw new ExceptionPropertyAccess('Property "resource_list" already was adjusted so no SET is possible until dbSave in '.get_called_class().'::unitSetResourceList', ERR_ERROR);
987 987
     }
988 988
     $this->resourcesAdjust($resource_list, true);
989 989
   }
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
       // Check for negative unit value
1018 1018
       if ($this->resource_list[$resource_id] < 0) {
1019 1019
         // TODO
1020
-        throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR);
1020
+        throw new Exception('Resource '.$resource_id.' will become negative in '.get_called_class().'::unitAdjustResourceList', ERR_ERROR);
1021 1021
       }
1022 1022
     }
1023 1023
   }
@@ -1325,14 +1325,14 @@  discard block
 block discarded – undo
1325 1325
       if (FLIGHT_ALLOWED == $validateResult[$missionType]) {
1326 1326
         $this->allowed_missions[$missionType] = $mission;
1327 1327
       } else {
1328
-        if($missionType == $this->mission_type) {
1328
+        if ($missionType == $this->mission_type) {
1329 1329
         }
1330 1330
         unset($this->allowed_missions[$missionType]);
1331 1331
       }
1332 1332
     }
1333 1333
 
1334
-    if(empty($this->allowed_missions)) {
1335
-      if($this->mission_type != MT_NONE && isset($validateResult[$this->mission_type])) {
1334
+    if (empty($this->allowed_missions)) {
1335
+      if ($this->mission_type != MT_NONE && isset($validateResult[$this->mission_type])) {
1336 1336
         throw new ExceptionFleetInvalid($validateResult[$this->mission_type], $validateResult[$this->mission_type]);
1337 1337
       } else {
1338 1338
         throw new ExceptionFleetInvalid(FLIGHT_MISSION_IMPOSSIBLE, FLIGHT_MISSION_IMPOSSIBLE);
@@ -1570,7 +1570,7 @@  discard block
 block discarded – undo
1570 1570
     $template_result['.']['fleets'][] = $this->fleetRenderer->renderFleet($this, SN_TIME_NOW, $timeMissionJob);
1571 1571
 
1572 1572
     $template_result += array(
1573
-      'mission'         => classLocale::$lang['type_mission'][$this->_mission_type] . ($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' ' . pretty_time($timeMissionJob) : ''),
1573
+      'mission'         => classLocale::$lang['type_mission'][$this->_mission_type].($this->_mission_type == MT_EXPLORE || $this->_mission_type == MT_HOLD ? ' '.pretty_time($timeMissionJob) : ''),
1574 1574
       'dist'            => pretty_number($this->travelData['distance']),
1575 1575
       'speed'           => pretty_number($this->travelData['fleet_speed']),
1576 1576
       'deute_need'      => pretty_number($this->travelData['consumption']),
Please login to merge, or discard this patch.
classes/Common/GlobalContainer.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -52,82 +52,82 @@
 block discarded – undo
52 52
     $gc = $this;
53 53
 
54 54
     // Default db
55
-    $gc->db = function ($c) {
55
+    $gc->db = function($c) {
56 56
       classSupernova::$db = $db = new \db_mysql($c);
57 57
 
58 58
       return $db;
59 59
     };
60 60
 
61
-    $gc->debug = function ($c) {
61
+    $gc->debug = function($c) {
62 62
       return new \debug();
63 63
     };
64 64
 
65
-    $gc->types = function ($c) {
65
+    $gc->types = function($c) {
66 66
       return new \Common\Types();
67 67
     };
68 68
 
69
-    $gc->cache = function ($c) {
69
+    $gc->cache = function($c) {
70 70
       return new \classCache(classSupernova::$cache_prefix);
71 71
     };
72 72
 
73
-    $gc->config = function ($c) {
73
+    $gc->config = function($c) {
74 74
       return new \classConfig(classSupernova::$cache_prefix);
75 75
     };
76 76
 
77
-    $gc->localePlayer = function (GlobalContainer $c) {
77
+    $gc->localePlayer = function(GlobalContainer $c) {
78 78
       return new \classLocale($c->config->server_locale_log_usage);
79 79
     };
80 80
 
81
-    $gc->dbGlobalRowOperator = function (GlobalContainer $c) {
81
+    $gc->dbGlobalRowOperator = function(GlobalContainer $c) {
82 82
       return new \DbRowDirectOperator($c->db);
83 83
     };
84 84
 
85
-    $gc->query = $gc->factory(function (GlobalContainer $c) {
85
+    $gc->query = $gc->factory(function(GlobalContainer $c) {
86 86
       return new \DbQueryConstructor($c->db);
87 87
     });
88 88
 
89
-    $gc->cacheOperator = function (GlobalContainer $gc) {
89
+    $gc->cacheOperator = function(GlobalContainer $gc) {
90 90
       return new \SnDbCachedOperator($gc);
91 91
     };
92 92
 
93 93
     $gc->snCacheClass = 'SnCache';
94
-    $gc->snCache = function (GlobalContainer $gc) {
94
+    $gc->snCache = function(GlobalContainer $gc) {
95 95
       return $gc->db->snCache;
96 96
     };
97 97
 
98 98
     $gc->buddyClass = 'Buddy\BuddyModel';
99
-    $gc->buddyModel = function (GlobalContainer $c) {
99
+    $gc->buddyModel = function(GlobalContainer $c) {
100 100
       return new $c->buddyClass($c);
101 101
     };
102 102
 
103
-    $gc->unitModel = function (GlobalContainer $c) {
103
+    $gc->unitModel = function(GlobalContainer $c) {
104 104
       return new \V2Unit\V2UnitModel($c);
105 105
     };
106
-    $gc->unitList = $this->factory(function (GlobalContainer $c) {
106
+    $gc->unitList = $this->factory(function(GlobalContainer $c) {
107 107
       return new \V2Unit\V2UnitList($c);
108 108
     });
109 109
 
110
-    $gc->fleetModel = function (GlobalContainer $c) {
110
+    $gc->fleetModel = function(GlobalContainer $c) {
111 111
       return new V2FleetModel($c);
112 112
     };
113 113
 
114
-    $gc->planetRenderer = function (GlobalContainer $c) {
114
+    $gc->planetRenderer = function(GlobalContainer $c) {
115 115
       return new PlanetRenderer($c);
116 116
     };
117 117
 
118
-    $gc->fleetRenderer = function (GlobalContainer $c) {
118
+    $gc->fleetRenderer = function(GlobalContainer $c) {
119 119
       return new \FleetRenderer($c);
120 120
     };
121 121
 
122
-    $gc->groupFleet = function (GlobalContainer $c) {
122
+    $gc->groupFleet = function(GlobalContainer $c) {
123 123
       return sn_get_groups('fleet');
124 124
     };
125 125
 
126
-    $gc->groupFleetAndMissiles = function (GlobalContainer $c) {
126
+    $gc->groupFleetAndMissiles = function(GlobalContainer $c) {
127 127
       return sn_get_groups(array('fleet', GROUP_STR_MISSILES));
128 128
     };
129 129
 
130
-    $gc->groupRecyclers = function (GlobalContainer $c) {
130
+    $gc->groupRecyclers = function(GlobalContainer $c) {
131 131
       return sn_get_groups('flt_recyclers');
132 132
     };
133 133
 
Please login to merge, or discard this patch.
classes/FleetRenderer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
   public function renderFleet(Fleet $fleet, $missionStartTimeStamp = SN_TIME_NOW, $timeMissionJob = 0) {
48 48
     $unitList = $fleet->getUnitList();
49 49
     if ($unitList->unitsCount() <= 0) {
50
-      message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet' . DOT_PHP_EX, 5);
50
+      message(classLocale::$lang['fl_err_no_ships'], classLocale::$lang['fl_error'], 'fleet'.DOT_PHP_EX, 5);
51 51
     }
52 52
 
53 53
     $timeToReturn = $fleet->travelData['duration'] * 2 + $timeMissionJob;
Please login to merge, or discard this patch.
classes/DBRow.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
    * @param db_mysql|null $db
87 87
    */
88 88
   public static function setDb($db = null) {
89
-    if(empty($db) || !($db instanceof db_mysql)) {
89
+    if (empty($db) || !($db instanceof db_mysql)) {
90 90
       $db = null;
91 91
     }
92 92
     static::$db = !empty($db) || !class_exists('classSupernova', false) ? $db : classSupernova::$db;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
   public function dbLoad($dbId, $lockSkip = false) {
150 150
     $dbId = idval($dbId);
151 151
     if ($dbId <= 0) {
152
-      classSupernova::$debug->error(get_called_class() . '::' . __METHOD__ . ' $dbId not positive = ' . $dbId);
152
+      classSupernova::$debug->error(get_called_class().'::'.__METHOD__.' $dbId not positive = '.$dbId);
153 153
 
154 154
       return;
155 155
     }
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
       $this->dbGetLockById($this->_dbId);
162 162
     }
163 163
 
164
-    $db_row = classSupernova::$db->doSelectFetchArray("SELECT * FROM `{{" . static::$_table . "}}` WHERE `" . static::$_dbIdFieldName . "` = " . $this->_dbId . " LIMIT 1 FOR UPDATE;");
164
+    $db_row = classSupernova::$db->doSelectFetchArray("SELECT * FROM `{{".static::$_table."}}` WHERE `".static::$_dbIdFieldName."` = ".$this->_dbId." LIMIT 1 FOR UPDATE;");
165 165
     if (empty($db_row)) {
166 166
       return;
167 167
     }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
     if ($this->isNew()) {
194 194
       // No DB_ID - new unit
195 195
       if ($this->isEmpty()) {
196
-        classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - object is empty on ' . get_called_class() . '::dbSave');
196
+        classSupernova::$debug->error(__FILE__.':'.__LINE__.' - object is empty on '.get_called_class().'::dbSave');
197 197
       }
198 198
       $this->dbInsert();
199 199
     } else {
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
         $this->dbDelete();
203 203
       } else {
204 204
         if (!sn_db_transaction_check(false)) {
205
-          classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - transaction should always be started on ' . get_called_class() . '::dbUpdate');
205
+          classSupernova::$debug->error(__FILE__.':'.__LINE__.' - transaction should always be started on '.get_called_class().'::dbUpdate');
206 206
         }
207 207
         $this->dbUpdate();
208 208
       }
@@ -230,13 +230,13 @@  discard block
 block discarded – undo
230 230
   // TODO - protected
231 231
   public function dbInsert() {
232 232
     if (!$this->isNew()) {
233
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - record db_id is not empty on ' . get_called_class() . '::dbInsert');
233
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - record db_id is not empty on '.get_called_class().'::dbInsert');
234 234
     }
235 235
 
236 236
     $fieldSet = $this->dbMakeFieldSet(false);
237 237
 
238 238
     if (!static::$db->doInsertSet(static::$_table, $fieldSet)) {
239
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - error saving record ' . get_called_class() . '::dbInsert');
239
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - error saving record '.get_called_class().'::dbInsert');
240 240
     }
241 241
     $this->_dbId = static::$db->db_insert_id();
242 242
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
   public function dbUpdate() {
251 251
     // TODO - Update
252 252
     if ($this->isNew()) {
253
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbUpdate');
253
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbUpdate');
254 254
     }
255 255
     $this->db_field_update($this->dbMakeFieldUpdate());
256 256
   }
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
   // TODO - protected
262 262
   public function dbDelete() {
263 263
     if ($this->isNew()) {
264
-      classSupernova::$debug->error(__FILE__ . ':' . __LINE__ . ' - unit db_id is empty on dbDelete');
264
+      classSupernova::$debug->error(__FILE__.':'.__LINE__.' - unit db_id is empty on dbDelete');
265 265
     }
266 266
     classSupernova::$gc->db->doDeleteRow(
267 267
       static::$_table,
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
       }
453 453
     }
454 454
 
455
-    if(empty($set)) {
455
+    if (empty($set)) {
456 456
       $theResult = true;
457 457
     } else {
458 458
       $theResult = classSupernova::$db->doUpdateRowAdjust(
Please login to merge, or discard this patch.
classes/Entity/KeyedModel.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
   /**
91 91
    * @param KeyedContainer $cEntity
92 92
    */
93
-  protected function onSaveUnchanged($cEntity){
93
+  protected function onSaveUnchanged($cEntity) {
94 94
     // TODO - or just save nothing ?????
95 95
     // throw new \Exception('EntityModel isNotEmpty, have dbId and not CHANGED! It can\'t be!');
96 96
     // Do nothing
Please login to merge, or discard this patch.
classes/Entity/EntityModel.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
     // Generate changeset row
200 200
     // Foreach all rows. If there is change and no delta - then put delta. Otherwise put change
201 201
     // If row not empty - update
202
-    throw new \Exception(__CLASS__ . '::update() in ' . get_called_class() . 'is not yet implemented');
202
+    throw new \Exception(__CLASS__.'::update() in '.get_called_class().'is not yet implemented');
203 203
   }
204 204
 
205 205
   /**
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
    * @throws \Exception
209 209
    */
210 210
   protected function delete($cEntity) {
211
-    throw new \Exception(__CLASS__ . '::delete() in ' . get_called_class() . 'is not yet implemented');
211
+    throw new \Exception(__CLASS__.'::delete() in '.get_called_class().'is not yet implemented');
212 212
   }
213 213
 
214 214
   /**
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
   protected function onSaveUnchanged($cEntity) {
225 225
     // TODO - or just save nothing ?????
226 226
 //    throw new \Exception('EntityModel isNotEmpty, have dbId and not CHANGED! It can\'t be!');
227
-    throw new \Exception(__CLASS__ . '::unchanged() in ' . get_called_class() . 'is not yet implemented');
227
+    throw new \Exception(__CLASS__.'::unchanged() in '.get_called_class().'is not yet implemented');
228 228
   }
229 229
 
230 230
   /**
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
   protected function onSaveNew($cEntity) {
240 240
     // Just created container and doesn't use it
241 241
 //    throw new \Exception('EntityModel isEmpty but not loaded! It can\'t be!');
242
-    throw new \Exception(__CLASS__ . '::emptyAction() in ' . get_called_class() . 'is not yet implemented');
242
+    throw new \Exception(__CLASS__.'::emptyAction() in '.get_called_class().'is not yet implemented');
243 243
   }
244 244
 
245 245
   /**
Please login to merge, or discard this patch.
classes/db_mysql.php 2 patches
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
   public function load_db_settings($configFile = '') {
99 99
     $dbsettings = array();
100 100
 
101
-    empty($configFile) ? $configFile = SN_ROOT_PHYSICAL . "config" . DOT_PHP_EX : false;
101
+    empty($configFile) ? $configFile = SN_ROOT_PHYSICAL."config".DOT_PHP_EX : false;
102 102
 
103 103
     require $configFile;
104 104
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     }
119 119
 
120 120
     if (empty($this->dbsettings)) {
121
-      $this->load_db_settings(SN_ROOT_PHYSICAL . "config.php");
121
+      $this->load_db_settings(SN_ROOT_PHYSICAL."config.php");
122 122
     }
123 123
 
124 124
     // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     $sql = $query;
171 171
     if (strpos($sql, '{{') !== false) {
172 172
       foreach ($this->table_list as $tableName) {
173
-        $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql);
173
+        $sql = str_replace("{{{$tableName}}}", $this->db_prefix.$tableName, $sql);
174 174
       }
175 175
     }
176 176
 
@@ -241,12 +241,12 @@  discard block
 block discarded – undo
241 241
 
242 242
     $queryResult = null;
243 243
     try {
244
-      $queryResult = $this->db_sql_query($stringQuery . DbSqlHelper::quoteComment($queryTrace));
244
+      $queryResult = $this->db_sql_query($stringQuery.DbSqlHelper::quoteComment($queryTrace));
245 245
       if (!$queryResult) {
246 246
         throw new Exception();
247 247
       }
248 248
     } catch (Exception $e) {
249
-      classSupernova::$debug->error($this->db_error() . "<br />{$query}<br />", 'SQL Error');
249
+      classSupernova::$debug->error($this->db_error()."<br />{$query}<br />", 'SQL Error');
250 250
     }
251 251
 
252 252
     return $queryResult;
@@ -300,16 +300,16 @@  discard block
 block discarded – undo
300 300
     if (!empty($where)) {
301 301
       foreach ($where as $key => &$value) {
302 302
         if (!is_int($key)) {
303
-          $value = "`$key` = '" . $this->db_escape($value) . "'";
303
+          $value = "`$key` = '".$this->db_escape($value)."'";
304 304
         }
305 305
       }
306 306
     }
307 307
 
308 308
     $query =
309
-      "SELECT " . implode(',', $fields) .
310
-      " FROM `{{{$table}}}`" .
311
-      (!empty($where) ? ' WHERE ' . implode(' AND ', $where) : '') .
312
-      ($isOneRecord == DB_RECORD_ONE ? ' LIMIT 1' : '') .
309
+      "SELECT ".implode(',', $fields).
310
+      " FROM `{{{$table}}}`".
311
+      (!empty($where) ? ' WHERE '.implode(' AND ', $where) : '').
312
+      ($isOneRecord == DB_RECORD_ONE ? ' LIMIT 1' : '').
313 313
       ($forUpdate == DB_SELECT_FOR_UPDATE ? ' FOR UPDATE' : '');
314 314
 
315 315
     return $this->doSql($query);
@@ -603,10 +603,10 @@  discard block
 block discarded – undo
603 603
       $this->isWatching = true;
604 604
       $msg = "\$query = \"{$query}\"\n\r";
605 605
       if (!empty($_POST)) {
606
-        $msg .= "\n\r" . dump($_POST, '$_POST');
606
+        $msg .= "\n\r".dump($_POST, '$_POST');
607 607
       }
608 608
       if (!empty($_GET)) {
609
-        $msg .= "\n\r" . dump($_GET, '$_GET');
609
+        $msg .= "\n\r".dump($_GET, '$_GET');
610 610
       }
611 611
       classSupernova::$debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true));
612 612
       $this->isWatching = false;
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 
622 622
     global $user, $dm_change_legit, $mm_change_legit;
623 623
 
624
-    switch(true) {
624
+    switch (true) {
625 625
       case stripos($query, 'RUNCATE TABL') != false:
626 626
       case stripos($query, 'ROP TABL') != false:
627 627
       case stripos($query, 'ENAME TABL') != false:
@@ -632,37 +632,37 @@  discard block
 block discarded – undo
632 632
       case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit:
633 633
       case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit:
634 634
       case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0:
635
-        $report = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n";
635
+        $report = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n";
636 636
         $report .= ">Database Inforamation\n";
637
-        $report .= "\tID - " . $user['id'] . "\n";
638
-        $report .= "\tUser - " . $user['username'] . "\n";
639
-        $report .= "\tAuth level - " . $user['authlevel'] . "\n";
640
-        $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n";
641
-        $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n";
642
-        $report .= "\tUser IP - " . $user['user_lastip'] . "\n";
643
-        $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n";
644
-        $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n";
645
-        $report .= "\tCurrent Page - " . $user['current_page'] . "\n";
646
-        $report .= "\tRegister Time - " . $user['register_time'] . "\n";
637
+        $report .= "\tID - ".$user['id']."\n";
638
+        $report .= "\tUser - ".$user['username']."\n";
639
+        $report .= "\tAuth level - ".$user['authlevel']."\n";
640
+        $report .= "\tAdmin Notes - ".$user['adminNotes']."\n";
641
+        $report .= "\tCurrent Planet - ".$user['current_planet']."\n";
642
+        $report .= "\tUser IP - ".$user['user_lastip']."\n";
643
+        $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n";
644
+        $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n";
645
+        $report .= "\tCurrent Page - ".$user['current_page']."\n";
646
+        $report .= "\tRegister Time - ".$user['register_time']."\n";
647 647
         $report .= "\n";
648 648
 
649 649
         $report .= ">Query Information\n";
650
-        $report .= "\tQuery - " . $query . "\n";
650
+        $report .= "\tQuery - ".$query."\n";
651 651
         $report .= "\n";
652 652
 
653 653
         $report .= ">\$_SERVER Information\n";
654
-        $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n";
655
-        $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n";
656
-        $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n";
657
-        $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n";
658
-        $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n";
659
-        $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n";
660
-        $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n";
661
-        $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n";
654
+        $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n";
655
+        $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n";
656
+        $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n";
657
+        $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n";
658
+        $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n";
659
+        $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n";
660
+        $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n";
661
+        $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n";
662 662
 
663 663
         $report .= "\n--------------------------------------------------------------------------------------------------\n";
664 664
 
665
-        $fp = fopen(SN_ROOT_PHYSICAL . 'badqrys.txt', 'a');
665
+        $fp = fopen(SN_ROOT_PHYSICAL.'badqrys.txt', 'a');
666 666
         fwrite($fp, $report);
667 667
         fclose($fp);
668 668
 
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
     $prefix_length = strlen($this->db_prefix);
684 684
 
685 685
     $tl = array();
686
-    while($row = $this->db_fetch($query)) {
686
+    while ($row = $this->db_fetch($query)) {
687 687
       foreach ($row as $table_name) {
688 688
         if (strpos($table_name, $this->db_prefix) === 0) {
689 689
           $table_name = substr($table_name, $prefix_length);
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
     if (is_bool($query)) {
818 818
       throw new Exception('Result of SHOW STATUS command is boolean - which should never happen. Connection to DB is lost?');
819 819
     }
820
-    while($row = db_fetch($query)) {
820
+    while ($row = db_fetch($query)) {
821 821
       $result[$row['Variable_name']] = $row['Value'];
822 822
     }
823 823
 
Please login to merge, or discard this patch.
Doc Comments   +22 added lines, -4 removed lines patch added patch discarded remove patch
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
   /**
165 165
    * @param string $query
166 166
    *
167
-   * @return mixed|string
167
+   * @return string
168 168
    */
169 169
   public function replaceTablePlaceholders($query) {
170 170
     $sql = $query;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
   }
179 179
 
180 180
   /**
181
-   * @param $query
181
+   * @param string $query
182 182
    */
183 183
   protected function logQuery($query) {
184 184
     if (!classSupernova::$config->debug) {
@@ -290,6 +290,7 @@  discard block
 block discarded – undo
290 290
    * @param array  $fields
291 291
    * @param array  $where
292 292
    * @param bool   $isOneRecord
293
+   * @param boolean $forUpdate
293 294
    *
294 295
    * @return array|bool|mysqli_result|null
295 296
    *
@@ -332,6 +333,10 @@  discard block
 block discarded – undo
332 333
 
333 334
   //
334 335
   // INSERT/REPLACE ----------------------------------------------------------------------------------------------------
336
+
337
+  /**
338
+   * @param string $query
339
+   */
335 340
   public function doInsertComplex($query) {
336 341
     return $this->doSql($query);
337 342
   }
@@ -408,7 +413,7 @@  discard block
 block discarded – undo
408 413
    * Self-contained - means no params used
409 414
    * Such queries usually used to make large amount of in-base calculations
410 415
    *
411
-   * @param $query
416
+   * @param string $query
412 417
    *
413 418
    * @return array|bool|mysqli_result|null
414 419
    */
@@ -425,13 +430,16 @@  discard block
 block discarded – undo
425 430
   }
426 431
 
427 432
   /**
428
-   * @param $DbQuery DbQuery
433
+   * @param DbQuery $DbQuery DbQuery
429 434
    */
430 435
   public function doUpdateDbQueryAdjust($DbQuery) {
431 436
     return $this->doUpdateDbQuery($DbQuery);
432 437
   }
433 438
 
434 439
 
440
+  /**
441
+   * @param boolean $isOneRecord
442
+   */
435 443
   protected function doUpdateWhere($table, $fieldsSet, $fieldsAdjust = array(), $where = array(), $isOneRecord = DB_RECORDS_ALL, $whereDanger = array()) {
436 444
     $query = DbQuery::build($this)
437 445
       ->setTable($table)
@@ -450,6 +458,9 @@  discard block
 block discarded – undo
450 458
     return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORD_ONE);
451 459
   }
452 460
 
461
+  /**
462
+   * @param string $table
463
+   */
453 464
   public function doUpdateTableSet($table, $fieldsAndValues, $where = array()) {
454 465
     return $this->doUpdateWhere($table, $fieldsAndValues, array(), $where, DB_RECORDS_ALL);
455 466
   }
@@ -559,6 +570,10 @@  discard block
 block discarded – undo
559 570
   //
560 571
   // OTHER FUNCTIONS ----------------------------------------------------------------------------------------------------------
561 572
   // TODO Заменить это на новый логгер
573
+
574
+  /**
575
+   * @param string $query
576
+   */
562 577
   protected function security_watch_user_queries($query) {
563 578
     global $user;
564 579
 
@@ -582,6 +597,9 @@  discard block
 block discarded – undo
582 597
   }
583 598
 
584 599
 
600
+  /**
601
+   * @param string $query
602
+   */
585 603
   public function security_query_check_bad_words($query) {
586 604
     if ($this->skipQueryCheck) {
587 605
       return;
Please login to merge, or discard this patch.
includes/includes/sys_stat.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -43,23 +43,23 @@  discard block
 block discarded – undo
43 43
 
44 44
   $sta_update_msg = db_escape($sta_update_msg);
45 45
 
46
-  if($next_step) {
46
+  if ($next_step) {
47 47
     $sta_update_step++;
48 48
   }
49 49
   $sta_update_msg = "Update in progress. Step {$sta_update_step}/14: {$sta_update_msg}.";
50 50
 
51 51
   classSupernova::$config->db_saveItem('var_stat_update_msg', $sta_update_msg);
52
-  if($next_step) {
52
+  if ($next_step) {
53 53
     classSupernova::$debug->warning($sta_update_msg, 'Stat update', LOG_INFO_STAT_PROCESS);
54 54
   }
55 55
 }
56 56
 
57 57
 function sys_stat_calculate_flush(&$data, $force = false) {
58
-  if(count($data) < 25 && !$force) {
58
+  if (count($data) < 25 && !$force) {
59 59
     return;
60 60
   }
61 61
 
62
-  if(!empty($data)) {
62
+  if (!empty($data)) {
63 63
     classSupernova::$gc->db->doInsertBatch(
64 64
       TABLE_STAT_POINTS, $data, array(
65 65
       'id_owner',
@@ -114,11 +114,11 @@  discard block
 block discarded – undo
114 114
   classSupernova::$gc->cacheOperator->db_lock_tables('users');
115 115
   $user_list = DBStaticUser::db_user_list('', true, 'id, dark_matter, metal, crystal, deuterium, user_as_ally, ally_id');
116 116
   $row_num = count($user_list);
117
-  foreach($user_list as $player) {
118
-    if($i++ % 100 == 0) {
117
+  foreach ($user_list as $player) {
118
+    if ($i++ % 100 == 0) {
119 119
       sta_set_time_limit("calculating players stats (player {$i}/{$row_num})", false);
120 120
     }
121
-    if(array_key_exists($user_id = $player['id'], $user_skip_list)) {
121
+    if (array_key_exists($user_id = $player['id'], $user_skip_list)) {
122 122
       continue;
123 123
     }
124 124
 
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
     $counts[$user_id][UNIT_RESOURCES] += $resources;
128 128
 
129 129
     // А здесь мы фильтруем пользователей по $user_skip_list - далее не нужно этого делать, потому что
130
-    if(!isset($user_skip_list[$user_id])) {
130
+    if (!isset($user_skip_list[$user_id])) {
131 131
       $user_allies[$user_id] = $player['ally_id'];
132 132
     }
133 133
   }
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
   $i = 0;
140 140
   $query = DBStaticPlanet::db_planet_list_resources_by_owner();
141 141
   $row_num = classSupernova::$db->db_num_rows($query);
142
-  while($planet = db_fetch($query)) {
143
-    if($i++ % 100 == 0) {
142
+  while ($planet = db_fetch($query)) {
143
+    if ($i++ % 100 == 0) {
144 144
       sta_set_time_limit("calculating planets stats (planet {$i}/{$row_num})", false);
145 145
     }
146
-    if(array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) {
146
+    if (array_key_exists($user_id = $planet['id_owner'], $user_skip_list)) {
147 147
       continue;
148 148
     }
149 149
 
@@ -157,22 +157,22 @@  discard block
 block discarded – undo
157 157
   $i = 0;
158 158
   $query = FleetList::dbQueryAllId();
159 159
   $row_num = classSupernova::$db->db_num_rows($query);
160
-  while($fleet_row = db_fetch($query)) {
161
-    if($i++ % 100 == 0) {
160
+  while ($fleet_row = db_fetch($query)) {
161
+    if ($i++ % 100 == 0) {
162 162
       sta_set_time_limit("calculating flying fleets stats (fleet {$i}/{$row_num})", false);
163 163
     }
164 164
     $objFleet = new Fleet();
165 165
     // TODO - без дополнительной инициализации и перераспределений памяти на каждый new Fleet()/unset($fleet)
166 166
     // К тому же при включённом кэшировании это быстро забъёт кэш холодными данными
167 167
     $objFleet->dbRowParse($fleet_row);
168
-    if(array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) {
168
+    if (array_key_exists($user_id = $objFleet->playerOwnerId, $user_skip_list)) {
169 169
       continue;
170 170
     }
171 171
 
172
-    foreach($objFleet->shipsIterator() as $unit_id => $unit) {
172
+    foreach ($objFleet->shipsIterator() as $unit_id => $unit) {
173 173
       $counts[$user_id][UNIT_SHIPS] += $unit->count;
174 174
 
175
-      if(!isset($unit_cost_cache[$unit_id][0])) {
175
+      if (!isset($unit_cost_cache[$unit_id][0])) {
176 176
         $unit_cost_cache[$unit_id][0] = get_unit_param($unit_id, P_COST);
177 177
       }
178 178
       $unit_cost_data = &$unit_cost_cache[$unit_id][0];
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
   $i = 0;
192 192
   $query = DBStaticUnit::db_unit_list_stat_calculate();
193 193
   $row_num = classSupernova::$db->db_num_rows($query);
194
-  while($unit = db_fetch($query)) {
195
-    if($i++ % 100 == 0) {
194
+  while ($unit = db_fetch($query)) {
195
+    if ($i++ % 100 == 0) {
196 196
       sta_set_time_limit("calculating unit stats (unit {$i}/{$row_num})", false);
197 197
     }
198
-    if(array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) {
198
+    if (array_key_exists($user_id = $unit['unit_player_id'], $user_skip_list)) {
199 199
       continue;
200 200
     }
201 201
 
@@ -209,11 +209,11 @@  discard block
 block discarded – undo
209 209
   $i = 0;
210 210
   $query = DBStaticQue::db_que_list_stat();
211 211
   $row_num = classSupernova::$db->db_num_rows($query);
212
-  while($que_item = db_fetch($query)) {
213
-    if($i++ % 100 == 0) {
212
+  while ($que_item = db_fetch($query)) {
213
+    if ($i++ % 100 == 0) {
214 214
       sta_set_time_limit("calculating ques stats (que item {$i}/{$row_num})", false);
215 215
     }
216
-    if(array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) {
216
+    if (array_key_exists($user_id = $que_item['que_player_id'], $user_skip_list)) {
217 217
       continue;
218 218
     }
219 219
     $que_unit_amount = $que_item['que_unit_amount'];
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
   sta_set_time_limit('posting new user stats to DB');
242 242
   $data = array();
243
-  foreach($user_allies as $user_id => $ally_id) {
243
+  foreach ($user_allies as $user_id => $ally_id) {
244 244
     $points[$user_id][UNIT_RESOURCES] = $counts[$user_id][UNIT_RESOURCES] / 1000;
245 245
     $points[$user_id] = array_map('floor', $points[$user_id]);
246 246
     $counts[$user_id] = array_map('floor', $counts[$user_id]);
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
         SUM(u.`tech_points`)+aus.`tech_points`, SUM(u.`tech_count`)+aus.`tech_count`, SUM(u.`build_points`)+aus.`build_points`, SUM(u.`build_count`)+aus.`build_count`,
294 294
         SUM(u.`defs_points`)+aus.`defs_points`, SUM(u.`defs_count`)+aus.`defs_count`, SUM(u.`fleet_points`)+aus.`fleet_points`, SUM(u.`fleet_count`)+aus.`fleet_count`,
295 295
         SUM(u.`res_points`)+aus.`res_points`, SUM(u.`res_count`)+aus.`res_count`, SUM(u.`total_points`)+aus.`total_points`, SUM(u.`total_count`)+aus.`total_count`,
296
-        " . SN_TIME_NOW . ", NULL, u.`id_ally`, 2, 1,
296
+        " . SN_TIME_NOW.", NULL, u.`id_ally`, 2, 1,
297 297
         a.tech_rank, a.build_rank, a.defs_rank, a.fleet_rank, a.res_rank, a.total_rank
298 298
       FROM `{{statpoints}}` AS u
299 299
         JOIN `{{alliance}}` AS al ON al.id = u.id_ally
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 
315 315
   // Updating player's ranks
316 316
   sta_set_time_limit("updating ranks for players");
317
-  foreach($rankNames as $rankName) {
317
+  foreach ($rankNames as $rankName) {
318 318
     sta_set_time_limit("updating player rank '{$rankName}'", false);
319 319
     classSupernova::$db->doSql($qryResetRowNum);
320 320
     classSupernova::$db->doUpdateReallyComplex(sprintf($qryFormat, $rankName, 1));
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 
323 323
   sta_set_time_limit("updating ranks for Alliances");
324 324
   // Updating Allie's ranks
325
-  foreach($rankNames as $rankName) {
325
+  foreach ($rankNames as $rankName) {
326 326
     sta_set_time_limit("updating Alliances rank '{$rankName}'", false);
327 327
     classSupernova::$db->doSql($qryResetRowNum);
328 328
     classSupernova::$db->doUpdateReallyComplex(sprintf($qryFormat, $rankName, 2));
Please login to merge, or discard this patch.