Test Failed
Branch trunk (412648)
by SuperNova.WS
03:40
created
classes/RequestInfo.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -89,15 +89,15 @@  discard block
 block discarded – undo
89 89
     // Инфа об устройстве и браузере - общая для всех
90 90
     sn_db_transaction_start();
91 91
     $this->device_cypher = $_COOKIE[SN_COOKIE_D];
92
-    if($this->device_cypher) {
92
+    if ($this->device_cypher) {
93 93
       $cypher_safe = db_escape($this->device_cypher);
94 94
       $device_id = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true);
95
-      if(!empty($device_id['device_id'])) {
95
+      if (!empty($device_id['device_id'])) {
96 96
         $this->device_id = $device_id['device_id'];
97 97
       }
98 98
     }
99 99
 
100
-    if($this->device_id <= 0) {
100
+    if ($this->device_id <= 0) {
101 101
       do {
102 102
         $cypher_safe = db_escape($this->device_cypher = sys_random_string());
103 103
         $row = doquery("SELECT `device_id` FROM {{security_device}} WHERE `device_cypher` = '{$cypher_safe}' LIMIT 1 FOR UPDATE", true);
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
     $this->page_address_id = db_get_set_unique_id_value($this->page_address, 'url_id', 'security_url', 'url_string');
119 119
     sn_db_transaction_commit();
120 120
 
121
-    if($this->write_full_url) {
121
+    if ($this->write_full_url) {
122 122
       sn_db_transaction_start();
123 123
       $this->page_url = substr($_SERVER['REQUEST_URI'], strlen(SN_ROOT_RELATIVE));
124
-      if(strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) {
124
+      if (strpos($_SERVER['REQUEST_URI'], '/simulator.php') === 0) {
125 125
         $this->page_url = '/simulator.php';
126 126
       }
127 127
       $this->page_url_id = db_get_set_unique_id_value($this->page_url, 'url_id', 'security_url', 'url_string');
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
    */
145 145
   public function db_security_entry_insert($user_id_unsafe) {
146 146
     // TODO $user_id = !empty(self::$user['id']) ? self::$user['id'] : 'NULL';
147
-    if(empty($user_id_unsafe)) {
147
+    if (empty($user_id_unsafe)) {
148 148
       // self::flog('Нет ИД пользователя');
149 149
       return true;
150 150
     }
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
   public function db_counter_insert($user_id_unsafe) {
168 168
     global $config, $sys_stop_log_hit, $is_watching;
169 169
 
170
-    if($sys_stop_log_hit || !$config->game_counter) {
170
+    if ($sys_stop_log_hit || !$config->game_counter) {
171 171
       return;
172 172
     }
173 173
 
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
 //      $this->ip_v4_int . ", '{$proxy_safe}', " . $this->page_address_id . ", " . $this->page_url_id . ");");
184 184
     doquery(
185 185
       "INSERT INTO {{counter}} SET
186
-        `visit_time` = '" . SN_TIME_SQL. "',
186
+        `visit_time` = '" . SN_TIME_SQL . "',
187 187
         `user_id` = {$user_id_safe},
188 188
         `device_id` = {$this->device_id},
189 189
         `browser_id` = {$this->browser_id},
190 190
         `user_ip` = {$this->ip_v4_int},
191 191
         `user_proxy` = '{$proxy_safe}',
192 192
         `page_url_id` = {$this->page_address_id}" .
193
-        ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '' ).
193
+        ($this->write_full_url ? ", `plain_url_id` = {$this->page_url_id}" : '') .
194 194
       ";");
195 195
 
196 196
     $is_watching = false;
Please login to merge, or discard this patch.
classes/debug.php 4 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -140,11 +140,13 @@
 block discarded – undo
140 140
       $error_backtrace['locks'] = classSupernova::$locks;
141 141
       $error_backtrace['cSN_data'] = classSupernova::$data;
142 142
       foreach($error_backtrace['cSN_data'] as &$location) {
143
-        foreach($location as $location_id => &$location_data) //          $location_data = $location_id;
143
+        foreach($location as $location_id => &$location_data) {
144
+          //          $location_data = $location_id;
144 145
         {
145 146
           $location_data = isset($location_data['username']) ? $location_data['username'] :
146 147
             (isset($location_data['name']) ? $location_data['name'] : $location_id);
147 148
         }
149
+        }
148 150
       }
149 151
       $error_backtrace['cSN_queries'] = classSupernova::$queries;
150 152
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@
 block discarded – undo
76 76
 
77 77
     $result = array();
78 78
     $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++;
79
-    $result[] = "tID {$transaction_id}";
79
+    $result[] = "tid {$transaction_id}";
80 80
     foreach($backtrace as $a_trace) {
81 81
       if(in_array($a_trace['function'], $exclude_functions)) {
82 82
         continue;
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -228,6 +228,9 @@
 block discarded – undo
228 228
     }
229 229
   }
230 230
 
231
+  /**
232
+   * @param string $message
233
+   */
231 234
   function warning($message, $title = 'System Message', $log_code = 300, $dump = false) {
232 235
     global $user, $lang, $sys_log_disabled;
233 236
 
Please login to merge, or discard this patch.
Spacing   +42 added lines, -43 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
  * que esperabas!!! soy newbie!!! D':<
25 25
 */
26 26
 
27
-if(!defined('INSIDE')) {
27
+if (!defined('INSIDE')) {
28 28
   die("attemp hacking");
29 29
 }
30 30
 
@@ -37,16 +37,16 @@  discard block
 block discarded – undo
37 37
   function log_file($message, $ident_change = 0) {
38 38
     static $ident = 0;
39 39
 
40
-    if(!defined('SN_DEBUG_LOG')) {
40
+    if (!defined('SN_DEBUG_LOG')) {
41 41
       return;
42 42
     }
43 43
 
44
-    if($this->log_file_handler === null) {
44
+    if ($this->log_file_handler === null) {
45 45
       $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+');
46 46
       @fwrite($this->log_file_handler, "\r\n\r\n");
47 47
     }
48 48
     $ident_change < 0 ? $ident += $ident_change * 2 : false;
49
-    if($this->log_file_handler) {
49
+    if ($this->log_file_handler) {
50 50
       @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n");
51 51
     }
52 52
     $ident_change > 0 ? $ident += $ident_change * 2 : false;
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     $result = array();
82 82
     $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++;
83 83
     $result[] = "tID {$transaction_id}";
84
-    foreach($backtrace as $a_trace) {
85
-      if(in_array($a_trace['function'], $exclude_functions)) {
84
+    foreach ($backtrace as $a_trace) {
85
+      if (in_array($a_trace['function'], $exclude_functions)) {
86 86
         continue;
87 87
       }
88 88
       $function =
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
       $result[] = "{$function} - '{$file}' Line {$a_trace['line']}";
100 100
 
101
-      if(!$long_comment) {
101
+      if (!$long_comment) {
102 102
         break;
103 103
       }
104 104
     }
@@ -107,26 +107,26 @@  discard block
 block discarded – undo
107 107
   }
108 108
 
109 109
   function dump($dump = false, $force_base = false, $deadlock = false) {
110
-    if($dump === false) {
110
+    if ($dump === false) {
111 111
       return;
112 112
     }
113 113
 
114 114
     $error_backtrace = array();
115 115
     $base_dump = false;
116 116
 
117
-    if($force_base === true) {
117
+    if ($force_base === true) {
118 118
       $base_dump = true;
119 119
     }
120 120
 
121
-    if($dump === true) {
121
+    if ($dump === true) {
122 122
       $base_dump = true;
123 123
     } else {
124
-      if(!is_array($dump)) {
124
+      if (!is_array($dump)) {
125 125
         $dump = array('var' => $dump);
126 126
       }
127 127
 
128
-      foreach($dump as $dump_var_name => $dump_var) {
129
-        if($dump_var_name == 'base_dump') {
128
+      foreach ($dump as $dump_var_name => $dump_var) {
129
+        if ($dump_var_name == 'base_dump') {
130 130
           $base_dump = $dump_var;
131 131
         } else {
132 132
           $error_backtrace[$dump_var_name] = $dump_var;
@@ -134,25 +134,24 @@  discard block
 block discarded – undo
134 134
       }
135 135
     }
136 136
 
137
-    if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
137
+    if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
138 138
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
139 139
       $error_backtrace['locks'] = classSupernova::$locks;
140 140
       $error_backtrace['cSN_data'] = classSupernova::$data;
141
-      foreach($error_backtrace['cSN_data'] as &$location) {
142
-        foreach($location as $location_id => &$location_data) //          $location_data = $location_id;
141
+      foreach ($error_backtrace['cSN_data'] as &$location) {
142
+        foreach ($location as $location_id => &$location_data) //          $location_data = $location_id;
143 143
         {
144
-          $location_data = isset($location_data['username']) ? $location_data['username'] :
145
-            (isset($location_data['name']) ? $location_data['name'] : $location_id);
144
+          $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id);
146 145
         }
147 146
       }
148 147
       $error_backtrace['cSN_queries'] = classSupernova::$queries;
149 148
     }
150 149
 
151
-    if($base_dump) {
152
-      if(!is_array($this->log_array) || empty($this->log_array)) {
150
+    if ($base_dump) {
151
+      if (!is_array($this->log_array) || empty($this->log_array)) {
153 152
         $this->log_array = [];
154 153
       } else {
155
-        foreach($this->log_array as $log) {
154
+        foreach ($this->log_array as $log) {
156 155
           $error_backtrace['queries'][] = $log;
157 156
         }
158 157
       }
@@ -164,17 +163,17 @@  discard block
 block discarded – undo
164 163
       // Converting object instances to object names
165 164
 
166 165
       foreach ($error_backtrace['backtrace'] as &$backtrace) {
167
-        if(is_object($backtrace['object'])) {
166
+        if (is_object($backtrace['object'])) {
168 167
           $backtrace['object'] = get_class($backtrace['object']);
169 168
         }
170 169
 
171
-        if(empty($backtrace['args'])) {
170
+        if (empty($backtrace['args'])) {
172 171
           continue;
173 172
         }
174 173
 
175 174
         // Doing same conversion for backtrace params
176
-        foreach($backtrace['args'] as &$arg) {
177
-          if(is_object($arg)) {
175
+        foreach ($backtrace['args'] as &$arg) {
176
+          if (is_object($arg)) {
178 177
             $arg = 'object::' . get_class($arg);
179 178
           }
180 179
         }
@@ -203,14 +202,14 @@  discard block
 block discarded – undo
203 202
   function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) {
204 203
     global $config, $sys_stop_log_hit, $lang, $sys_log_disabled, $user;
205 204
 
206
-    if(empty(classSupernova::$db->connected)) {
205
+    if (empty(classSupernova::$db->connected)) {
207 206
       // TODO - писать ошибку в файл
208 207
       die('SQL server currently unavailable. Please contact Administration...');
209 208
     }
210 209
 
211 210
     sn_db_transaction_rollback();
212 211
 
213
-    if(classSupernova::$config->debug == 1) {
212
+    if (classSupernova::$config->debug == 1) {
214 213
       echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>";
215 214
       echo "<table>{$this->log}</table>";
216 215
     }
@@ -220,7 +219,7 @@  discard block
 block discarded – undo
220 219
     $error_text = db_escape($message);
221 220
     $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false);
222 221
 
223
-    if(!$sys_log_disabled) {
222
+    if (!$sys_log_disabled) {
224 223
       $query = "INSERT INTO `{{logs}}` SET
225 224
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "',
226 225
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -238,7 +237,7 @@  discard block
 block discarded – undo
238 237
       ob_start();
239 238
       print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}");
240 239
 
241
-      foreach($error_backtrace as $name => $value) {
240
+      foreach ($error_backtrace as $name => $value) {
242 241
         print('<hr>');
243 242
         pdump($value, $name);
244 243
       }
@@ -250,14 +249,14 @@  discard block
 block discarded – undo
250 249
   function warning($message, $title = 'System Message', $log_code = 300, $dump = false) {
251 250
     global $user, $lang, $sys_log_disabled;
252 251
 
253
-    if(empty(classSupernova::$db->connected)) {
252
+    if (empty(classSupernova::$db->connected)) {
254 253
       // TODO - писать ошибку в файл
255 254
       die('SQL server currently unavailable. Please contact Administration...');
256 255
     }
257 256
 
258 257
     $error_backtrace = $this->dump($dump, false);
259 258
 
260
-    if(!$sys_log_disabled) {
259
+    if (!$sys_log_disabled) {
261 260
       $query = "INSERT INTO `{{logs}}` SET
262 261
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . ($user['id'] ? db_escape($user['id']) : 0) . "',
263 262
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -275,11 +274,11 @@  discard block
 block discarded – undo
275 274
 // Dump variables nicer then var_dump()
276 275
 
277 276
 function dump($value, $varname = null, $level = 0, $dumper = '') {
278
-  if(isset($varname)) {
277
+  if (isset($varname)) {
279 278
     $varname .= " = ";
280 279
   }
281 280
 
282
-  if($level == -1) {
281
+  if ($level == -1) {
283 282
     $trans[' '] = '&there4;';
284 283
     $trans["\t"] = '&rArr;';
285 284
     $trans["\n"] = '&para;;';
@@ -288,7 +287,7 @@  discard block
 block discarded – undo
288 287
 
289 288
     return strtr(htmlspecialchars($value), $trans);
290 289
   }
291
-  if($level == 0) {
290
+  if ($level == 0) {
292 291
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
293 292
     $dumper = mt_rand(10, 99) . '|' . $varname;
294 293
   }
@@ -296,22 +295,22 @@  discard block
 block discarded – undo
296 295
   $type = gettype($value);
297 296
   $dumper .= $type;
298 297
 
299
-  if($type == 'string') {
298
+  if ($type == 'string') {
300 299
     $dumper .= '(' . strlen($value) . ')';
301 300
     $value = dump($value, '', -1);
302
-  } elseif($type == 'boolean') {
301
+  } elseif ($type == 'boolean') {
303 302
     $value = ($value ? 'true' : 'false');
304
-  } elseif($type == 'object') {
303
+  } elseif ($type == 'object') {
305 304
     $props = get_class_vars(get_class($value));
306 305
     $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
307
-    foreach($props as $key => $val) {
306
+    foreach ($props as $key => $val) {
308 307
       $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
309 308
       $dumper .= dump($value->$key, '', $level + 1);
310 309
     }
311 310
     $value = '';
312
-  } elseif($type == 'array') {
311
+  } elseif ($type == 'array') {
313 312
     $dumper .= '(' . count($value) . ')';
314
-    foreach($value as $key => $val) {
313
+    foreach ($value as $key => $val) {
315 314
       $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
316 315
       $dumper .= dump($val, '', $level + 1);
317 316
     }
@@ -331,7 +330,7 @@  discard block
 block discarded – undo
331 330
 //  $backtrace = $backtrace[1];
332 331
 
333 332
   $caller = '';
334
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
333
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
335 334
     $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
336 335
       (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
337 336
       $backtrace[1]['function'] .
@@ -358,7 +357,7 @@  discard block
 block discarded – undo
358 357
 }
359 358
 
360 359
 function pr($prePrint = false) {
361
-  if($prePrint) {
360
+  if ($prePrint) {
362 361
     print("<br>");
363 362
   }
364 363
   print(mt_rand() . "<br>");
@@ -368,7 +367,7 @@  discard block
 block discarded – undo
368 367
   global $_PRINT_COUNT_VALUE;
369 368
   $_PRINT_COUNT_VALUE++;
370 369
 
371
-  if($prePrint) {
370
+  if ($prePrint) {
372 371
     print("<br>");
373 372
   }
374 373
   print($_PRINT_COUNT_VALUE . "<br>");
Please login to merge, or discard this patch.
notes.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -15,34 +15,34 @@  discard block
 block discarded – undo
15 15
 $template = gettemplate('notes', true);
16 16
 
17 17
 $result = array();
18
-if(($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) {
18
+if (($result_message = sys_get_param_str('MESSAGE')) && isset($lang[$result_message])) {
19 19
   $result[] = array('STATUS' => sys_get_param_int('STATUS'), 'MESSAGE' => $lang[$result_message]);
20 20
 }
21 21
 
22 22
 $note_id_edit = sys_get_param_id('note_id_edit');
23
-if(sys_get_param('note_delete')) {
23
+if (sys_get_param('note_delete')) {
24 24
   try {
25 25
     $not = '';
26 26
     $query_where = '';
27
-    switch(sys_get_param_str('note_delete_range')) {
27
+    switch (sys_get_param_str('note_delete_range')) {
28 28
       case 'all':
29 29
       break;
30 30
 
31 31
       case 'marked_not':
32 32
         $not = 'NOT';
33 33
       case 'marked':
34
-        if(!is_array($notes_marked = sys_get_param('note'))) {
34
+        if (!is_array($notes_marked = sys_get_param('note'))) {
35 35
           throw new exception('note_err_none_selected', ERR_WARNING);
36 36
         }
37 37
 
38 38
         $notes_marked_filtered = array();
39
-        foreach($notes_marked as $note_id => $note_select) {
40
-          if($note_select == 'on' && $note_id = idval($note_id)) {
39
+        foreach ($notes_marked as $note_id => $note_select) {
40
+          if ($note_select == 'on' && $note_id = idval($note_id)) {
41 41
             $notes_marked_filtered[] = $note_id;
42 42
           }
43 43
         }
44 44
 
45
-        if(empty($notes_marked_filtered)) {
45
+        if (empty($notes_marked_filtered)) {
46 46
           throw new exception('note_err_none_selected', ERR_WARNING);
47 47
         }
48 48
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     doquery("DELETE FROM {{notes}} WHERE `owner` = {$user['id']} {$query_where};");
60 60
     sn_db_transaction_commit();
61 61
     throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE);
62
-  } catch(exception $e) {
62
+  } catch (exception $e) {
63 63
     $note_id_edit = 0;
64 64
     sn_db_transaction_rollback();
65 65
     $result[] = array(
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
       'MESSAGE' => $lang[$e->getMessage()],
68 68
     );
69 69
   }
70
-} elseif(($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) {
70
+} elseif (($note_title = sys_get_param_str('note_title')) || ($note_text = sys_get_param_str('note_text'))) {
71 71
   $note_title == db_escape($lang['note_new_title']) ? $note_title = '' : false;
72 72
   ($note_text = sys_get_param_str('note_text')) == db_escape($lang['note_new_text']) ? $note_text = '' : false;
73 73
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     $note_system = max(0, min(sys_get_param_id('note_system'), classSupernova::$config->game_maxSystem));
77 77
     $note_planet = max(0, min(sys_get_param_id('note_planet'), classSupernova::$config->game_maxPlanet + 1));
78 78
 
79
-    if(!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) {
79
+    if (!$note_text && !$note_title && !$note_galaxy && !$note_system && !$note_planet) {
80 80
       throw new exception('note_err_note_empty', ERR_WARNING);
81 81
     }
82 82
 
@@ -85,15 +85,15 @@  discard block
 block discarded – undo
85 85
     $note_sticky = intval(sys_get_param_id('note_sticky')) ? 1 : 0;
86 86
 
87 87
     sn_db_transaction_start();
88
-    if($note_id_edit) {
88
+    if ($note_id_edit) {
89 89
       $check_note_id = doquery("SELECT `id`, `owner` FROM {{notes}} WHERE `id` = {$note_id_edit} LIMIT 1 FOR UPDATE", true);
90
-      if(!$check_note_id) {
90
+      if (!$check_note_id) {
91 91
         throw new exception('note_err_note_not_found', ERR_ERROR);
92 92
       }
93 93
     }
94 94
 
95
-    if($note_id_edit) {
96
-      if($check_note_id['owner'] != $user['id']) {
95
+    if ($note_id_edit) {
96
+      if ($check_note_id['owner'] != $user['id']) {
97 97
         throw new exception('note_err_owner_wrong', ERR_ERROR);
98 98
       }
99 99
 
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
     sn_db_transaction_commit();
109 109
     sys_redirect('notes.php?STATUS=' . ERR_NONE . '&MESSAGE=' . ($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added'));
110 110
 //    throw new exception($note_id_edit ? 'note_err_none_changed' : 'note_err_none_added', ERR_NONE);
111
-  } catch(exception $e) {
111
+  } catch (exception $e) {
112 112
     $note_id_edit = 0;
113 113
     sn_db_transaction_rollback();
114 114
     $result[] = array(
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
   }
119 119
 }
120 120
 
121
-if(!$note_id_edit) {
121
+if (!$note_id_edit) {
122 122
   note_assign($template, array(
123 123
     'id' => 0,
124 124
     'time' => SN_TIME_NOW,
@@ -131,13 +131,13 @@  discard block
 block discarded – undo
131 131
 
132 132
 $note_exist = false;
133 133
 $notes_query = doquery("SELECT * FROM {{notes}} WHERE owner={$user['id']} ORDER BY priority DESC, galaxy ASC, system ASC, planet ASC, planet_type ASC, `time` DESC");
134
-while($note_row = db_fetch($notes_query)) {
134
+while ($note_row = db_fetch($notes_query)) {
135 135
   note_assign($template, $note_row);
136 136
   $note_exist = $note_exist || $note_row['id'] == $note_id_edit;
137 137
 }
138 138
 $note_id_edit = $note_exist ? $note_id_edit : 0;
139 139
 
140
-foreach($note_priority_classes as $note_priority_id => $note_priority_class) {
140
+foreach ($note_priority_classes as $note_priority_id => $note_priority_class) {
141 141
   $template->assign_block_vars('note_priority', array(
142 142
     'ID' => $note_priority_id,
143 143
     'CLASS' => $note_priority_classes[$note_priority_id],
@@ -145,14 +145,14 @@  discard block
 block discarded – undo
145 145
   ));
146 146
 }
147 147
 
148
-foreach($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) {
148
+foreach ($lang['sys_planet_type'] as $planet_type_id => $planet_type_string) {
149 149
   $template->assign_block_vars('planet_type', array(
150 150
     'ID' => $planet_type_id,
151 151
     'TEXT' => $planet_type_string,
152 152
   ));
153 153
 }
154 154
 
155
-foreach($result as $result_data) {
155
+foreach ($result as $result_data) {
156 156
   $template->assign_block_vars('result', $result_data);
157 157
 }
158 158
 
Please login to merge, or discard this patch.
includes/pages/imperium.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -22,17 +22,17 @@  discard block
 block discarded – undo
22 22
   $sn_group_factories = sn_get_groups('factories');
23 23
   $planet_density = sn_get_groups('planet_density');
24 24
 
25
-  if(sys_get_param('save_production')) {
25
+  if (sys_get_param('save_production')) {
26 26
     $production = sys_get_param('percent');
27
-    if(is_array($production) && !empty($production)) {
27
+    if (is_array($production) && !empty($production)) {
28 28
       // sn_db_transaction_start();
29 29
       $query = array();
30 30
       $planet_row_list = DBStaticPlanet::db_planet_list_sorted($user, false, '*');
31 31
       // while($planet = db_fetch($planet_row_list))
32
-      foreach($planet_row_list as $planet) {
33
-        foreach($sn_group_factories as $factory_unit_id) {
32
+      foreach ($planet_row_list as $planet) {
33
+        foreach ($sn_group_factories as $factory_unit_id) {
34 34
           $unit_db_name_porcent = pname_factory_production_field_name($factory_unit_id);
35
-          if(
35
+          if (
36 36
             get_unit_param($factory_unit_id, P_MINING_IS_MANAGED)
37 37
             && isset($production[$factory_unit_id][$planet['id']])
38 38
             && ($actual_porcent = intval($production[$factory_unit_id][$planet['id']] / 10)) >= 0
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
           }
44 44
         }
45 45
       }
46
-      foreach($query as $planet_id => $query_data) {
46
+      foreach ($query as $planet_id => $query_data) {
47 47
         DBStaticPlanet::db_planet_set_by_id($planet_id, implode(',', $query_data));
48 48
       }
49 49
       // sn_db_transaction_commit();
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
   $planet_row_list = DBStaticPlanet::db_planet_list_sorted($user);
54 54
   // while ($planet = db_fetch($planet_row_list))
55
-  foreach($planet_row_list as $planet) {
55
+  foreach ($planet_row_list as $planet) {
56 56
     sn_db_transaction_start();
57 57
     $global_data = sys_o_get_updated($user, $planet['id'], SN_TIME_NOW, false, true);
58 58
     $planets[$planet['id']] = $global_data['planet'];
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
   $template = gettemplate('imperium', $template);
65 65
   $template->assign_var('amount', count($planets) + 2);
66 66
 
67
-  for($i = 100; $i >= 0; $i -= 10) {
67
+  for ($i = 100; $i >= 0; $i -= 10) {
68 68
     $template->assign_block_vars('percent', array('PERCENT' => $i));
69 69
   }
70 70
 
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
     $planet_template = tpl_parse_planet($planet);
80 80
 
81 81
     $planet_fleet_id = 0;
82
-    $fleet_list = $planet_template['fleet_list'];//flt_get_fleets_to_planet($planet);
83
-    if($fleet_list['own']['count'])
82
+    $fleet_list = $planet_template['fleet_list']; //flt_get_fleets_to_planet($planet);
83
+    if ($fleet_list['own']['count'])
84 84
     {
85 85
       $planet_fleet_id = "p{$fleet_id}";
86 86
       $fleets[] = tpl_parse_fleet_sn($fleet_list['own']['total'], $planet_fleet_id);
@@ -142,19 +142,19 @@  discard block
 block discarded – undo
142 142
     UNIT_DEFENCE => 'defense',
143 143
   );
144 144
 
145
-  foreach($show_groups as $unit_group_id => $mode)
145
+  foreach ($show_groups as $unit_group_id => $mode)
146 146
   {
147 147
     $template->assign_block_vars('prods', array(
148 148
       'NAME' => $lang['tech'][$unit_group_id],
149 149
     ));
150 150
     $unit_group = get_unit_param('techtree', $unit_group_id);
151
-    foreach($unit_group as $unit_id)
151
+    foreach ($unit_group as $unit_id)
152 152
     {
153 153
       $unit_count = $unit_count_abs = 0;
154 154
       $block_vars = array();
155 155
       $unit_is_factory = in_array($unit_id, $sn_group_factories) && get_unit_param($unit_id, P_MINING_IS_MANAGED);
156 156
       // $unit_db_name = pname_resource_name($unit_id);
157
-      foreach($planets as $planet)
157
+      foreach ($planets as $planet)
158 158
       {
159 159
         $unit_level_plain = mrc_get_level($user, $planet, $unit_id, false, true);
160 160
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
         $level_plus['LEVEL_PLUS_GREEN'] = 0;
164 164
 
165 165
         $level_plus['PERCENT'] = $unit_is_factory ? ($unit_level_plain ? $planet[pname_factory_production_field_name($unit_id)] * 10 : -1) : -1;
166
-        switch($mode)
166
+        switch ($mode)
167 167
         {
168 168
           /*
169 169
           case 'structures':
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
 
179 179
           /** @noinspection PhpMissingBreakStatementInspection */
180 180
           case 'fleet':
181
-            $level_plus['LEVEL_PLUS_YELLOW'] = $planet['fleet_list']['own']['total'][$unit_id]<=0 ? $planet['fleet_list']['own']['total'][$unit_id] : "+{$planet['fleet_list']['own']['total'][$unit_id]}";
181
+            $level_plus['LEVEL_PLUS_YELLOW'] = $planet['fleet_list']['own']['total'][$unit_id] <= 0 ? $planet['fleet_list']['own']['total'][$unit_id] : "+{$planet['fleet_list']['own']['total'][$unit_id]}";
182 182
             $total['units'][$unit_id]['LEVEL_PLUS_YELLOW'] += $level_plus['LEVEL_PLUS_YELLOW'];
183 183
 
184 184
           case 'structures':
185 185
           case 'defense':
186 186
             $level_plus_build = $ques[$planet['id']]['in_que'][que_get_unit_que($unit_id)][$user['id']][$planet['id']][$unit_id];
187
-            if($level_plus_build)
187
+            if ($level_plus_build)
188 188
             {
189 189
               $level_plus['LEVEL_PLUS_GREEN'] = $level_plus_build < 0 ? $level_plus_build : "+{$level_plus_build}";
190 190
               // $level_plus['LEVEL_PLUS_GREEN'] = "+{$level_plus_build}";
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
         $unit_count_abs += $unit_level_plain + abs($level_plus['LEVEL_PLUS_YELLOW']) + abs($level_plus['LEVEL_PLUS_GREEN']);
206 206
       }
207 207
 
208
-      if($unit_count_abs)
208
+      if ($unit_count_abs)
209 209
       {
210 210
         $template->assign_block_vars('prods', array(
211 211
           'ID'    => $unit_id,
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
           'MODE'  => $mode,
215 215
         ));
216 216
 
217
-        foreach($block_vars as $block_var)
217
+        foreach ($block_vars as $block_var)
218 218
         {
219 219
           $template->assign_block_vars('prods.planet', $block_var);
220 220
         }
Please login to merge, or discard this patch.
includes/db/db_helpers.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,19 +27,19 @@  discard block
 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
     }
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function missile_list_convert_to_fleet(&$missile_db_list, &$fleet_db_list) {
61 61
   // Missile attack
62
-  foreach($missile_db_list as $irak) {
63
-    if($irak['fleet_end_time'] >= SN_TIME_NOW) {
62
+  foreach ($missile_db_list as $irak) {
63
+    if ($irak['fleet_end_time'] >= SN_TIME_NOW) {
64 64
       $irak['fleet_start_type'] = PT_PLANET;
65 65
       $planet_start = DBStaticPlanet::db_planet_by_vector($irak, 'fleet_start_', false, 'name');
66 66
       $irak['fleet_id'] = -$irak['id'];
Please login to merge, or discard this patch.
includes/general_pname.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,12 +2,10 @@
 block discarded – undo
2 2
 
3 3
 // Эти функции будут переписаны по добавлению инфы в БД
4 4
 
5
-function pname_factory_production_field_name($factory_unit_id)
6
-{
5
+function pname_factory_production_field_name($factory_unit_id) {
7 6
   return get_unit_param($factory_unit_id, P_NAME) . '_porcent';
8 7
 }
9 8
 
10
-function pname_resource_name($resource_id)
11
-{
9
+function pname_resource_name($resource_id) {
12 10
   return get_unit_param($resource_id, P_NAME);
13 11
 }
14 12
\ No newline at end of file
Please login to merge, or discard this patch.
includes/functions/uni_functions.php 2 patches
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
 
8 8
   $possible_cores = array();
9 9
   $probability = 0;
10
-  foreach($density_list as $possible_core_id => $core_data) {
11
-    if(!$core_data[UNIT_PLANET_DENSITY_RARITY]) {
10
+  foreach ($density_list as $possible_core_id => $core_data) {
11
+    if (!$core_data[UNIT_PLANET_DENSITY_RARITY]) {
12 12
       continue;
13 13
     }
14 14
 
15
-    if(
15
+    if (
16 16
       // Core type exists
17 17
       in_array($possible_core_id, $position_data['core_types'])
18 18
       // Limit core type with planet sector count
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 
34 34
   $random = mt_rand(1, $probability);
35 35
   $selected_core = null;
36
-  foreach($possible_cores as $core_type => $core_info) {
37
-    if($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) {
36
+  foreach ($possible_cores as $core_type => $core_info) {
37
+    if ($random <= $core_info[UNIT_PLANET_DENSITY_RARITY]) {
38 38
       $selected_core = $core_info;
39 39
       break;
40 40
     }
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 
60 60
   $Position = intval($Position);
61 61
 
62
-  if(!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) {
62
+  if (!isset($options['skip_check']) && DBStaticPlanet::db_planet_by_gspt($Galaxy, $System, $Position, PT_PLANET, true, '`id`')) {
63 63
     return false;
64 64
   }
65 65
 
@@ -68,11 +68,11 @@  discard block
 block discarded – undo
68 68
 
69 69
   $planet_generator = sn_get_groups('planet_generator');
70 70
 
71
-  if($HomeWorld) {
71
+  if ($HomeWorld) {
72 72
     $position_data = $planet_generator[0];
73 73
   } else {
74 74
     $position_data = $planet_generator[$Position >= UNIVERSE_RANDOM_PLANET_START || $Position < 1 ? UNIVERSE_RANDOM_PLANET_START : $Position];
75
-    if($Position >= UNIVERSE_RANDOM_PLANET_START) {
75
+    if ($Position >= UNIVERSE_RANDOM_PLANET_START) {
76 76
       // Корректируем температуру для планеты-странника
77 77
       $position_data['t_max_max'] -= UNIVERSE_RANDOM_PLANET_TEMPERATURE_DECREASE * ($Position - UNIVERSE_RANDOM_PLANET_START);
78 78
     }
@@ -172,15 +172,15 @@  discard block
 block discarded – undo
172 172
   $moon_name = '';
173 173
   $moon_row = array();
174 174
   $moon = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_MOON, false, 'id');
175
-  if(!$moon['id']) {
175
+  if (!$moon['id']) {
176 176
     $moon_planet = DBStaticPlanet::db_planet_by_gspt($pos_galaxy, $pos_system, $pos_planet, PT_PLANET, true, '`id`, `temp_min`, `temp_max`, `name`, `debris_metal`, `debris_crystal`');
177 177
 
178
-    if($moon_planet['id']) {
178
+    if ($moon_planet['id']) {
179 179
       $base_storage_size = BASE_STORAGE_SIZE;
180 180
 
181
-      if(!$moon_chance) {
181
+      if (!$moon_chance) {
182 182
         $size = mt_rand(1100, 8999);
183
-      } elseif($moon_chance <= 100) {
183
+      } elseif ($moon_chance <= 100) {
184 184
         $size = mt_rand($moon_chance * 100 + 1000, $moon_chance * 200 + 2999);
185 185
       } else {
186 186
         $size = $moon_chance;
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
 
197 197
       $field_max = ceil($size / 1000);
198 198
 
199
-      if(isset($options['image']) && $options['image']) {
199
+      if (isset($options['image']) && $options['image']) {
200 200
         $moon_image = $options['image'];
201 201
       } else {
202 202
         $moon_image = 'mond';
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
           `deuterium` = '0', `deuterium_perhour` = '0', `deuterium_max` = '{$base_storage_size}'"
212 212
       );
213 213
 
214
-      if($update_debris) {
214
+      if ($update_debris) {
215 215
         $debris_spent = $moon_chance * 1000000;
216 216
         $metal_spent  = round(min($moon_planet['debris_metal'], $debris_spent * mt_rand(50, 75) / 100));
217 217
         $crystal_spent = min($moon_planet['debris_crystal'], $debris_spent - $metal_spent);
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
   $planet_row['id'] = $user['current_planet'];
248 248
 
249 249
   // Пытаемся переключить на новую планету
250
-  if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet'])
250
+  if (($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet'])
251 251
   {
252 252
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id');
253 253
   }
@@ -257,15 +257,15 @@  discard block
 block discarded – undo
257 257
   }
258 258
 
259 259
   // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету
260
-  if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
260
+  if (!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
261 261
   {
262 262
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id');
263 263
     // Если текущей планеты не существует - выставляем Столицу
264
-    if(!isset($planet_row['id']))
264
+    if (!isset($planet_row['id']))
265 265
     {
266 266
       $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['id_planet'], $user['id'], false, 'id');
267 267
       // Если и столицы не существует - значит что-то очень не так с записью пользователя
268
-      if(!isset($planet_row['id']))
268
+      if (!isset($planet_row['id']))
269 269
       {
270 270
         global $debug;
271 271
         $debug->error("User ID {$user['id']} has Capital planet {$user['id_planet']} but this planet does not exists", 'User record error', 502);
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
   }
275 275
 
276 276
   // Если производилось переключение планеты - делаем запись в юзере
277
-  if($user['current_planet'] != $planet_row['id'])
277
+  if ($user['current_planet'] != $planet_row['id'])
278 278
   {
279 279
     db_user_set_by_id($user['id'], "`current_planet` = '{$planet_row['id']}'");
280 280
     $user['current_planet'] = $planet_row['id'];
@@ -298,7 +298,7 @@  discard block
 block discarded – undo
298 298
 {
299 299
   global $lang;
300 300
 
301
-  if(!$from['id'])
301
+  if (!$from['id'])
302 302
   {
303 303
     $result = $lang['sys_planet_expedition'];
304 304
   }
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 function uni_calculate_moon_chance($FleetDebris)
338 338
 {
339 339
   $MoonChance = $FleetDebris / 1000000;
340
-  return ($MoonChance < 1) ? 0 : ($MoonChance>30 ? 30 : $MoonChance);
340
+  return ($MoonChance < 1) ? 0 : ($MoonChance > 30 ? 30 : $MoonChance);
341 341
 }
342 342
 
343 343
 function uni_coordinates_valid($coordinates, $prefix = '')
@@ -359,11 +359,11 @@  discard block
 block discarded – undo
359 359
   global $lang, $config;
360 360
 
361 361
   try {
362
-    if($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) {
362
+    if ($planetrow['planet_teleport_next'] && $planetrow['planet_teleport_next'] > SN_TIME_NOW) {
363 363
       throw new exception($lang['ov_teleport_err_cooldown'], ERR_ERROR);
364 364
     }
365 365
 
366
-    if(mrc_get_level($user, false, RES_DARK_MATTER) < $config->planet_teleport_cost) {
366
+    if (mrc_get_level($user, false, RES_DARK_MATTER) < $config->planet_teleport_cost) {
367 367
       throw new exception($lang['ov_teleport_err_no_dark_matter'], ERR_ERROR);
368 368
     }
369 369
 
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 //    if(!empty($incoming['incoming'])) {
376 376
 //      throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR);
377 377
 //    }
378
-    if(fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) {
378
+    if (fleet_count_incoming($planetrow['galaxy'], $planetrow['system'], $planetrow['planet'])) {
379 379
       throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR);
380 380
     }
381 381
 
@@ -384,10 +384,10 @@  discard block
 block discarded – undo
384 384
     //  throw new exception($lang['ov_teleport_err_fleet'], ERR_ERROR);
385 385
     //}
386 386
 
387
-    if(is_array($new_coordinates)) {
387
+    if (is_array($new_coordinates)) {
388 388
       $new_coordinates['planet_type'] = PT_PLANET;
389 389
       $incoming = DBStaticPlanet::db_planet_by_vector($new_coordinates, '', true, 'id');
390
-      if($incoming['id']) {
390
+      if ($incoming['id']) {
391 391
         throw new exception($lang['ov_teleport_err_destination_busy'], ERR_ERROR);
392 392
       }
393 393
     }
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
       'result'  => ERR_NONE,
397 397
       'message' => '',
398 398
     );
399
-  } catch(exception $e) {
399
+  } catch (exception $e) {
400 400
     $response = array(
401 401
       'result'  => $e->getCode(),
402 402
       'message' => $e->getMessage(),
Please login to merge, or discard this patch.
Braces   +14 added lines, -23 removed lines patch added patch discarded remove patch
@@ -242,24 +242,24 @@  discard block
 block discarded – undo
242 242
  * 1 - copyright 2008 By Chlorel for XNova
243 243
  *
244 244
  */
245
-function SetSelectedPlanet(&$user)
246
-{
245
+function SetSelectedPlanet(&$user) {
247 246
   $planet_row['id'] = $user['current_planet'];
248 247
 
249 248
   // Пытаемся переключить на новую планету
250 249
   if(($selected_planet = sys_get_param_id('cp')) && $selected_planet != $user['current_planet'])
251 250
   {
252 251
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($selected_planet, $user['id'], false, 'id');
253
-  }
254
-  else
252
+  } else
255 253
   {
256 254
     $planet_row = DBStaticPlanet::db_planet_by_id($planet_row['id']);
257 255
   }
258 256
 
259 257
   // Если новая планета не найдена или было переключения - проверяем текущую выбранную планету
260
-  if(!isset($planet_row['id'])) // || $planet_row['id'] != $user['current_planet']
258
+  if(!isset($planet_row['id'])) {
259
+    // || $planet_row['id'] != $user['current_planet']
261 260
   {
262 261
     $planet_row = DBStaticPlanet::db_planet_by_id_and_owner($user['current_planet'], $user['id'], false, 'id');
262
+  }
263 263
     // Если текущей планеты не существует - выставляем Столицу
264 264
     if(!isset($planet_row['id']))
265 265
     {
@@ -284,25 +284,21 @@  discard block
 block discarded – undo
284 284
 }
285 285
 
286 286
 // ----------------------------------------------------------------------------------------------------------------
287
-function uni_render_coordinates($from, $prefix = '')
288
-{
287
+function uni_render_coordinates($from, $prefix = '') {
289 288
   return "[{$from[$prefix . 'galaxy']}:{$from[$prefix . 'system']}:{$from[$prefix . 'planet']}]";
290 289
 }
291 290
 
292
-function uni_render_planet($from)
293
-{
291
+function uni_render_planet($from) {
294 292
   return "{$from['name']} [{$from['galaxy']}:{$from['system']}:{$from['planet']}]";
295 293
 }
296 294
 
297
-function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false)
298
-{
295
+function uni_render_planet_full($from, $prefix = '', $html_safe = true, $include_id = false) {
299 296
   global $lang;
300 297
 
301 298
   if(!$from['id'])
302 299
   {
303 300
     $result = $lang['sys_planet_expedition'];
304
-  }
305
-  else
301
+  } else
306 302
   {
307 303
     $from_planet_id = $include_id ? (
308 304
       'ID {' . ($from['id'] ? $from['id'] : ($from[$prefix . 'planet_id'] ? $from[$prefix . 'planet_id'] : 0)) . '} '
@@ -318,30 +314,25 @@  discard block
 block discarded – undo
318 314
   return $result;
319 315
 }
320 316
 
321
-function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php')
322
-{
317
+function uni_render_coordinates_url($from, $prefix = '', $page = 'galaxy.php') {
323 318
   return $page . (strpos($page, '?') === false ? '?' : '&') . "galaxy={$from[$prefix . 'galaxy']}&system={$from[$prefix . 'system']}&planet={$from[$prefix . 'planet']}";
324 319
 }
325 320
 
326
-function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '')
327
-{
321
+function uni_render_coordinates_href($from, $prefix = '', $mode = 0, $fleet_type = '') {
328 322
   return '<a href="' . uni_render_coordinates_url($from, $prefix, "galaxy.php?mode={$mode}") . '"' . ($fleet_type ? " {$fleet_type}" : '') . '>' . uni_render_coordinates($from, $prefix) . '</a>';
329 323
 }
330 324
 
331
-function uni_get_time_to_jump($moon_row)
332
-{
325
+function uni_get_time_to_jump($moon_row) {
333 326
   $jump_gate_level = mrc_get_level($user, $moon_row, STRUC_MOON_GATE);
334 327
   return $jump_gate_level ? max(0, $moon_row['last_jump_time'] + abs(60 * 60 / $jump_gate_level) - SN_TIME_NOW) : 0;
335 328
 }
336 329
 
337
-function uni_calculate_moon_chance($FleetDebris)
338
-{
330
+function uni_calculate_moon_chance($FleetDebris) {
339 331
   $MoonChance = $FleetDebris / 1000000;
340 332
   return ($MoonChance < 1) ? 0 : ($MoonChance>30 ? 30 : $MoonChance);
341 333
 }
342 334
 
343
-function uni_coordinates_valid($coordinates, $prefix = '')
344
-{
335
+function uni_coordinates_valid($coordinates, $prefix = '') {
345 336
   global $config;
346 337
 
347 338
   // array_walk($coordinates, 'intval');
Please login to merge, or discard this patch.
includes/functions/flt_mission_missile.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -4,8 +4,7 @@  discard block
 block discarded – undo
4 4
 // Open Source
5 5
 // V1
6 6
 //
7
-function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0')
8
-{
7
+function COE_missileAttack($defenceTech, $attackerTech, $MIPs, $structures, $targetedStructure = '0') {
9 8
   // Here we select which part of defense should take damage: structure or shield
10 9
   // $damageTo = P_SHIELD;
11 10
   // $damageTo = P_STRUCTURE;
@@ -34,8 +33,7 @@  discard block
 block discarded – undo
34 33
     $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] );
35 34
     $structures[$targetedStructure][0] -= $structsDestroyed;
36 35
     $MIPDamage -= $structsDestroyed*$damageDone;
37
-  }
38
-  else
36
+  } else
39 37
   {
40 38
     // REALLY random attack
41 39
     $can_be_damaged = sn_get_groups('defense_active');
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
   $mip_data = get_unit_param(UNIT_DEF_MISSILE_INTERPLANET);
15 15
   $MIPDamage = floor(mrc_modify_value($attackerTech, false, TECH_WEAPON, $MIPs * $mip_data[P_ATTACK] * mt_rand(80, 120) / 100));
16
-  foreach($structures as $key => $structure)
16
+  foreach ($structures as $key => $structure)
17 17
   {
18 18
     $unit_info = get_unit_param($key);
19 19
     $amplify = isset($mip_data[P_AMPLIFY][$key]) ? $mip_data[P_AMPLIFY][$key] : 1;
@@ -31,9 +31,9 @@  discard block
 block discarded – undo
31 31
   {
32 32
     //attacking only selected structure
33 33
     $damageDone = $structures[$targetedStructure][$damageTo];
34
-    $structsDestroyed = min( floor($MIPDamage/$damageDone), $structures[$targetedStructure][0] );
34
+    $structsDestroyed = min(floor($MIPDamage / $damageDone), $structures[$targetedStructure][0]);
35 35
     $structures[$targetedStructure][0] -= $structsDestroyed;
36
-    $MIPDamage -= $structsDestroyed*$damageDone;
36
+    $MIPDamage -= $structsDestroyed * $damageDone;
37 37
   }
38 38
   else
39 39
   {
@@ -44,16 +44,16 @@  discard block
 block discarded – undo
44 44
     do
45 45
     {
46 46
       // finding is there any structure that can be damaged with leftovers of $MIPDamage
47
-      foreach($can_be_damaged as $key => $unit_id)
47
+      foreach ($can_be_damaged as $key => $unit_id)
48 48
       {
49 49
 //debug($structures[$unit_id][0]);
50 50
 //debug($structures[$unit_id][$damageTo], $MIPDamage);
51
-        if($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage)
51
+        if ($structures[$unit_id][0] <= 0 || $structures[$unit_id][$damageTo] > $MIPDamage)
52 52
         {
53 53
           unset($can_be_damaged[$key]);
54 54
         }
55 55
       }
56
-      if(empty($can_be_damaged))
56
+      if (empty($can_be_damaged))
57 57
       {
58 58
         break;
59 59
       }
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 //debug($destroyed, 'Actually destroyed');
73 73
 
74 74
 //print('<hr>');
75
-    } while($MIPDamage > 0 && !empty($can_be_damaged));
75
+    } while ($MIPDamage > 0 && !empty($can_be_damaged));
76 76
 //debug($MIPDamage, 'MIPDamage left');
77 77
   }
78 78
 //debug($structures);//die();
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
     $crystal += $destroyed * $unit_info[P_COST][RES_CRYSTAL] / 4;
88 88
   }
89 89
 
90
-  $return['structures'] = $structures;     // Structures left after attack
91
-  $return['metal']      = floor($metal);   // Metal scraps
90
+  $return['structures'] = $structures; // Structures left after attack
91
+  $return['metal']      = floor($metal); // Metal scraps
92 92
   $return['crystal']    = floor($crystal); // Crystal scraps
93 93
 
94 94
   return $return;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
   $iraks = doquery("SELECT * FROM {{iraks}} WHERE `fleet_end_time` <= " . SN_TIME_NOW . " FOR UPDATE;");
114 114
 
115
-  while($fleetRow = db_fetch($iraks)) {
115
+  while ($fleetRow = db_fetch($iraks)) {
116 116
     set_time_limit(15);
117 117
     $db_changeset = array();
118 118
 
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 
129 129
     $rowAttacker = db_user_by_id($fleetRow['fleet_owner'], true);
130 130
 
131
-    if($target_planet_row['id']) {
131
+    if ($target_planet_row['id']) {
132 132
       $planetDefense = array();
133
-      foreach(sn_get_groups('defense_active') as $unit_id) {
133
+      foreach (sn_get_groups('defense_active') as $unit_id) {
134 134
         $planetDefense[$unit_id] = array(mrc_get_level($targetUser, $target_planet_row, $unit_id, true, true));
135 135
       }
136 136
 
@@ -141,23 +141,23 @@  discard block
 block discarded – undo
141 141
         $message = $lang['mip_all_destroyed'];
142 142
         $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit(UNIT_DEF_MISSILE_INTERCEPTOR, -$missiles, $targetUser, $target_planet_row['id']);
143 143
       } else {
144
-        if($interceptors) {
144
+        if ($interceptors) {
145 145
           $message = sprintf($lang['mip_destroyed'], $interceptors);
146 146
           $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit(UNIT_DEF_MISSILE_INTERCEPTOR, -$interceptors, $targetUser, $target_planet_row['id']);
147 147
         }
148 148
 
149 149
         $attackResult = COE_missileAttack($targetUser, $rowAttacker, $missiles - $interceptors, $planetDefense, $fleetRow['primaer']);
150 150
 
151
-        foreach($attackResult['structures'] as $key => $structure) {
151
+        foreach ($attackResult['structures'] as $key => $structure) {
152 152
           $destroyed = $planetDefense[$key][0] - $structure[0];
153
-          if($destroyed) {
153
+          if ($destroyed) {
154 154
             $db_changeset['unit'][] = OldDbChangeSet::db_changeset_prepare_unit($key, -$destroyed, $targetUser, $target_planet_row['id']);
155 155
 
156 156
             $message .= "&nbsp;&nbsp;{$lang['tech'][$key]} - {$destroyed} {$lang['quantity']}<br>";
157 157
           }
158 158
         }
159 159
 
160
-        if(!empty($message)) {
160
+        if (!empty($message)) {
161 161
           $message = $lang['mip_defense_destroyed'] . $message . "{$lang['mip_recycled']}{$lang['Metal']}: {$attackResult['metal']}, {$lang['Crystal']}: {$attackResult['crystal']}<br>";
162 162
 
163 163
           DBStaticPlanet::db_planet_set_by_id($target_planet_row['id'], "`metal` = `metal` + {$attackResult['metal']}, `crystal` = `crystal` + {$attackResult['crystal']}");
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 
175 175
       empty($message) ? $message = $lang['mip_no_defense'] : false;
176 176
 
177
-      msg_send_simple_message ( $fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message );
178
-      msg_send_simple_message ( $fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message );
177
+      msg_send_simple_message($fleetRow['fleet_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message);
178
+      msg_send_simple_message($fleetRow['fleet_target_owner'], '', SN_TIME_NOW, MSG_TYPE_SPY, $lang['mip_sender_amd'], $lang['mip_subject_amd'], $message_vorlage . $message);
179 179
     }
180 180
     doquery("DELETE FROM {{iraks}} WHERE id = '{$fleetRow['id']}';");
181 181
   }
Please login to merge, or discard this patch.
includes/functions/sys_maintenance.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
     array('query' => 'DELETE FROM {{aks}} WHERE `id` NOT IN (SELECT DISTINCT `fleet_group` FROM {{fleets}});', 'result' => false, 'error' => '', 'affected_rows' => 0),
16 16
   );
17 17
 
18
-  foreach($queries as &$query)
18
+  foreach ($queries as &$query)
19 19
   {
20 20
     $query['result'] = doquery($query['query']);
21 21
     $query['error']  = classSupernova::$db->db_error();
22
-    $query['affected_rows']  = classSupernova::$db->db_affected_rows();
22
+    $query['affected_rows'] = classSupernova::$db->db_affected_rows();
23 23
   }
24 24
 
25 25
   return $queries;
@@ -51,30 +51,30 @@  discard block
 block discarded – undo
51 51
   $recorded_run = strtotime($recorded_run);
52 52
 
53 53
   $prev_run_array = getdate($recorded_run);
54
-  $prev_run_array = array($prev_run_array['seconds'],$prev_run_array['minutes'],$prev_run_array['hours'],$prev_run_array['mday'],$prev_run_array['mon'],$prev_run_array['year']);
54
+  $prev_run_array = array($prev_run_array['seconds'], $prev_run_array['minutes'], $prev_run_array['hours'], $prev_run_array['mday'], $prev_run_array['mon'], $prev_run_array['year']);
55 55
   $today_array = getdate(SN_TIME_NOW);
56
-  $today_array = array($today_array['seconds'],$today_array['minutes'],$today_array['hours'],$today_array['mday'],$today_array['mon'],$today_array['year']);
56
+  $today_array = array($today_array['seconds'], $today_array['minutes'], $today_array['hours'], $today_array['mday'], $today_array['mon'], $today_array['year']);
57 57
   $scheduleList = explode(',', $scheduleList);
58 58
   array_walk($scheduleList, function(&$schedule) use ($prev_run_array, $today_array, $date_part_names_reverse, &$possible_schedules) {
59 59
     $schedule = array('schedule_array' => array_reverse(explode(':', trim($schedule))));
60 60
 
61 61
     $interval = $date_part_names_reverse[count($schedule['schedule_array'])];
62 62
 
63
-    foreach($prev_run_array as $index => $date_part) {
63
+    foreach ($prev_run_array as $index => $date_part) {
64 64
       $schedule['array']['recorded'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $date_part;
65 65
       $schedule['array']['now'][$index] = isset($schedule['schedule_array'][$index]) ? intval($schedule['schedule_array'][$index]) : $today_array[$index];
66 66
     }
67
-    if($schedule['array']['recorded'] == $schedule['array']['now']) {
67
+    if ($schedule['array']['recorded'] == $schedule['array']['now']) {
68 68
       unset($schedule['array']['now']);
69 69
     }
70 70
 
71
-    foreach($schedule['array'] as $name => $array) {
71
+    foreach ($schedule['array'] as $name => $array) {
72 72
       $schedule['string'][$name] = "{$array[5]}-{$array[4]}-{$array[3]} {$array[2]}:{$array[1]}:{$array[0]}";
73 73
       $schedule['string'][$name . '_next'] = $schedule['string'][$name] . ' +1 ' . $interval;
74 74
       $schedule['string'][$name . '_prev'] = $schedule['string'][$name] . ' -1 ' . $interval;
75 75
     }
76 76
 
77
-    foreach($schedule['string'] as $string) {
77
+    foreach ($schedule['string'] as $string) {
78 78
       $timestamp = strtotime($string);
79 79
       $schedule['timestamp'][$timestamp] = $possible_schedules[$timestamp] = date(FMT_DATE_TIME_SQL, strtotime($string));
80 80
     }
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
   $prev_run = 0;
86 86
   $next_run = 0;
87
-  foreach($possible_schedules as $timestamp => $string_date) {
87
+  foreach ($possible_schedules as $timestamp => $string_date) {
88 88
     $prev_run = SN_TIME_NOW >= $timestamp ? $timestamp : $prev_run;
89 89
     $next_run = SN_TIME_NOW < $timestamp && !$next_run ? $timestamp : $next_run;
90 90
   }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-function sys_maintenance()
4
-{
3
+function sys_maintenance() {
5 4
   global $config;
6 5
 
7 6
   $bashing_time_limit = SN_TIME_NOW - $config->fleet_bashing_scope;
@@ -42,8 +41,7 @@  discard block
 block discarded – undo
42 41
  * TODO: 2. [<m|w|d|h|m|s>@]<time>
43 42
  */
44 43
 
45
-function sys_schedule_get_prev_run($scheduleList, $recorded_run = SN_TIME_NOW, $return_next_run = false)
46
-{
44
+function sys_schedule_get_prev_run($scheduleList, $recorded_run = SN_TIME_NOW, $return_next_run = false) {
47 45
   static $date_part_names_reverse = array('seconds', 'minutes', 'hours', 'days', 'months', 'years',);
48 46
 
49 47
   $possible_schedules = array();
Please login to merge, or discard this patch.