Completed
Push — work-fleets ( 4d76fa...c97fe0 )
by SuperNova.WS
05:17
created
includes/classes/UBE/UBEFleet.php 2 patches
Doc Comments   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
   }
151 151
 
152 152
   /**
153
-   * @param $ube_report_id
153
+   * @param integer $ube_report_id
154 154
    *
155 155
    * @return array
156 156
    *
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 
289 289
 
290 290
   /**
291
-   * @param $ube_report_id
291
+   * @param integer $ube_report_id
292 292
    *
293 293
    * @return array
294 294
    */
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
   // Рендерит таблицу общего результата боя
337 337
   /**
338 338
    * @param $array
339
-   * @param $lang_header_index
339
+   * @param string $lang_header_index
340 340
    *
341 341
    * @return array
342 342
    */
@@ -362,6 +362,9 @@  discard block
 block discarded – undo
362 362
   }
363 363
 
364 364
 
365
+  /**
366
+   * @param integer $ube_report_id
367
+   */
365 368
   public function sql_generate_outcome_unit_array(&$sql_perform_report_unit, $ube_report_id) {
366 369
     $fleet_id = $this->db_id;
367 370
 
@@ -468,6 +471,10 @@  discard block
 block discarded – undo
468 471
     $this->fleet_capacity -= $fleet_total_resources;
469 472
   }
470 473
 
474
+  /**
475
+   * @param integer $is_small_fleet_recce
476
+   * @param integer $reapers_status
477
+   */
471 478
   public function db_save_combat_result_fleet($is_small_fleet_recce, $reapers_status) {
472 479
     $ship_count_initial = $this->unit_list->unitsCount();
473 480
     $ship_count_lost = $this->unit_list->unitCountLost();
@@ -535,7 +542,7 @@  discard block
 block discarded – undo
535 542
 
536 543
   /**
537 544
    * @param UBEFleetList $fleet_list
538
-   * @param              $is_simulator
545
+   * @param              boolean $is_simulator
539 546
    *
540 547
    * @version 2016-02-25 23:42:45 41a4.68
541 548
    */
Please login to merge, or discard this patch.
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -162,20 +162,20 @@  discard block
 block discarded – undo
162 162
       $this->owner_id,
163 163
       $this->db_id,
164 164
 
165
-      (float)$this->UBE_PLANET[PLANET_ID],
166
-      "'" . db_escape($this->UBE_PLANET[PLANET_NAME]) . "'",
167
-      (int)$this->UBE_PLANET[PLANET_GALAXY],
168
-      (int)$this->UBE_PLANET[PLANET_SYSTEM],
169
-      (int)$this->UBE_PLANET[PLANET_PLANET],
170
-      (int)$this->UBE_PLANET[PLANET_TYPE],
171
-
172
-      (float)$this->resource_list[RES_METAL],
173
-      (float)$this->resource_list[RES_CRYSTAL],
174
-      (float)$this->resource_list[RES_DEUTERIUM],
175
-
176
-      (float)$this->fleet_bonus->calcBonus(P_ATTACK),
177
-      (float)$this->fleet_bonus->calcBonus(P_SHIELD),
178
-      (float)$this->fleet_bonus->calcBonus(P_ARMOR),
165
+      (float) $this->UBE_PLANET[PLANET_ID],
166
+      "'".db_escape($this->UBE_PLANET[PLANET_NAME])."'",
167
+      (int) $this->UBE_PLANET[PLANET_GALAXY],
168
+      (int) $this->UBE_PLANET[PLANET_SYSTEM],
169
+      (int) $this->UBE_PLANET[PLANET_PLANET],
170
+      (int) $this->UBE_PLANET[PLANET_TYPE],
171
+
172
+      (float) $this->resource_list[RES_METAL],
173
+      (float) $this->resource_list[RES_CRYSTAL],
174
+      (float) $this->resource_list[RES_DEUTERIUM],
175
+
176
+      (float) $this->fleet_bonus->calcBonus(P_ATTACK),
177
+      (float) $this->fleet_bonus->calcBonus(P_SHIELD),
178
+      (float) $this->fleet_bonus->calcBonus(P_ARMOR),
179 179
     );
180 180
   }
181 181
 
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
     $this->group_id = $objFleet->group_id;
191 191
 
192 192
     $fleet_unit_list = $objFleet->shipsGetArray();
