Completed
Push — work-fleets ( 5b06a4...37e31f )
by SuperNova.WS
04:49
created
galaxy.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 $uni_system = sys_get_param_int('system', $planetrow['system']);
19 19
 $planet = sys_get_param_int('planet', $planetrow['planet']);
20 20
 
21
-if($mode == 'name') {
21
+if ($mode == 'name') {
22 22
   require_once('includes/includes/uni_rename.php');
23 23
 }
24 24
 
@@ -39,8 +39,8 @@  discard block
 block discarded – undo
39 39
 
40 40
 $flying_fleet_count = FleetList::fleet_count_flying($user['id']);
41 41
 
42
-if($mode == 1) {
43
-} elseif($mode == 2 || $mode == 3) {
42
+if ($mode == 1) {
43
+} elseif ($mode == 2 || $mode == 3) {
44 44
   $planet = $planetrow['planet'];
45 45
 } else {
46 46
   $uni_galaxy = $planetrow['galaxy'];
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 $PhalanxRange = GetPhalanxRange($HavePhalanx);
67 67
 
68 68
 $planet_precache_query = db_planet_list_in_system($uni_galaxy, $uni_system);
69
-if(!empty($planet_precache_query)) {
70
-  foreach($planet_precache_query as $planet_row) {
69
+if (!empty($planet_precache_query)) {
70
+  foreach ($planet_precache_query as $planet_row) {
71 71
     $planet_list[$planet_row['planet']][$planet_row['planet_type']] = $planet_row;
72 72
   }
73 73
 }
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
  * @var Fleet[][][] $fleet_list
86 86
  */
87 87
 $fleet_list = array();
88
-foreach($system_fleet_list->_container as $objFleetSystem) {
89
-  if(!$objFleetSystem->isReturning()) {
88
+foreach ($system_fleet_list->_container as $objFleetSystem) {
89
+  if (!$objFleetSystem->isReturning()) {
90 90
     $fleet_planet = $objFleetSystem->fleet_end_planet;
91 91
     $fleet_type = $objFleetSystem->fleet_end_type;
92 92
   } else {
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 $recycler_info = array();
102 102
 $planet_recyclers_orbiting = 0;
103 103
 $recyclers_fleet = array();
104
-foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
104
+foreach (sn_get_groups('flt_recyclers') as $recycler_id) {
105 105
   $recycler_info[$recycler_id] = get_ship_data($recycler_id, $user);
106 106
   $recyclers_fleet[$recycler_id] = mrc_get_level($user, $planetrow, $recycler_id);
107 107
   $planet_recyclers_orbiting += $recyclers_fleet[$recycler_id];
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 $fleet_id = 1;
112 112
 $fleets = array();
113 113
 $config_game_max_planet = $config->game_maxPlanet + 1;
114
-for($Planet = 1; $Planet < $config_game_max_planet; $Planet++) {
114
+for ($Planet = 1; $Planet < $config_game_max_planet; $Planet++) {
115 115
   unset($uni_galaxyRowPlanet);
116 116
   unset($uni_galaxyRowMoon);
117 117
   unset($uni_galaxyRowUser);
@@ -121,27 +121,27 @@  discard block
 block discarded – undo
121 121
   $uni_galaxyRowPlanet = $planet_list[$Planet][PT_PLANET];
122 122
 
123 123
   $planet_fleet_id = 0;
124
-  if($uni_galaxyRowPlanet['destruyed']) {
124
+  if ($uni_galaxyRowPlanet['destruyed']) {
125 125
     CheckAbandonPlanetState($uni_galaxyRowPlanet);
126
-  } elseif($uni_galaxyRowPlanet['id']) {
127
-    if($cached['users'][$uni_galaxyRowPlanet['id_owner']]) {
126
+  } elseif ($uni_galaxyRowPlanet['id']) {
127
+    if ($cached['users'][$uni_galaxyRowPlanet['id_owner']]) {
128 128
       $uni_galaxyRowUser = $cached['users'][$uni_galaxyRowPlanet['id_owner']];
129 129
     } else {
130 130
       $uni_galaxyRowUser = db_user_by_id($uni_galaxyRowPlanet['id_owner']);
131 131
       $cached['users'][$uni_galaxyRowUser['id']] = $uni_galaxyRowUser;
132 132
     }
133 133
 
134
-    if(!$uni_galaxyRowUser['id']) {
134
+    if (!$uni_galaxyRowUser['id']) {
135 135
       $debug->warning("Planet '{$uni_galaxyRowPlanet['name']}' [{$uni_galaxy}:{$uni_system}:{$Planet}] has no owner!", 'Userless planet', 503);
136 136
       $uni_galaxyRowPlanet['destruyed'] = SN_TIME_NOW + 60 * 60 * 24;
137 137
       $uni_galaxyRowPlanet['id_owner'] = 0;
138 138
       db_planet_set_by_id($uni_galaxyRowPlanet['id'], "id_owner = 0, destruyed = {$uni_galaxyRowPlanet['destruyed']}");
139 139
     }
140 140
 
141
-    if($uni_galaxyRowUser['id']) {
141
+    if ($uni_galaxyRowUser['id']) {
142 142
       $planetcount++;
143
-      if($uni_galaxyRowUser['ally_id']) {
144
-        if($cached['allies'][$uni_galaxyRowUser['ally_id']]) {
143
+      if ($uni_galaxyRowUser['ally_id']) {
144
+        if ($cached['allies'][$uni_galaxyRowUser['ally_id']]) {
145 145
           $allyquery = $cached['allies'][$uni_galaxyRowUser['ally_id']];
146 146
         } else {
147 147
           $allyquery = db_ally_get_by_id($uni_galaxyRowUser['ally_id']);
@@ -150,19 +150,19 @@  discard block
 block discarded – undo
150 150
       }
151 151
 
152 152
       $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_PLANET]);
153
-      if(!empty($fleets_to_planet['own']['count'])) {
153
+      if (!empty($fleets_to_planet['own']['count'])) {
154 154
         $planet_fleet_id = $fleet_id;
155 155
         $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id);
156 156
         $fleet_id++;
157 157
       }
158 158
 
159 159
       $uni_galaxyRowMoon = $planet_list[$Planet][PT_MOON];
160
-      if($uni_galaxyRowMoon['destruyed']) {
160
+      if ($uni_galaxyRowMoon['destruyed']) {
161 161
         CheckAbandonPlanetState($uni_galaxyRowMoon);
162 162
       } else {
163 163
         $moon_fleet_id = 0;
164 164
         $fleets_to_planet = flt_get_fleets_to_planet_by_array_of_Fleet($fleet_list[$Planet][PT_MOON]);
165
-        if(!empty($fleets_to_planet['own']['count'])) {
165
+        if (!empty($fleets_to_planet['own']['count'])) {
166 166
           $moon_fleet_id = $fleet_id;
167 167
           $fleets[] = tpl_parse_fleet_sn($fleets_to_planet['own']['total'], $fleet_id);
168 168
           $fleet_id++;
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
 
174 174
   $recyclers_incoming_capacity = 0;
175 175
   $uni_galaxyRowPlanet['debris'] = $uni_galaxyRowPlanet['debris_metal'] + $uni_galaxyRowPlanet['debris_crystal'];
176
-  if($uni_galaxyRowPlanet['debris']) {
177
-    if(!empty($fleet_list[$Planet][PT_DEBRIS])) {
178
-      foreach($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) {
179
-        if($objFleetToDebris->playerOwnerId == $user['id']) {
176
+  if ($uni_galaxyRowPlanet['debris']) {
177
+    if (!empty($fleet_list[$Planet][PT_DEBRIS])) {
178
+      foreach ($fleet_list[$Planet][PT_DEBRIS] as $objFleetToDebris) {
179
+        if ($objFleetToDebris->playerOwnerId == $user['id']) {
180 180
           $recyclers_incoming_capacity += $objFleetToDebris->shipsGetCapacityRecyclers($recycler_info);
181 181
         }
182 182
       }
@@ -253,21 +253,21 @@  discard block
 block discarded – undo
253 253
 
254 254
 tpl_assign_fleet($template, $fleets);
255 255
 
256
-foreach(sn_get_groups('defense_active') as $unit_id) {
256
+foreach (sn_get_groups('defense_active') as $unit_id) {
257 257
   $template->assign_block_vars('defense_active', array(
258 258
     'ID'   => $unit_id,
259 259
     'NAME' => $lang['tech'][$unit_id],
260 260
   ));
261 261
 }
262 262
 
263
-foreach($cached['users'] as $PlanetUser) {
264
-  if(!$PlanetUser) {
263
+foreach ($cached['users'] as $PlanetUser) {
264
+  if (!$PlanetUser) {
265 265
     continue;
266 266
   }
267 267
 
268 268
   $user_ally = $cached['allies'][$PlanetUser['ally_id']];
269
-  if(isset($user_ally)) {
270
-    if($PlanetUser['id'] == $user_ally['ally_owner']) {
269
+  if (isset($user_ally)) {
270
+    if ($PlanetUser['id'] == $user_ally['ally_owner']) {
271 271
       $user_rank_title = $user_ally['ally_owner_range'];
272 272
     } else {
273 273
       $ally_ranks = explode(';', $user_ally['ranklist']);
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
   ));
291 291
 }
292 292
 
293
-foreach($cached['allies'] as $PlanetAlly) {
294
-  if($PlanetAlly) {
293
+foreach ($cached['allies'] as $PlanetAlly) {
294
+  if ($PlanetAlly) {
295 295
     $template->assign_block_vars('alliances', array(
296 296
       'ID'      => $PlanetAlly['id'],
297 297
       'NAME_JS' => js_safe_string($PlanetAlly['ally_name']),
Please login to merge, or discard this patch.
includes/classes/Fleet.php 2 patches
Doc Comments   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -591,6 +591,9 @@  discard block
 block discarded – undo
591 591
     return max(0, $this->shipsGetCapacity() - $this->resourcesGetTotal());
592 592
   }
593 593
 
594
+  /**
595
+   * @param integer $ship_id
596
+   */
594 597
   public function shipsGetTotalById($ship_id) {
595 598
     return $this->unitList->unitsCountById($ship_id);
596 599
   }
@@ -705,7 +708,7 @@  discard block
 block discarded – undo
705 708
   /**
706 709
    * Set current resource list from array of units
707 710
    *
708
-   * @param array $resource_list
711
+   * @param integer[] $resource_list
709 712
    */
710 713
   public function resourcesSet($resource_list) {
711 714
     if(!empty($this->propertiesAdjusted['resource_list'])) {
@@ -781,7 +784,6 @@  discard block
 block discarded – undo
781 784
    * Restores fleet or resources to planet
782 785
    *
783 786
    * @param bool $start
784
-   * @param bool $only_resources
785 787
    * @param int  $result
786 788
    *
787 789
    * @return int
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
   public function dbInsert() {
284 284
     // WARNING! MISSION TIMES MUST BE SET WITH set_times() method!
285 285
     // TODO - more checks!
286
-    if(empty($this->_time_launch)) {
286
+    if (empty($this->_time_launch)) {
287 287
       die('Fleet time not set!');
288 288
     }
289 289
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
     // Записываем изменения в БД
364 364
     $this->dbSave();
365 365
 
366
-    if($this->_group_id) {
366
+    if ($this->_group_id) {
367 367
       // TODO: Make here to delete only one AKS - by adding aks_fleet_count to AKS table
368 368
       db_fleet_aks_purge();
369 369
     }
@@ -434,15 +434,15 @@  discard block
 block discarded – undo
434 434
    */
435 435
   // TODO - separate shipList and unitList
436 436
   public function unitsSetFromArray($unit_array) {
437
-    foreach($unit_array as $unit_id => $unit_count) {
437
+    foreach ($unit_array as $unit_id => $unit_count) {
438 438
       $unit_count = floatval($unit_count);
439
-      if(!$unit_count) {
439
+      if (!$unit_count) {
440 440
         continue;
441 441
       }
442 442
 
443
-      if($this->isShip($unit_id)) {
443
+      if ($this->isShip($unit_id)) {
444 444
         $this->unitList->unitSetCount($unit_id, $unit_count);
445
-      } elseif($this->isResource($unit_id)) {
445
+      } elseif ($this->isResource($unit_id)) {
446 446
         $this->resource_list[$unit_id] = $unit_count;
447 447
       } else {
448 448
         throw new Exception('Trying to pass to fleet non-resource and non-ship ' . var_export($unit_array, true), ERR_ERROR);
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
   public function parse_missile_db_row($missile_db_row) {
472 472
 //    $this->_reset();
473 473
 
474
-    if(empty($missile_db_row) || !is_array($missile_db_row)) {
474
+    if (empty($missile_db_row) || !is_array($missile_db_row)) {
475 475
       return;
476 476
     }
477 477
 
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
   public function shipsGetCapacityRecyclers(array $recycler_info) {
608 608
     $recyclers_incoming_capacity = 0;
609 609
     $fleet_data = $this->shipsGetArray();
610
-    foreach($recycler_info as $recycler_id => $recycler_data) {
610
+    foreach ($recycler_info as $recycler_id => $recycler_data) {
611 611
       $recyclers_incoming_capacity += $fleet_data[$recycler_id] * $recycler_data['capacity'];
612 612
     }
613 613
 
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
     sn_db_transaction_check(true);
628 628
 
629 629
     // Если флот уже обработан - не существует или возращается - тогда ничего не делаем
630
-    if($this->isEmpty()) {
630
+    if ($this->isEmpty()) {
631 631
       return $result;
632 632
     }
633 633
 
@@ -649,18 +649,18 @@  discard block
 block discarded – undo
649 649
     // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом
650 650
     // Флот, который возвращается на захваченную планету, пропадает
651 651
     // Ship landing is possible only to fleet owner's planet
652
-    if($this->getPlayerOwnerId() == $planet_arrival['id_owner']) {
652
+    if ($this->getPlayerOwnerId() == $planet_arrival['id_owner']) {
653 653
       $db_changeset = array();
654 654
 
655 655
       $fleet_array = $this->shipsGetArray();
656
-      foreach($fleet_array as $ship_id => $ship_count) {
657
-        if($ship_count) {
656
+      foreach ($fleet_array as $ship_id => $ship_count) {
657
+        if ($ship_count) {
658 658
           $db_changeset['unit'][] = sn_db_unit_changeset_prepare($ship_id, $ship_count, $user, $planet_arrival['id']);
659 659
         }
660 660
       }
661 661
 
662 662
       // Adjusting ship amount on planet
663
-      if(!empty($db_changeset)) {
663
+      if (!empty($db_changeset)) {
664 664
         db_changeset_apply($db_changeset);
665 665
       }
666 666
 
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
    * @param array $resource_list
709 709
    */
710 710
   public function resourcesSet($resource_list) {
711
-    if(!empty($this->propertiesAdjusted['resource_list'])) {
711
+    if (!empty($this->propertiesAdjusted['resource_list'])) {
712 712
       throw new PropertyAccessException('Property "resource_list" already was adjusted so no SET is possible until dbSave in ' . get_called_class() . '::unitSetResourceList', ERR_ERROR);
713 713
     }
714 714
     $this->resourcesAdjust($resource_list, true);
@@ -722,13 +722,13 @@  discard block
 block discarded – undo
722 722
   public function resourcesAdjust($resource_delta_list, $replace_value = false) {
723 723
     !is_array($resource_delta_list) ? $resource_delta_list = array() : false;
724 724
 
725
-    foreach($resource_delta_list as $resource_id => $unit_delta) {
726
-      if(!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) {
725
+    foreach ($resource_delta_list as $resource_id => $unit_delta) {
726
+      if (!UnitResourceLoot::is_in_group($resource_id) || !($unit_delta = floor($unit_delta))) {
727 727
         // Not a resource or no resources - continuing
728 728
         continue;
729 729
       }
730 730
 
731
-      if($replace_value) {
731
+      if ($replace_value) {
732 732
         $this->resource_list[$resource_id] = $unit_delta;
733 733
       } else {
734 734
         $this->resource_list[$resource_id] += $unit_delta;
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
       }
739 739
 
740 740
       // Check for negative unit value
741
-      if($this->resource_list[$resource_id] < 0) {
741
+      if ($this->resource_list[$resource_id] < 0) {
742 742
         // TODO
743 743
         throw new Exception('Resource ' . $resource_id . ' will become negative in ' . get_called_class() . '::unitAdjustResourceList', ERR_ERROR);
744 744
       }
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
     sn_db_transaction_check(true);
791 791
 
792 792
     // Если флот уже обработан - не существует или возращается - тогда ничего не делаем
793
-    if(!$this->resourcesGetTotal()) {
793
+    if (!$this->resourcesGetTotal()) {
794 794
       return $result;
795 795
     }
796 796
 
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
     // TODO - Проверка, что планета всё еще существует на указанных координатах, а не телепортировалась, не удалена хозяином, не уничтожена врагом
811 811
 
812 812
     // Restoring resources to planet
813
-    if($this->resourcesGetTotal()) {
813
+    if ($this->resourcesGetTotal()) {
814 814
       $fleet_resources = $this->resourcesGetList();
815 815
       db_planet_set_by_id($planet_arrival['id'],
816 816
         "`metal` = `metal` + '{$fleet_resources[RES_METAL]}', `crystal` = `crystal` + '{$fleet_resources[RES_CRYSTAL]}', `deuterium` = `deuterium` + '{$fleet_resources[RES_DEUTERIUM]}'");
Please login to merge, or discard this patch.
includes/classes/UnitList.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
    * @param Unit  $value
89 89
    */
90 90
   public function offsetSet($offset, $value) {
91
-    if(isset($this->mapUnitIdToDb[$value->unitId])) {
91
+    if (isset($this->mapUnitIdToDb[$value->unitId])) {
92 92
       classSupernova::$debug->error('UnitList::offsetSet: Unit with UnitId ' . $value->unitId . ' already exists');
93 93
     }
94 94
     $this->mapUnitIdToDb[$value->unitId] = $value;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
   }
97 97
 
98 98
   public function offsetUnset($offset) {
99
-    if(!empty($this[$offset]->unitId)) {
99
+    if (!empty($this[$offset]->unitId)) {
100 100
 //      $unit_id = $this[$offset]->unitId;
101 101
 //      $this->mapUnitIdToDb[$unit_id] = null;
102 102
 //      unset($this->mapUnitIdToDb[$unit_id]);
@@ -118,20 +118,20 @@  discard block
 block discarded – undo
118 118
   public function dbLoad($dbId) {
119 119
 //    $this->_reset();
120 120
 
121
-    if($dbId <= 0) {
121
+    if ($dbId <= 0) {
122 122
       return;
123 123
     }
124 124
 
125
-    if(!is_object($this->locatedAt)) {
125
+    if (!is_object($this->locatedAt)) {
126 126
       classSupernova::$debug->error('UnitList::dbLoad have no locatedAt field set');
127 127
     }
128 128
 
129 129
     $unit_array = classSupernova::db_get_unit_list_by_location(0, $this->getLocationType(), $this->getLocationDbId());
130
-    if(!is_array($unit_array)) {
130
+    if (!is_array($unit_array)) {
131 131
       return;
132 132
     }
133 133
 
134
-    foreach($unit_array as $unit_db_row) {
134
+    foreach ($unit_array as $unit_db_row) {
135 135
       $unit = $this->_createElement();
136 136
       $unit->setLocatedAt($this);
137 137
       $unit->dbRowParse($unit_db_row);
@@ -147,25 +147,25 @@  discard block
 block discarded – undo
147 147
   }
148 148
 
149 149
   public function dbSave() {
150
-    if(!is_object($this->locatedAt)) {
150
+    if (!is_object($this->locatedAt)) {
151 151
       classSupernova::$debug->error('UnitList::dbSave have no locatedAt field set');
152 152
     }
153 153
 
154
-    foreach($this->mapUnitIdToDb as $unit) {
154
+    foreach ($this->mapUnitIdToDb as $unit) {
155 155
       $unit_db_id = $unit->dbId;
156 156
       $unit->dbSave();
157 157
 
158
-      if($unit->isEmpty()) {
158
+      if ($unit->isEmpty()) {
159 159
         // Removing unit object
160 160
         // TODO - change when there will be common bus for all objects
161 161
         // ...or should I? If COUNT is empty - it means that object does not exists in DB. So it should be deleted from PHP memory and cache too
162 162
         unset($this[$unit_db_id]);
163 163
       } else {
164
-        if($unit->dbId <= 0) {
164
+        if ($unit->dbId <= 0) {
165 165
           classSupernova::$debug->error('Error writing unit to DB');
166 166
         }
167 167
         // If unit is new then putting unit object to container
168
-        if(empty($this->_container[$unit->dbId])) {
168
+        if (empty($this->_container[$unit->dbId])) {
169 169
           $this->_container[$unit->dbId] = $unit;
170 170
         }
171 171
       }
@@ -200,7 +200,7 @@  discard block
 block discarded – undo
200 200
   }
201 201
 
202 202
   public function unitGetCount($unit_id) {
203
-    if(empty($this->mapUnitIdToDb[$unit_id])) {
203
+    if (empty($this->mapUnitIdToDb[$unit_id])) {
204 204
       throw new Exception('Unit [' . $unit_id . '] is not exists in UnitList');
205 205
     }
206 206
     return $this->mapUnitIdToDb[$unit_id]->count;
@@ -215,14 +215,14 @@  discard block
 block discarded – undo
215 215
    * @param bool $replace_value
216 216
    */
217 217
   public function unitAdjustCount($unit_id, $unit_count = 0, $replace_value = false) {
218
-    if(empty($this->mapUnitIdToDb[$unit_id])) {
218
+    if (empty($this->mapUnitIdToDb[$unit_id])) {
219 219
       // If unit not exists - creating one and setting all attributes
220 220
       $this->mapUnitIdToDb[$unit_id] = $this->_createElement();
221 221
       $this->mapUnitIdToDb[$unit_id]->setUnitId($unit_id);
222 222
       $this->mapUnitIdToDb[$unit_id]->setLocatedAt($this);
223 223
     }
224 224
 
225
-    if($replace_value) {
225
+    if ($replace_value) {
226 226
       $this->mapUnitIdToDb[$unit_id]->count = $unit_count;
227 227
     } else {
228 228
       $this->mapUnitIdToDb[$unit_id]->adjustCount($unit_count);
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
    */
237 237
   public function unitsGetArray() {
238 238
     $result = array();
239
-    foreach($this->mapUnitIdToDb as $unit) {
239
+    foreach ($this->mapUnitIdToDb as $unit) {
240 240
       $result[$unit->unitId] = $unit->count;
241 241
     }
242 242
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
   }
245 245
 
246 246
   public function unitsCountApplyLossMultiplier($ships_lost_multiplier) {
247
-    foreach($this->mapUnitIdToDb as $unit_id => $unit) {
247
+    foreach ($this->mapUnitIdToDb as $unit_id => $unit) {
248 248
       $unit->count = floor($unit->count * $ships_lost_multiplier);
249 249
     }
250 250
   }
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 
271 271
   public function unitsPropertySumById($unit_id = 0, $propertyName = 'count') {
272 272
     $result = 0;
273
-    foreach($this->mapUnitIdToDb as $unit) {
274
-      if(!$unit_id || $unit->unitId == $unit_id) {
273
+    foreach ($this->mapUnitIdToDb as $unit) {
274
+      if (!$unit_id || $unit->unitId == $unit_id) {
275 275
         $result += $unit->$propertyName;
276 276
       }
277 277
     }
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 
353 353
     print('</tr>');
354 354
 
355
-    foreach($this->mapUnitIdToDb as $unit) {
355
+    foreach ($this->mapUnitIdToDb as $unit) {
356 356
       print('<tr>');
357 357
 
358 358
       print('<td>');
@@ -403,14 +403,14 @@  discard block
 block discarded – undo
403 403
 
404 404
 
405 405
   public function unitZeroDbId() {
406
-    foreach($this->mapUnitIdToDb as $unit) {
406
+    foreach ($this->mapUnitIdToDb as $unit) {
407 407
       $unit->zeroDbId();
408 408
     }
409 409
   }
410 410
 
411 411
 
412 412
   public function unitZeroCount() {
413
-    foreach($this->mapUnitIdToDb as $unit) {
413
+    foreach ($this->mapUnitIdToDb as $unit) {
414 414
       $unit->count = 0;
415 415
     }
416 416
   }
Please login to merge, or discard this patch.
overview.php 2 patches
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,32 +1,32 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * index.php - overview.php
4
- *
5
- * 2.4 - copyright (c) 2010 by Gorlum for http://supernova.ws
6
- *     [-] Removed News frame
7
- *     [-] Time & Usersonline moved to Top-Frame
8
- * 2.3 - copyright (c) 2010 by Gorlum for http://supernova.ws
9
- *     [*] Complying with PCG
10
- * 2.2 - copyright (c) 2010 by Gorlum for http://supernova.ws
11
- *     [+] Redo flying fleet list
12
- * 2.1 - copyright (c) 2010 by Gorlum for http://supernova.ws
13
- *     [+] Planets on planet list now have indication of planet fill
14
- *     [+] Planets on planet list now have indication when there is enemy fleet flying to planet
15
- * 2.0 - copyright (c) 2010 by Gorlum for http://supernova.ws
16
- *     [+] Now there is full planet list on right side of screen a-la oGame
17
- *     [+] Planet list now include icons for buildings/tech/fleet on progress
18
- * 1.5 - copyright (c) 2010 by Gorlum for http://supernova.ws
19
- *     [*] Subplanet timers now use sn_timer.js library
20
- * 1.4 - copyright (c) 2010 by Gorlum for http://supernova.ws
21
- *     [*] All mainplanet timers now use new sn_timer.js library
22
- * 1.3 - copyright (c) 2010 by Gorlum for http://supernova.ws
23
- *     [*] Adjusted layouts of player infos
24
- * 1.2 - copyright (c) 2010 by Gorlum for http://supernova.ws
25
- *     [*] Adjusted layouts of planet infos
26
- * 1.1 - Security checks by Gorlum for http://supernova.ws
27
- * @version 1
28
- * @copyright 2008 By Chlorel for XNova
29
- */
3
+   * index.php - overview.php
4
+   *
5
+   * 2.4 - copyright (c) 2010 by Gorlum for http://supernova.ws
6
+   *     [-] Removed News frame
7
+   *     [-] Time & Usersonline moved to Top-Frame
8
+   * 2.3 - copyright (c) 2010 by Gorlum for http://supernova.ws
9
+   *     [*] Complying with PCG
10
+   * 2.2 - copyright (c) 2010 by Gorlum for http://supernova.ws
11
+   *     [+] Redo flying fleet list
12
+   * 2.1 - copyright (c) 2010 by Gorlum for http://supernova.ws
13
+   *     [+] Planets on planet list now have indication of planet fill
14
+   *     [+] Planets on planet list now have indication when there is enemy fleet flying to planet
15
+   * 2.0 - copyright (c) 2010 by Gorlum for http://supernova.ws
16
+   *     [+] Now there is full planet list on right side of screen a-la oGame
17
+   *     [+] Planet list now include icons for buildings/tech/fleet on progress
18
+   * 1.5 - copyright (c) 2010 by Gorlum for http://supernova.ws
19
+   *     [*] Subplanet timers now use sn_timer.js library
20
+   * 1.4 - copyright (c) 2010 by Gorlum for http://supernova.ws
21
+   *     [*] All mainplanet timers now use new sn_timer.js library
22
+   * 1.3 - copyright (c) 2010 by Gorlum for http://supernova.ws
23
+   *     [*] Adjusted layouts of player infos
24
+   * 1.2 - copyright (c) 2010 by Gorlum for http://supernova.ws
25
+   *     [*] Adjusted layouts of planet infos
26
+   * 1.1 - Security checks by Gorlum for http://supernova.ws
27
+   * @version 1
28
+   * @copyright 2008 By Chlorel for XNova
29
+   */
30 30
 
31 31
 //define('SN_RENDER_NAVBAR_PLANET', false);
32 32
 
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 $result = array();
80 80
 
81
-switch($mode = sys_get_param_str('mode')) {
81
+switch ($mode = sys_get_param_str('mode')) {
82 82
   case 'manage':
83 83
     sn_sys_sector_buy('overview.php?mode=manage');
84 84
 
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
     $template  = gettemplate('planet_manage', true);
89 89
     $planet_id = sys_get_param_id('planet_id');
90 90
 
91
-    if(sys_get_param_str('rename') && $new_name = sys_get_param_str('new_name')) {
91
+    if (sys_get_param_str('rename') && $new_name = sys_get_param_str('new_name')) {
92 92
       $planetrow['name'] = $new_name;
93 93
 //      $new_name = db_escape($new_name);
94 94
       db_planet_set_by_id($planetrow['id'], "`name` = '{$new_name}'");
95
-    } elseif(sys_get_param_str('action') == 'make_capital') {
95
+    } elseif (sys_get_param_str('action') == 'make_capital') {
96 96
       try {
97 97
         sn_db_transaction_start();
98 98
         $user = db_user_by_id($user['id'], true, '*');
@@ -101,15 +101,15 @@  discard block
 block discarded – undo
101 101
 //        $user = $global_data['user'];
102 102
 //        $planetrow = $global_data['planet'];
103 103
 
104
-        if($planetrow['planet_type'] != PT_PLANET) {
104
+        if ($planetrow['planet_type'] != PT_PLANET) {
105 105
           throw new exception(classLocale::$lang['ov_capital_err_not_a_planet'], ERR_ERROR);
106 106
         }
107 107
 
108
-        if($planetrow['id'] == $user['id_planet']) {
108
+        if ($planetrow['id'] == $user['id_planet']) {
109 109
           throw new exception(classLocale::$lang['ov_capital_err_capital_already'], ERR_ERROR);
110 110
         }
111 111
 
112
-        if($user_dark_matter < $config->planet_capital_cost) {
112
+        if ($user_dark_matter < $config->planet_capital_cost) {
113 113
           throw new exception(classLocale::$lang['ov_capital_err_no_dark_matter'], ERR_ERROR);
114 114
         }
115 115
 
@@ -126,16 +126,16 @@  discard block
 block discarded – undo
126 126
         );
127 127
         sn_db_transaction_commit();
128 128
         sys_redirect('overview.php?mode=manage');
129
-      } catch(exception $e) {
129
+      } catch (exception $e) {
130 130
         sn_db_transaction_rollback();
131 131
         $result[] = array(
132 132
           'STATUS'  => $e->getCode(),
133 133
           'MESSAGE' => $e->getMessage(),
134 134
         );
135 135
       }
136
-    } elseif(sys_get_param_str('action') == 'planet_teleport') {
136
+    } elseif (sys_get_param_str('action') == 'planet_teleport') {
137 137
       try {
138
-        if(!uni_coordinates_valid($new_coordinates = array(
138
+        if (!uni_coordinates_valid($new_coordinates = array(
139 139
           'galaxy' => sys_get_param_int('new_galaxy'),
140 140
           'system' => sys_get_param_int('new_system'),
141 141
           'planet' => sys_get_param_int('new_planet')))
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
 //        $planetrow = $global_data['planet'];
153 153
 
154 154
         $can_teleport = uni_planet_teleport_check($user, $planetrow, $new_coordinates);
155
-        if($can_teleport['result'] != ERR_NONE) {
155
+        if ($can_teleport['result'] != ERR_NONE) {
156 156
           throw new exception($can_teleport['message'], $can_teleport['result']);
157 157
         }
158 158
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         db_planet_set_by_gspt($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], PT_ALL,
164 164
           "galaxy = {$new_coordinates['galaxy']}, system = {$new_coordinates['system']}, planet = {$new_coordinates['planet']}, planet_teleport_next = {$planet_teleport_next}");
165 165
 
166
-        if($planetrow['id'] == $user['id_planet']) {
166
+        if ($planetrow['id'] == $user['id_planet']) {
167 167
           db_user_set_by_id($user['id'], "galaxy = {$new_coordinates['galaxy']}, system = {$new_coordinates['system']}, planet = {$new_coordinates['planet']}");
168 168
         }
169 169
 
@@ -176,17 +176,17 @@  discard block
 block discarded – undo
176 176
           'MESSAGE' => classLocale::$lang['ov_teleport_err_none'],
177 177
         );
178 178
         sys_redirect('overview.php?mode=manage');
179
-      } catch(exception $e) {
179
+      } catch (exception $e) {
180 180
         sn_db_transaction_rollback();
181 181
         $result[] = array(
182 182
           'STATUS'  => $e->getCode(),
183 183
           'MESSAGE' => $e->getMessage(),
184 184
         );
185 185
       }
186
-    } elseif(sys_get_param_str('action') == 'planet_abandon') {
186
+    } elseif (sys_get_param_str('action') == 'planet_abandon') {
187 187
       // if(sec_password_check($user['id'], sys_get_param('abandon_confirm'))) {
188
-      if(classSupernova::$auth->password_check(sys_get_param('abandon_confirm'))) {
189
-        if($user['id_planet'] != $user['current_planet'] && $user['current_planet'] == $planet_id) {
188
+      if (classSupernova::$auth->password_check(sys_get_param('abandon_confirm'))) {
189
+        if ($user['id_planet'] != $user['current_planet'] && $user['current_planet'] == $planet_id) {
190 190
           $destroyed = SN_TIME_NOW + 60 * 60 * 24;
191 191
           db_planet_set_by_id($user['current_planet'], "`destruyed`='{$destroyed}', `id_owner`=0");
192 192
           db_planet_set_by_parent($user['current_planet'], "`destruyed`='{$destroyed}', `id_owner`=0");
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
           message(classLocale::$lang['ov_delete_wrong_planet'], classLocale::$lang['colony_abandon'], 'overview.php?mode=manage');
197 197
         }
198 198
       } else {
199
-        message(classLocale::$lang['ov_delete_wrong_pass'] , classLocale::$lang['colony_abandon'], 'overview.php?mode=manage');
199
+        message(classLocale::$lang['ov_delete_wrong_pass'], classLocale::$lang['colony_abandon'], 'overview.php?mode=manage');
200 200
       }
201
-    } elseif(
201
+    } elseif (
202 202
       ($hire = sys_get_param_int('hire')) && in_array($hire, sn_get_groups('governors'))
203 203
       && (
204 204
         !get_unit_param($hire, P_MAX_STACK) ||
@@ -213,8 +213,8 @@  discard block
 block discarded – undo
213 213
       $user = db_user_by_id($user['id'], true);
214 214
       $planetrow = db_planet_by_id($planetrow['id'], true);
215 215
       $build_data = eco_get_build_data($user, $planetrow, $hire, $planetrow['PLANET_GOVERNOR_ID'] == $hire ? $planetrow['PLANET_GOVERNOR_LEVEL'] : 0);
216
-      if($build_data['CAN'][BUILD_CREATE]) {
217
-        if($planetrow['PLANET_GOVERNOR_ID'] == $hire) {
216
+      if ($build_data['CAN'][BUILD_CREATE]) {
217
+        if ($planetrow['PLANET_GOVERNOR_ID'] == $hire) {
218 218
           $planetrow['PLANET_GOVERNOR_LEVEL']++;
219 219
           $query = '`PLANET_GOVERNOR_LEVEL` + 1';
220 220
         } else {
@@ -240,8 +240,8 @@  discard block
 block discarded – undo
240 240
 
241 241
     lng_include('mrc_mercenary');
242 242
     int_planet_pretemplate($planetrow, $template);
243
-    foreach(sn_get_groups('governors') as $governor_id) {
244
-      if($planetrow['planet_type'] == PT_MOON && $governor_id == MRC_TECHNOLOGIST) {
243
+    foreach (sn_get_groups('governors') as $governor_id) {
244
+      if ($planetrow['planet_type'] == PT_MOON && $governor_id == MRC_TECHNOLOGIST) {
245 245
         continue;
246 246
       }
247 247
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
       'PAGE_HINT'   => classLocale::$lang['ov_manage_page_hint'],
294 294
     ));
295 295
 
296
-    foreach($result as &$a_result) {
296
+    foreach ($result as &$a_result) {
297 297
       $template->assign_block_vars('result', $a_result);
298 298
     }
299 299
 
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
   default:
304 304
     sn_sys_sector_buy();
305 305
 
306
-    if(sys_get_param_str('rename') && $new_name = sys_get_param_str('new_name')) {
306
+    if (sys_get_param_str('rename') && $new_name = sys_get_param_str('new_name')) {
307 307
       $planetrow['name'] = $new_name;
308 308
       $new_name_safe = db_escape($new_name);
309 309
       db_planet_set_by_id($planetrow['id'], "`name` = '{$new_name_safe}'");
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 
334 334
     $planet_count = 0;
335 335
     $planets_query = db_planet_list_sorted($user, false, '*');
336
-    foreach($planets_query as $an_id => $UserPlanet) {
336
+    foreach ($planets_query as $an_id => $UserPlanet) {
337 337
       sn_db_transaction_start();
338 338
       $UserPlanet = sys_o_get_updated($user, $UserPlanet['id'], SN_TIME_NOW, false, true);
339 339
       sn_db_transaction_commit();
@@ -344,16 +344,16 @@  discard block
 block discarded – undo
344 344
 
345 345
       $planet_fleet_id = 0;
346 346
       $fleet_list = $template_planet['fleet_list'];
347
-      if($fleet_list['own']['count']) {
347
+      if ($fleet_list['own']['count']) {
348 348
         $planet_fleet_id = "p{$UserPlanet['id']}";
349 349
         $fleets_to_planet[$UserPlanet['id']] = tpl_parse_fleet_sn($fleet_list['own']['total'], $planet_fleet_id);
350 350
 //        $fleet_id++;tpl_parse_fleet_sn
351 351
       }
352
-      if($UserPlanet['planet_type'] == PT_MOON) {
352
+      if ($UserPlanet['planet_type'] == PT_MOON) {
353 353
         continue;
354 354
       }
355 355
       $moon = db_planet_by_parent($UserPlanet['id']);
356
-      if($moon) {
356
+      if ($moon) {
357 357
         $moon_fill = min(100, floor($moon['field_current'] / eco_planet_fields_max($moon) * 100));
358 358
       } else {
359 359
         $moon_fill = 0;
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
     tpl_assign_fleet($template, $fleets);
394 394
 
395 395
     $lune = $planetrow['planet_type'] == PT_PLANET ? db_planet_by_parent($planetrow['id']) : db_planet_by_id($planetrow['parent_planet']);
396
-    if($lune) {
396
+    if ($lune) {
397 397
       $template->assign_vars(array(
398 398
         'MOON_ID' => $lune['id'],
399 399
         'MOON_IMG' => $lune['image'],
@@ -405,15 +405,15 @@  discard block
 block discarded – undo
405 405
     $planet_fill = $planet_fill > 100 ? 100 : $planet_fill;
406 406
 
407 407
     $planet_recyclers_orbiting = 0;
408
-    foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
408
+    foreach (sn_get_groups('flt_recyclers') as $recycler_id) {
409 409
       $planet_recyclers_orbiting += mrc_get_level($user, $planetrow, $recycler_id);
410 410
     }
411 411
 
412 412
     int_planet_pretemplate($planetrow, $template);
413 413
 
414 414
     $sn_group_ques = sn_get_groups('ques');
415
-    if(!defined('GAME_STRUCTURES_DISABLED') || !GAME_STRUCTURES_DISABLED) {
416
-      foreach(array(QUE_STRUCTURES => $sn_group_ques[QUE_STRUCTURES]) as $que_id => $que_type_data) {
415
+    if (!defined('GAME_STRUCTURES_DISABLED') || !GAME_STRUCTURES_DISABLED) {
416
+      foreach (array(QUE_STRUCTURES => $sn_group_ques[QUE_STRUCTURES]) as $que_id => $que_type_data) {
417 417
         $this_que = $que['ques'][$que_id][$user['id']][$planetrow['id']];
418 418
         $template->assign_block_vars('ques', array(
419 419
           'ID'     => $que_id,
@@ -421,8 +421,8 @@  discard block
 block discarded – undo
421 421
           'LENGTH' => empty($this_que) ? 0 : count($this_que),
422 422
         ));
423 423
 
424
-        if(!empty($this_que)) {
425
-          foreach($this_que as $que_item) {
424
+        if (!empty($this_que)) {
425
+          foreach ($this_que as $que_item) {
426 426
             $template->assign_block_vars('que', que_tpl_parse_element($que_item));
427 427
           }
428 428
         }
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
       'LENGTH' => $que_hangar_length,
437 437
     ));
438 438
 
439
-    if(!defined('GAME_DEFENSE_DISABLED') || !GAME_DEFENSE_DISABLED) {
439
+    if (!defined('GAME_DEFENSE_DISABLED') || !GAME_DEFENSE_DISABLED) {
440 440
       $que_hangar_length = tpl_assign_hangar($template, $planetrow, SUBQUE_DEFENSE);
441 441
       $template->assign_block_vars('ques', array(
442 442
         'ID'     => SUBQUE_DEFENSE,
@@ -448,12 +448,12 @@  discard block
 block discarded – undo
448 448
     $overview_planet_rows = $user['opt_int_overview_planet_rows'];
449 449
     $overview_planet_columns = $user['opt_int_overview_planet_columns'];
450 450
 
451
-    if($overview_planet_rows <= 0 && $overview_planet_columns <= 0) {
451
+    if ($overview_planet_rows <= 0 && $overview_planet_columns <= 0) {
452 452
       $overview_planet_rows = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_rows'];
453 453
       $overview_planet_columns = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_columns'];
454 454
     }
455 455
 
456
-    if($overview_planet_rows > 0 && $overview_planet_columns <= 0) {
456
+    if ($overview_planet_rows > 0 && $overview_planet_columns <= 0) {
457 457
       $overview_planet_columns = ceil($planet_count / $overview_planet_rows);
458 458
     }
459 459
 
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
     ));
511 511
     tpl_set_resource_info($template, $planetrow, $fleets_to_planet, 2);
512 512
 
513
-    foreach($result as &$a_result) {
513
+    foreach ($result as &$a_result) {
514 514
       $template->assign_block_vars('result', $a_result);
515 515
     }
516 516
 
Please login to merge, or discard this patch.
includes/vars_combats.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     'shield' => 10,
36 36
     'armor' => 400,
37 37
     'attack' => 5,
38
-    'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ),
38
+    'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,),
39 39
   ),
40 40
   SHIP_CARGO_BIG => array(
41 41
     'name' => 'big_ship_cargo',
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     'shield' => 25,
56 56
     'armor' => 1200,
57 57
     'attack' => 5,
58
-    'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ),
58
+    'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,),
59 59
     'engine' => array(
60 60
       array(
61 61
         'tech' => TECH_ENGINE_CHEMICAL,
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     'shield' => 50,
84 84
     'armor' => 3000,
85 85
     'attack' => 10,
86
-    'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ),
86
+    'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,),
87 87
     'engine' => array(
88 88
       array(
89 89
         'tech' => TECH_ENGINE_ION,
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
     'shield' => 200,
112 112
     'armor' => 70000,
113 113
     'attack' => 50,
114
-    'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250, ),
114
+    'amplify' => array(SHIP_SPY => 100, SHIP_SATTELITE_SOLAR => 250,),
115 115
     'engine' => array(
116 116
       array(
117 117
         'tech' => TECH_ENGINE_HYPER,
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
     'shield' => 100,
141 141
     'armor' => 3000,
142 142
     'attack' => 50,
143
-    'amplify' => array(SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21, ),
143
+    'amplify' => array(SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21,),
144 144
     'engine' => array(
145 145
       array(
146 146
         'tech' => TECH_ENGINE_ION,
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     'shield' => 10,
169 169
     'armor' => 1600,
170 170
     'attack' => 1,
171
-    'amplify' => array(SHIP_SPY => 500.05, SHIP_SATTELITE_SOLAR => 1050, ),
171
+    'amplify' => array(SHIP_SPY => 500.05, SHIP_SATTELITE_SOLAR => 1050,),
172 172
     'engine' => array(
173 173
       array(
174 174
         'tech' => TECH_ENGINE_CHEMICAL,
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
     'shield' =>  0.01,
197 197
     'armor' => 100,
198 198
     'attack' =>  0.01,
199
-    'amplify' => array( SHIP_SPY => 1,),
199
+    'amplify' => array(SHIP_SPY => 1,),
200 200
     'engine' => array(
201 201
       array(
202 202
         'tech' => TECH_ENGINE_CHEMICAL,
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
       'factor' => 1,
221 221
     ),
222 222
     P_UNIT_PRODUCTION => array(
223
-      RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 4 + 20) * $level * (0.1 * $production_factor);},
223
+      RES_ENERGY => function($level, $production_factor, $user, $planet_row) {return ($planet_row["temp_max"] / 4 + 20) * $level * (0.1 * $production_factor); },
224 224
     ),
225 225
     P_MINING_IS_MANAGED => true,
226 226
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
     'shield' => 10,
230 230
     'armor' => 200,
231 231
     'attack' => 1,
232
-    'amplify' => array(SHIP_SPY => 1, ),
232
+    'amplify' => array(SHIP_SPY => 1,),
233 233
     'engine' => array(
234 234
       array(
235 235
         'tech' => TECH_ENGINE_CHEMICAL,
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
     'shield' => 10,
262 262
     'armor' => 400,
263 263
     'attack' => 50,
264
-    'amplify' => array(SHIP_CARGO_SMALL => 16.4, SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21, ),
264
+    'amplify' => array(SHIP_CARGO_SMALL => 16.4, SHIP_SPY => 10.001, SHIP_SATTELITE_SOLAR => 21,),
265 265
     'engine' => array(
266 266
       array(
267 267
         'tech' => TECH_ENGINE_CHEMICAL,
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
     'shield' => 25,
291 291
     'armor' => 1000,
292 292
     'attack' => 150,
293
-    'amplify' => array(SHIP_CARGO_SMALL => 8.2, SHIP_SPY => 3.33367, SHIP_SATTELITE_SOLAR => 7, ),
293
+    'amplify' => array(SHIP_CARGO_SMALL => 8.2, SHIP_SPY => 3.33367, SHIP_SATTELITE_SOLAR => 7,),
294 294
     'engine' => array(
295 295
       array(
296 296
         'tech' => TECH_ENGINE_ION,
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
     'shield' =>  50,
350 350
     'armor' => 2700,
351 351
     'attack' => 400,
352
-    'amplify' => array(SHIP_SMALL_FIGHTER_LIGHT => 6.15, SHIP_SPY => 1.25013, SHIP_SATTELITE_SOLAR => 2.625, UNIT_DEF_TURRET_MISSILE => 5.5, ),
352
+    'amplify' => array(SHIP_SMALL_FIGHTER_LIGHT => 6.15, SHIP_SPY => 1.25013, SHIP_SATTELITE_SOLAR => 2.625, UNIT_DEF_TURRET_MISSILE => 5.5,),
353 353
     'engine' => array(
354 354
       array(
355 355
         'tech' => TECH_ENGINE_ION,
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
     'shield' =>  200,
409 409
     'armor' =>  6000,
410 410
     'attack' => 1000,
411
-    'amplify' => array(SHIP_SPY => 0.50005, SHIP_SATTELITE_SOLAR => 1.05, UNIT_DEF_TURRET_MISSILE => 1.76, ),
411
+    'amplify' => array(SHIP_SPY => 0.50005, SHIP_SATTELITE_SOLAR => 1.05, UNIT_DEF_TURRET_MISSILE => 1.76,),
412 412
     'engine' => array(
413 413
       array(
414 414
         'tech' => TECH_ENGINE_HYPER,
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
     'shield' =>  500,
505 505
     'armor' => 11000,
506 506
     'attack' => 2000,
507
-    'amplify' => array(SHIP_SPY => 0.25003, SHIP_SATTELITE_SOLAR => 0.525, SHIP_LARGE_BATTLESHIP => 7.4, UNIT_DEF_TURRET_LASER_SMALL => 1.125, ),
507
+    'amplify' => array(SHIP_SPY => 0.25003, SHIP_SATTELITE_SOLAR => 0.525, SHIP_LARGE_BATTLESHIP => 7.4, UNIT_DEF_TURRET_LASER_SMALL => 1.125,),
508 508
     'engine' => array(
509 509
       array(
510 510
         'tech' => TECH_ENGINE_HYPER,
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
     'shield' => 20,
609 609
     'armor' => 200,
610 610
     'attack' => 80,
611
-    'amplify' => array(SHIP_SPY => 7, ),
611
+    'amplify' => array(SHIP_SPY => 7,),
612 612
   ),
613 613
   UNIT_DEF_TURRET_LASER_SMALL => array(
614 614
     'name' => 'small_laser',
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
     'shield' => 25,
627 627
     'armor' => 200,
628 628
     'attack' => 100,
629
-    'amplify' => array(SHIP_SPY => 5, ),
629
+    'amplify' => array(SHIP_SPY => 5,),
630 630
   ),
631 631
   UNIT_DEF_TURRET_LASER_BIG => array(
632 632
     'name' => 'big_laser',
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
     'shield' => 100,
645 645
     'armor' => 800,
646 646
     'attack' => 250,
647
-    'amplify' => array(SHIP_SPY => 2, ),
647
+    'amplify' => array(SHIP_SPY => 2,),
648 648
   ),
649 649
   UNIT_DEF_TURRET_GAUSS => array(
650 650
     'name' => 'gauss_canyon',
@@ -662,7 +662,7 @@  discard block
 block discarded – undo
662 662
     'armor' => 3500,
663 663
     'shield' => 200,
664 664
     'attack' => 1100,
665
-    'amplify' => array(SHIP_SPY => 0.5, ),
665
+    'amplify' => array(SHIP_SPY => 0.5,),
666 666
   ),
667 667
   UNIT_DEF_TURRET_ION => array(
668 668
     'name' => 'ionic_canyon',
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
     'shield' => 500,
681 681
     'armor' => 800,
682 682
     'attack' => 150,
683
-    'amplify' => array(SHIP_SPY => 3.3, ),
683
+    'amplify' => array(SHIP_SPY => 3.3,),
684 684
   ),
685 685
   UNIT_DEF_TURRET_PLASMA => array(
686 686
     'name' => 'buster_canyon',
@@ -698,7 +698,7 @@  discard block
 block discarded – undo
698 698
     'shield' => 300,
699 699
     'armor' => 10000,
700 700
     'attack' => 3000,
701
-    'amplify' => array(SHIP_SPY => 0.17, ),
701
+    'amplify' => array(SHIP_SPY => 0.17,),
702 702
   ),
703 703
 
704 704
   UNIT_DEF_SHIELD_SMALL => array(
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
     'shield' => 2000,
719 719
     'armor' => 2000,
720 720
     'attack' => 1,
721
-    'amplify' => array(SHIP_SPY => 500, ),
721
+    'amplify' => array(SHIP_SPY => 500,),
722 722
   ),
723 723
   UNIT_DEF_SHIELD_BIG => array(
724 724
     'name' => 'big_protection_shield',
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
     'shield' => 2000,
738 738
     'armor' => 10000,
739 739
     'attack' => 1,
740
-    'amplify' => array(SHIP_SPY => 500, ),
740
+    'amplify' => array(SHIP_SPY => 500,),
741 741
   ),
742 742
   UNIT_DEF_SHIELD_PLANET => array(
743 743
     'name'      => 'planet_protector',
Please login to merge, or discard this patch.
includes/classes/module.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -239,6 +239,9 @@
 block discarded – undo
239 239
     }
240 240
   }
241 241
 
242
+  /**
243
+   * @param string $arrayName
244
+   */
242 245
   protected function mergeArraySpecial($arrayName) {
243 246
     global $sn_mvc;
244 247
 
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     require SN_ROOT_PHYSICAL . 'config.php';
77 77
 
78 78
     $module_config_array = get_class($this) . '_config';
79
-    if(!empty($$module_config_array) && is_array($$module_config_array)) {
79
+    if (!empty($$module_config_array) && is_array($$module_config_array)) {
80 80
       $this->config = $$module_config_array;
81 81
 
82 82
       return true;
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
 
95 95
     // TODO: Load configuration from DB. Manifest setting
96 96
     // Trying to load configuration from file
97
-    if(!$config_exists = $this->loadModuleRootConfig()) {
97
+    if (!$config_exists = $this->loadModuleRootConfig()) {
98 98
       // Конфигурация может лежать в config_path в манифеста или в корне модуля
99
-      if(isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) {
99
+      if (isset($this->manifest['config_path']) && file_exists($config_filename = $this->manifest['config_path'] . '/config.php')) {
100 100
         $config_exists = true;
101
-      } elseif(file_exists($config_filename = dirname($filename) . '/config.php')) {
101
+      } elseif (file_exists($config_filename = dirname($filename) . '/config.php')) {
102 102
         $config_exists = true;
103 103
       }
104 104
 
105
-      if($config_exists) {
105
+      if ($config_exists) {
106 106
         include($config_filename);
107 107
         $module_config_array = $class_module_name . '_config';
108 108
         $this->config = $$module_config_array;
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 
120 120
     // Checking module status - is it installed and active
121 121
     $this->check_status();
122
-    if(!$this->manifest['active']) {
122
+    if (!$this->manifest['active']) {
123 123
       return;
124 124
     }
125 125
 
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 
140 140
   protected function setSystemConstants() {
141 141
     // Setting constants - if any
142
-    if(empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) {
142
+    if (empty($this->manifest['constants']) || !is_array($this->manifest['constants'])) {
143 143
       return;
144 144
     }
145 145
 
146
-    foreach($this->manifest['constants'] as $constant_name => $constant_value) {
146
+    foreach ($this->manifest['constants'] as $constant_name => $constant_value) {
147 147
       defined($constant_name) || define($constant_name, $constant_value);
148 148
     }
149 149
   }
@@ -155,48 +155,48 @@  discard block
 block discarded – undo
155 155
     // New values from module variables will overwrite previous values (for root variables) and array elements with corresponding indexes (for arrays)
156 156
     // Constants as array indexes are honored - it's make valid such declarations as 'sn_data[ques][QUE_STRUCTURES]'
157 157
     $this->manifest['vars'] = $this->__assign_vars();
158
-    if(empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) {
158
+    if (empty($this->manifest['vars']) || !is_array($this->manifest['vars'])) {
159 159
       return;
160 160
     }
161 161
 
162 162
     $vars_assigned = array();
163
-    foreach($this->manifest['vars'] as $var_name => $var_value) {
163
+    foreach ($this->manifest['vars'] as $var_name => $var_value) {
164 164
       $sub_vars = explode('[', str_replace(']', '', $var_name));
165 165
       $var_name = $sub_vars[0];
166 166
 
167
-      if(!isset($vars_assigned[$var_name])) {
167
+      if (!isset($vars_assigned[$var_name])) {
168 168
         $vars_assigned[$var_name] = true;
169 169
         global $$var_name;
170 170
       }
171 171
 
172 172
       $pointer = &$$var_name;
173
-      if(($n = count($sub_vars)) > 1) {
174
-        for($i = 1; $i < $n; $i++) {
175
-          if(defined($sub_vars[$i])) {
173
+      if (($n = count($sub_vars)) > 1) {
174
+        for ($i = 1; $i < $n; $i++) {
175
+          if (defined($sub_vars[$i])) {
176 176
             $sub_vars[$i] = constant($sub_vars[$i]);
177 177
           }
178 178
 
179
-          if(!isset($pointer[$sub_vars[$i]]) && $i != $n) {
179
+          if (!isset($pointer[$sub_vars[$i]]) && $i != $n) {
180 180
             $pointer[$sub_vars[$i]] = array();
181 181
           }
182 182
           $pointer = &$pointer[$sub_vars[$i]];
183 183
         }
184 184
       }
185 185
 
186
-      if(!isset($pointer) || !is_array($pointer)) {
186
+      if (!isset($pointer) || !is_array($pointer)) {
187 187
         $pointer = $var_value;
188
-      } elseif(is_array($$var_name)) {
188
+      } elseif (is_array($$var_name)) {
189 189
         $pointer = array_merge_recursive_numeric($pointer, $var_value);
190 190
       }
191 191
     }
192 192
   }
193 193
 
194 194
   protected function mergeMenu(&$sn_menu_extra, &$menu_patch) {
195
-    if(!is_array($menu_patch)) {
195
+    if (!is_array($menu_patch)) {
196 196
       return;
197 197
     }
198 198
 
199
-    foreach($menu_patch as $menu_item_name => $menu_item_data) {
199
+    foreach ($menu_patch as $menu_item_name => $menu_item_data) {
200 200
       $sn_menu_extra[$menu_item_name] = $menu_item_data;
201 201
     }
202 202
   }
@@ -205,34 +205,34 @@  discard block
 block discarded – undo
205 205
     // Overriding function if any
206 206
     sn_sys_handler_add(classSupernova::$functions, $this->manifest['functions'], $this);
207 207
 
208
-    foreach(classSupernova::$sn_mvc as $handler_type => &$handler_data) {
208
+    foreach (classSupernova::$sn_mvc as $handler_type => &$handler_data) {
209 209
       sn_sys_handler_add($handler_data, $this->manifest['mvc'][$handler_type], $this, $handler_type);
210 210
     }
211 211
   }
212 212
 
213 213
   protected function mergeNavbarButton() {
214
-    if(empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) {
214
+    if (empty($this->manifest['navbar_prefix_button']) || !is_array($this->manifest['navbar_prefix_button'])) {
215 215
       return;
216 216
     }
217 217
 
218
-    foreach($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) {
218
+    foreach ($this->manifest['navbar_prefix_button'] as $button_image => $button_url_relative) {
219 219
       classSupernova::$sn_mvc['navbar_prefix_button'][$button_image] = $button_url_relative;
220 220
     }
221 221
   }
222 222
 
223 223
   protected function mergeI18N() {
224 224
     $arrayName = 'i18n';
225
-    if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) {
225
+    if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) {
226 226
       return;
227 227
     }
228 228
 
229
-    foreach($this->manifest[$arrayName] as $pageName => &$contentList) {
230
-      foreach($contentList as &$i18n_file_data) {
231
-        if(is_array($i18n_file_data) && !$i18n_file_data['path']) {
229
+    foreach ($this->manifest[$arrayName] as $pageName => &$contentList) {
230
+      foreach ($contentList as &$i18n_file_data) {
231
+        if (is_array($i18n_file_data) && !$i18n_file_data['path']) {
232 232
           $i18n_file_data['path'] = $this->manifest['root_relative'];
233 233
         }
234 234
       }
235
-      if(!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) {
235
+      if (!isset(classSupernova::$sn_mvc[$arrayName][$pageName])) {
236 236
         classSupernova::$sn_mvc[$arrayName][$pageName] = array();
237 237
       }
238 238
       classSupernova::$sn_mvc[$arrayName][$pageName] += $contentList;
@@ -240,13 +240,13 @@  discard block
 block discarded – undo
240 240
   }
241 241
 
242 242
   protected function mergeArraySpecial($arrayName) {
243
-    if(empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) {
243
+    if (empty($this->manifest[$arrayName]) || !is_array($this->manifest[$arrayName])) {
244 244
       return;
245 245
     }
246 246
 
247
-    foreach($this->manifest[$arrayName] as $pageName => &$contentList) {
247
+    foreach ($this->manifest[$arrayName] as $pageName => &$contentList) {
248 248
       !isset(classSupernova::$sn_mvc[$arrayName][$pageName]) ? classSupernova::$sn_mvc[$arrayName][$pageName] = array() : false;
249
-      foreach($contentList as $contentName => &$content) {
249
+      foreach ($contentList as $contentName => &$content) {
250 250
         classSupernova::$sn_mvc[$arrayName][$pageName][$contentName] = $content;
251 251
       }
252 252
     }
Please login to merge, or discard this patch.
includes/includes/flt_page3.inc 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 // @version 1.0
4 4
 // @copyright 2008 by Chlorel for XNova
5 5
 
6
-if(SN_IN_FLEET !== true) {
6
+if (SN_IN_FLEET !== true) {
7 7
   $debug->error("Attempt to call FLEET page mode {$mode} directly - not from fleet.php", 'Forbidden', 403);
8 8
 }
9 9
 
@@ -19,25 +19,25 @@  discard block
 block discarded – undo
19 19
 
20 20
   // Test de coherance de la destination (voir si elle se trouve dans les limites de l'univers connu
21 21
   $errorlist = '';
22
-  if(!$galaxy || $galaxy > $config->game_maxGalaxy || $galaxy < 1) {
22
+  if (!$galaxy || $galaxy > $config->game_maxGalaxy || $galaxy < 1) {
23 23
     $errorlist .= $lang['fl_limit_galaxy'];
24 24
   }
25
-  if(!$system || $system > $config->game_maxSystem || $system < 1) {
25
+  if (!$system || $system > $config->game_maxSystem || $system < 1) {
26 26
     $errorlist .= $lang['fl_limit_system'];
27 27
   }
28
-  if(!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE)) {
28
+  if (!$planet || $planet < 1 || ($planet > $config->game_maxPlanet && $target_mission != MT_EXPLORE)) {
29 29
     $errorlist .= $lang['fl_limit_planet'];
30 30
   }
31
-  if($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) {
31
+  if ($planetrow['galaxy'] == $galaxy && $planetrow['system'] == $system && $planetrow['planet'] == $planet && $planetrow['planet_type'] == $planet_type) {
32 32
     $errorlist .= $lang['fl_ownpl_err'];
33 33
   }
34
-  if(!$planet_type) {
34
+  if (!$planet_type) {
35 35
     $errorlist .= $lang['fl_no_planettype'];
36 36
   }
37
-  if($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) {
37
+  if ($planet_type != PT_PLANET && $planet_type != PT_DEBRIS && $planet_type != PT_MOON) {
38 38
     $errorlist .= $lang['fl_fleet_err_pl'];
39 39
   }
40
-  if(empty($missiontype[$target_mission])) {
40
+  if (empty($missiontype[$target_mission])) {
41 41
     $errorlist .= $lang['fl_bad_mission'];
42 42
   }
43 43
 
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
   $TransDeuterium = max(0, sys_get_param_float('resource2'));
47 47
   $StorageNeeded = $TransMetal + $TransCrystal + $TransDeuterium;
48 48
 
49
-  if(!$StorageNeeded && $target_mission == MT_TRANSPORT) {
49
+  if (!$StorageNeeded && $target_mission == MT_TRANSPORT) {
50 50
     $errorlist .= $lang['fl_noenoughtgoods'];
51 51
   }
52 52
 
@@ -55,41 +55,41 @@  discard block
 block discarded – undo
55 55
   $user = db_user_by_id($user['id'], true);
56 56
   $planetrow = db_planet_by_id($planetrow['id'], true);
57 57
 
58
-  if($target_mission == MT_EXPLORE) {
59
-    if($MaxExpeditions == 0) {
58
+  if ($target_mission == MT_EXPLORE) {
59
+    if ($MaxExpeditions == 0) {
60 60
       $errorlist .= $lang['fl_expe_notech'];
61
-    } elseif($FlyingExpeditions >= $MaxExpeditions) {
61
+    } elseif ($FlyingExpeditions >= $MaxExpeditions) {
62 62
       $errorlist .= $lang['fl_expe_max'];
63 63
     }
64 64
   } else {
65
-    if($TargetPlanet['id_owner']) {
66
-      if($target_mission == MT_COLONIZE) {
65
+    if ($TargetPlanet['id_owner']) {
66
+      if ($target_mission == MT_COLONIZE) {
67 67
         $errorlist .= $lang['fl_colonized'];
68 68
       }
69 69
 
70
-      if($TargetPlanet['id_owner'] == $planetrow['id_owner']) {
71
-        if($target_mission == MT_ATTACK) {
70
+      if ($TargetPlanet['id_owner'] == $planetrow['id_owner']) {
71
+        if ($target_mission == MT_ATTACK) {
72 72
           $errorlist .= $lang['fl_no_self_attack'];
73 73
         }
74 74
 
75
-        if($target_mission == MT_SPY) {
75
+        if ($target_mission == MT_SPY) {
76 76
           $errorlist .= $lang['fl_no_self_spy'];
77 77
         }
78 78
       } else {
79
-        if($target_mission == MT_RELOCATE) {
79
+        if ($target_mission == MT_RELOCATE) {
80 80
           $errorlist .= $lang['fl_only_stay_at_home'];
81 81
         }
82 82
       }
83 83
     } else {
84
-      if($target_mission < MT_COLONIZE) {
84
+      if ($target_mission < MT_COLONIZE) {
85 85
         $errorlist .= $lang['fl_unknow_target'];
86 86
       } else {
87
-        if($target_mission == MT_DESTROY) {
87
+        if ($target_mission == MT_DESTROY) {
88 88
           $errorlist .= $lang['fl_nomoon'];
89 89
         }
90 90
 
91
-        if($target_mission == MT_RECYCLE) {
92
-          if($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) {
91
+        if ($target_mission == MT_RECYCLE) {
92
+          if ($TargetPlanet['debris_metal'] + $TargetPlanet['debris_crystal'] == 0) {
93 93
             $errorlist .= $lang['fl_nodebris'];
94 94
           }
95 95
         }
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
   }
99 99
 
100 100
 
101
-  if(sn_module::$sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) {
101
+  if (sn_module::$sn_module['unit_captain']->manifest['active'] && $captain_id = sys_get_param_id('captain_id')) {
102 102
     $captain = sn_module::$sn_module['unit_captain']->unit_captain_get($planetrow['id']);
103 103
 //      mrc_get_level($user, $planetrow, UNIT_CAPTAIN, true);
104
-    if(!$captain) {
104
+    if (!$captain) {
105 105
       $errorlist .= $lang['module_unit_captain_error_no_captain'];
106
-    } elseif($captain['unit_location_type'] == LOC_PLANET) {
107
-      if($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) {
106
+    } elseif ($captain['unit_location_type'] == LOC_PLANET) {
107
+      if ($target_mission == MT_RELOCATE && ($arriving_captain = mrc_get_level($user, $TargetPlanet, UNIT_CAPTAIN, true))) {
108 108
         $errorlist .= $lang['module_unit_captain_error_captain_already_bound'];
109 109
       }
110 110
     } else {
@@ -112,14 +112,14 @@  discard block
 block discarded – undo
112 112
     }
113 113
   }
114 114
 
115
-  if($errorlist) {
115
+  if ($errorlist) {
116 116
     sn_db_transaction_rollback();
117 117
     message("<span class='error'><ul>{$errorlist}</ul></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, false);
118 118
   }
119 119
 
120 120
   // On verifie s'il y a assez de vaisseaux sur la planete !
121
-  foreach($fleetarray as $Ship => $Count) {
122
-    if($Count > mrc_get_level($user, $planetrow, $Ship)) {
121
+  foreach ($fleetarray as $Ship => $Count) {
122
+    if ($Count > mrc_get_level($user, $planetrow, $Ship)) {
123 123
       message("<span class='error'><b>{$lang['fl_fleet_err']}</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
124 124
     }
125 125
   }
@@ -130,10 +130,10 @@  discard block
 block discarded – undo
130 130
   //But is it acs??
131 131
   //Well all acs fleets must have a fleet code.
132 132
   //The co-ords must be the same as where the acs fleet is going.
133
-  if($fleet_group && sys_get_param_str('acs_target_mr') == "g{$galaxy}s{$system}p{$planet}t{$planet_type}") {
133
+  if ($fleet_group && sys_get_param_str('acs_target_mr') == "g{$galaxy}s{$system}p{$planet}t{$planet_type}") {
134 134
     //ACS attack must exist (if acs fleet has arrived this will also return false (2 checks in 1!!!)
135 135
     $aks = db_acs_get_by_group_id($fleet_group);
136
-    if(!$aks) {
136
+    if (!$aks) {
137 137
       $fleet_group = 0;
138 138
     } else {
139 139
       //Also it must be mission type 2
@@ -144,31 +144,31 @@  discard block
 block discarded – undo
144 144
       $planet = $aks['planet'];
145 145
       $planet_type = $aks['planet_type'];
146 146
     }
147
-  } elseif($target_mission == MT_AKS) {
147
+  } elseif ($target_mission == MT_AKS) {
148 148
     //Check that a failed acs attack isn't being sent, if it is, make it an attack fleet.
149 149
     $target_mission = MT_ATTACK;
150 150
   }
151 151
 
152
-  if($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) {
152
+  if ($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) {
153 153
     $TargetPlanet = array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet, 'id_owner' => 0);
154 154
   }
155 155
   $options = array('fleet_speed_percent' => $speed_percent, 'fleet_group' => $fleet_group, 'resources' => $StorageNeeded);
156 156
   $cant_attack = flt_can_attack($planetrow, $TargetPlanet, $fleetarray, $target_mission, $options);
157 157
 
158
-  if($cant_attack !== ATTACK_ALLOWED) {
158
+  if ($cant_attack !== ATTACK_ALLOWED) {
159 159
     message("<span class='error'><b>{$lang['fl_attack_error'][$cant_attack]}</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 99);
160 160
   }
161 161
 
162 162
   $speed_possible = array(10, 9, 8, 7, 6, 5, 4, 3, 2, 1);
163
-  if(!in_array($speed_percent, $speed_possible)) {
163
+  if (!in_array($speed_percent, $speed_possible)) {
164 164
     message("<span class='error'><b>" . $lang['fl_cheat_speed'] . "</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
165 165
   }
166 166
 
167 167
   $mission_time_in_seconds = 0;
168 168
   $arrival_time = SN_TIME_NOW + $time_to_travel;
169
-  if($target_mission == MT_AKS && $aks) {
169
+  if ($target_mission == MT_AKS && $aks) {
170 170
 //    if($fleet_start_time > $aks['ankunft']) {
171
-    if($arrival_time > $aks['ankunft']) {
171
+    if ($arrival_time > $aks['ankunft']) {
172 172
       message($lang['fl_aks_too_slow'] . 'Fleet arrival: ' . date(FMT_DATE_TIME, $arrival_time) . " AKS arrival: " . date(FMT_DATE_TIME, $aks['ankunft']), $lang['fl_error']);
173 173
     }
174 174
     $group_sync_delta_time = $aks['ankunft'] - $arrival_time;
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
     // Set return time to ACS return time + fleet's time to travel
178 178
     $return_time = $aks['ankunft'] + $time_to_travel;
179 179
   } else {
180
-    if($target_mission == MT_EXPLORE || $target_mission == MT_HOLD) {
180
+    if ($target_mission == MT_EXPLORE || $target_mission == MT_HOLD) {
181 181
       $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : ($target_mission == MT_HOLD ? 12 : 0);
182
-      if($max_duration) {
182
+      if ($max_duration) {
183 183
         $mission_time_in_hours = sys_get_param_id('missiontime');
184
-        if($mission_time_in_hours > $max_duration || $mission_time_in_hours < 1) {
184
+        if ($mission_time_in_hours > $max_duration || $mission_time_in_hours < 1) {
185 185
           $debug->warning('Supplying wrong mission time', 'Hack attempt', 302, array('base_dump' => true));
186 186
           die();
187 187
         }
@@ -195,19 +195,19 @@  discard block
 block discarded – undo
195 195
   $FleetStorage = 0;
196 196
 
197 197
   $db_changeset = array();
198
-  foreach($fleetarray as $Ship => $Count) {
198
+  foreach ($fleetarray as $Ship => $Count) {
199 199
     $FleetStorage += get_unit_param($Ship, P_CAPACITY) * $Count;
200 200
     $db_changeset['unit'][] = sn_db_unit_changeset_prepare($Ship, -$Count, $user, $planetrow['id']);
201 201
   }
202 202
   $FleetStorage -= $consumption;
203 203
 
204
-  if($StorageNeeded > $FleetStorage) {
204
+  if ($StorageNeeded > $FleetStorage) {
205 205
     message("<span class='error'><b>" . $lang['fl_nostoragespa'] . pretty_number($StorageNeeded - $FleetStorage) . "</b></span>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
206 206
   }
207
-  if($planetrow['deuterium'] < $TransDeuterium + $consumption) {
207
+  if ($planetrow['deuterium'] < $TransDeuterium + $consumption) {
208 208
     message("<font color=\"red\"><b>" . $lang['fl_no_deuterium'] . pretty_number($TransDeuterium + $consumption - $planetrow['deuterium']) . "</b></font>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
209 209
   }
210
-  if(($planetrow['metal'] < $TransMetal) || ($planetrow['crystal'] < $TransCrystal)) {
210
+  if (($planetrow['metal'] < $TransMetal) || ($planetrow['crystal'] < $TransCrystal)) {
211 211
     message("<font color=\"red\"><b>" . $lang['fl_no_resources'] . "</b></font>", $lang['fl_error'], 'fleet' . DOT_PHP_EX, 2);
212 212
   }
213 213
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 
238 238
   $template = gettemplate('fleet3', true);
239 239
 
240
-  if(is_array($captain)) {
240
+  if (is_array($captain)) {
241 241
     db_unit_set_by_id($captain['unit_id'], "`unit_location_type` = " . LOC_FLEET . ", `unit_location_id` = {$objFleet->dbId}");
242 242
   }
243 243
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
     'START_LEFT'         => floor($return_time + 1 - SN_TIME_NOW),
251 251
   );
252 252
 
253
-  if(!empty($TargetPlanet)) {
253
+  if (!empty($TargetPlanet)) {
254 254
     $template_route += array(
255 255
       'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']],
256 256
       'END_COORDS'       => uni_render_coordinates($TargetPlanet),
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
   $template->assign_block_vars('fleets', $template_route);
264 264
 
265 265
   $sn_groups_fleet = sn_get_groups('fleet');
266
-  foreach($fleetarray as $ship_id => $ship_count) {
267
-    if(in_array($ship_id, $sn_groups_fleet) && $ship_count) {
266
+  foreach ($fleetarray as $ship_id => $ship_count) {
267
+    if (in_array($ship_id, $sn_groups_fleet) && $ship_count) {
268 268
 //      $ship_base_data = get_ship_data($ship_id, $user);
269 269
       $template->assign_block_vars('fleets.ships', array(
270 270
         'ID'          => $ship_id,
Please login to merge, or discard this patch.
includes/includes/flt_page2.inc 1 patch
Spacing   +10 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     'START_NAME'         => $planetrow['name'],
28 28
   );
29 29
 
30
-  if(!empty($TargetPlanet)) {
30
+  if (!empty($TargetPlanet)) {
31 31
     $template_route += array(
32 32
       'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']],
33 33
       'END_COORDS'       => uni_render_coordinates($TargetPlanet),
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
   $template->assign_block_vars('fleets', $template_route);
39 39
 
40 40
   $sn_groups_fleet = sn_get_groups('fleet');
41
-  foreach($fleetarray as $ship_id => $ship_count) {
42
-    if(in_array($ship_id, $sn_groups_fleet) && $ship_count) {
41
+  foreach ($fleetarray as $ship_id => $ship_count) {
42
+    if (in_array($ship_id, $sn_groups_fleet) && $ship_count) {
43 43
 //      $ship_base_data = get_ship_data($ship_id, $user);
44 44
       $template->assign_block_vars('fleets.ships', array(
45 45
         'ID'          => $ship_id,
@@ -57,11 +57,10 @@  discard block
 block discarded – undo
57 57
     $fleet_capacity += get_unit_param($Ship, P_CAPACITY) * $Count;
58 58
   }
59 59
 
60
-  $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) :
61
-    (isset($missiontype[MT_HOLD]) ? 12 : 0);
62
-  if($max_duration) {
60
+  $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : (isset($missiontype[MT_HOLD]) ? 12 : 0);
61
+  if ($max_duration) {
63 62
     $config_game_speed_expedition = ($target_mission == MT_EXPLORE && $config->game_speed_expedition ? $config->game_speed_expedition : 1);
64
-    for($i = 1; $i <= $max_duration; $i++) {
63
+    for ($i = 1; $i <= $max_duration; $i++) {
65 64
       $template->assign_block_vars('duration', array(
66 65
         'ID' => $i,
67 66
         'TIME' => pretty_time(ceil($i * 3600 / $config_game_speed_expedition)),
@@ -80,7 +79,7 @@  discard block
 block discarded – undo
80 79
   // $TableTitle = uni_render_planet_full($planetrow) . '&nbsp;=&gt;&nbsp;' . uni_render_planet_full($temp);
81 80
 
82 81
   $sn_group_resources = sn_get_groups('resources');
83
-  for($i = 0; $i<3; $i++) {
82
+  for ($i = 0; $i < 3; $i++) {
84 83
     $amount = $planetrow[$sn_group_resources[$i]] - ($i == 2 ? $consumption : 0);
85 84
     $template->assign_block_vars('resources', array(
86 85
       'ID' => $i,
@@ -90,7 +89,7 @@  discard block
 block discarded – undo
90 89
     ));
91 90
   }
92 91
 
93
-  if(sn_module::$sn_module['unit_captain']->manifest['active'] && ($captain = sn_module::$sn_module['unit_captain']->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) {
92
+  if (sn_module::$sn_module['unit_captain']->manifest['active'] && ($captain = sn_module::$sn_module['unit_captain']->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) {
94 93
     $template->assign_vars(array(
95 94
       'CAPTAIN_ID' => $captain['unit_id'],
96 95
       'CAPTAIN_LEVEL' => $captain['captain_level'],
@@ -111,9 +110,9 @@  discard block
 block discarded – undo
111 110
     // 'TableTitle' => $TableTitle,
112 111
 
113 112
     'speedallsmin' => sys_get_param_float('speedallsmin'),
114
-    'speed' => sys_get_param_int('speed') ,
113
+    'speed' => sys_get_param_int('speed'),
115 114
 
116
-    'fleet_group' => sys_get_param_id('fleet_group') ,
115
+    'fleet_group' => sys_get_param_id('fleet_group'),
117 116
     'acs_target_mr' => sys_get_param_str('acs_target_mr'),
118 117
 
119 118
     'MAX_DURATION' => $max_duration,
Please login to merge, or discard this patch.
includes/classes/core_auth.php 2 patches
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -199,18 +199,18 @@  discard block
 block discarded – undo
199 199
     // TODO Хотя тут может получится вечный цикл - ПОДУМАТЬ
200 200
     // TODO Тут же можно пробовать провести попытку слияния аккаунтов - хотя это и очень небезопасно
201 201
 
202
-    if(sys_get_param('login_player_register_logout')) {
202
+    if (sys_get_param('login_player_register_logout')) {
203 203
       $this->logout();
204 204
     }
205 205
 
206 206
     $original_suggest = '';
207 207
     // Смотрим - есть ли у нас данные от пользователя
208
-    if(($player_name_submitted = sys_get_param('submit_player_name'))) {
208
+    if (($player_name_submitted = sys_get_param('submit_player_name'))) {
209 209
       // Попытка регистрации нового игрока из данных, введенных пользователем
210 210
       $this->player_suggested_name = sys_get_param_str_unsafe('player_suggested_name');
211 211
     } else {
212
-      foreach($this->providers_authorised as $provider) {
213
-        if($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5
212
+      foreach ($this->providers_authorised as $provider) {
213
+        if ($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5
214 214
           $original_suggest = $provider->player_name_suggest();
215 215
           break;
216 216
         }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
     }
219 219
 
220 220
     // Если у нас провайдеры не дают имени и пользователь не дал свой вариант - это у нас первый логин в игру
221
-    if(!$this->player_suggested_name) {
221
+    if (!$this->player_suggested_name) {
222 222
       $max_user_id = db_player_get_max_id(); // 4.5
223 223
       // TODO - предлагать имя игрока по локали
224 224
 
@@ -227,15 +227,15 @@  discard block
 block discarded – undo
227 227
         sn_db_transaction_rollback();
228 228
         $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000);
229 229
         sn_db_transaction_start();
230
-      } while(db_player_name_exists($this->player_suggested_name));
230
+      } while (db_player_name_exists($this->player_suggested_name));
231 231
 
232 232
     }
233 233
 
234
-    if($player_name_submitted) {
234
+    if ($player_name_submitted) {
235 235
       $this->register_player_db_create($this->player_suggested_name); // OK 4.5
236
-      if($this->register_status == LOGIN_SUCCESS) {
236
+      if ($this->register_status == LOGIN_SUCCESS) {
237 237
         sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
238
-      } elseif($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
238
+      } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
239 239
         // self::$player_suggested_name .= ' ' . $this->account->account_id;
240 240
       }
241 241
 //      if(self::$login_status != LOGIN_SUCCESS) {
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         : false
260 260
       );
261 261
 
262
-    if($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
262
+    if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
263 263
       $prohibited_characters = array_map(function($value) {
264 264
         return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
265 265
       }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
@@ -293,27 +293,27 @@  discard block
 block discarded – undo
293 293
     global $lang;
294 294
 
295 295
     // !self::$is_init ? self::init() : false;
296
-    if(empty(sn_module::$sn_module_list['auth'])) {
296
+    if (empty(sn_module::$sn_module_list['auth'])) {
297 297
       die('{Не обнаружено ни одного провайдера авторизации в core_auth::login()!}');
298 298
     }
299 299
 
300 300
     !empty($_POST) ? self::flog(dump($_POST, '$_POST')) : false;
301 301
     !empty($_GET) ? self::flog(dump($_GET, '$_GET')) : false;
302
-    !empty($_COOKIE) ? self::flog(dump($_COOKIE,'$_COOKIE')) : false;
302
+    !empty($_COOKIE) ? self::flog(dump($_COOKIE, '$_COOKIE')) : false;
303 303
 
304 304
     $this->auth_reset(); // OK v4.5
305 305
 
306 306
     $this->providers = array();
307
-    foreach(sn_module::$sn_module_list['auth'] as $module_name => $module) {
307
+    foreach (sn_module::$sn_module_list['auth'] as $module_name => $module) {
308 308
       $this->providers[$module->provider_id] = $module;
309 309
     }
310 310
 
311 311
     // $this->providers = array_reverse($this->providers, true); // НИНАДА! СН-аккаунт должен всегда авторизироваться первым!
312 312
 
313
-    foreach($this->providers as $provider_id => $provider) {
313
+    foreach ($this->providers as $provider_id => $provider) {
314 314
       $login_status = $provider->login(); // OK v4.5
315 315
       self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? $lang['sys_login_messages'][$provider->account_login_status] : dump($provider)));
316
-      if($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
316
+      if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
317 317
         $this->providers_authorised[$provider_id] = &$this->providers[$provider_id];
318 318
 
319 319
         $this->user_id_to_provider = array_replace_recursive(
@@ -321,15 +321,15 @@  discard block
 block discarded – undo
321 321
           // static::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5
322 322
           PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5
323 323
         );
324
-      } elseif($login_status != LOGIN_UNDEFINED) {
324
+      } elseif ($login_status != LOGIN_UNDEFINED) {
325 325
         $this->provider_error_list[$provider_id] = $login_status;
326 326
       }
327 327
     }
328 328
 
329
-    if(empty($this->providers_authorised)) {
329
+    if (empty($this->providers_authorised)) {
330 330
       // Ни один аккаунт не авторизирован
331 331
       // Проверяем - есть ли у нас ошибки в аккаунтах?
332
-      if(!empty($this->provider_error_list)) {
332
+      if (!empty($this->provider_error_list)) {
333 333
         // Если есть - выводим их
334 334
         self::$login_status = reset($this->provider_error_list);
335 335
       }
@@ -344,12 +344,12 @@  discard block
 block discarded – undo
344 344
       // В self::$accessible_user_row_list - список доступных игроков для данных аккаунтов с соответствующими записями из таблицы `users`
345 345
 
346 346
       // Остались ли у нас в списке доступные игроки?
347
-      if(empty($this->accessible_user_row_list)) {
347
+      if (empty($this->accessible_user_row_list)) {
348 348
         // Нет ни одного игрока ни на одном авторизированном аккаунте
349 349
         // Надо регать нового игрока
350 350
 
351 351
         // Сейчас происходит процесс регистрации игрока?
352
-        if(!$this->is_player_register) {
352
+        if (!$this->is_player_register) {
353 353
           // Нет - отправляем на процесс регистрации
354 354
           $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id'));
355 355
           sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : ''));
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
         // Да, есть доступные игроки, которые так же прописаны в базе
359 359
         $this->get_active_user(); // 4.5
360 360
 
361
-        if($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) {
361
+        if ($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) {
362 362
           $a_user = db_user_by_id($this->is_impersonating);
363 363
           $this->impersonator_username = $a_user['username'];
364 364
         }
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
 
367 367
         //Прописываем текущего игрока на все авторизированные аккаунты
368 368
         // TODO - ИЛИ ВСЕХ ИГРОКОВ??
369
-        if(empty($this->is_impersonating)) {
370
-          foreach($this->providers_authorised as $provider_id => $provider) {
371
-            if(empty($this->user_id_to_provider[self::$user['id']][$provider_id])) {
369
+        if (empty($this->is_impersonating)) {
370
+          foreach ($this->providers_authorised as $provider_id => $provider) {
371
+            if (empty($this->user_id_to_provider[self::$user['id']][$provider_id])) {
372 372
               // self::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']);
373 373
               PlayerToAccountTranslate::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']);
374 374
               $this->user_id_to_provider[self::$user['id']][$provider_id][$provider->account->account_id] = true;
@@ -378,9 +378,9 @@  discard block
 block discarded – undo
378 378
       }
379 379
     }
380 380
 
381
-    if(empty(self::$user['id'])) {
381
+    if (empty(self::$user['id'])) {
382 382
       self::cookie_set(''); // OK 4.5
383
-    } elseif(self::$user['id'] != $_COOKIE[SN_COOKIE_U]) {
383
+    } elseif (self::$user['id'] != $_COOKIE[SN_COOKIE_U]) {
384 384
       self::cookie_set(self::$user['id']); // OK 4.5
385 385
     }
386 386
 
@@ -399,21 +399,21 @@  discard block
 block discarded – undo
399 399
    */
400 400
   // OK v4.7
401 401
   public function logout($redirect = true) {
402
-    if(!empty($_COOKIE[SN_COOKIE_U_I])) {
402
+    if (!empty($_COOKIE[SN_COOKIE_U_I])) {
403 403
       self::cookie_set($_COOKIE[SN_COOKIE_U_I]);
404 404
       self::cookie_set(0, true);
405 405
       self::$main_provider->logout();
406 406
     } else {
407
-      foreach($this->providers as $provider_name => $provider) {
407
+      foreach ($this->providers as $provider_name => $provider) {
408 408
         $provider->logout();
409 409
       }
410 410
 
411 411
       self::cookie_set(0);
412 412
     }
413 413
 
414
-    if($redirect === true) {
414
+    if ($redirect === true) {
415 415
       sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php'));
416
-    } elseif($redirect !== false) {
416
+    } elseif ($redirect !== false) {
417 417
       sys_redirect($redirect);
418 418
     }
419 419
   }
@@ -424,15 +424,15 @@  discard block
 block discarded – undo
424 424
    * @param $user_selected
425 425
    */
426 426
   public function impersonate($user_selected) {
427
-    if($_COOKIE[SN_COOKIE_U_I]) {
427
+    if ($_COOKIE[SN_COOKIE_U_I]) {
428 428
       die('You already impersonating someone. Go back to living other\'s life! Or clear your cookies and try again'); // TODO: Log it
429 429
     }
430 430
 
431
-    if($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) {
431
+    if ($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) {
432 432
       die('You can\'t impersonate - too low level'); // TODO: Log it
433 433
     }
434 434
 
435
-    if($this->auth_level_max_local <= $user_selected['authlevel']) {
435
+    if ($this->auth_level_max_local <= $user_selected['authlevel']) {
436 436
       die('You can\'t impersonate this account - level is greater or equal to yours'); // TODO: Log it
437 437
     }
438 438
 
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
     $account_translate = reset($account_translate[$user_selected['id']][self::$main_provider->provider_id]);
441 441
     $account_to_impersonate = new Account(self::$main_provider->db);
442 442
     $account_to_impersonate->db_get_by_id($account_translate['provider_account_id']);
443
-    if(!$account_to_impersonate->is_exists) {
443
+    if (!$account_to_impersonate->is_exists) {
444 444
       die('Какая-то ошибка - не могу найти аккаунт для имперсонации'); // TODO: Log it
445 445
     }
446 446
     self::$main_provider->impersonate($account_to_impersonate);
@@ -466,12 +466,12 @@  discard block
 block discarded – undo
466 466
   public function password_check($password_unsafe) {
467 467
     $result = false;
468 468
 
469
-    if(empty($this->providers_authorised)) {
469
+    if (empty($this->providers_authorised)) {
470 470
       // TODO - такого быть не может!
471 471
       self::flog("password_check: Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true);
472 472
     } else {
473
-      foreach($this->providers_authorised as $provider_id => $provider) {
474
-        if($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) {
473
+      foreach ($this->providers_authorised as $provider_id => $provider) {
474
+        if ($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) {
475 475
           $result = $result || $provider->password_check($password_unsafe);
476 476
         }
477 477
       }
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
   public function password_change($old_password_unsafe, $new_password_unsafe) {
493 493
     global $lang;
494 494
 
495
-    if(empty($this->providers_authorised)) {
495
+    if (empty($this->providers_authorised)) {
496 496
       // TODO - такого быть не может!
497 497
       self::flog("Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true);
498 498
       return false;
@@ -505,8 +505,8 @@  discard block
 block discarded – undo
505 505
     $salt_unsafe = self::password_salt_generate();
506 506
 
507 507
     $providers_changed_password = array();
508
-    foreach($this->providers_authorised as $provider_id => $provider) {
509
-      if(
508
+    foreach ($this->providers_authorised as $provider_id => $provider) {
509
+      if (
510 510
         !$provider->is_feature_supported(AUTH_FEATURE_PASSWORD_CHANGE)
511 511
         || !$provider->password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe)
512 512
       ) {
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
       $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id);
519 519
 
520 520
       // Рассылаем уведомления о смене пароля в ЛС
521
-      foreach($account_translation as $user_id => $provider_info) {
521
+      foreach ($account_translation as $user_id => $provider_info) {
522 522
         // TODO - УКазывать тип аккаунта, на котором сменён пароль
523 523
         msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN,
524 524
           $lang['sys_administration'], $lang['sys_login_register_message_title'],
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
       sn_db_transaction_start();
566 566
       // Проверить наличие такого имени в истории имён
567 567
 
568
-      if(db_player_name_exists($player_name_unsafe)) {
568
+      if (db_player_name_exists($player_name_unsafe)) {
569 569
         throw new Exception(REGISTER_ERROR_PLAYER_NAME_EXISTS, ERR_ERROR);
570 570
       }
571 571
 
@@ -573,11 +573,11 @@  discard block
 block discarded – undo
573 573
       $player_language = '';
574 574
       $player_email = '';
575 575
       // TODO - порнография - работа должна происходить над списком аккаунтов, а не только на одном аккаунте...
576
-      foreach($this->providers_authorised as $provider) {
577
-        if(!$player_language && $provider->account->account_language) {
576
+      foreach ($this->providers_authorised as $provider) {
577
+        if (!$player_language && $provider->account->account_language) {
578 578
           $player_language = $provider->account->account_language;
579 579
         }
580
-        if(!$player_email && $provider->account->account_email) {
580
+        if (!$player_email && $provider->account->account_email) {
581 581
           $player_email = $provider->account->account_email;
582 582
         }
583 583
       }
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
       ));
594 594
       // Зарегестрировать на него аккаунты из self::$accounts_authorised
595 595
       $a_user = self::$user;
596
-      foreach($this->providers_authorised as $provider) {
596
+      foreach ($this->providers_authorised as $provider) {
597 597
         // TODO - порнография. Должен быть отдельный класс трансляторов - в т.ч. и кэширующий транслятор
598 598
         // TODO - ну и работа должна происходить над списком аккаунтов, а не только на одном аккаунте...
599 599
         // self::db_translate_register_user($provider->provider_id, $provider->account->account_id, $a_user['id']);
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 
606 606
       sn_db_transaction_commit();
607 607
       $this->register_status = LOGIN_SUCCESS;
608
-    } catch(Exception $e) {
608
+    } catch (Exception $e) {
609 609
       sn_db_transaction_rollback();
610 610
 
611 611
       // Если старое имя занято
@@ -624,10 +624,10 @@  discard block
 block discarded – undo
624 624
     // Пробиваем все ИД игроков по базе - есть ли вообще такие записи
625 625
     // Вообще-то это не особо нужно - у нас по определению стоят констраинты
626 626
     // Зато так мы узнаем максимальный authlevel, проверим права имперсонейта и вытащим все записи юзеров
627
-    foreach($this->user_id_to_provider as $user_id => $cork) {
627
+    foreach ($this->user_id_to_provider as $user_id => $cork) {
628 628
       $user = db_user_by_id($user_id);
629 629
       // Если записи игрока в БД не существует?
630
-      if(empty($user['id'])) {
630
+      if (empty($user['id'])) {
631 631
         // Удаляем этого и переходим к следующему
632 632
         unset($this->user_id_to_provider[$user_id]);
633 633
         // Де-регистрируем игрока из таблицы трансляции игроков
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
   // OK v4.5
649 649
   protected function get_active_user() {
650 650
     // Проверяем куку "текущего игрока" из браузера
651
-    if(
651
+    if (
652 652
       // Кука не пустая
653 653
       ($_COOKIE[SN_COOKIE_U] = trim($_COOKIE[SN_COOKIE_U])) && !empty($_COOKIE[SN_COOKIE_U])
654 654
       // И в куке находится ID
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
     }
674 674
 
675 675
     // В куке нет валидного ИД записи игрока, доступной с текущих аккаунтов
676
-    if(empty(self::$user['id'])) {
676
+    if (empty(self::$user['id'])) {
677 677
       // Берем первого из доступных
678 678
       // TODO - default_user
679 679
       self::$user = reset($this->accessible_user_row_list);
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 
698 698
     $result = array();
699 699
 
700
-    if($user_id && empty($this->is_impersonating)) {
700
+    if ($user_id && empty($this->is_impersonating)) {
701 701
       // self::db_counter_insert();
702 702
       self::$device->db_counter_insert($user_id);
703 703
 
@@ -705,12 +705,12 @@  discard block
 block discarded – undo
705 705
 
706 706
       sys_user_options_unpack($user);
707 707
 
708
-      if($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) {
708
+      if ($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) {
709 709
         $user['banaday'] = 0;
710 710
         $user['vacation'] = SN_TIME_NOW;
711 711
       }
712 712
 
713
-      $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip'];
713
+      $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip'];
714 714
       $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain'];
715 715
 
716 716
       $result[F_BANNED_STATUS] = $user['banaday'];
@@ -724,9 +724,9 @@  discard block
 block discarded – undo
724 724
       );
725 725
     }
726 726
 
727
-    if($extra = $config->security_ban_extra) {
727
+    if ($extra = $config->security_ban_extra) {
728 728
       $extra = explode(',', $extra);
729
-      array_walk($extra,'trim');
729
+      array_walk($extra, 'trim');
730 730
       in_array(self::$device->device_id, $extra) and die();
731 731
     }
732 732
 
@@ -762,21 +762,21 @@  discard block
 block discarded – undo
762 762
   protected function register_player_name_validate($player_name_unsafe) {
763 763
     // TODO - переделать под RAW-строки
764 764
     // Если имя игрока пустое - NO GO!
765
-    if(trim($player_name_unsafe) == '') {
765
+    if (trim($player_name_unsafe) == '') {
766 766
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_EMPTY, ERR_ERROR);
767 767
     }
768 768
     // Проверяем, что бы в начале и конце не было пустых символов
769
-    if($player_name_unsafe != trim($player_name_unsafe)) {
769
+    if ($player_name_unsafe != trim($player_name_unsafe)) {
770 770
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_TRIMMED, ERR_ERROR);
771 771
     }
772 772
     // Если логин имеет запрещенные символы - NO GO!
773
-    if(strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
773
+    if (strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
774 774
       // TODO - выдавать в сообщение об ошибке список запрещенных символов
775 775
       // TODO - заранее извещать игрока, какие символы являются запрещенными
776 776
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_RESTRICTED_CHARACTERS, ERR_ERROR);
777 777
     }
778 778
     // Если логин меньше минимальной длины - NO GO!
779
-    if(strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) {
779
+    if (strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) {
780 780
       // TODO - выдавать в сообщение об ошибке минимальную длину имени игрока
781 781
       // TODO - заранее извещать игрока, какая минимальная и максимальная длина имени
782 782
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_SHORT, ERR_ERROR);
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
   }
835 835
 
836 836
   protected static function flog($message, $die = false) {
837
-    if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
837
+    if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
838 838
       return;
839 839
     }
840 840
     list($called, $caller) = debug_backtrace(false);
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
     $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false;
848 848
 
849 849
     classSupernova::log_file("$message - $caller_name");
850
-    if($die) {
850
+    if ($die) {
851 851
       // pdump($caller);
852 852
       // pdump(debug_backtrace(false));
853 853
       $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
Please login to merge, or discard this patch.
Doc Comments   +7 added lines, -1 removed lines patch added patch discarded remove patch
@@ -286,7 +286,6 @@  discard block
 block discarded – undo
286 286
   /**
287 287
    * Функция пытается залогиниться по всем известным провайдерам
288 288
    *
289
-   * @param null $result
290 289
    */
291 290
   public function login() {
292 291
     if(empty(sn_module::$sn_module_list['auth'])) {
@@ -823,10 +822,17 @@  discard block
 block discarded – undo
823 822
 
824 823
   // OK v4.5
825 824
   // TODO - REMEMBER_ME
825
+
826
+  /**
827
+   * @param integer $period
828
+   */
826 829
   protected static function cookie_set($value, $impersonate = false, $period = null) {
827 830
     sn_setcookie($impersonate ? SN_COOKIE_U_I : SN_COOKIE_U, $value, $period === null ? SN_TIME_NOW + PERIOD_YEAR : $period, SN_ROOT_RELATIVE);
828 831
   }
829 832
 
833
+  /**
834
+   * @param string $message
835
+   */
830 836
   protected static function flog($message, $die = false) {
831 837
     if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
832 838
       return;
Please login to merge, or discard this patch.