Completed
Push — work-fleets ( 1bdd41...8f5403 )
by SuperNova.WS
04:54
created
includes/functions/sys_maintenance.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@  discard block
 block discarded – undo
24 24
     ),
25 25
   );
26 26
 
27
-  foreach($queries as &$query) {
28
-    if(!empty($query['query'])) {
27
+  foreach ($queries as &$query) {
28
+    if (!empty($query['query'])) {
29 29
       $query['result'] = doquery($query['query']);
30
-    } elseif(!empty($query['callable']) && is_callable($query['callable'])) {
30
+    } elseif (!empty($query['callable']) && is_callable($query['callable'])) {
31 31
       call_user_func($query['callable']);
32 32
     }
33 33
     $query['error'] = classSupernova::$db->db_error();
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
   $today_array = array($today_array['seconds'], $today_array['minutes'], $today_array['hours'], $today_array['mday'], $today_array['mon'], $today_array['year']);
72 72
 //  pdump($prev_run_array);
73 73
   $scheduleList = explode(',', $scheduleList);
74
-  array_walk($scheduleList, function (&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) {
74
+  array_walk($scheduleList, function(&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) {
75 75
     // pdump($schedule);
76 76
     $schedule = array('schedule_array' => array_reverse(explode(':', trim($schedule))));
77 77
 
@@ -83,21 +83,21 @@  discard block
 block discarded – undo
83 83
     */
84 84
     // pdump($schedule);
85 85
 
86
-    foreach($prev_run_array as $index => $date_part) {
86
+    foreach ($prev_run_array as $index => $date_part) {
87 87
       $schedule['array']['recorded'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $date_part;
88 88
       $schedule['array']['now'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $today_array[$index];
89 89
     }
90
-    if($schedule['array']['recorded'] == $schedule['array']['now']) {
90
+    if ($schedule['array']['recorded'] == $schedule['array']['now']) {
91 91
       unset($schedule['array']['now']);
92 92
     }
93 93
 
94
-    foreach($schedule['array'] as $name => $array) {
94
+    foreach ($schedule['array'] as $name => $array) {
95 95
       $schedule['string'][$name] = "{$array[5]}-{$array[4]}-{$array[3]} {$array[2]}:{$array[1]}:{$array[0]}";
96 96
       $schedule['string'][$name . '_next'] = $schedule['string'][$name] . ' +1 ' . $interval;
97 97
       $schedule['string'][$name . '_prev'] = $schedule['string'][$name] . ' -1 ' . $interval;
98 98
     }
99 99
 
100
-    foreach($schedule['string'] as $string) {
100
+    foreach ($schedule['string'] as $string) {
101 101
       $timestamp = strtotime($string);
102 102
       $schedule['timestamp'][$timestamp] = $possible_schedules[$timestamp] = date(FMT_DATE_TIME_SQL, strtotime($string));
103 103
     }
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 
130 130
   $prev_run = 0;
131 131
   $next_run = 0;
132
-  foreach($possible_schedules as $timestamp => $string_date) {
132
+  foreach ($possible_schedules as $timestamp => $string_date) {
133 133
     $prev_run = SN_TIME_NOW >= $timestamp ? $timestamp : $prev_run;
134 134
     $next_run = SN_TIME_NOW < $timestamp && !$next_run ? $timestamp : $next_run;
135 135
 //    pdump($schedule, '$schedule ' . date(FMT_DATE_TIME_SQL, $schedule));
Please login to merge, or discard this patch.
includes/functions/geoip.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-function geoip_status(){return sn_function_call(__FUNCTION__, array(&$result));}
3
+function geoip_status() {return sn_function_call(__FUNCTION__, array(&$result)); }
4 4
 function sn_geoip_status(&$result) {
5 5
   return $result = false;
6 6
 }
7 7
 
8
-function geoip_ip_info($ip){return sn_function_call(__FUNCTION__, array($ip, &$result));}
8
+function geoip_ip_info($ip) {return sn_function_call(__FUNCTION__, array($ip, &$result)); }
9 9
 function sn_geoip_ip_info($ip, &$result) {
10 10
   return $result = false;
11 11
 }
Please login to merge, or discard this patch.
includes/functions/ali_alliances.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 function ali_rank_list_save($ranks) {
4 4
   global $user;
5 5
 
6
-  if(!empty($ranks)) {
7
-    foreach($ranks as $rank => $rights) {
6
+  if (!empty($ranks)) {
7
+    foreach ($ranks as $rank => $rights) {
8 8
       $rights = implode(',', $rights);
9 9
       $ranklist .= $rights . ';';
10 10
     }
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
   $temp_array = array();
23 23
   $query = db_ally_diplomacy_get_relations($ally_from, $ally_to);
24 24
 
25
-  while($record = db_fetch($query)) {
25
+  while ($record = db_fetch($query)) {
26 26
     $temp_array[$record['alliance_diplomacy_contr_ally_id']] = $record;
27 27
   }
28 28
 
Please login to merge, or discard this patch.
includes/db/db_helpers.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@
 block discarded – undo
27 27
  */
28 28
 function db_set_make_safe_string($set, $delta = false) {
29 29
   $set_safe = array();
30
-  foreach($set as $field => $value) {
31
-    if(empty($field)) {
30
+  foreach ($set as $field => $value) {
31
+    if (empty($field)) {
32 32
       continue;
33 33
     }
34 34
 
35 35
     $field = '`' . db_escape($field) . '`';
36 36
     $new_value = $value;
37
-    if($value === null) {
37
+    if ($value === null) {
38 38
       $new_value = 'NULL';
39
-    } elseif(is_string($value) && (string)($new_value = floatval($value)) != (string)$value) {
39
+    } elseif (is_string($value) && (string) ($new_value = floatval($value)) != (string) $value) {
40 40
       // non-float
41 41
       $new_value = '"' . db_escape($value) . '"';
42
-    } elseif($delta) {
42
+    } elseif ($delta) {
43 43
       // float and DELTA-set
44 44
       $new_value = "{$field} + ({$new_value})";
45 45
     }
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: Gorlum
5
- * Date: 26.12.2015
6
- * Time: 17:19
7
- */
3
+   * Created by PhpStorm.
4
+   * User: Gorlum
5
+   * Date: 26.12.2015
6
+   * Time: 17:19
7
+   */
8 8
 
9 9
 /**
10 10
  * Normalize and make ID safe
Please login to merge, or discard this patch.
includes/db/db_queries.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 function db_stat_list_statistic($who, $is_common_stat, $Rank, $start, $source = false) {
87 87
 // pdump($source);
88
-  if(!$source) {
88
+  if (!$source) {
89 89
     $source = array(
90 90
       'statpoints' => 'statpoints',
91 91
       'users'      => 'users',
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
     );
107 107
   }
108 108
 // pdump($source);
109
-  if($who == 1) {
110
-    if($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday`
109
+  if ($who == 1) {
110
+    if ($is_common_stat) { // , UNIX_TIMESTAMP(CONCAT(YEAR(CURRENT_DATE), DATE_FORMAT(`user_birthday`, '-%m-%d'))) AS `nearest_birthday`
111 111
       $query_str =
112 112
         "SELECT
113 113
       @rownum:=@rownum+1 rownum, subject.{$source['id']} as `id`, sp.{$Rank}_rank as rank, sp.{$Rank}_old_rank as rank_old, sp.{$Rank}_points as points, subject.{$source['username']} as `name`, subject.*
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) {
192 192
   $current_value_safe = db_escape($current_value_unsafe);
193 193
   $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true);
194
-  if(!isset($value_id['id_field']) || !$value_id['id_field']) {
194
+  if (!isset($value_id['id_field']) || !$value_id['id_field']) {
195 195
     doquery("INSERT INTO {{{$db_table_name}}} (`{$db_value_field_name}`) VALUES ('{$current_value_safe}');");
196 196
     $variable_id = db_insert_id();
197 197
   } else {
Please login to merge, or discard this patch.
Doc Comments   +20 added lines, -15 removed lines patch added patch discarded remove patch
@@ -188,6 +188,11 @@  discard block
 block discarded – undo
188 188
  */
189 189
 // OK v4
190 190
 // TODO - вынести в отдельный класс
191
+/**
192
+ * @param string $db_id_field_name
193
+ * @param string $db_table_name
194
+ * @param string $db_value_field_name
195
+ */
191 196
 function db_get_set_unique_id_value($current_value_unsafe, $db_id_field_name, $db_table_name, $db_value_field_name) {
192 197
   $current_value_safe = db_escape($current_value_unsafe);
193 198
   $value_id = doquery("SELECT `{$db_id_field_name}` AS id_field FROM {{{$db_table_name}}} WHERE `{$db_value_field_name}` = '{$current_value_safe}' LIMIT 1 FOR UPDATE", true);
@@ -220,7 +225,7 @@  discard block
 block discarded – undo
220 225
 
221 226
 /**
222 227
  * @param $user
223
- * @param $username_safe
228
+ * @param string $username_safe
224 229
  */
225 230
 function db_player_name_history_replace($user, $username_safe) {
226 231
   doquery("REPLACE INTO {{player_name_history}} SET `player_id` = {$user['id']}, `player_name` = '{$username_safe}'");
@@ -228,7 +233,7 @@  discard block
 block discarded – undo
228 233
 
229 234
 
230 235
 /**
231
- * @param $username_safe
236
+ * @param string $username_safe
232 237
  *
233 238
  * @return array|bool|mysqli_result|null
234 239
  */
@@ -485,12 +490,12 @@  discard block
 block discarded – undo
485 490
 
486 491
 
487 492
 /**
488
- * @param $user_id
489
- * @param $change_type
493
+ * @param integer $user_id
494
+ * @param integer $change_type
490 495
  * @param $dark_matter
491
- * @param $comment
496
+ * @param string $comment
492 497
  * @param $row
493
- * @param $page_url
498
+ * @param string $page_url
494 499
  */
495 500
 function db_log_dark_matter_insert($user_id, $change_type, $dark_matter, $comment, $row, $page_url) {
496 501
   doquery(
@@ -506,7 +511,7 @@  discard block
 block discarded – undo
506 511
 /**
507 512
  * @param $user_id_safe
508 513
  *
509
- * @return array|bool|mysqli_result|null
514
+ * @return integer
510 515
  */
511 516
 function db_referral_get_by_id($user_id_safe) {
512 517
   $old_referral = doquery("SELECT * FROM {{referrals}} WHERE `id` = {$user_id_safe} LIMIT 1 FOR UPDATE;", true);
@@ -534,9 +539,9 @@  discard block
 block discarded – undo
534 539
 
535 540
 // Quests ***********************************************************************************************************
536 541
 /**
537
- * @param $query_add_select
542
+ * @param string $query_add_select
538 543
  * @param $query_add_from
539
- * @param $query_add_where
544
+ * @param string $query_add_where
540 545
  *
541 546
  * @return array|bool|mysqli_result|null
542 547
  */
@@ -580,11 +585,11 @@  discard block
 block discarded – undo
580 585
 }
581 586
 
582 587
 /**
583
- * @param $quest_name
584
- * @param $quest_type
585
- * @param $quest_description
588
+ * @param string $quest_name
589
+ * @param integer $quest_type
590
+ * @param string $quest_description
586 591
  * @param $quest_conditions
587
- * @param $quest_rewards
592
+ * @param string $quest_rewards
588 593
  * @param $quest_id
589 594
  */
590 595
 function db_quest_update($quest_name, $quest_type, $quest_description, $quest_conditions, $quest_rewards, $quest_id) {
@@ -607,7 +612,7 @@  discard block
 block discarded – undo
607 612
 /**
608 613
  * @param $banner
609 614
  * @param $banned
610
- * @param $reason
615
+ * @param string $reason
611 616
  * @param $ban_until
612 617
  */
613 618
 function db_ban_insert($banner, $banned, $reason, $ban_until) {
@@ -630,7 +635,7 @@  discard block
 block discarded – undo
630 635
 /**
631 636
  * @param $banner
632 637
  * @param $banned
633
- * @param $reason
638
+ * @param string $reason
634 639
  */
635 640
 function db_ban_insert_unset($banner, $banned, $reason) {
636 641
   doquery(
Please login to merge, or discard this patch.
includes/includes/flt_mission_hold.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
  * @copyright 2008 by Gorlum for Project "SuperNova.WS"
11 11
  */
12 12
 function flt_mission_hold($mission_data) {
13
-  if($mission_data->fleet->time_mission_job_complete < SN_TIME_NOW) {
13
+  if ($mission_data->fleet->time_mission_job_complete < SN_TIME_NOW) {
14 14
     $mission_data->fleet->mark_fleet_as_returned_and_save();
15 15
 
16 16
     return CACHE_FLEET;
Please login to merge, or discard this patch.
includes/includes/flt_mission_relocate.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
   $destination_planet = &$mission_data->dst_planet;
18 18
 
19
-  if(empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) {
19
+  if (empty($destination_planet['id_owner']) || $objFleet->playerOwnerId != $destination_planet['id_owner']) {
20 20
     $objFleet->mark_fleet_as_returned_and_save();
21 21
 
22 22
     return CACHE_FLEET;
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
       $fleet_resources[RES_DEUTERIUM], $lang['Deuterium']
32 32
     ) . '<br />' . $lang['sys_relocate_mess_user'];
33 33
   $fleet_real_array = $objFleet->get_unit_list();
34
-  foreach($fleet_real_array as $ship_id => $ship_count) {
34
+  foreach ($fleet_real_array as $ship_id => $ship_count) {
35 35
     $Message .= $lang['tech'][$ship_id] . ' - ' . $ship_count . '<br />';
36 36
   }
37 37
   msg_send_simple_message(
Please login to merge, or discard this patch.
includes/includes/flt_mission_transport.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
   $source_planet = &$mission_data->src_planet;
17 17
   $destination_planet = &$mission_data->dst_planet;
18 18
 
19
-  if(!isset($destination_planet['id']) || !$destination_planet['id_owner']) {
19
+  if (!isset($destination_planet['id']) || !$destination_planet['id_owner']) {
20 20
     $objFleet->mark_fleet_as_returned_and_save();
21 21
 
22 22
     return CACHE_FLEET;
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     $fleet_resources[RES_DEUTERIUM], $lang['Deuterium']);
32 32
   msg_send_simple_message($objFleet->target_owner_id, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message);
33 33
 
34
-  if($objFleet->target_owner_id <> $objFleet->playerOwnerId) {
34
+  if ($objFleet->target_owner_id <> $objFleet->playerOwnerId) {
35 35
     msg_send_simple_message($objFleet->playerOwnerId, '', $objFleet->time_arrive_to_target, MSG_TYPE_TRANSPORT, $lang['sys_mess_tower'], $lang['sys_mess_transport'], $Message);
36 36
   }
37 37
 
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 /**
32 32
  * Fleet mission "Relocate"
33 33
  *
34
- * @param $mission_data Mission
34
+ * @param Mission $mission_data Mission
35 35
  *
36 36
  * @return int
37 37
  *
Please login to merge, or discard this patch.
includes/includes/flt_mission_recycle.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
   $destination_planet = &$mission_data->dst_planet;
22 22
 
23
-  if(empty($destination_planet['id'])) {
23
+  if (empty($destination_planet['id'])) {
24 24
     $objFleet->mark_fleet_as_returned();
25 25
     $objFleet->flush_changes_to_db();
26 26
 
@@ -31,10 +31,10 @@  discard block
 block discarded – undo
31 31
   $OtherFleetCapacity = 0;
32 32
 
33 33
   $fleet_array = $objFleet->get_unit_list();
34
-  foreach($fleet_array as $unit_id => $unit_count) {
35
-    if(in_array($unit_id, sn_get_groups('fleet'))) {
34
+  foreach ($fleet_array as $unit_id => $unit_count) {
35
+    if (in_array($unit_id, sn_get_groups('fleet'))) {
36 36
       $capacity = get_unit_param($unit_id, P_CAPACITY) * $unit_count;
37
-      if(in_array($unit_id, sn_get_groups('flt_recyclers'))) {
37
+      if (in_array($unit_id, sn_get_groups('flt_recyclers'))) {
38 38
         $RecyclerCapacity += $capacity;
39 39
       } else {
40 40
         $OtherFleetCapacity += $capacity;
@@ -43,33 +43,33 @@  discard block
 block discarded – undo
43 43
   }
44 44
 
45 45
   $fleet_resources_amount = $objFleet->get_resources_amount();
46
-  if($fleet_resources_amount > $OtherFleetCapacity) {
46
+  if ($fleet_resources_amount > $OtherFleetCapacity) {
47 47
     // Если во флоте есть другие корабли И количество ресурсов больше, чем их ёмкость трюмов - значит часть этих ресурсов лежит в трюмах переработчиков
48 48
     // Уменьшаем ёмкость переработчиков на указанную величину
49 49
     $RecyclerCapacity -= ($fleet_resources_amount - $OtherFleetCapacity);
50 50
   }
51 51
 
52 52
   $resources_recycled = array();
53
-  if(($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) {
53
+  if (($destination_planet["debris_metal"] + $destination_planet["debris_crystal"]) <= $RecyclerCapacity) {
54 54
     $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
55 55
     $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
56 56
   } else {
57
-    if(($destination_planet["debris_metal"] > $RecyclerCapacity / 2) &&
57
+    if (($destination_planet["debris_metal"] > $RecyclerCapacity / 2) &&
58 58
       ($destination_planet["debris_crystal"] > $RecyclerCapacity / 2)
59 59
     ) {
60 60
       $resources_recycled[RES_METAL] = $RecyclerCapacity / 2;
61 61
       $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity / 2;
62 62
     } else {
63
-      if($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) {
63
+      if ($destination_planet["debris_metal"] > $destination_planet["debris_crystal"]) {
64 64
         $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
65
-        if($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) {
65
+        if ($destination_planet["debris_metal"] > ($RecyclerCapacity - $resources_recycled[RES_CRYSTAL])) {
66 66
           $resources_recycled[RES_METAL] = $RecyclerCapacity - $resources_recycled[RES_CRYSTAL];
67 67
         } else {
68 68
           $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
69 69
         }
70 70
       } else {
71 71
         $resources_recycled[RES_METAL] = $destination_planet["debris_metal"];
72
-        if($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) {
72
+        if ($destination_planet["debris_crystal"] > ($RecyclerCapacity - $resources_recycled[RES_METAL])) {
73 73
           $resources_recycled[RES_CRYSTAL] = $RecyclerCapacity - $resources_recycled[RES_METAL];
74 74
         } else {
75 75
           $resources_recycled[RES_CRYSTAL] = $destination_planet["debris_crystal"];
Please login to merge, or discard this patch.