193
-    foreach($fleet_unit_list as $unit_id => $unit_count) {
194
-      if(!$unit_count) {
193
+    foreach ($fleet_unit_list as $unit_id => $unit_count) {
194
+      if (!$unit_count) {
195 195
         continue;
196 196
       }
197 197
 
198 198
       $unit_type = get_unit_param($unit_id, P_UNIT_TYPE);
199
-      if($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
199
+      if ($unit_type == UNIT_SHIPS || $unit_type == UNIT_DEFENCE) {
200 200
         $this->unit_list->unitAdjustCount($unit_id, $unit_count);
201 201
       }
202 202
     }
@@ -232,13 +232,13 @@  discard block
 block discarded – undo
232 232
 //      }
233 233
 //    }
234 234
 
235
-    foreach($sn_group_combat as $unit_id) {
236
-      if($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) {
235
+    foreach ($sn_group_combat as $unit_id) {
236
+      if ($unit_count = mrc_get_level($player_db_row, $planet_row, $unit_id)) {
237 237
         $this->unit_list->unitAdjustCount($unit_id, $unit_count);
238 238
       }
239 239
     }
240 240
 
241
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
241
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
242 242
       $this->resource_list[$resource_id] = floor(mrc_get_level($player_db_row, $planet_row, $resource_id));
243 243
     }
244 244
 
@@ -297,27 +297,27 @@  discard block
 block discarded – undo
297 297
       $ube_report_id,
298 298
       $this->db_id,
299 299
 
300
-      (float)$this->resources_lost_on_units[RES_METAL],
301
-      (float)$this->resources_lost_on_units[RES_CRYSTAL],
302
-      (float)$this->resources_lost_on_units[RES_DEUTERIUM],
303
-      (float)$this->cargo_dropped[RES_METAL],
304
-      (float)$this->cargo_dropped[RES_CRYSTAL],
305
-      (float)$this->cargo_dropped[RES_DEUTERIUM],
306
-      (float)$this->resources_looted[RES_METAL],
307
-      (float)$this->resources_looted[RES_CRYSTAL],
308
-      (float)$this->resources_looted[RES_DEUTERIUM],
309
-      (float)$this->resources_lost_in_metal[RES_METAL],
300
+      (float) $this->resources_lost_on_units[RES_METAL],
301
+      (float) $this->resources_lost_on_units[RES_CRYSTAL],
302
+      (float) $this->resources_lost_on_units[RES_DEUTERIUM],
303
+      (float) $this->cargo_dropped[RES_METAL],
304
+      (float) $this->cargo_dropped[RES_CRYSTAL],
305
+      (float) $this->cargo_dropped[RES_DEUTERIUM],
306
+      (float) $this->resources_looted[RES_METAL],
307
+      (float) $this->resources_looted[RES_CRYSTAL],
308
+      (float) $this->resources_looted[RES_DEUTERIUM],
309
+      (float) $this->resources_lost_in_metal[RES_METAL],
310 310
     );
311 311
   }
312 312
 
313 313
   public function report_render_outcome_side_fleet() {
314 314
     $UBE_DEFENCE_RESTORE = array();
315 315
     $UBE_UNITS_LOST = array();
316
-    foreach($this->unit_list->_container as $UBEUnit) {
317
-      if($UBEUnit->units_restored) {
316
+    foreach ($this->unit_list->_container as $UBEUnit) {
317
+      if ($UBEUnit->units_restored) {
318 318
         $UBE_DEFENCE_RESTORE[$UBEUnit->unitId] = $UBEUnit->units_restored;
319 319
       }
320
-      if($UBEUnit->units_lost) {
320
+      if ($UBEUnit->units_lost) {
321 321
         $UBE_UNITS_LOST[$UBEUnit->unitId] = $UBEUnit->units_lost;
322 322
       }
323 323
     }
@@ -342,16 +342,16 @@  discard block
 block discarded – undo
342 342
    */
343 343
   protected function report_render_outcome_side_fleet_line(&$array, $lang_header_index) {
344 344
     $result = array();
345
-    if(!empty($array)) {
346
-      foreach($array as $unit_id => $unit_count) {
347
-        if($unit_count) {
345
+    if (!empty($array)) {
346
+      foreach ($array as $unit_id => $unit_count) {
347
+        if ($unit_count) {
348 348
           $result[] = array(
349 349
             'NAME' => classLocale::$lang['tech'][$unit_id],
350 350
             'LOSS' => pretty_number($unit_count),
351 351
           );
352 352
         }
353 353
       }
354
-      if($lang_header_index && count($result)) {
354
+      if ($lang_header_index && count($result)) {
355 355
         array_unshift($result, array('NAME' => classLocale::$lang[$lang_header_index]));
356 356
       }
357 357
     }
@@ -364,16 +364,16 @@  discard block
 block discarded – undo
364 364
     $fleet_id = $this->db_id;
365 365
 
366 366
     $unit_sort_order = 0;
367
-    foreach($this->unit_list->_container as $UBEUnit) {
368
-      if($UBEUnit->units_lost || $UBEUnit->units_restored) {
367
+    foreach ($this->unit_list->_container as $UBEUnit) {
368
+      if ($UBEUnit->units_lost || $UBEUnit->units_restored) {
369 369
         $unit_sort_order++;
370 370
         $sql_perform_report_unit[] = array(
371 371
           $ube_report_id,
372 372
           $fleet_id,
373 373
 
374 374
           $UBEUnit->unitId,
375
-          (float)$UBEUnit->units_restored,
376
-          (float)$UBEUnit->units_lost,
375
+          (float) $UBEUnit->units_restored,
376
+          (float) $UBEUnit->units_lost,
377 377
 
378 378
           $unit_sort_order,
379 379
         );
@@ -389,9 +389,9 @@  discard block
 block discarded – undo
389 389
   function ube_combat_result_calculate_resources() {
390 390
     $resource_delta_fleet = array();
391 391
     // Если во флоте остались юниты или это планета - генерируем изменение ресурсов
392
-    foreach(sn_get_groups('resources_loot') as $resource_id) {
393
-      $resource_change = (float)$this->resources_looted[$resource_id] + (float)$this->cargo_dropped[$resource_id];
394
-      if($resource_change) {
392
+    foreach (sn_get_groups('resources_loot') as $resource_id) {
393
+      $resource_change = (float) $this->resources_looted[$resource_id] + (float) $this->cargo_dropped[$resource_id];
394
+      if ($resource_change) {
395 395
         $resource_delta_fleet[$resource_id] = -($resource_change);
396 396
       }
397 397
     }
@@ -424,12 +424,12 @@  discard block
 block discarded – undo
424 424
     );
425 425
 
426 426
     $this->fleet_capacity = 0;
427
-    foreach($this->unit_list->_container as $UBEUnit) {
427
+    foreach ($this->unit_list->_container as $UBEUnit) {
428 428
       $this->fleet_capacity += $UBEUnit->capacity * $UBEUnit->getCount();
429 429
 
430
-      if($UBEUnit->units_lost) {
431
-        foreach($UBEUnit->price as $resource_id => $unit_resource_price) {
432
-          if(!$unit_resource_price) {
430
+      if ($UBEUnit->units_lost) {
431
+        foreach ($UBEUnit->price as $resource_id => $unit_resource_price) {
432
+          if (!$unit_resource_price) {
433 433
             continue;
434 434
           }
435 435
 
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
           $this->resources_lost_on_units[$resource_id] += $resources_lost;
438 438
           // Если это корабль - прибавляем потери к обломкам на орбите
439 439
           // TODO - опция выбрасывания обороны в обломки
440
-          if($UBEUnit->getType() == UNIT_SHIPS) {
440
+          if ($UBEUnit->getType() == UNIT_SHIPS) {
441 441
             $this->resources_lost_on_ships[$resource_id] += $resources_lost;
442 442
           }
443 443
         }
@@ -449,11 +449,11 @@  discard block
 block discarded – undo
449 449
 
450 450
     // Если емкость трюмов меньше количество ресурсов - часть ресов выбрасываем нахуй
451 451
     // На планете ($fleet_id = 0) ресурсы в космос не выбрасываются
452
-    if($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) {
452
+    if ($this->db_id != 0 && $this->fleet_capacity < $fleet_total_resources) {
453 453
       $drop_share = 1 - $this->fleet_capacity / $fleet_total_resources; // Какая часть ресурсов выброшена
454
-      foreach($this->resource_list as $resource_id => &$resource_amount) {
454
+      foreach ($this->resource_list as $resource_id => &$resource_amount) {
455 455
         // Не просчитываем ресурсы, которых нет на борту кораблей флота
456
-        if(!$resource_amount) {
456
+        if (!$resource_amount) {
457 457
           continue;
458 458
         }
459 459
 
@@ -474,19 +474,19 @@  discard block
 block discarded – undo
474 474
     $objFleet2->setDbId($this->db_id);
475 475
 
476 476
     // Если это была миссия Уничтожения И звезда смерти взорвалась И мы работаем с аттакерами - значит все аттакеры умерли
477
-    if($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) {
477
+    if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER && $reapers_status == UBE_MOON_REAPERS_DIED) {
478 478
       $objFleet2->dbDelete();
479
-    } elseif($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial ||
479
+    } elseif ($ship_count_initial == 0) { // $ship_count_lost == $ship_count_initial ||
480 480
       $objFleet2->dbDelete();
481 481
     } else {
482
-      if($ship_count_lost) {
482
+      if ($ship_count_lost) {
483 483
         // Просматриваем результаты изменения флотов
484
-        foreach($this->unit_list->_container as $UBEUnit) {
484
+        foreach ($this->unit_list->_container as $UBEUnit) {
485 485
           // Перебираем аутком на случай восстановления юнитов
486 486
 //          if(($units_left = $UBEUnit->getCount() - (float)$UBEUnit->units_lost) > 0) {
487 487
 //            $fleet_real_array[$UBEUnit->unitId] = $units_left;
488 488
 //          };
489
-          if(floatval($UBEUnit->units_lost) != 0) {
489
+          if (floatval($UBEUnit->units_lost) != 0) {
490 490
             $objFleet2->shipAdjustCount($UBEUnit->unitId, floatval($UBEUnit->units_lost));
491 491
           };
492 492
         }
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
       $objFleet2->resourcesAdjust($resource_delta_fleet);
497 497
 
498 498
       // Если защитник и не РМФ - отправляем флот назад
499
-      if($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) {
499
+      if ($this->is_attacker == UBE_PLAYER_IS_ATTACKER || ($this->is_attacker == UBE_PLAYER_IS_DEFENDER && !$is_small_fleet_recce)) {
500 500
         $objFleet2->markReturned();
501 501
       }
502 502
       $objFleet2->dbSave();
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
   public function calculate_unit_partial_data(UBEASA $side_ASA) {
527 527
     $this->fleet_share_of_side_armor = $this->total_stats[P_ARMOR] / $side_ASA->getArmor();
528 528
 
529
-    foreach($this->unit_list->_container as $UBEUnit) {
529
+    foreach ($this->unit_list->_container as $UBEUnit) {
530 530
       $UBEUnit->share_of_side_armor = $UBEUnit->pool_armor / $side_ASA->getArmor();
531 531
     }
532 532
   }
@@ -538,9 +538,9 @@  discard block
 block discarded – undo
538 538
    * @version 2016-02-25 23:42:45 41a4.68
539 539
    */
540 540
   public function attack_fleets(UBEFleetList $fleet_list, $is_simulator) {
541
-    foreach($fleet_list->_container as $defending_fleet) {
541
+    foreach ($fleet_list->_container as $defending_fleet) {
542 542
       // Не атакуются флоты на своей стороне
543
-      if($this->is_attacker == $defending_fleet->is_attacker) {
543
+      if ($this->is_attacker == $defending_fleet->is_attacker) {
544 544
         continue;
545 545
       }
546 546
       $this->attack_fleet($defending_fleet, $is_simulator);
@@ -556,12 +556,12 @@  discard block
 block discarded – undo
556 556
   public function attack_fleet(UBEFleet $defending_fleet, $is_simulator) {
557 557
     UBEDebug::unit_dump_header();
558 558
 
559
-    foreach($this->unit_list->_container as $attacking_unit_pool) {
559
+    foreach ($this->unit_list->_container as $attacking_unit_pool) {
560 560
       UBEDebug::unit_dump($attacking_unit_pool, 'attacker');
561 561
 
562 562
       // if($attack_unit_count <= 0) continue; // TODO: Это пока нельзя включать - вот если будут "боевые порядки юнитов..."
563
-      foreach($defending_fleet->unit_list->_container as $defending_unit_pool) {
564
-        if($defending_unit_pool->isEmpty()) {
563
+      foreach ($defending_fleet->unit_list->_container as $defending_unit_pool) {
564
+        if ($defending_unit_pool->isEmpty()) {
565 565
           continue;
566 566
         }
567 567
 
Please login to merge, or discard this patch.
includes/includes/flt_flying_fleet_handler2.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
  *
11 11
  * @param Fleet $objFleet
12 12
  * @param bool  $start
13
- * @param null  $result
13
+ * @param integer  $result
14 14
  *
15 15
  * @return mixed
16 16
  */
Please login to merge, or discard this patch.
Spacing   +24 added lines, -28 removed lines patch added patch discarded remove patch
@@ -19,15 +19,11 @@  discard block
 block discarded – undo
19 19
 // ------------------------------------------------------------------
20 20
 function flt_flyingFleetsSort($a, $b) {
21 21
   // Сравниваем время флотов - кто раньше, тот и первый обрабатывается
22
-  return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 :
23
-    // Если время - одинаковое, сравниваем события флотов
22
+  return $a['fleet_time'] > $b['fleet_time'] ? 1 : ($a['fleet_time'] < $b['fleet_time'] ? -1 : // Если время - одинаковое, сравниваем события флотов
24 23
     // Если события - одинаковые, то флоты равны
25
-    ($a['fleet_event'] == $b['fleet_event'] ? 0 :
26
-      // Если события разные - первыми считаем прибывающие флоты
27
-      ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 :
28
-        // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
29
-        ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 :
30
-          // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
24
+    ($a['fleet_event'] == $b['fleet_event'] ? 0 : // Если события разные - первыми считаем прибывающие флоты
25
+      ($a['fleet_event'] == EVENT_FLT_ARRIVE ? 1 : ($b['fleet_event'] == EVENT_FLT_ARRIVE ? -1 : // Если нет прибывающих флотов - дальше считаем флоты, которые закончили миссию
26
+        ($a['fleet_event'] == EVENT_FLT_ACOMPLISH ? 1 : ($b['fleet_event'] == EVENT_FLT_ACOMPLISH ? -1 : // Если нет флотов, закончивших задание - остались возвращающиеся флоты, которые равны между собой
31 27
           // TODO: Добавить еще проверку по ID флота и/или времени запуска - что бы обсчитывать их в порядке запуска
32 28
           (
33 29
           0 // Вообще сюда доходить не должно - будет отсекаться на равенстве событий
@@ -41,11 +37,11 @@  discard block
 block discarded – undo
41 37
 function log_file($msg) {
42 38
   static $handler;
43 39
 
44
-  if(!$handler) {
40
+  if (!$handler) {
45 41
     $handler = fopen('event.log', 'a+');
46 42
   }
47 43
 
48
-  fwrite($handler, date(FMT_DATE_TIME_SQL, time()) . ' ' . $msg . "\r\n");
44
+  fwrite($handler, date(FMT_DATE_TIME_SQL, time()).' '.$msg."\r\n");
49 45
 }
50 46
 
51 47
 // ------------------------------------------------------------------
@@ -80,12 +76,12 @@  discard block
 block discarded – undo
80 76
 
81 77
   */
82 78
 
83
-  if(classSupernova::$config->game_disable != GAME_DISABLE_NONE || $skip_fleet_update) {
79
+  if (classSupernova::$config->game_disable != GAME_DISABLE_NONE || $skip_fleet_update) {
84 80
     return;
85 81
   }
86 82
 
87 83
   sn_db_transaction_start();
88
-  if(classSupernova::$config->db_loadItem('game_disable') != GAME_DISABLE_NONE || SN_TIME_NOW - strtotime(classSupernova::$config->db_loadItem('fleet_update_last')) <= classSupernova::$config->fleet_update_interval) {
84
+  if (classSupernova::$config->db_loadItem('game_disable') != GAME_DISABLE_NONE || SN_TIME_NOW - strtotime(classSupernova::$config->db_loadItem('fleet_update_last')) <= classSupernova::$config->fleet_update_interval) {
89 85
     sn_db_transaction_rollback();
90 86
 
91 87
     return;
@@ -93,14 +89,14 @@  discard block
 block discarded – undo
93 89
 
94 90
 
95 91
   // Watchdog timer
96
-  if(classSupernova::$config->db_loadItem('fleet_update_lock')) {
97
-    if(defined('DEBUG_FLYING_FLEETS')) {
92
+  if (classSupernova::$config->db_loadItem('fleet_update_lock')) {
93
+    if (defined('DEBUG_FLYING_FLEETS')) {
98 94
       $random = 0;
99 95
     } else {
100 96
       $random = mt_rand(240, 300);
101 97
     }
102 98
 
103
-    if(SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_lock) <= $random) {
99
+    if (SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_lock) <= $random) {
104 100
       sn_db_transaction_rollback();
105 101
 
106 102
       return;
@@ -124,11 +120,11 @@  discard block
 block discarded – undo
124 120
   $missions_used = array();
125 121
 
126 122
   $objFleetList = FleetList::dbGetFleetListCurrentTick();
127
-  foreach($objFleetList->_container as $objFleet) {
123
+  foreach ($objFleetList->_container as $objFleet) {
128 124
     set_time_limit(15);
129 125
     // TODO - Унифицировать код с темплейтным разбором эвентов на планете!
130 126
     $missions_used[$objFleet->mission_type] = 1;
131
-    if($objFleet->time_arrive_to_target <= SN_TIME_NOW && !$objFleet->isReturning()) {
127
+    if ($objFleet->time_arrive_to_target <= SN_TIME_NOW && !$objFleet->isReturning()) {
132 128
       $fleet_event_list[] = array(
133 129
         'object'      => $objFleet,
134 130
         'fleet_time'  => $objFleet->time_arrive_to_target,
@@ -136,7 +132,7 @@  discard block
 block discarded – undo
136 132
       );
137 133
     }
138 134
 
139
-    if($objFleet->time_mission_job_complete > 0 && $objFleet->time_mission_job_complete <= SN_TIME_NOW && !$objFleet->isReturning()) {
135
+    if ($objFleet->time_mission_job_complete > 0 && $objFleet->time_mission_job_complete <= SN_TIME_NOW && !$objFleet->isReturning()) {
140 136
       $fleet_event_list[] = array(
141 137
         'object'      => $objFleet,
142 138
         'fleet_time'  => $objFleet->time_mission_job_complete,
@@ -144,7 +140,7 @@  discard block
 block discarded – undo
144 140
       );
145 141
     }
146 142
 
147
-    if($objFleet->time_return_to_source <= SN_TIME_NOW) {
143
+    if ($objFleet->time_return_to_source <= SN_TIME_NOW) {
148 144
       $fleet_event_list[] = array(
149 145
         'object'      => $objFleet,
150 146
         'fleet_time'  => $objFleet->time_return_to_source,
@@ -170,17 +166,17 @@  discard block
 block discarded – undo
170 166
 //    MT_MISSILE => 'flt_mission_missile.php',
171 167
     MT_EXPLORE   => 'flt_mission_explore',
172 168
   );
173
-  foreach($missions_used as $mission_id => $cork) {
174
-    require_once(SN_ROOT_PHYSICAL . "includes/includes/{$mission_files[$mission_id]}" . DOT_PHP_EX);
169
+  foreach ($missions_used as $mission_id => $cork) {
170
+    require_once(SN_ROOT_PHYSICAL."includes/includes/{$mission_files[$mission_id]}".DOT_PHP_EX);
175 171
   }
176 172
 
177 173
 //log_file('Обработка миссий');
178 174
   $sn_groups_mission = sn_get_groups('missions');
179
-  foreach($fleet_event_list as $fleet_event) {
175
+  foreach ($fleet_event_list as $fleet_event) {
180 176
     // TODO: Указатель тут потом сделать
181 177
     // TODO: СЕЙЧАС НАДО ПРОВЕРЯТЬ ПО БАЗЕ - А ЖИВОЙ ЛИ ФЛОТ?!
182 178
     $fleet_row = $fleet_event['fleet_row'];
183
-    if(empty($fleet_event['object'])) {
179
+    if (empty($fleet_event['object'])) {
184 180
       // Fleet was destroyed in course of previous actions
185 181
       continue;
186 182
     }
@@ -205,20 +201,20 @@  discard block
 block discarded – undo
205 201
 
206 202
     $objFleet->dbLoad($objFleet->dbId);
207 203
 
208
-    if(!$objFleet->dbId) {
204
+    if (!$objFleet->dbId) {
209 205
       // Fleet was destroyed in course of previous actions
210 206
       sn_db_transaction_commit();
211 207
       continue;
212 208
     }
213 209
 
214
-    if($fleet_event['fleet_event'] == EVENT_FLT_RETURN) {
210
+    if ($fleet_event['fleet_event'] == EVENT_FLT_RETURN) {
215 211
       // Fleet returns to planet
216 212
       $objFleet->shipsLand(true);
217 213
       sn_db_transaction_commit();
218 214
       continue;
219 215
     }
220 216
 
221
-    if($fleet_event['fleet_event'] == EVENT_FLT_ARRIVE && $objFleet->isReturning()) {
217
+    if ($fleet_event['fleet_event'] == EVENT_FLT_ARRIVE && $objFleet->isReturning()) {
222 218
       // При событии EVENT_FLT_ARRIVE флот всегда должен иметь fleet_mess == 0
223 219
       // В противном случае это означает, что флот уже был обработан ранее - например, при САБе
224 220
       sn_db_transaction_commit();
@@ -238,13 +234,13 @@  discard block
 block discarded – undo
238 234
     $objMission->dst_planet = $mission_data['dst_planet'] ? db_planet_by_vector($objFleet->target_coordinates_typed(), '', true, '`id`, `id_owner`, `name`') : null;
239 235
     $objMission->fleet_event = $fleet_event['fleet_event'];
240 236
 
241
-    if($objMission->dst_planet && $objMission->dst_planet['id_owner']) {
237
+    if ($objMission->dst_planet && $objMission->dst_planet['id_owner']) {
242 238
       $update_result = sys_o_get_updated($objMission->dst_planet['id_owner'], $objMission->dst_planet['id'], $objFleet->time_arrive_to_target);
243 239
       $objMission->dst_user = !empty($objMission->dst_user) ? $update_result['user'] : null;
244 240
       $objMission->dst_planet = $update_result['planet'];
245 241
     }
246 242
 
247
-    switch($objFleet->mission_type) {
243
+    switch ($objFleet->mission_type) {
248 244
       // Для боевых атак нужно обновлять по САБу и по холду - таки надо возвращать данные из обработчика миссий!
249 245
       case MT_ACS:
250 246
       case MT_ATTACK:
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   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
   }
74 74
 
75 75
   function loadModuleRootConfig() {
76
-    require SN_ROOT_PHYSICAL . 'config.php';
76
+    require SN_ROOT_PHYSICAL.'config.php';
77 77
 
78
-    $module_config_array = get_class($this) . '_config';
79
-    if(!empty($$module_config_array) && is_array($$module_config_array)) {
78
+    $module_config_array = get_class($this).'_config';
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,17 +94,17 @@  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
-        $module_config_array = $class_module_name . '_config';
107
+        $module_config_array = $class_module_name.'_config';
108 108
         $this->config = $$module_config_array;
109 109
       }
110 110
     }
@@ -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) : false;
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.
messages.php 2 patches
Switch Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -48,106 +48,106 @@  discard block
 block discarded – undo
48 48
 }
49 49
 
50 50
 switch($mode) {
51
-  case 'write':
52
-    $error_list = array();
53
-    $template = gettemplate('msg_message_compose', true);
51
+    case 'write':
52
+      $error_list = array();
53
+      $template = gettemplate('msg_message_compose', true);
54 54
 
55
-    $recipient_name = sys_get_param_str_unsafe('recipient_name');
56
-    if($recipient_name) {
57
-      $recipient_row = db_user_by_username($recipient_name);
58
-    }
55
+      $recipient_name = sys_get_param_str_unsafe('recipient_name');
56
+      if($recipient_name) {
57
+        $recipient_row = db_user_by_username($recipient_name);
58
+      }
59 59
 
60
-    if(!$recipient_row) {
61
-      $recipient_id = sys_get_param_id('id');
62
-      $recipient_row = db_user_by_id($recipient_id);
63 60
       if(!$recipient_row) {
64
-        $recipient_id = 0;
61
+        $recipient_id = sys_get_param_id('id');
62
+        $recipient_row = db_user_by_id($recipient_id);
63
+        if(!$recipient_row) {
64
+          $recipient_id = 0;
65
+        }
65 66
       }
66
-    }
67
-
68
-    if($recipient_row) {
69
-      $recipient_id = $recipient_row['id'];
70
-      $recipient_name = $recipient_row['username'];
71
-    }
72
-
73
-    if($recipient_id == $user['id']) {
74
-      $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_self_send'], 'STATUS' => ERR_ERROR);
75
-    }
76
-
77
-    $re = 0;
78
-    $subject = sys_get_param_str('subject');
79
-    while(strpos($subject, classLocale::$lang['msg_answer_prefix']) !== false) {
80
-      $subject = substr($subject, strlen(classLocale::$lang['msg_answer_prefix']));
81
-      $re++;
82
-    }
83
-    $re ? $subject = classLocale::$lang['msg_answer_prefix'] . $subject : false;
84 67
 
85
-    if(sys_get_param_str('msg_send')) {
86
-      $subject = $subject ? $subject : classLocale::$lang['msg_subject_default'];
68
+      if($recipient_row) {
69
+        $recipient_id = $recipient_row['id'];
70
+        $recipient_name = $recipient_row['username'];
71
+      }
87 72
 
88
-      if(!$recipient_id) {
89
-        $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_player_not_found'], 'STATUS' => ERR_ERROR);
73
+      if($recipient_id == $user['id']) {
74
+        $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_self_send'], 'STATUS' => ERR_ERROR);
90 75
       }
91 76
 
92
-      $text = sys_get_param_str('text');
93
-      if(!$text) {
94
-        $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_no_text'], 'STATUS' => ERR_ERROR);
77
+      $re = 0;
78
+      $subject = sys_get_param_str('subject');
79
+      while(strpos($subject, classLocale::$lang['msg_answer_prefix']) !== false) {
80
+        $subject = substr($subject, strlen(classLocale::$lang['msg_answer_prefix']));
81
+        $re++;
95 82
       }
83
+      $re ? $subject = classLocale::$lang['msg_answer_prefix'] . $subject : false;
96 84
 
97
-      if(empty($error_list)) {
98
-        $error_list[] = array('MESSAGE' => classLocale::$lang['msg_not_message_sent'], 'STATUS' => ERR_NONE);
85
+      if(sys_get_param_str('msg_send')) {
86
+        $subject = $subject ? $subject : classLocale::$lang['msg_subject_default'];
99 87
 
100
-        $user_safe_name = db_escape($user['username']);
101
-        $recipient_name = db_escape($recipient_name);
102
-        msg_send_simple_message($recipient_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, "{$user_safe_name} [{$user['galaxy']}:{$user['system']}:{$user['planet']}]", $subject, $text, true);
88
+        if(!$recipient_id) {
89
+          $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_player_not_found'], 'STATUS' => ERR_ERROR);
90
+        }
103 91
 
104
-        //$recipient_id = 0;
105
-        //$recipient_name = '';
106
-        //$subject = '';
107
-        $text = '';
92
+        $text = sys_get_param_str('text');
93
+        if(!$text) {
94
+          $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_no_text'], 'STATUS' => ERR_ERROR);
95
+        }
108 96
 
109
-        $msg_sent = true;
110
-      } else {
111
-        $subject = sys_get_param_str_unsafe('subject');
112
-        $text = sys_get_param_str_unsafe('text');
113
-      }
114
-      $recipient_name = sys_get_param_str_unsafe('recipient_name');
115
-    }
97
+        if(empty($error_list)) {
98
+          $error_list[] = array('MESSAGE' => classLocale::$lang['msg_not_message_sent'], 'STATUS' => ERR_NONE);
116 99
 
117
-    $subject = $subject ? $subject : classLocale::$lang['msg_subject_default'];
100
+          $user_safe_name = db_escape($user['username']);
101
+          $recipient_name = db_escape($recipient_name);
102
+          msg_send_simple_message($recipient_id, $user['id'], SN_TIME_NOW, MSG_TYPE_PLAYER, "{$user_safe_name} [{$user['galaxy']}:{$user['system']}:{$user['planet']}]", $subject, $text, true);
118 103
 
119
-    $template->assign_vars(array(
120
-      'RECIPIENT_ID'   => $recipient_id,
121
-      'RECIPIENT_NAME' => htmlspecialchars($recipient_name),
122
-      'SUBJECT'        => htmlspecialchars($subject),
123
-      'TEXT'           => htmlspecialchars($text),
124
-    ));
104
+          //$recipient_id = 0;
105
+          //$recipient_name = '';
106
+          //$subject = '';
107
+          $text = '';
125 108
 
126
-    foreach($error_list as $error_message) {
127
-      $template->assign_block_vars('result', $error_message);
128
-    }
109
+          $msg_sent = true;
110
+        } else {
111
+          $subject = sys_get_param_str_unsafe('subject');
112
+          $text = sys_get_param_str_unsafe('text');
113
+        }
114
+        $recipient_name = sys_get_param_str_unsafe('recipient_name');
115
+      }
129 116
 
130
-    $message_query = db_message_list_get_last_20($user, $recipient_id);
131
-    while($message_row = db_fetch($message_query)) {
132
-      $template->assign_block_vars('messages', array(
133
-        'ID'   => $message_row['message_id'],
134
-        'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF),
135
-        'FROM' => htmlspecialchars($message_row['message_from']),
136
-        'SUBJ' => htmlspecialchars($message_row['message_subject']),
137
-        'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']),
117
+      $subject = $subject ? $subject : classLocale::$lang['msg_subject_default'];
138 118
 
139
-        'FROM_ID' => $message_row['message_sender'],
119
+      $template->assign_vars(array(
120
+        'RECIPIENT_ID'   => $recipient_id,
121
+        'RECIPIENT_NAME' => htmlspecialchars($recipient_name),
122
+        'SUBJECT'        => htmlspecialchars($subject),
123
+        'TEXT'           => htmlspecialchars($text),
140 124
       ));
141
-    }
142 125
 
143
-  break;
126
+      foreach($error_list as $error_message) {
127
+        $template->assign_block_vars('result', $error_message);
128
+      }
129
+
130
+      $message_query = db_message_list_get_last_20($user, $recipient_id);
131
+      while($message_row = db_fetch($message_query)) {
132
+        $template->assign_block_vars('messages', array(
133
+          'ID'   => $message_row['message_id'],
134
+          'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF),
135
+          'FROM' => htmlspecialchars($message_row['message_from']),
136
+          'SUBJ' => htmlspecialchars($message_row['message_subject']),
137
+          'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']),
138
+
139
+          'FROM_ID' => $message_row['message_sender'],
140
+        ));
141
+      }
144 142
 
145
-  case 'delete':
146
-    $query_add = '';
143
+    break;
147 144
 
148
-    $message_range = sys_get_param_str('message_range');
145
+    case 'delete':
146
+      $query_add = '';
149 147
 
150
-    switch($message_range) {
148
+      $message_range = sys_get_param_str('message_range');
149
+
150
+      switch($message_range) {
151 151
       case 'unchecked':
152 152
       case 'checked':
153 153
         $marked_message_list = sys_get_param('mark', array());
@@ -171,65 +171,65 @@  discard block
 block discarded – undo
171 171
       case 'all':
172 172
         $query_add = $query_add ? $query_add : true;
173 173
       break;
174
-    }
174
+      }
175 175
 
176 176
     if($query_add) {
177 177
       $query_add = $query_add === true ? '' : $query_add;
178 178
       db_message_list_delete($user, $query_add);
179 179
     }
180 180
 
181
-  case 'show':
182
-    if($current_class == MSG_TYPE_OUTBOX) {
183
-      $message_query = db_message_list_outbox_by_user_id($user['id']);
184
-    } else {
185
-      if($current_class == MSG_TYPE_NEW) {
186
-        $SubUpdateQry = array();
187
-        foreach($sn_message_class_list as $message_class_id => $message_class) {
188
-          if($message_class_id != MSG_TYPE_OUTBOX) {
189
-            $SubUpdateQry[] = "`{$message_class['name']}` = '0'";
190
-            $user[$message_class['name']] = 0;
181
+    case 'show':
182
+      if($current_class == MSG_TYPE_OUTBOX) {
183
+        $message_query = db_message_list_outbox_by_user_id($user['id']);
184
+      } else {
185
+        if($current_class == MSG_TYPE_NEW) {
186
+          $SubUpdateQry = array();
187
+          foreach($sn_message_class_list as $message_class_id => $message_class) {
188
+            if($message_class_id != MSG_TYPE_OUTBOX) {
189
+              $SubUpdateQry[] = "`{$message_class['name']}` = '0'";
190
+              $user[$message_class['name']] = 0;
191
+            }
191 192
           }
193
+          $SubUpdateQry = implode(',', $SubUpdateQry);
194
+        } else {
195
+          $SubUpdateQry = "`{$sn_message_class_list[$current_class]['name']}` = '0', `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` = `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` - '{$user[$sn_message_class_list[$current_class]['name']]}'";
196
+          $SubSelectQry = "AND `message_type` = '{$current_class}'";
197
+
198
+          $user[$sn_message_class_list[MSG_TYPE_NEW]['name']] -= $user[$sn_message_class_list[$current_class]['name']];
199
+          $user[$sn_message_class_list[$current_class]['name']] = 0;
192 200
         }
193
-        $SubUpdateQry = implode(',', $SubUpdateQry);
194
-      } else {
195
-        $SubUpdateQry = "`{$sn_message_class_list[$current_class]['name']}` = '0', `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` = `{$sn_message_class_list[MSG_TYPE_NEW]['name']}` - '{$user[$sn_message_class_list[$current_class]['name']]}'";
196
-        $SubSelectQry = "AND `message_type` = '{$current_class}'";
197 201
 
198
-        $user[$sn_message_class_list[MSG_TYPE_NEW]['name']] -= $user[$sn_message_class_list[$current_class]['name']];
199
-        $user[$sn_message_class_list[$current_class]['name']] = 0;
202
+        db_user_set_by_id($user['id'], $SubUpdateQry);
203
+        $message_query = db_message_list_by_owner_and_string($user, $SubSelectQry);
200 204
       }
201 205
 
202
-      db_user_set_by_id($user['id'], $SubUpdateQry);
203
-      $message_query = db_message_list_by_owner_and_string($user, $SubSelectQry);
204
-    }
205
-
206
-    if(sys_get_param_int('return')) {
207
-      header('Location: messages.php');
208
-      die();
209
-    }
206
+      if(sys_get_param_int('return')) {
207
+        header('Location: messages.php');
208
+        die();
209
+      }
210 210
 
211
-    $template = gettemplate('msg_message_list', true);
212
-    while($message_row = db_fetch($message_query)) {
213
-      $template->assign_block_vars('messages', array(
214
-        'ID'   => $message_row['message_id'],
215
-        'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF),
216
-        'FROM' => htmlspecialchars($message_row['message_from']),
217
-        'SUBJ' => htmlspecialchars($message_row['message_subject']),
218
-        'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']),
219
-
220
-        'FROM_ID'        => $message_row['message_sender'],
221
-        'SUBJ_SANITIZED' => htmlspecialchars($message_row['message_subject']),
222
-        'STYLE'          => $current_class == MSG_TYPE_OUTBOX ? $sn_message_class_list[MSG_TYPE_OUTBOX]['name'] : $sn_message_class_list[$message_row['message_type']]['name'],
223
-      ));
224
-    }
211
+      $template = gettemplate('msg_message_list', true);
212
+      while($message_row = db_fetch($message_query)) {
213
+        $template->assign_block_vars('messages', array(
214
+          'ID'   => $message_row['message_id'],
215
+          'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF),
216
+          'FROM' => htmlspecialchars($message_row['message_from']),
217
+          'SUBJ' => htmlspecialchars($message_row['message_subject']),
218
+          'TEXT' => in_array($message_row['message_type'], array(MSG_TYPE_PLAYER, MSG_TYPE_ALLIANCE)) && $message_row['message_sender'] ? nl2br(htmlspecialchars($message_row['message_text'])) : nl2br($message_row['message_text']),
219
+
220
+          'FROM_ID'        => $message_row['message_sender'],
221
+          'SUBJ_SANITIZED' => htmlspecialchars($message_row['message_subject']),
222
+          'STYLE'          => $current_class == MSG_TYPE_OUTBOX ? $sn_message_class_list[MSG_TYPE_OUTBOX]['name'] : $sn_message_class_list[$message_row['message_type']]['name'],
223
+        ));
224
+      }
225 225
 
226
-    $current_class_text = classLocale::$lang['msg_class'][$current_class];
226
+      $current_class_text = classLocale::$lang['msg_class'][$current_class];
227 227
 
228
-    $template->assign_vars(array(
229
-      "MESSAGE_CLASS"      => $current_class,
230
-      "MESSAGE_CLASS_TEXT" => $current_class_text,
231
-    ));
232
-  break;
228
+      $template->assign_vars(array(
229
+        "MESSAGE_CLASS"      => $current_class,
230
+        "MESSAGE_CLASS_TEXT" => $current_class_text,
231
+      ));
232
+    break;
233 233
 }
234 234
 
235 235
 if(!$template) {
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -36,65 +36,65 @@  discard block
 block discarded – undo
36 36
  *
37 37
  */
38 38
 
39
-include('common.' . substr(strrchr(__FILE__, '.'), 1));
39
+include('common.'.substr(strrchr(__FILE__, '.'), 1));
40 40
 
41 41
 lng_include('messages');
42 42
 
43 43
 $mode = sys_get_param_str('msg_delete') ? 'delete' : sys_get_param_str('mode');
44 44
 $current_class = sys_get_param_int('message_class');
45
-if(!isset($sn_message_class_list[$current_class])) {
45
+if (!isset($sn_message_class_list[$current_class])) {
46 46
   $current_class = 0;
47 47
   $mode = '';
48 48
 }
49 49
 
50
-switch($mode) {
50
+switch ($mode) {
51 51
   case 'write':
52 52
     $error_list = array();
53 53
     $template = gettemplate('msg_message_compose', true);
54 54
 
55 55
     $recipient_name = sys_get_param_str_unsafe('recipient_name');
56
-    if($recipient_name) {
56
+    if ($recipient_name) {
57 57
       $recipient_row = db_user_by_username($recipient_name);
58 58
     }
59 59
 
60
-    if(!$recipient_row) {
60
+    if (!$recipient_row) {
61 61
       $recipient_id = sys_get_param_id('id');
62 62
       $recipient_row = db_user_by_id($recipient_id);
63
-      if(!$recipient_row) {
63
+      if (!$recipient_row) {
64 64
         $recipient_id = 0;
65 65
       }
66 66
     }
67 67
 
68
-    if($recipient_row) {
68
+    if ($recipient_row) {
69 69
       $recipient_id = $recipient_row['id'];
70 70
       $recipient_name = $recipient_row['username'];
71 71
     }
72 72
 
73
-    if($recipient_id == $user['id']) {
73
+    if ($recipient_id == $user['id']) {
74 74
       $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_self_send'], 'STATUS' => ERR_ERROR);
75 75
     }
76 76
 
77 77
     $re = 0;
78 78
     $subject = sys_get_param_str('subject');
79
-    while(strpos($subject, classLocale::$lang['msg_answer_prefix']) !== false) {
79
+    while (strpos($subject, classLocale::$lang['msg_answer_prefix']) !== false) {
80 80
       $subject = substr($subject, strlen(classLocale::$lang['msg_answer_prefix']));
81 81
       $re++;
82 82
     }
83
-    $re ? $subject = classLocale::$lang['msg_answer_prefix'] . $subject : false;
83
+    $re ? $subject = classLocale::$lang['msg_answer_prefix'].$subject : false;
84 84
 
85
-    if(sys_get_param_str('msg_send')) {
85
+    if (sys_get_param_str('msg_send')) {
86 86
       $subject = $subject ? $subject : classLocale::$lang['msg_subject_default'];
87 87
 
88
-      if(!$recipient_id) {
88
+      if (!$recipient_id) {
89 89
         $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_player_not_found'], 'STATUS' => ERR_ERROR);
90 90
       }
91 91
 
92 92
       $text = sys_get_param_str('text');
93
-      if(!$text) {
93
+      if (!$text) {
94 94
         $error_list[] = array('MESSAGE' => classLocale::$lang['msg_err_no_text'], 'STATUS' => ERR_ERROR);
95 95
       }
96 96
 
97
-      if(empty($error_list)) {
97
+      if (empty($error_list)) {
98 98
         $error_list[] = array('MESSAGE' => classLocale::$lang['msg_not_message_sent'], 'STATUS' => ERR_NONE);
99 99
 
100 100
         $user_safe_name = db_escape($user['username']);
@@ -123,12 +123,12 @@  discard block
 block discarded – undo
123 123
       'TEXT'           => htmlspecialchars($text),
124 124
     ));
125 125
 
126
-    foreach($error_list as $error_message) {
126
+    foreach ($error_list as $error_message) {
127 127
       $template->assign_block_vars('result', $error_message);
128 128
     }
129 129
 
130 130
     $message_query = db_message_list_get_last_20($user, $recipient_id);
131
-    while($message_row = db_fetch($message_query)) {
131
+    while ($message_row = db_fetch($message_query)) {
132 132
       $template->assign_block_vars('messages', array(
133 133
         'ID'   => $message_row['message_id'],
134 134
         'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF),
@@ -147,25 +147,25 @@  discard block
 block discarded – undo
147 147
 
148 148
     $message_range = sys_get_param_str('message_range');
149 149
 
150
-    switch($message_range) {
150
+    switch ($message_range) {
151 151
       case 'unchecked':
152 152
       case 'checked':
153 153
         $marked_message_list = sys_get_param('mark', array());
154
-        if($message_range == 'checked' && empty($marked_message_list)) {
154
+        if ($message_range == 'checked' && empty($marked_message_list)) {
155 155
           break;
156 156
         }
157 157
 
158 158
         $query_add = implode(',', $marked_message_list);
159
-        if($query_add) {
159
+        if ($query_add) {
160 160
           $query_add = "IN ({$query_add})";
161
-          if($message_range == 'unchecked') {
161
+          if ($message_range == 'unchecked') {
162 162
             $query_add = "NOT {$query_add}";
163 163
           }
164 164
           $query_add = " AND `message_id` {$query_add}";
165 165
         }
166 166
 
167 167
       case 'class':
168
-        if($current_class != MSG_TYPE_OUTBOX && $current_class != MSG_TYPE_NEW) {
168
+        if ($current_class != MSG_TYPE_OUTBOX && $current_class != MSG_TYPE_NEW) {
169 169
           $query_add .= " AND `message_type` = {$current_class}";
170 170
         }
171 171
       case 'all':
@@ -173,19 +173,19 @@  discard block
 block discarded – undo
173 173
       break;
174 174
     }
175 175
 
176
-    if($query_add) {
176
+    if ($query_add) {
177 177
       $query_add = $query_add === true ? '' : $query_add;
178 178
       db_message_list_delete($user, $query_add);
179 179
     }
180 180
 
181 181
   case 'show':
182
-    if($current_class == MSG_TYPE_OUTBOX) {
182
+    if ($current_class == MSG_TYPE_OUTBOX) {
183 183
       $message_query = db_message_list_outbox_by_user_id($user['id']);
184 184
     } else {
185
-      if($current_class == MSG_TYPE_NEW) {
185
+      if ($current_class == MSG_TYPE_NEW) {
186 186
         $SubUpdateQry = array();
187
-        foreach($sn_message_class_list as $message_class_id => $message_class) {
188
-          if($message_class_id != MSG_TYPE_OUTBOX) {
187
+        foreach ($sn_message_class_list as $message_class_id => $message_class) {
188
+          if ($message_class_id != MSG_TYPE_OUTBOX) {
189 189
             $SubUpdateQry[] = "`{$message_class['name']}` = '0'";
190 190
             $user[$message_class['name']] = 0;
191 191
           }
@@ -203,13 +203,13 @@  discard block
 block discarded – undo
203 203
       $message_query = db_message_list_by_owner_and_string($user, $SubSelectQry);
204 204
     }
205 205
 
206
-    if(sys_get_param_int('return')) {
206
+    if (sys_get_param_int('return')) {
207 207
       header('Location: messages.php');
208 208
       die();
209 209
     }
210 210
 
211 211
     $template = gettemplate('msg_message_list', true);
212
-    while($message_row = db_fetch($message_query)) {
212
+    while ($message_row = db_fetch($message_query)) {
213 213
       $template->assign_block_vars('messages', array(
214 214
         'ID'   => $message_row['message_id'],
215 215
         'DATE' => date(FMT_DATE_TIME, $message_row['message_time'] + SN_CLIENT_TIME_DIFF),
@@ -232,18 +232,18 @@  discard block
 block discarded – undo
232 232
   break;
233 233
 }
234 234
 
235
-if(!$template) {
235
+if (!$template) {
236 236
   $template = gettemplate('msg_message_class', true);
237 237
 
238 238
   $query = db_message_count_by_owner_and_type($user);
239
-  while($message_row = db_fetch($query)) {
239
+  while ($message_row = db_fetch($query)) {
240 240
     $messages_total[$message_row['message_type']] = $message_row['message_count'];
241 241
     $messages_total[MSG_TYPE_NEW] += $message_row['message_count'];
242 242
   }
243 243
 
244 244
   $messages_total[MSG_TYPE_OUTBOX] = db_message_count_outbox($user);
245 245
 
246
-  foreach($sn_message_class_list as $message_class_id => $message_class) {
246
+  foreach ($sn_message_class_list as $message_class_id => $message_class) {
247 247
     $template->assign_block_vars('message_class', array(
248 248
       'ID'     => $message_class_id,
249 249
       'STYLE'  => $message_class['name'],
Please login to merge, or discard this patch.
includes/classes/core_auth.php 2 patches
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.
Spacing   +77 added lines, -77 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,24 +218,24 @@  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
 
225 225
       // Проверить наличие такого имени в истории имён
226 226
       do {
227 227
         sn_db_transaction_rollback();
228
-        $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000);
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) {
237
-        sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
238
-      } elseif($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
236
+      if ($this->register_status == LOGIN_SUCCESS) {
237
+        sys_redirect(SN_ROOT_VIRTUAL.'overview.php');
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,9 +259,9 @@  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
-        return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
264
+        return "'".htmlentities($value, ENT_QUOTES, 'UTF-8')."'";
265 265
       }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
266 266
       $template_result[F_PLAYER_REGISTER_MESSAGE] .= implode(', ', $prohibited_characters);
267 267
     }
@@ -289,27 +289,27 @@  discard block
 block discarded – undo
289 289
    * @param null $result
290 290
    */
291 291
   public function login() {
292
-    if(empty(sn_module::$sn_module_list['auth'])) {
292
+    if (empty(sn_module::$sn_module_list['auth'])) {
293 293
       die('{Не обнаружено ни одного провайдера авторизации в core_auth::login()!}');
294 294
     }
295 295
 
296 296
     !empty($_POST) ? self::flog(dump($_POST, '$_POST')) : false;
297 297
     !empty($_GET) ? self::flog(dump($_GET, '$_GET')) : false;
298
-    !empty($_COOKIE) ? self::flog(dump($_COOKIE,'$_COOKIE')) : false;
298
+    !empty($_COOKIE) ? self::flog(dump($_COOKIE, '$_COOKIE')) : false;
299 299
 
300 300
     $this->auth_reset(); // OK v4.5
301 301
 
302 302
     $this->providers = array();
303
-    foreach(sn_module::$sn_module_list['auth'] as $module_name => $module) {
303
+    foreach (sn_module::$sn_module_list['auth'] as $module_name => $module) {
304 304
       $this->providers[$module->provider_id] = $module;
305 305
     }
306 306
 
307 307
     // $this->providers = array_reverse($this->providers, true); // НИНАДА! СН-аккаунт должен всегда авторизироваться первым!
308 308
 
309
-    foreach($this->providers as $provider_id => $provider) {
309
+    foreach ($this->providers as $provider_id => $provider) {
310 310
       $login_status = $provider->login(); // OK v4.5
311
-      self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider)));
312
-      if($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
311
+      self::flog(($provider->manifest['name'].'->'.'login_try - ').(empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider)));
312
+      if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
313 313
         $this->providers_authorised[$provider_id] = &$this->providers[$provider_id];
314 314
 
315 315
         $this->user_id_to_provider = array_replace_recursive(
@@ -317,15 +317,15 @@  discard block
 block discarded – undo
317 317
           // static::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5
318 318
           PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5
319 319
         );
320
-      } elseif($login_status != LOGIN_UNDEFINED) {
320
+      } elseif ($login_status != LOGIN_UNDEFINED) {
321 321
         $this->provider_error_list[$provider_id] = $login_status;
322 322
       }
323 323
     }
324 324
 
325
-    if(empty($this->providers_authorised)) {
325
+    if (empty($this->providers_authorised)) {
326 326
       // Ни один аккаунт не авторизирован
327 327
       // Проверяем - есть ли у нас ошибки в аккаунтах?
328
-      if(!empty($this->provider_error_list)) {
328
+      if (!empty($this->provider_error_list)) {
329 329
         // Если есть - выводим их
330 330
         self::$login_status = reset($this->provider_error_list);
331 331
       }
@@ -340,21 +340,21 @@  discard block
 block discarded – undo
340 340
       // В self::$accessible_user_row_list - список доступных игроков для данных аккаунтов с соответствующими записями из таблицы `users`
341 341
 
342 342
       // Остались ли у нас в списке доступные игроки?
343
-      if(empty($this->accessible_user_row_list)) {
343
+      if (empty($this->accessible_user_row_list)) {
344 344
         // Нет ни одного игрока ни на одном авторизированном аккаунте
345 345
         // Надо регать нового игрока
346 346
 
347 347
         // Сейчас происходит процесс регистрации игрока?
348
-        if(!$this->is_player_register) {
348
+        if (!$this->is_player_register) {
349 349
           // Нет - отправляем на процесс регистрации
350 350
           $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id'));
351
-          sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : ''));
351
+          sys_redirect(SN_ROOT_VIRTUAL.'index.php?page=player_register&player_register=1'.($partner_id ? '&id_ref='.$partner_id : ''));
352 352
         }
353 353
       } else {
354 354
         // Да, есть доступные игроки, которые так же прописаны в базе
355 355
         $this->get_active_user(); // 4.5
356 356
 
357
-        if($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) {
357
+        if ($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) {
358 358
           $a_user = db_user_by_id($this->is_impersonating);
359 359
           $this->impersonator_username = $a_user['username'];
360 360
         }
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 
363 363
         //Прописываем текущего игрока на все авторизированные аккаунты
364 364
         // TODO - ИЛИ ВСЕХ ИГРОКОВ??
365
-        if(empty($this->is_impersonating)) {
366
-          foreach($this->providers_authorised as $provider_id => $provider) {
367
-            if(empty($this->user_id_to_provider[self::$user['id']][$provider_id])) {
365
+        if (empty($this->is_impersonating)) {
366
+          foreach ($this->providers_authorised as $provider_id => $provider) {
367
+            if (empty($this->user_id_to_provider[self::$user['id']][$provider_id])) {
368 368
               // self::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']);
369 369
               PlayerToAccountTranslate::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']);
370 370
               $this->user_id_to_provider[self::$user['id']][$provider_id][$provider->account->account_id] = true;
@@ -374,9 +374,9 @@  discard block
 block discarded – undo
374 374
       }
375 375
     }
376 376
 
377
-    if(empty(self::$user['id'])) {
377
+    if (empty(self::$user['id'])) {
378 378
       self::cookie_set(''); // OK 4.5
379
-    } elseif(self::$user['id'] != $_COOKIE[SN_COOKIE_U]) {
379
+    } elseif (self::$user['id'] != $_COOKIE[SN_COOKIE_U]) {
380 380
       self::cookie_set(self::$user['id']); // OK 4.5
381 381
     }
382 382
 
@@ -395,21 +395,21 @@  discard block
 block discarded – undo
395 395
    */
396 396
   // OK v4.7
397 397
   public function logout($redirect = true) {
398
-    if(!empty($_COOKIE[SN_COOKIE_U_I])) {
398
+    if (!empty($_COOKIE[SN_COOKIE_U_I])) {
399 399
       self::cookie_set($_COOKIE[SN_COOKIE_U_I]);
400 400
       self::cookie_set(0, true);
401 401
       self::$main_provider->logout();
402 402
     } else {
403
-      foreach($this->providers as $provider_name => $provider) {
403
+      foreach ($this->providers as $provider_name => $provider) {
404 404
         $provider->logout();
405 405
       }
406 406
 
407 407
       self::cookie_set(0);
408 408
     }
409 409
 
410
-    if($redirect === true) {
411
-      sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php'));
412
-    } elseif($redirect !== false) {
410
+    if ($redirect === true) {
411
+      sys_redirect(SN_ROOT_RELATIVE.(empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php'));
412
+    } elseif ($redirect !== false) {
413 413
       sys_redirect($redirect);
414 414
     }
415 415
   }
@@ -420,15 +420,15 @@  discard block
 block discarded – undo
420 420
    * @param $user_selected
421 421
    */
422 422
   public function impersonate($user_selected) {
423
-    if($_COOKIE[SN_COOKIE_U_I]) {
423
+    if ($_COOKIE[SN_COOKIE_U_I]) {
424 424
       die('You already impersonating someone. Go back to living other\'s life! Or clear your cookies and try again'); // TODO: Log it
425 425
     }
426 426
 
427
-    if($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) {
427
+    if ($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) {
428 428
       die('You can\'t impersonate - too low level'); // TODO: Log it
429 429
     }
430 430
 
431
-    if($this->auth_level_max_local <= $user_selected['authlevel']) {
431
+    if ($this->auth_level_max_local <= $user_selected['authlevel']) {
432 432
       die('You can\'t impersonate this account - level is greater or equal to yours'); // TODO: Log it
433 433
     }
434 434
 
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
     $account_translate = reset($account_translate[$user_selected['id']][self::$main_provider->provider_id]);
437 437
     $account_to_impersonate = new Account(self::$main_provider->db);
438 438
     $account_to_impersonate->db_get_by_id($account_translate['provider_account_id']);
439
-    if(!$account_to_impersonate->is_exists) {
439
+    if (!$account_to_impersonate->is_exists) {
440 440
       die('Какая-то ошибка - не могу найти аккаунт для имперсонации'); // TODO: Log it
441 441
     }
442 442
     self::$main_provider->impersonate($account_to_impersonate);
@@ -462,12 +462,12 @@  discard block
 block discarded – undo
462 462
   public function password_check($password_unsafe) {
463 463
     $result = false;
464 464
 
465
-    if(empty($this->providers_authorised)) {
465
+    if (empty($this->providers_authorised)) {
466 466
       // TODO - такого быть не может!
467 467
       self::flog("password_check: Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true);
468 468
     } else {
469
-      foreach($this->providers_authorised as $provider_id => $provider) {
470
-        if($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) {
469
+      foreach ($this->providers_authorised as $provider_id => $provider) {
470
+        if ($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) {
471 471
           $result = $result || $provider->password_check($password_unsafe);
472 472
         }
473 473
       }
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
    */
487 487
   // OK v4.6
488 488
   public function password_change($old_password_unsafe, $new_password_unsafe) {
489
-    if(empty($this->providers_authorised)) {
489
+    if (empty($this->providers_authorised)) {
490 490
       // TODO - такого быть не может!
491 491
       self::flog("Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true);
492 492
       return false;
@@ -499,8 +499,8 @@  discard block
 block discarded – undo
499 499
     $salt_unsafe = self::password_salt_generate();
500 500
 
501 501
     $providers_changed_password = array();
502
-    foreach($this->providers_authorised as $provider_id => $provider) {
503
-      if(
502
+    foreach ($this->providers_authorised as $provider_id => $provider) {
503
+      if (
504 504
         !$provider->is_feature_supported(AUTH_FEATURE_PASSWORD_CHANGE)
505 505
         || !$provider->password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe)
506 506
       ) {
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
       $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id);
513 513
 
514 514
       // Рассылаем уведомления о смене пароля в ЛС
515
-      foreach($account_translation as $user_id => $provider_info) {
515
+      foreach ($account_translation as $user_id => $provider_info) {
516 516
         // TODO - УКазывать тип аккаунта, на котором сменён пароль
517 517
         msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN,
518 518
           classLocale::$lang['sys_administration'], classLocale::$lang['sys_login_register_message_title'],
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
       sn_db_transaction_start();
560 560
       // Проверить наличие такого имени в истории имён
561 561
 
562
-      if(db_player_name_exists($player_name_unsafe)) {
562
+      if (db_player_name_exists($player_name_unsafe)) {
563 563
         throw new Exception(REGISTER_ERROR_PLAYER_NAME_EXISTS, ERR_ERROR);
564 564
       }
565 565
 
@@ -567,11 +567,11 @@  discard block
 block discarded – undo
567 567
       $player_language = '';
568 568
       $player_email = '';
569 569
       // TODO - порнография - работа должна происходить над списком аккаунтов, а не только на одном аккаунте...
570
-      foreach($this->providers_authorised as $provider) {
571
-        if(!$player_language && $provider->account->account_language) {
570
+      foreach ($this->providers_authorised as $provider) {
571
+        if (!$player_language && $provider->account->account_language) {
572 572
           $player_language = $provider->account->account_language;
573 573
         }
574
-        if(!$player_email && $provider->account->account_email) {
574
+        if (!$player_email && $provider->account->account_email) {
575 575
           $player_email = $provider->account->account_email;
576 576
         }
577 577
       }
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
       ));
588 588
       // Зарегестрировать на него аккаунты из self::$accounts_authorised
589 589
       $a_user = self::$user;
590
-      foreach($this->providers_authorised as $provider) {
590
+      foreach ($this->providers_authorised as $provider) {
591 591
         // TODO - порнография. Должен быть отдельный класс трансляторов - в т.ч. и кэширующий транслятор
592 592
         // TODO - ну и работа должна происходить над списком аккаунтов, а не только на одном аккаунте...
593 593
         // self::db_translate_register_user($provider->provider_id, $provider->account->account_id, $a_user['id']);
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 
600 600
       sn_db_transaction_commit();
601 601
       $this->register_status = LOGIN_SUCCESS;
602
-    } catch(Exception $e) {
602
+    } catch (Exception $e) {
603 603
       sn_db_transaction_rollback();
604 604
 
605 605
       // Если старое имя занято
@@ -618,10 +618,10 @@  discard block
 block discarded – undo
618 618
     // Пробиваем все ИД игроков по базе - есть ли вообще такие записи
619 619
     // Вообще-то это не особо нужно - у нас по определению стоят констраинты
620 620
     // Зато так мы узнаем максимальный authlevel, проверим права имперсонейта и вытащим все записи юзеров
621
-    foreach($this->user_id_to_provider as $user_id => $cork) {
621
+    foreach ($this->user_id_to_provider as $user_id => $cork) {
622 622
       $user = db_user_by_id($user_id);
623 623
       // Если записи игрока в БД не существует?
624
-      if(empty($user['id'])) {
624
+      if (empty($user['id'])) {
625 625
         // Удаляем этого и переходим к следующему
626 626
         unset($this->user_id_to_provider[$user_id]);
627 627
         // Де-регистрируем игрока из таблицы трансляции игроков
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
   // OK v4.5
643 643
   protected function get_active_user() {
644 644
     // Проверяем куку "текущего игрока" из браузера
645
-    if(
645
+    if (
646 646
       // Кука не пустая
647 647
       ($_COOKIE[SN_COOKIE_U] = trim($_COOKIE[SN_COOKIE_U])) && !empty($_COOKIE[SN_COOKIE_U])
648 648
       // И в куке находится ID
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
     }
668 668
 
669 669
     // В куке нет валидного ИД записи игрока, доступной с текущих аккаунтов
670
-    if(empty(self::$user['id'])) {
670
+    if (empty(self::$user['id'])) {
671 671
       // Берем первого из доступных
672 672
       // TODO - default_user
673 673
       self::$user = reset($this->accessible_user_row_list);
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 
690 690
     $result = array();
691 691
 
692
-    if($user_id && empty($this->is_impersonating)) {
692
+    if ($user_id && empty($this->is_impersonating)) {
693 693
       // self::db_counter_insert();
694 694
       self::$device->db_counter_insert($user_id);
695 695
 
@@ -697,12 +697,12 @@  discard block
 block discarded – undo
697 697
 
698 698
       sys_user_options_unpack($user);
699 699
 
700
-      if($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) {
700
+      if ($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) {
701 701
         $user['banaday'] = 0;
702 702
         $user['vacation'] = SN_TIME_NOW;
703 703
       }
704 704
 
705
-      $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip'];
705
+      $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip'];
706 706
       $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain'];
707 707
 
708 708
       $result[F_BANNED_STATUS] = $user['banaday'];
@@ -710,15 +710,15 @@  discard block
 block discarded – undo
710 710
 
711 711
       $proxy_safe = static::$db->db_escape(self::$device->ip_v4_proxy_chain);
712 712
 
713
-      db_user_set_by_id($user['id'], "`onlinetime` = " . SN_TIME_NOW . ",
714
-      `banaday` = " . static::$db->db_escape($user['banaday']) . ", `vacation` = " . static::$db->db_escape($user['vacation']) . ",
715
-      `user_lastip` = '" . static::$db->db_escape($user['user_lastip']) . "', `user_last_proxy` = '{$proxy_safe}', `user_last_browser_id` = " . self::$device->browser_id
713
+      db_user_set_by_id($user['id'], "`onlinetime` = ".SN_TIME_NOW.",
714
+      `banaday` = " . static::$db->db_escape($user['banaday']).", `vacation` = ".static::$db->db_escape($user['vacation']).",
715
+      `user_lastip` = '" . static::$db->db_escape($user['user_lastip'])."', `user_last_proxy` = '{$proxy_safe}', `user_last_browser_id` = ".self::$device->browser_id
716 716
       );
717 717
     }
718 718
 
719
-    if($extra = classSupernova::$config->security_ban_extra) {
719
+    if ($extra = classSupernova::$config->security_ban_extra) {
720 720
       $extra = explode(',', $extra);
721
-      array_walk($extra,'trim');
721
+      array_walk($extra, 'trim');
722 722
       in_array(self::$device->device_id, $extra) and die();
723 723
     }
724 724
 
@@ -754,21 +754,21 @@  discard block
 block discarded – undo
754 754
   protected function register_player_name_validate($player_name_unsafe) {
755 755
     // TODO - переделать под RAW-строки
756 756
     // Если имя игрока пустое - NO GO!
757
-    if(trim($player_name_unsafe) == '') {
757
+    if (trim($player_name_unsafe) == '') {
758 758
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_EMPTY, ERR_ERROR);
759 759
     }
760 760
     // Проверяем, что бы в начале и конце не было пустых символов
761
-    if($player_name_unsafe != trim($player_name_unsafe)) {
761
+    if ($player_name_unsafe != trim($player_name_unsafe)) {
762 762
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_TRIMMED, ERR_ERROR);
763 763
     }
764 764
     // Если логин имеет запрещенные символы - NO GO!
765
-    if(strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
765
+    if (strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
766 766
       // TODO - выдавать в сообщение об ошибке список запрещенных символов
767 767
       // TODO - заранее извещать игрока, какие символы являются запрещенными
768 768
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_RESTRICTED_CHARACTERS, ERR_ERROR);
769 769
     }
770 770
     // Если логин меньше минимальной длины - NO GO!
771
-    if(strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) {
771
+    if (strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) {
772 772
       // TODO - выдавать в сообщение об ошибке минимальную длину имени игрока
773 773
       // TODO - заранее извещать игрока, какая минимальная и максимальная длина имени
774 774
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_SHORT, ERR_ERROR);
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
    */
806 806
   // OK v4
807 807
   public static function password_encode($password, $salt) {
808
-    return md5($password . $salt);
808
+    return md5($password.$salt);
809 809
   }
810 810
   /**
811 811
    * Генерирует соль
@@ -826,23 +826,23 @@  discard block
 block discarded – undo
826 826
   }
827 827
 
828 828
   protected static function flog($message, $die = false) {
829
-    if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
829
+    if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
830 830
       return;
831 831
     }
832 832
     list($called, $caller) = debug_backtrace(false);
833 833
     $caller_name =
834
-      (!empty($caller['class']) ? $caller['class'] : '') .
835
-      (!empty($caller['type']) ? $caller['type'] : '') .
836
-      (!empty($caller['function']) ? $caller['function'] : '') .
837
-      (!empty($called['line']) ? ':' . $called['line'] : '');
834
+      (!empty($caller['class']) ? $caller['class'] : '').
835
+      (!empty($caller['type']) ? $caller['type'] : '').
836
+      (!empty($caller['function']) ? $caller['function'] : '').
837
+      (!empty($called['line']) ? ':'.$called['line'] : '');
838 838
 
839 839
     $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false;
840 840
 
841 841
     classSupernova::log_file("$message - $caller_name");
842
-    if($die) {
842
+    if ($die) {
843 843
       // pdump($caller);
844 844
       // pdump(debug_backtrace(false));
845
-      $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
845
+      $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в ".get_called_class()." (располагается в ".get_class()."). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
846 846
     }
847 847
   }
848 848
 
Please login to merge, or discard this patch.
admin/includes/admin_planet_edit.inc.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
 
22 22
 function sn_admin_planet_edit_template(&$template, $edit_planet_row, $mode) {
23 23
   $unit_list = sn_get_groups($mode);
24
-  if(empty($unit_list)) {
24
+  if (empty($unit_list)) {
25 25
     return;
26 26
   }
27 27
   $name_list = classLocale::$lang['tech'];
28 28
 
29
-  foreach($unit_list as $unit_id) {
29
+  foreach ($unit_list as $unit_id) {
30 30
     $template->assign_block_vars('unit', array(
31 31
       'ID'    => $unit_id,
32 32
       'NAME'  => $name_list[$unit_id],
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 function admin_planet_edit_query_string($unit_id, $unit_amount, $mode) { return sn_function_call(__FUNCTION__, array($unit_id, $unit_amount, $mode)); }
40 40
 
41 41
 function sn_admin_planet_edit_query_string($unit_id, $unit_amount, $mode) {
42
-  if($unit_amount && in_array($unit_id, sn_get_groups($mode))) {
42
+  if ($unit_amount && in_array($unit_id, sn_get_groups($mode))) {
43 43
     $unit_amount = round($unit_amount);
44 44
     $unit_name = get_unit_param($unit_id, P_NAME);
45 45
     $result = "{$unit_name} = GREATEST(0, {$unit_name} + ({$unit_amount}))";
Please login to merge, or discard this patch.
includes/pages/contact.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
   $query = db_user_list("`authlevel` > 0 ORDER BY `authlevel` ASC");
17 17
 
18 18
   // while($row = db_fetch($query))
19
-  foreach($query as $row) {
19
+  foreach ($query as $row) {
20 20
     $template_result['.']['contact'][] = array(
21 21
       'NAME'  => $row['username'],
22 22
       'LEVEL' => classLocale::$lang['user_level'][$row['authlevel']],
Please login to merge, or discard this patch.
includes/classes/Account.php 2 patches
Doc Comments   +21 added lines patch added patch discarded remove patch
@@ -171,6 +171,10 @@  discard block
 block discarded – undo
171 171
    * @return bool
172 172
    */
173 173
   // OK v4.5
174
+
175
+  /**
176
+   * @param string $account_name_unsafe
177
+   */
174 178
   public function db_get_by_name($account_name_unsafe) {
175 179
     $this->reset();
176 180
 
@@ -207,6 +211,11 @@  discard block
 block discarded – undo
207 211
    *
208 212
    */
209 213
   // OK v4.5
214
+
215
+  /**
216
+   * @param string $account_name_unsafe
217
+   * @param string $email_unsafe
218
+   */
210 219
   public function db_get_by_name_or_email($account_name_unsafe, $email_unsafe) {
211 220
     $this->reset();
212 221
 
@@ -223,6 +232,13 @@  discard block
 block discarded – undo
223 232
    * @throws Exception
224 233
    */
225 234
   // OK v4.5
235
+
236
+  /**
237
+   * @param string $account_name_unsafe
238
+   * @param string $password_raw
239
+   * @param string $email_unsafe
240
+   * @param string $language_unsafe
241
+   */
226 242
   public function db_create($account_name_unsafe, $password_raw, $email_unsafe, $language_unsafe = null, $salt_unsafe = null) {
227 243
     $this->reset();
228 244
 
@@ -317,6 +333,11 @@  discard block
 block discarded – undo
317 333
    * @return int|string
318 334
    */
319 335
   // OK 4.8
336
+
337
+  /**
338
+   * @param integer $change_type
339
+   * @param double $metamatter
340
+   */
320 341
   protected function db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe) {
321 342
     $provider_id_safe = intval(core_auth::$main_provider->provider_id);
322 343
     //$account_id_safe = $this->db->db_escape($this->account_id);
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
     $this->reset();
80 80
     $this->db = is_object($db) ? $db : classSupernova::$db;
81 81
 
82
-    foreach($this->table_check as $table_name) {
83
-      if(empty($this->db->table_list[$table_name])) {
82
+    foreach ($this->table_check as $table_name) {
83
+      if (empty($this->db->table_list[$table_name])) {
84 84
         die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br />
85 85
               В противном случае - сообщите Администрации сервера об ошибке.<br/>
86 86
               Не хватает таблицы для работы системы авторизации: ' . $table_name);
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
    */
105 105
   // OK v4.6
106 106
   public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) {
107
-    if(!$this->password_check($old_password_unsafe)) {
107
+    if (!$this->password_check($old_password_unsafe)) {
108 108
       return false;
109 109
     }
110 110
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
   // OK v4.5
126 126
   public function assign_from_db_row($row) {
127 127
     $this->reset();
128
-    if(empty($row) || !is_array($row)) {
128
+    if (empty($row) || !is_array($row)) {
129 129
       return false;
130 130
     }
131 131
     $this->account_id = $row['account_id'];
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
         `account_email` = LOWER('{$email_safe}'),
243 243
         `account_language` = '{$language_safe}'"
244 244
     );
245
-    if(!$result) {
245
+    if (!$result) {
246 246
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
247 247
     }
248 248
 
249
-    if(!($account_id = $this->db->db_insert_id())) {
249
+    if (!($account_id = $this->db->db_insert_id())) {
250 250
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
251 251
     }
252 252
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
       WHERE `account_id` = '{$account_id_safe}'"
277 277
     ) ? true : false;
278 278
 
279
-    if($result) {
279
+    if ($result) {
280 280
       $result = $this->db_get_by_id($this->account_id);
281 281
     }
282 282
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
   public function metamatter_change($change_type, $metamatter, $comment = '', $already_changed = false) {
364 364
     global $mm_change_legit;
365 365
 
366
-    if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
366
+    if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
367 367
       classSupernova::$debug->error('Ошибка при попытке манипуляции с ММ');
368 368
 
369 369
       return false;
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 
374 374
     $mm_change_legit = true;
375 375
     // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER);
376
-    if($already_changed) {
376
+    if ($already_changed) {
377 377
       $metamatter_total_delta = 0;
378 378
       $result = -1;
379 379
     } else {
@@ -383,17 +383,17 @@  discard block
 block discarded – undo
383 383
       $result = $this->db->doquery(
384 384
         "UPDATE {{account}}
385 385
         SET
386
-          `account_metamatter` = `account_metamatter` + '{$metamatter}'" .
387
-        ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$classConfig->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') .
386
+          `account_metamatter` = `account_metamatter` + '{$metamatter}'".
387
+        ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$classConfig->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '').
388 388
         " WHERE `account_id` = {$account_id_safe}"
389 389
       );
390
-      if(!$result) {
390
+      if (!$result) {
391 391
         classSupernova::$debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
392 392
       }
393 393
       $result = classSupernova::$db->db_affected_rows();
394 394
     }
395 395
 
396
-    if(empty(core_auth::$user['id'])) {
396
+    if (empty(core_auth::$user['id'])) {
397 397
       $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id);
398 398
       reset($user_list);
399 399
       $user_id_unsafe = key($user_list);
@@ -402,30 +402,30 @@  discard block
 block discarded – undo
402 402
     }
403 403
     $user_id_safe = $this->db->db_escape($user_id_unsafe);
404 404
 
405
-    if(!$result) {
405
+    if (!$result) {
406 406
       classSupernova::$debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
407 407
     }
408 408
 
409
-    if(!$already_changed) {
409
+    if (!$already_changed) {
410 410
       $this->account_metamatter += $metamatter;
411 411
       $this->account_metamatter_total += $metamatter_total_delta;
412 412
     }
413 413
 
414
-    if(is_array($comment)) {
414
+    if (is_array($comment)) {
415 415
       $comment = call_user_func_array('sprintf', $comment);
416 416
     }
417 417
 
418 418
     $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe);
419 419
 
420
-    if($metamatter > 0 && !empty($user_id_safe)) {
420
+    if ($metamatter > 0 && !empty($user_id_safe)) {
421 421
       $old_referral = db_referral_get_by_id($user_id_safe);
422
-      if($old_referral['id']) {
422
+      if ($old_referral['id']) {
423 423
         $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM;
424 424
         db_referral_update_dm($user_id_safe, $dark_matter_from_metamatter);
425 425
         $new_referral = db_referral_get_by_id($user_id_safe);
426 426
 
427 427
         $partner_bonus = floor($new_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) : 0);
428
-        if($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) {
428
+        if ($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) {
429 429
           rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}");
430 430
         }
431 431
       }
Please login to merge, or discard this patch.