Completed
Push — work-fleets ( 044eff...9436a2 )
by SuperNova.WS
08:51
created
includes/functions/_news.php 1 patch
Spacing   +15 added lines, -16 removed lines patch added patch discarded remove patch
@@ -11,15 +11,15 @@  discard block
 block discarded – undo
11 11
   $announce_list = db_news_list_get_by_query($template, $query_where, $query_limit);
12 12
 
13 13
   $users = array();
14
-  while($announce = db_fetch($announce_list)) {
15
-    if($announce['user_id'] && !isset($users[$announce['user_id']])) {
14
+  while ($announce = db_fetch($announce_list)) {
15
+    if ($announce['user_id'] && !isset($users[$announce['user_id']])) {
16 16
       $users[$announce['user_id']] = DBStaticUser::db_user_by_id($announce['user_id']);
17 17
     }
18 18
 
19 19
     $survey_vote = array('survey_vote_id' => 1);
20 20
     $survey_complete = strtotime($announce['survey_until']) < SN_TIME_NOW;
21 21
 
22
-    if($announce['survey_id'] && !empty($user['id'])) {
22
+    if ($announce['survey_id'] && !empty($user['id'])) {
23 23
       $survey_vote = !$survey_complete ? db_survey_get_vote($announce, $user) : array();
24 24
     }
25 25
 
@@ -31,8 +31,7 @@  discard block
 block discarded – undo
31 31
       'ANNOUNCE'        => cht_message_parse($announce['strAnnounce'], false, intval($announce['authlevel'])),
32 32
       'DETAIL_URL'      => $announce['detail_url'],
33 33
       'USER_NAME'       =>
34
-        isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) :
35
-          js_safe_string($announce['user_name']),
34
+        isset($users[$announce['user_id']]) && $users[$announce['user_id']] ? player_nick_render_to_html($users[$announce['user_id']], array('color' => true)) : js_safe_string($announce['user_name']),
36 35
       'NEW'             => $announce['unix_time'] + classSupernova::$config->game_news_actual >= SN_TIME_NOW,
37 36
       'FUTURE'          => $announce['unix_time'] > SN_TIME_NOW,
38 37
       'SURVEY_ID'       => $announce['survey_id'],
@@ -42,25 +41,25 @@  discard block
 block discarded – undo
42 41
       'SURVEY_UNTIL'    => $announce['survey_until'],
43 42
     ));
44 43
 
45
-    foreach($announce_exploded as $announce_paragraph) {
44
+    foreach ($announce_exploded as $announce_paragraph) {
46 45
       $template->assign_block_vars('announces.paragraph', array(
47 46
         'TEXT' => $announce_paragraph,
48 47
       ));
49 48
     }
50 49
 
51
-    if($announce['survey_id']) {
50
+    if ($announce['survey_id']) {
52 51
       $survey_query = db_survey_get_answer_texts($announce);
53 52
       $survey_vote_result = array();
54 53
       $total_votes = 0;
55
-      while($row = db_fetch($survey_query)) {
54
+      while ($row = db_fetch($survey_query)) {
56 55
         $survey_vote_result[] = $row;
57 56
         $total_votes += $row['VOTES'];
58 57
       }
59 58
 
60
-      if(empty($survey_vote) && !$survey_complete) {
59
+      if (empty($survey_vote) && !$survey_complete) {
61 60
         // Can vote
62 61
         $survey_query = db_survey_answers_get_list_by_parent($announce);
63
-        while($row = db_fetch($survey_query)) {
62
+        while ($row = db_fetch($survey_query)) {
64 63
           $template->assign_block_vars('announces.survey_answers', array(
65 64
             'ID'   => $row['survey_answer_id'],
66 65
             'TEXT' => $row['survey_answer_text'],
@@ -68,7 +67,7 @@  discard block
 block discarded – undo
68 67
         }
69 68
       } else {
70 69
         // Show result
71
-        foreach($survey_vote_result as &$vote_result) {
70
+        foreach ($survey_vote_result as &$vote_result) {
72 71
           $vote_percent = $total_votes ? $vote_result['VOTES'] / $total_votes * 100 : 0;
73 72
           $vote_result['PERCENT'] = $vote_percent;
74 73
           $vote_result['PERCENT_TEXT'] = round($vote_percent, 1);
@@ -85,8 +84,8 @@  discard block
 block discarded – undo
85 84
 }
86 85
 
87 86
 function nws_mark_read(&$user) {
88
-  if(isset($user['id'])) {
89
-    DBStaticUser::db_user_set_by_id($user['id'], '`news_lastread` = ' . SN_TIME_NOW);
87
+  if (isset($user['id'])) {
88
+    DBStaticUser::db_user_set_by_id($user['id'], '`news_lastread` = '.SN_TIME_NOW);
90 89
     $user['news_lastread'] = SN_TIME_NOW;
91 90
   }
92 91
 
@@ -94,17 +93,17 @@  discard block
 block discarded – undo
94 93
 }
95 94
 
96 95
 function survey_vote(&$user) {
97
-  if(empty($user['id'])) {
96
+  if (empty($user['id'])) {
98 97
     return true;
99 98
   }
100 99
 
101 100
   sn_db_transaction_start();
102 101
   $survey_id = sys_get_param_id('survey_id');
103 102
   $is_voted = db_survey_vote_get($user, $survey_id);
104
-  if(empty($is_voted)) {
103
+  if (empty($is_voted)) {
105 104
     $survey_vote_id = sys_get_param_id('survey_vote');
106 105
     $is_answer_exists = db_survey_answer_get($survey_id, $survey_vote_id);
107
-    if(!empty($is_answer_exists)) {
106
+    if (!empty($is_answer_exists)) {
108 107
       $user_name_safe = db_escape($user['username']);
109 108
       db_survey_vote_insert($user, $survey_id, $survey_vote_id, $user_name_safe);
110 109
     }
Please login to merge, or discard this patch.
includes/alliance/ali_internal_members.inc 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -2,31 +2,31 @@  discard block
 block discarded – undo
2 2
 
3 3
 $classLocale = classLocale::$lang;
4 4
 
5
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
5
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
6 6
   classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
7 7
 }
8 8
 
9 9
 // Changing rank for single user
10 10
 $id_user = sys_get_param_id('id_user');
11
-if(isset($_GET['id_rank'])) {
11
+if (isset($_GET['id_rank'])) {
12 12
   $id_rank = sys_get_param_int('id_rank');
13 13
 }
14
-if($id_user && isset($id_rank) && $user_admin) {
14
+if ($id_user && isset($id_rank) && $user_admin) {
15 15
   DBStaticUser::db_user_set_by_id($id_user, "`ally_rank_id` = {$id_rank}");
16 16
 }
17 17
 
18 18
 $id_kick = sys_get_param_id('kick');
19 19
 
20
-if($id_kick && $user_can_kick) {
20
+if ($id_kick && $user_can_kick) {
21 21
   $u = DBStaticUser::db_user_by_id($id_kick, true);
22
-  if($u['ally_id'] == $ally['id'] && $u['id'] != $ally['ally_owner']) {
22
+  if ($u['ally_id'] == $ally['id'] && $u['id'] != $ally['ally_owner']) {
23 23
     DBStaticUser::db_user_set_by_id($id_kick, '`ally_id`= null, `ally_name` = null, `ally_tag` = null, ally_register_time = 0, ally_rank_id = 0');
24 24
     db_ally_update_member_decrease($ally);
25 25
   }
26 26
 }
27 27
 
28 28
 $sort2 = sys_get_param_int('sort2');
29
-if($sort2) {
29
+if ($sort2) {
30 30
   $sort2s = "DESC";
31 31
   $sort2 = 0;
32 32
 } else {
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 }
36 36
 
37 37
 $sort1 = sys_get_param_int('sort1');
38
-if($sort1 > 5 || $sort1 < 0) {
38
+if ($sort1 > 5 || $sort1 < 0) {
39 39
   $sort1 = 0;
40 40
 }
41 41
 $sort1s = array(
@@ -49,28 +49,28 @@  discard block
 block discarded – undo
49 49
 
50 50
 $template = gettemplate('ali_members', true);
51 51
 
52
-$userList = DBStaticUser::db_user_list("`ally_id`= {$user['ally_id']} ORDER BY " . sprintf($sort1s[$sort1], $sort2s), false,
52
+$userList = DBStaticUser::db_user_list("`ally_id`= {$user['ally_id']} ORDER BY ".sprintf($sort1s[$sort1], $sort2s), false,
53 53
   'id, username, galaxy, system, planet, onlinetime, ally_rank_id, ally_register_time, total_points');
54 54
 
55 55
 // while ($userRow = db_fetch($userList))
56
-foreach($userList as $userRow) {
56
+foreach ($userList as $userRow) {
57 57
   $i++;
58
-  if(!isset($ranks[$userRow['ally_rank_id']])) {
58
+  if (!isset($ranks[$userRow['ally_rank_id']])) {
59 59
     $userRow['ally_rank_id'] = 0;
60 60
   }
61 61
 
62
-  if($ally['ally_owner'] == $userRow['id']) {
62
+  if ($ally['ally_owner'] == $userRow['id']) {
63 63
     $ally_range = ($ally['ally_owner_range']) ? $ally['ally_owner_range'] : classLocale::$lang['Founder'];
64 64
   } else {
65
-    if($user_admin) {
66
-      $ally_range = '<select onchange="window.location=\'alliance.php?mode=admin&edit=members&id_user=' . $userRow['id'] . '&id_rank=\' + this.value">';
65
+    if ($user_admin) {
66
+      $ally_range = '<select onchange="window.location=\'alliance.php?mode=admin&edit=members&id_user='.$userRow['id'].'&id_rank=\' + this.value">';
67 67
 
68
-      foreach($ranks as $rankID => $rankArray) {
69
-        $ally_range .= '<option value="' . $rankID . '"';
70
-        if($rankID == $userRow['ally_rank_id']) {
68
+      foreach ($ranks as $rankID => $rankArray) {
69
+        $ally_range .= '<option value="'.$rankID.'"';
70
+        if ($rankID == $userRow['ally_rank_id']) {
71 71
           $ally_range .= " selected";
72 72
         }
73
-        $ally_range .= '>' . $rankArray['name'];
73
+        $ally_range .= '>'.$rankArray['name'];
74 74
         $ally_range .= '</option>';
75 75
       }
76 76
       $ally_range .= '</select>';
@@ -80,20 +80,20 @@  discard block
 block discarded – undo
80 80
   }
81 81
 
82 82
   $last_active = time() - $userRow["onlinetime"];
83
-  if($user_admin) {
84
-    if($last_active < 60) {
83
+  if ($user_admin) {
84
+    if ($last_active < 60) {
85 85
       $tmp = "lime>{$classLocale['On']}";
86
-    } elseif($last_active < 60 * 60) {
86
+    } elseif ($last_active < 60 * 60) {
87 87
       $last_active = round($last_active / 60);
88 88
       $tmp = "lime>{$last_active} {$classLocale['sys_min_short']}";
89
-    } elseif($last_active < 60 * 60 * 24) {
89
+    } elseif ($last_active < 60 * 60 * 24) {
90 90
       $last_active = round($last_active / (60 * 60));
91 91
       $tmp = "green>{$last_active} {$classLocale['sys_hrs_short']}";
92 92
     } else {
93 93
       $last_active = round($last_active / (60 * 60 * 24));
94
-      if($last_active < 7) {
94
+      if ($last_active < 7) {
95 95
         $tmp = "yellow";
96
-      } elseif($last_active < 30) {
96
+      } elseif ($last_active < 30) {
97 97
         $tmp = "orange";
98 98
       } else {
99 99
         $tmp = "red";
@@ -101,10 +101,10 @@  discard block
 block discarded – undo
101 101
       $tmp .= ">{$last_active} {$classLocale['sys_day_short']}";
102 102
     }
103 103
   } else {
104
-    if($user_onlinestatus) {
105
-      if($last_active < 60 * 5) {
104
+    if ($user_onlinestatus) {
105
+      if ($last_active < 60 * 5) {
106 106
         $tmp = "lime>{$classLocale['On']}";
107
-      } elseif($last_active < 60 * 15) {
107
+      } elseif ($last_active < 60 * 15) {
108 108
         $tmp = "yellow>{$classLocale['ali_lessThen15min']}";
109 109
       } else {
110 110
         $tmp = "red>{$classLocale['Off']}";
@@ -124,21 +124,21 @@  discard block
 block discarded – undo
124 124
     'SYSTEM'        => $userRow['system'],
125 125
     'PLANET'        => $userRow['planet'],
126 126
     'POINTS'        => pretty_number($userRow['total_points']),
127
-    'ONLINE'        => '<font color=' . $tmp . '</font>',
127
+    'ONLINE'        => '<font color='.$tmp.'</font>',
128 128
     'RANK'          => $ally_range,
129 129
     'REGISTER_TIME' => date(FMT_DATE_TIME, $userRow['ally_register_time']),
130 130
     'SHOW_KICK'     => $user['id'] != $userRow['id'] && $ally['ally_owner'] != $userRow['id'],
131 131
   ));
132 132
 }
133 133
 
134
-if($i != $ally['ally_members']) {
134
+if ($i != $ally['ally_members']) {
135 135
   db_ally_update_member_set($i, $ally);
136 136
 }
137 137
 
138 138
 $template->assign_vars(array(
139
-  'mode'          => $mode . ($edit ? "&edit=" . $edit : ''),
139
+  'mode'          => $mode.($edit ? "&edit=".$edit : ''),
140 140
   'ADMIN_MODE'    => $user_can_kick,
141
-  'dpath'         => SN_ROOT_VIRTUAL . $dpath,
141
+  'dpath'         => SN_ROOT_VIRTUAL.$dpath,
142 142
   'onlineMessage' => $user_admin ? classLocale::$lang['ali_sys_lastActive'] : classLocale::$lang['Online'],
143 143
   'memberCount'   => count($userList),
144 144
   'memberslist'   => $page_list,
Please login to merge, or discard this patch.
includes/alliance/ali_internal_admin_request.inc 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if(!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
3
+if (!defined('SN_IN_ALLY') || SN_IN_ALLY !== true) {
4 4
   classSupernova::$debug->error("Attempt to call ALLIANCE page mode {$mode} directly - not from alliance.php", 'Forbidden', 403);
5 5
 }
6 6
 
@@ -10,16 +10,16 @@  discard block
 block discarded – undo
10 10
 
11 11
 $d = sys_get_param_id('d');
12 12
 
13
-if($d) {
13
+if ($d) {
14 14
   db_ally_request_deny($d);
15 15
 }
16 16
 
17 17
 $id_user = sys_get_param_id('id_user');
18 18
 
19
-if($id_user) {
19
+if ($id_user) {
20 20
   $ally_name_safe = db_escape($ally['ally_name']);
21 21
   $ally_tag_safe = db_escape($ally['ally_tag']);
22
-  DBStaticUser::db_user_set_by_id($id_user, "`ally_id` = '{$ally['id']}', `ally_name` = '{$ally_name_safe}', `ally_tag` = '{$ally_tag_safe}', `ally_register_time` = " . SN_TIME_NOW . ", `ally_rank_id` = 0");
22
+  DBStaticUser::db_user_set_by_id($id_user, "`ally_id` = '{$ally['id']}', `ally_name` = '{$ally_name_safe}', `ally_tag` = '{$ally_tag_safe}', `ally_register_time` = ".SN_TIME_NOW.", `ally_rank_id` = 0");
23 23
   db_ally_update_member_increase($ally);
24 24
   db_ally_request_delete_by_user_id($id_user);
25 25
 }
Please login to merge, or discard this patch.
includes/classes/UBE/UBEMoonCalculator.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
     $debris_for_moon = $debris->debris_total();
72 72
 
73
-    if(!$debris_for_moon) {
73
+    if (!$debris_for_moon) {
74 74
       return;
75 75
     }
76 76
 
@@ -78,12 +78,12 @@  discard block
 block discarded – undo
78 78
     $moon_chance = min($debris_for_moon / UBE_MOON_DEBRIS_PER_PERCENT, UBE_MOON_PERCENT_MAX); // TODO Configure
79 79
     $moon_chance = $moon_chance >= UBE_MOON_PERCENT_MIN ? $moon_chance : 0;
80 80
     $this->create_chance = $moon_chance;
81
-    if($moon_chance) {
82
-      if($is_simulator || mt_rand(1, 100) <= $moon_chance) {
81
+    if ($moon_chance) {
82
+      if ($is_simulator || mt_rand(1, 100) <= $moon_chance) {
83 83
         $this->status = UBE_MOON_CREATE_SUCCESS;
84 84
         $this->moon_diameter = round($is_simulator ? $moon_chance * 150 + 1999 : mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999));
85 85
 
86
-        if($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) {
86
+        if ($debris_for_moon <= UBE_MOON_DEBRIS_MAX_SPENT) {
87 87
           $debris->_reset();
88 88
         } else {
89 89
           $moon_debris_left_percent = ($debris_for_moon - UBE_MOON_DEBRIS_MAX_SPENT) / $debris_for_moon;
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
    */
103 103
   protected function moon_destroy_try($reapers) {
104 104
     // TODO: $is_simulator
105
-    if($reapers <= 0) {
105
+    if ($reapers <= 0) {
106 106
       return;
107 107
     }
108 108
 
@@ -120,8 +120,8 @@  discard block
 block discarded – undo
120 120
    * @version 2016-02-25 23:42:45 41a4.68
121 121
    */
122 122
   public function calculate_moon(UBE $ube) {
123
-    if(UBE_MOON_EXISTS == $this->status) {
124
-      if($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) {
123
+    if (UBE_MOON_EXISTS == $this->status) {
124
+      if ($ube->mission_type_id == MT_DESTROY && $ube->combat_result == UBE_COMBAT_RESULT_WIN) {
125 125
         $reapers = $ube->fleet_list->ube_calculate_attack_reapers();
126 126
         $this->moon_destroy_try($reapers);
127 127
       }
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
   }
132 132
 
133 133
   public function report_generate_sql() {
134
-    return "`ube_report_moon` = " . (int)$this->status . ",
135
-      `ube_report_moon_chance` = " . (int)$this->create_chance . ",
136
-      `ube_report_moon_size` = " . (float)$this->moon_diameter . ",
137
-      `ube_report_moon_reapers` = " . (int)$this->reapers_status . ",
138
-      `ube_report_moon_destroy_chance` = " . (int)$this->destroy_chance . ",
139
-      `ube_report_moon_reapers_die_chance` = " . (int)$this->reaper_die_chance;
134
+    return "`ube_report_moon` = ".(int) $this->status.",
135
+      `ube_report_moon_chance` = " . (int) $this->create_chance.",
136
+      `ube_report_moon_size` = " . (float) $this->moon_diameter.",
137
+      `ube_report_moon_reapers` = " . (int) $this->reapers_status.",
138
+      `ube_report_moon_destroy_chance` = " . (int) $this->destroy_chance.",
139
+      `ube_report_moon_reapers_die_chance` = " . (int) $this->reaper_die_chance;
140 140
   }
141 141
 
142 142
   public function report_render_moon() {
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
    * @param $planet_id
167 167
    */
168 168
   public function db_apply_result($planet_info, $destination_user_id) {
169
-    if($this->status == UBE_MOON_CREATE_SUCCESS) {
169
+    if ($this->status == UBE_MOON_CREATE_SUCCESS) {
170 170
       $moon_row = uni_create_moon($planet_info[PLANET_GALAXY], $planet_info[PLANET_SYSTEM], $planet_info[PLANET_PLANET], $destination_user_id, $this->moon_diameter, '', false);
171 171
       $this->moon_name = $moon_row['name'];
172 172
       unset($moon_row);
173
-    } elseif($this->status == UBE_MOON_DESTROY_SUCCESS) {
173
+    } elseif ($this->status == UBE_MOON_DESTROY_SUCCESS) {
174 174
       DBStaticPlanet::db_planet_delete_by_id($planet_info[PLANET_ID]);
175 175
     }
176 176
   }
@@ -179,18 +179,18 @@  discard block
 block discarded – undo
179 179
     $classLocale = classLocale::$lang;
180 180
 
181 181
     $text_defender = '';
182
-    if($this->status == UBE_MOON_CREATE_SUCCESS) {
182
+    if ($this->status == UBE_MOON_CREATE_SUCCESS) {
183 183
       $text_defender .= "{$classLocale['ube_report_moon_created']} {$this->moon_diameter} {$classLocale['sys_kilometers_short']}<br /><br />";
184
-    } elseif($this->status == UBE_MOON_CREATE_FAILED) {
184
+    } elseif ($this->status == UBE_MOON_CREATE_FAILED) {
185 185
       $text_defender .= "{$classLocale['ube_report_moon_chance']} {$this->create_chance}%<br /><br />";
186 186
     }
187 187
 
188
-    if($ube->mission_type_id == MT_DESTROY) {
189
-      if($this->reapers_status == UBE_MOON_REAPERS_NONE) {
188
+    if ($ube->mission_type_id == MT_DESTROY) {
189
+      if ($this->reapers_status == UBE_MOON_REAPERS_NONE) {
190 190
         $text_defender .= classLocale::$lang['ube_report_moon_reapers_none'];
191 191
       } else {
192 192
         $text_defender .= "{$classLocale['ube_report_moon_reapers_wave']}. {$classLocale['ube_report_moon_reapers_chance']} {$this->destroy_chance}%. ";
193
-        $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure'] . "<br />";
193
+        $text_defender .= classLocale::$lang[$this->status == UBE_MOON_DESTROY_SUCCESS ? 'ube_report_moon_reapers_success' : 'ube_report_moon_reapers_failure']."<br />";
194 194
 
195 195
         $text_defender .= "{$classLocale['ube_report_moon_reapers_outcome']} {$this->reaper_die_chance}%. ";
196 196
         $text_defender .= classLocale::$lang[$this->reapers_status == UBE_MOON_REAPERS_RETURNED ? 'ube_report_moon_reapers_survive' : 'ube_report_moon_reapers_died'];
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
    * @version 2016-02-25 23:42:45 41a4.68
216 216
    */
217 217
   public function ubeInitLoadStatis($destination_planet) {
218
-    if($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) {
218
+    if ($destination_planet['planet_type'] == PT_MOON || is_array($moon = DBStaticPlanet::db_planet_by_parent($destination_planet['id'], true, '`id`'))) {
219 219
       $this->status = UBE_MOON_EXISTS;
220 220
       $this->moon_diameter = !empty($moon['planet_type']) && $moon['planet_type'] == PT_MOON ? $moon['diameter'] : $destination_planet['diameter'];
221 221
       $this->reapers_status = UBE_MOON_REAPERS_NONE;
Please login to merge, or discard this patch.
includes/includes/art_artifact.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
   $unit_level = $artifact_level_old = mrc_get_level($user, null, $unit_id, true);
14 14
   if ($unit_level > 0) {
15 15
     $db_changeset = array();
16
-    switch($unit_id) {
16
+    switch ($unit_id) {
17 17
       case ART_LHC:
18 18
       case ART_HOOK_SMALL:
19 19
       case ART_HOOK_MEDIUM:
@@ -133,6 +133,6 @@  discard block
 block discarded – undo
133 133
 
134 134
   sn_db_transaction_commit();
135 135
   message($message, "{$classLocale['tech'][UNIT_ARTIFACTS]} - {$classLocale['tech'][$unit_id]}",
136
-    ($request_uri = sys_get_param_str_unsafe('REQUEST_URI')) ? $request_uri : ('artifacts' . DOT_PHP_EX . '#' . $unit_id),
136
+    ($request_uri = sys_get_param_str_unsafe('REQUEST_URI')) ? $request_uri : ('artifacts'.DOT_PHP_EX.'#'.$unit_id),
137 137
     5);
138 138
 }
Please login to merge, or discard this patch.
includes/classes/DBStaticPlanet.php 2 patches
Doc Comments   +14 added lines patch added patch discarded remove patch
@@ -21,11 +21,19 @@  discard block
 block discarded – undo
21 21
     return empty($result) ? null : $result;
22 22
   }
23 23
 
24
+  /**
25
+   * @param integer $galaxy
26
+   * @param integer $system
27
+   * @param integer $planet
28
+   */
24 29
   public static function db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update = false, $fields = '*') {
25 30
     return classSupernova::db_get_record_list(LOC_PLANET,
26 31
       "{{planets}}.`galaxy` = {$galaxy} AND {{planets}}.`system` = {$system} AND {{planets}}.`planet` = {$planet} AND {{planets}}.`planet_type` = {$planet_type}", true);
27 32
   }
28 33
 
34
+  /**
35
+   * @param integer $planet_type
36
+   */
29 37
   public static function db_planet_by_gspt($galaxy, $system, $planet, $planet_type, $for_update = false, $fields = '*') {
30 38
     $galaxy = intval($galaxy);
31 39
     $system = intval($system);
@@ -120,6 +128,9 @@  discard block
 block discarded – undo
120 128
       "`id_owner` = '{$user_row['id']}' {$conditions} ORDER BY {$order_by}");
121 129
   }
122 130
 
131
+  /**
132
+   * @param integer $planet_id
133
+   */
123 134
   public static function db_planet_list_by_user_or_planet($user_id, $planet_id) {
124 135
     if(!($user_id = idval($user_id)) && !($planet_id = idval($planet_id))) {
125 136
       return false;
@@ -138,6 +149,9 @@  discard block
 block discarded – undo
138 149
     return classSupernova::db_upd_record_by_id(LOC_PLANET, $planet_id, $set);
139 150
   }
140 151
 
152
+  /**
153
+   * @param integer $ui_planet_type
154
+   */
141 155
   public static function db_planet_set_by_gspt($ui_galaxy, $ui_system, $ui_planet, $ui_planet_type = PT_ALL, $set) {
142 156
     if(!($set = trim($set))) {
143 157
       return false;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -11 removed lines patch added patch discarded remove patch
@@ -55,11 +55,10 @@  discard block
 block discarded – undo
55 55
   }
56 56
 
57 57
   public static function db_planet_by_vector($vector, $prefix = '', $for_update = false, $fields = '*') {
58
-    $galaxy = isset($vector[$prefix . 'galaxy']) ? intval($vector[$prefix . 'galaxy']) : 0;
59
-    $system = isset($vector[$prefix . 'system']) ? intval($vector[$prefix . 'system']) : 0;
60
-    $planet = isset($vector[$prefix . 'planet']) ? intval($vector[$prefix . 'planet']) : 0;
61
-    $planet_type = isset($vector[$prefix . 'planet_type']) ? intval($vector[$prefix . 'planet_type']) :
62
-      (isset($vector[$prefix . 'type']) ? intval($vector[$prefix . 'type']) : 0);
58
+    $galaxy = isset($vector[$prefix.'galaxy']) ? intval($vector[$prefix.'galaxy']) : 0;
59
+    $system = isset($vector[$prefix.'system']) ? intval($vector[$prefix.'system']) : 0;
60
+    $planet = isset($vector[$prefix.'planet']) ? intval($vector[$prefix.'planet']) : 0;
61
+    $planet_type = isset($vector[$prefix.'planet_type']) ? intval($vector[$prefix.'planet_type']) : (isset($vector[$prefix.'type']) ? intval($vector[$prefix.'type']) : 0);
63 62
     $planet_type = $planet_type == PT_DEBRIS ? PT_PLANET : $planet_type;
64 63
 
65 64
     return DBStaticPlanet::db_planet_by_gspt_safe($galaxy, $system, $planet, $planet_type, $for_update, $fields);
@@ -85,7 +84,7 @@  discard block
 block discarded – undo
85 84
     }
86 85
 
87 86
     return classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET,
88
-      "`parent_planet` = {$parent_id} AND `planet_type` = " . PT_MOON, true);
87
+      "`parent_planet` = {$parent_id} AND `planet_type` = ".PT_MOON, true);
89 88
   }
90 89
 
91 90
   public static function db_planet_by_id_and_owner($planet_id, $owner_id, $for_update = false, $fields = '*') {
@@ -106,7 +105,7 @@  discard block
 block discarded – undo
106 105
     }
107 106
 
108 107
     return classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET,
109
-      "`planet_type` = " . PT_MOON . " AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}");
108
+      "`planet_type` = ".PT_MOON." AND `id_owner` = {$user_id} AND `id` != {$this_moon_id}");
110 109
   }
111 110
 
112 111
   public static function db_planet_list_in_system($galaxy, $system) {
@@ -132,7 +131,7 @@  discard block
 block discarded – undo
132 131
     );
133 132
     $order_by = classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT];
134 133
     empty($sort_orders[$order_by]) ? $order_by = SORT_ID : false;
135
-    $order_by = $sort_orders[$order_by] . ' ' . (classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC');
134
+    $order_by = $sort_orders[$order_by].' '.(classSupernova::$user_options[PLAYER_OPTION_PLANET_SORT_INVERSE] == SORT_ASCENDING ? 'ASC' : 'DESC');
136 135
 
137 136
     // Compilating query
138 137
     return classSupernova::$gc->cacheOperator->db_get_record_list(LOC_PLANET,
@@ -157,7 +156,7 @@  discard block
 block discarded – undo
157 156
       $fieldName = pname_resource_name($resourceId);
158 157
       $value = "{$fieldName} = {$fieldName} + ('{$value}')";
159 158
     }
160
-    if($query = implode(',', $planetRowFieldChanges)) {
159
+    if ($query = implode(',', $planetRowFieldChanges)) {
161 160
       classSupernova::$gc->db->doUpdate("UPDATE `{{planets}}` SET {$query} WHERE id = {$planetId}");
162 161
     }
163 162
   }
@@ -208,7 +207,7 @@  discard block
 block discarded – undo
208 207
       return false;
209 208
     }
210 209
     classSupernova::$gc->cacheOperator->db_del_record_by_id(LOC_PLANET, $planet_id);
211
-    classSupernova::$gc->cacheOperator->db_del_record_list(LOC_UNIT, "`unit_location_type` = " . LOC_PLANET . " AND `unit_location_id` = " . $planet_id);
210
+    classSupernova::$gc->cacheOperator->db_del_record_list(LOC_UNIT, "`unit_location_type` = ".LOC_PLANET." AND `unit_location_id` = ".$planet_id);
212 211
 
213 212
     // Очереди очистятся автоматически по FOREIGN KEY
214 213
     return true;
@@ -220,7 +219,7 @@  discard block
 block discarded – undo
220 219
       return false;
221 220
     }
222 221
     classSupernova::$gc->cacheOperator->db_del_record_list(LOC_PLANET, "`id_owner` = {$si_owner_id}");
223
-    classSupernova::$gc->cacheOperator->db_del_record_list(LOC_UNIT, "`unit_location_type` = " . LOC_PLANET . " AND `unit_player_id` = " . $si_owner_id);
222
+    classSupernova::$gc->cacheOperator->db_del_record_list(LOC_UNIT, "`unit_location_type` = ".LOC_PLANET." AND `unit_player_id` = ".$si_owner_id);
224 223
 
225 224
     // Очереди очистятся автоматически по FOREIGN KEY
226 225
     return true;
Please login to merge, or discard this patch.
includes/classes/DBStaticUnit.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -56,6 +56,9 @@  discard block
 block discarded – undo
56 56
     WHERE unit_player_id = {$user_id} AND unit_location_type = " . LOC_PLANET . " AND unit_level > 0 AND unit_snid IN (" . STRUC_LABORATORY . ", " . STRUC_LABORATORY_NANO . ");");
57 57
   }
58 58
 
59
+  /**
60
+   * @param string $set
61
+   */
59 62
   public static function db_unit_set_by_id($unit_id, $set) {
60 63
     return classSupernova::db_upd_record_by_id(LOC_UNIT, $unit_id, $set);
61 64
   }
@@ -69,6 +72,9 @@  discard block
 block discarded – undo
69 72
     return classSupernova::db_ins_record(LOC_UNIT, $set);
70 73
   }
71 74
 
75
+  /**
76
+   * @param integer $unit_location_type
77
+   */
72 78
   public static function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id, $unit_snid = 0) {
73 79
     return classSupernova::db_del_record_list(LOC_UNIT,
74 80
       "`unit_location_type` = {$unit_location_type} AND `unit_location_id` = {$unit_location_id}" .
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     }
25 25
 
26 26
     if (SnCache::isUnitLocatorNotSet($location_type, $location_id)) {
27
-      $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND " . DBStaticUnit::db_unit_time_restrictions());
27
+      $got_data = classSupernova::$gc->cacheOperator->db_get_record_list(LOC_UNIT, "unit_location_type = {$location_type} AND unit_location_id = {$location_id} AND ".DBStaticUnit::db_unit_time_restrictions());
28 28
       if (!empty($got_data) && is_array($got_data)) {
29 29
         foreach ($got_data as $unit_id => $unit_data) {
30 30
           SnCache::setUnitLocatorByLocationAndIDs($location_type, $location_id, $unit_data);
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
 
60 60
   public static function db_unit_count_by_user_and_type_and_snid($user_id, $unit_type = 0, $unit_snid = 0) {
61 61
     $query = classSupernova::$db->doSelect(
62
-      "SELECT unit_snid, sum(unit_level) as `qty`  FROM {{unit}} WHERE `unit_player_id` = {$user_id} " .
63
-      ($unit_type ? "AND `unit_type` = {$unit_type} " : '') .
64
-      ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '') .
62
+      "SELECT unit_snid, sum(unit_level) as `qty`  FROM {{unit}} WHERE `unit_player_id` = {$user_id} ".
63
+      ($unit_type ? "AND `unit_type` = {$unit_type} " : '').
64
+      ($unit_snid ? "AND `unit_snid` = {$unit_snid} " : '').
65 65
       'GROUP BY `unit_snid`'
66 66
     );
67 67
     $result = array();
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     WHERE
82 82
       f.fleet_owner = {$user_id} AND
83 83
       (f.fleet_start_planet_id = {$location_id} OR f.fleet_end_planet_id = {$location_id})
84
-      AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = " . LOC_FLEET . " AND " . self::db_unit_time_restrictions() .
85
-      " LIMIT 1" .
84
+      AND u.unit_snid = {$unit_snid} AND u.`unit_location_type` = ".LOC_FLEET." AND ".self::db_unit_time_restrictions().
85
+      " LIMIT 1".
86 86
       ($for_update ? ' FOR UPDATE' : ''));
87 87
   }
88 88
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
   public static function db_unit_list_laboratories($user_id) {
91 91
     return classSupernova::$db->doSelect("SELECT DISTINCT unit_location_id AS `id`
92 92
     FROM {{unit}}
93
-    WHERE unit_player_id = {$user_id} AND unit_location_type = " . LOC_PLANET . " AND unit_level > 0 AND unit_snid IN (" . STRUC_LABORATORY . ", " . STRUC_LABORATORY_NANO . ");");
93
+    WHERE unit_player_id = {$user_id} AND unit_location_type = ".LOC_PLANET." AND unit_level > 0 AND unit_snid IN (".STRUC_LABORATORY.", ".STRUC_LABORATORY_NANO.");");
94 94
   }
95 95
 
96 96
   public static function db_unit_set_by_id($unit_id, $set) {
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
 
109 109
   public static function db_unit_list_delete($user_id = 0, $unit_location_type, $unit_location_id = 0, $unit_snid = 0) {
110 110
     return classSupernova::$gc->cacheOperator->db_del_record_list(LOC_UNIT,
111
-      "`unit_location_type` = {$unit_location_type}" .
112
-      ($unit_location_id = idval($unit_location_id) ? " AND `unit_location_id` = {$unit_location_id}" : '') .
113
-      ($user_id = idval($user_id) ? " AND `unit_player_id` = {$user_id}" : '') .
111
+      "`unit_location_type` = {$unit_location_type}".
112
+      ($unit_location_id = idval($unit_location_id) ? " AND `unit_location_id` = {$unit_location_id}" : '').
113
+      ($user_id = idval($user_id) ? " AND `unit_player_id` = {$user_id}" : '').
114 114
       ($unit_snid = idval($unit_snid) ? " AND `unit_snid` = {$unit_snid}" : ''));
115 115
   }
116 116
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
     return classSupernova::$db->doSelect(
119 119
       "SELECT unit_player_id, unit_type, unit_snid, unit_level, count(*) AS unit_amount
120 120
     FROM `{{unit}}`
121
-    WHERE unit_level > 0 AND " . self::db_unit_time_restrictions() .
121
+    WHERE unit_level > 0 AND " . self::db_unit_time_restrictions().
122 122
       " GROUP BY unit_player_id, unit_type, unit_snid, unit_level"
123 123
     );
124 124
   }
@@ -130,15 +130,15 @@  discard block
 block discarded – undo
130 130
 
131 131
 
132 132
   public static function db_unit_list_admin_delete_mercenaries_finished() {
133
-    return classSupernova::$db->doDelete("DELETE FROM `{{unit}}` WHERE unit_time_finish IS NOT NULL AND unit_time_finish < FROM_UNIXTIME(" . SN_TIME_NOW . ") AND unit_type = " . UNIT_MERCENARIES);
133
+    return classSupernova::$db->doDelete("DELETE FROM `{{unit}}` WHERE unit_time_finish IS NOT NULL AND unit_time_finish < FROM_UNIXTIME(".SN_TIME_NOW.") AND unit_type = ".UNIT_MERCENARIES);
134 134
   }
135 135
 
136 136
   public static function db_unit_list_admin_set_mercenaries_expire_time($default_length) {
137 137
     return classSupernova::$db->doUpdate(
138 138
       "UPDATE `{{unit}}`
139 139
     SET
140
-      unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW . "),
141
-      unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length) . ")
140
+      unit_time_start = FROM_UNIXTIME(" . SN_TIME_NOW."),
141
+      unit_time_finish = FROM_UNIXTIME(" . (SN_TIME_NOW + $default_length).")
142 142
     WHERE unit_type = " . UNIT_MERCENARIES
143 143
     );
144 144
   }
@@ -163,13 +163,13 @@  discard block
 block discarded – undo
163 163
 
164 164
     $temp = DBStaticUnit::db_get_unit_by_location($user['id'], $unit_location, $location_id, $unit_id, true, 'unit_id');
165 165
     if (!empty($temp['unit_id'])) {
166
-      $result = (bool)classSupernova::$gc->cacheOperator->db_upd_record_list(
166
+      $result = (bool) classSupernova::$gc->cacheOperator->db_upd_record_list(
167 167
         LOC_UNIT, "`unit_level` = `unit_level` + ($unit_value)", "`unit_id` = {$temp['unit_id']}"
168 168
       );
169 169
     } else {
170 170
       $locationIdRendered = $unit_location == LOC_USER ? $user['id'] : $planet_id;
171 171
       $unitType = get_unit_param($unit_id, P_UNIT_TYPE);
172
-      $result = (bool)classSupernova::$gc->cacheOperator->db_ins_record(
172
+      $result = (bool) classSupernova::$gc->cacheOperator->db_ins_record(
173 173
         LOC_UNIT,
174 174
         "unit_player_id = {$user['id']}, 
175 175
         unit_location_type = {$unit_location}, 
Please login to merge, or discard this patch.
includes/classes/DBStaticFleetACS.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -51,16 +51,16 @@
 block discarded – undo
51 51
    */
52 52
   public static function db_acs_insert($fleetid, $user, $objFleet) {
53 53
     doquery("INSERT INTO {{aks}} SET
54
-          `name` = '" . db_escape(classLocale::$lang['flt_acs_prefix'] . $fleetid) . "',
55
-          `teilnehmer` = '" . $user['id'] . "',
56
-          `flotten` = '" . $fleetid . "',
57
-          `ankunft` = '" . $objFleet->time_arrive_to_target . "',
58
-          `galaxy` = '" . $objFleet->fleet_end_galaxy . "',
59
-          `system` = '" . $objFleet->fleet_end_system . "',
60
-          `planet` = '" . $objFleet->fleet_end_planet . "',
61
-          `planet_type` = '" . $objFleet->fleet_end_type . "',
62
-          `eingeladen` = '" . $user['id'] . "',
63
-          `fleet_end_time` = '" . $objFleet->time_return_to_source . "'");
54
+          `name` = '" . db_escape(classLocale::$lang['flt_acs_prefix'].$fleetid)."',
55
+          `teilnehmer` = '" . $user['id']."',
56
+          `flotten` = '" . $fleetid."',
57
+          `ankunft` = '" . $objFleet->time_arrive_to_target."',
58
+          `galaxy` = '" . $objFleet->fleet_end_galaxy."',
59
+          `system` = '" . $objFleet->fleet_end_system."',
60
+          `planet` = '" . $objFleet->fleet_end_planet."',
61
+          `planet_type` = '" . $objFleet->fleet_end_type."',
62
+          `eingeladen` = '" . $user['id']."',
63
+          `fleet_end_time` = '" . $objFleet->time_return_to_source."'");
64 64
   }
65 65
 
66 66
   /**
Please login to merge, or discard this patch.
includes/classes/DBStaticNews.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 function db_news_insert_set($announce_time, $text, $detail_url, $user) {
13 13
   doquery("INSERT INTO {{announce}}
14 14
         SET `tsTimeStamp` = FROM_UNIXTIME({$announce_time}), `strAnnounce`='{$text}', detail_url = '{$detail_url}',
15
-        `user_id` = {$user['id']}, `user_name` = '" . db_escape($user['username']) . "'");
15
+        `user_id` = {$user['id']}, `user_name` = '".db_escape($user['username'])."'");
16 16
 }
17 17
 
18 18
 function db_survey_insert($announce_id, $survey_question, $survey_until) {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
       LEFT JOIN {{survey}} AS s ON s.survey_announce_id = a.idAnnounce
94 94
       LEFT JOIN {{users}} AS u ON u.id = a.user_id
95 95
     {$query_where}
96
-    ORDER BY `tsTimeStamp` DESC, idAnnounce" .
96
+    ORDER BY `tsTimeStamp` DESC, idAnnounce".
97 97
     ($query_limit ? " LIMIT {$query_limit}" : ''));
98 98
 
99 99
   $template->assign_var('NEWS_COUNT', db_num_rows($announce_list));
Please login to merge, or discard this patch.