Completed
Push — work-fleets ( f5fbda...1bdd41 )
by SuperNova.WS
06:04
created
includes/debug.class.php 1 patch
Spacing   +37 added lines, -38 removed lines patch added patch discarded remove patch
@@ -50,16 +50,16 @@  discard block
 block discarded – undo
50 50
   function log_file($message, $ident_change = 0) {
51 51
     static $ident = 0;
52 52
 
53
-    if(!defined('SN_DEBUG_LOG')) {
53
+    if (!defined('SN_DEBUG_LOG')) {
54 54
       return;
55 55
     }
56 56
 
57
-    if($this->log_file_handler === null) {
57
+    if ($this->log_file_handler === null) {
58 58
       $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+');
59 59
       @fwrite($this->log_file_handler, "\r\n\r\n");
60 60
     }
61 61
     $ident_change < 0 ? $ident += $ident_change * 2 : false;
62
-    if($this->log_file_handler) {
62
+    if ($this->log_file_handler) {
63 63
       @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n");
64 64
     }
65 65
     $ident_change > 0 ? $ident += $ident_change * 2 : false;
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
     $result = array();
91 91
     $transaction_id = classSupernova::db_transaction_check(false) ? classSupernova::$transaction_id : classSupernova::$transaction_id++;
92 92
     $result[] = "tID {$transaction_id}";
93
-    foreach($backtrace as $a_trace) {
94
-      if(in_array($a_trace['function'], $exclude_functions)) {
93
+    foreach ($backtrace as $a_trace) {
94
+      if (in_array($a_trace['function'], $exclude_functions)) {
95 95
         continue;
96 96
       }
97 97
       $function =
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
       // $result[] = "{$function} ({$a_trace['line']})'{$file}'";
109 109
       $result[] = "{$function} - '{$file}' Line {$a_trace['line']}";
110 110
 
111
-      if(!$long_comment) {
111
+      if (!$long_comment) {
112 112
         break;
113 113
       }
114 114
     }
@@ -120,26 +120,26 @@  discard block
 block discarded – undo
120 120
   }
121 121
 
122 122
   function dump($dump = false, $force_base = false, $deadlock = false) {
123
-    if($dump === false) {
123
+    if ($dump === false) {
124 124
       return;
125 125
     }
126 126
 
127 127
     $error_backtrace = array();
128 128
     $base_dump = false;
129 129
 
130
-    if($force_base === true) {
130
+    if ($force_base === true) {
131 131
       $base_dump = true;
132 132
     }
133 133
 
134
-    if($dump === true) {
134
+    if ($dump === true) {
135 135
       $base_dump = true;
136 136
     } else {
137
-      if(!is_array($dump)) {
137
+      if (!is_array($dump)) {
138 138
         $dump = array('var' => $dump);
139 139
       }
140 140
 
141
-      foreach($dump as $dump_var_name => $dump_var) {
142
-        if($dump_var_name == 'base_dump') {
141
+      foreach ($dump as $dump_var_name => $dump_var) {
142
+        if ($dump_var_name == 'base_dump') {
143 143
           $base_dump = $dump_var;
144 144
         } else {
145 145
           $error_backtrace[$dump_var_name] = $dump_var;
@@ -148,26 +148,25 @@  discard block
 block discarded – undo
148 148
     }
149 149
 
150 150
 //    if($deadlock && ($q = db_fetch(classSupernova::$db->__db_query('SHOW ENGINE INNODB STATUS')))) {
151
-    if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
151
+    if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
152 152
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
153 153
       $error_backtrace['locks'] = classSupernova::$locks;
154 154
       $error_backtrace['cSN_data'] = classSupernova::$data;
155
-      foreach($error_backtrace['cSN_data'] as &$location) {
156
-        foreach($location as $location_id => &$location_data) //          $location_data = $location_id;
155
+      foreach ($error_backtrace['cSN_data'] as &$location) {
156
+        foreach ($location as $location_id => &$location_data) //          $location_data = $location_id;
157 157
         {
158
-          $location_data = isset($location_data['username']) ? $location_data['username'] :
159
-            (isset($location_data['name']) ? $location_data['name'] : $location_id);
158
+          $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id);
160 159
         }
161 160
       }
162 161
       $error_backtrace['cSN_queries'] = classSupernova::$queries;
163 162
     }
164 163
 
165
-    if($base_dump) {
166
-      if(is_array($this->log_array) && count($this->log_array) > 0) {
164
+    if ($base_dump) {
165
+      if (is_array($this->log_array) && count($this->log_array) > 0) {
167 166
 //        ;
168 167
 //      }
169 168
 //      {
170
-        foreach($this->log_array as $log) {
169
+        foreach ($this->log_array as $log) {
171 170
           $error_backtrace['queries'][] = $log;
172 171
         }
173 172
       }
@@ -198,14 +197,14 @@  discard block
 block discarded – undo
198 197
   function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) {
199 198
     global $sys_stop_log_hit, $sys_log_disabled, $user;
200 199
 
201
-    if(empty(classSupernova::$db->connected)) {
200
+    if (empty(classSupernova::$db->connected)) {
202 201
       // TODO - писать ошибку в файл
203 202
       die('SQL server currently unavailable. Please contact Administration...');
204 203
     }
205 204
 
206 205
     sn_db_transaction_rollback();
207 206
 
208
-    if(classSupernova::$config->debug == 1) {
207
+    if (classSupernova::$config->debug == 1) {
209 208
       echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>";
210 209
       echo "<table>{$this->log}</table>";
211 210
     }
@@ -215,7 +214,7 @@  discard block
 block discarded – undo
215 214
     $error_text = db_escape($message);
216 215
     $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false);
217 216
 
218
-    if(!$sys_log_disabled) {
217
+    if (!$sys_log_disabled) {
219 218
       $query = "INSERT INTO `{{logs}}` SET
220 219
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($user['id']) . "',
221 220
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -233,7 +232,7 @@  discard block
 block discarded – undo
233 232
       ob_start();
234 233
       print("<hr>User ID {$user['id']} raised error code {$error_code} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}");
235 234
 
236
-      foreach($error_backtrace as $name => $value) {
235
+      foreach ($error_backtrace as $name => $value) {
237 236
         print(__DEBUG_LINE);
238 237
         pdump($value, $name);
239 238
       }
@@ -245,14 +244,14 @@  discard block
 block discarded – undo
245 244
   function warning($message, $title = 'System Message', $log_code = 300, $dump = false) {
246 245
     global $user, $sys_log_disabled;
247 246
 
248
-    if(empty(classSupernova::$db->connected)) {
247
+    if (empty(classSupernova::$db->connected)) {
249 248
       // TODO - писать ошибку в файл
250 249
       die('SQL server currently unavailable. Please contact Administration...');
251 250
     }
252 251
 
253 252
     $error_backtrace = $this->dump($dump, false);
254 253
 
255
-    if(!$sys_log_disabled) {
254
+    if (!$sys_log_disabled) {
256 255
       $query = "INSERT INTO `{{logs}}` SET
257 256
         `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($user['id']) . "',
258 257
         `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
@@ -270,11 +269,11 @@  discard block
 block discarded – undo
270 269
 // Dump variables nicer then var_dump()
271 270
 
272 271
 function dump($value, $varname = null, $level = 0, $dumper = '') {
273
-  if(isset($varname)) {
272
+  if (isset($varname)) {
274 273
     $varname .= " = ";
275 274
   }
276 275
 
277
-  if($level == -1) {
276
+  if ($level == -1) {
278 277
     $trans[' '] = '&there4;';
279 278
     $trans["\t"] = '&rArr;';
280 279
     $trans["\n"] = '&para;;';
@@ -283,7 +282,7 @@  discard block
 block discarded – undo
283 282
 
284 283
     return strtr(htmlspecialchars($value), $trans);
285 284
   }
286
-  if($level == 0) {
285
+  if ($level == 0) {
287 286
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
288 287
     $dumper = mt_rand(10, 99) . '|' . $varname;
289 288
   }
@@ -291,22 +290,22 @@  discard block
 block discarded – undo
291 290
   $type = gettype($value);
292 291
   $dumper .= $type;
293 292
 
294
-  if($type == 'string') {
293
+  if ($type == 'string') {
295 294
     $dumper .= '(' . strlen($value) . ')';
296 295
     $value = dump($value, '', -1);
297
-  } elseif($type == 'boolean') {
296
+  } elseif ($type == 'boolean') {
298 297
     $value = ($value ? 'true' : 'false');
299
-  } elseif($type == 'object') {
298
+  } elseif ($type == 'object') {
300 299
     $props = get_class_vars(get_class($value));
301 300
     $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
302
-    foreach($props as $key => $val) {
301
+    foreach ($props as $key => $val) {
303 302
       $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
304 303
       $dumper .= dump($value->$key, '', $level + 1);
305 304
     }
306 305
     $value = '';
307
-  } elseif($type == 'array') {
306
+  } elseif ($type == 'array') {
308 307
     $dumper .= '(' . count($value) . ')';
309
-    foreach($value as $key => $val) {
308
+    foreach ($value as $key => $val) {
310 309
       $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
311 310
       $dumper .= dump($val, '', $level + 1);
312 311
     }
@@ -326,7 +325,7 @@  discard block
 block discarded – undo
326 325
 //  $backtrace = $backtrace[1];
327 326
 
328 327
   $caller = '';
329
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
328
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
330 329
     $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
331 330
       (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
332 331
       $backtrace[1]['function'] .
@@ -353,7 +352,7 @@  discard block
 block discarded – undo
353 352
 }
354 353
 
355 354
 function pr($prePrint = false) {
356
-  if($prePrint) {
355
+  if ($prePrint) {
357 356
     print(__DEBUG_CRLF);
358 357
   }
359 358
   print(mt_rand() . __DEBUG_CRLF);
@@ -363,7 +362,7 @@  discard block
 block discarded – undo
363 362
   global $_PRINT_COUNT_VALUE;
364 363
   $_PRINT_COUNT_VALUE++;
365 364
 
366
-  if($prePrint) {
365
+  if ($prePrint) {
367 366
     print(__DEBUG_CRLF);
368 367
   }
369 368
   print($_PRINT_COUNT_VALUE . __DEBUG_CRLF);
Please login to merge, or discard this patch.
includes/pages/options.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
   $language_new = sys_get_param_str('langer', $user['lang']);
14 14
 
15
-  if($language_new != $user['lang']) {
15
+  if ($language_new != $user['lang']) {
16 16
     classLocale::$lang->lng_switch($language_new);
17 17
   }
18 18
 
@@ -21,35 +21,35 @@  discard block
 block discarded – undo
21 21
 
22 22
   $FMT_DATE = preg_replace(array('/d/', '/m/', '/Y/'), array('DD', 'MM', 'YYYY'), FMT_DATE);
23 23
 
24
-  if(sys_get_param_str('mode') == 'change') {
25
-    if($user['authlevel'] > 0) {
24
+  if (sys_get_param_str('mode') == 'change') {
25
+    if ($user['authlevel'] > 0) {
26 26
       $planet_protection = sys_get_param_int('adm_pl_prot') ? $user['authlevel'] : 0;
27 27
       db_planet_set_by_owner($user['id'], "`id_level` = '{$planet_protection}'");
28 28
       db_user_set_by_id($user['id'], "`admin_protection` = '{$planet_protection}'");
29 29
       $user['admin_protection'] = $planet_protection;
30 30
     }
31 31
 
32
-    if(sys_get_param_int('vacation') && !classSupernova::$config->user_vacation_disable) {
32
+    if (sys_get_param_int('vacation') && !classSupernova::$config->user_vacation_disable) {
33 33
       sn_db_transaction_start();
34
-      if($user['authlevel'] < 3) {
35
-        if($user['vacation_next'] > SN_TIME_NOW) {
34
+      if ($user['authlevel'] < 3) {
35
+        if ($user['vacation_next'] > SN_TIME_NOW) {
36 36
           message(classLocale::$lang['opt_vacation_err_timeout'], classLocale::$lang['Error'], 'index.php?page=options', 5);
37 37
           die();
38 38
         }
39 39
 
40
-        if(FleetList::fleet_count_flying($user['id'])) {
40
+        if (FleetList::fleet_count_flying($user['id'])) {
41 41
           message(classLocale::$lang['opt_vacation_err_your_fleet'], classLocale::$lang['Error'], 'index.php?page=options', 5);
42 42
           die();
43 43
         }
44 44
 
45 45
         $que = que_get($user['id'], false);
46
-        if(!empty($que)) {
46
+        if (!empty($que)) {
47 47
           message(classLocale::$lang['opt_vacation_err_que'], classLocale::$lang['Error'], 'index.php?page=options', 5);
48 48
           die();
49 49
         }
50 50
 
51 51
         $query = classSupernova::db_get_record_list(LOC_PLANET, "`id_owner` = {$user['id']}");
52
-        foreach($query as $planet) {
52
+        foreach ($query as $planet) {
53 53
           // $planet = sys_o_get_updated($user, $planet, SN_TIME_NOW);
54 54
           // $planet = $planet['planet'];
55 55
 
@@ -68,9 +68,9 @@  discard block
 block discarded – undo
68 68
       sn_db_transaction_commit();
69 69
     }
70 70
 
71
-    foreach($user_option_list as $option_group_id => $option_group) {
72
-      foreach($option_group as $option_name => $option_value) {
73
-        if($user[$option_name] !== null) {
71
+    foreach ($user_option_list as $option_group_id => $option_group) {
72
+      foreach ($option_group as $option_name => $option_value) {
73
+        if ($user[$option_name] !== null) {
74 74
           $user[$option_name] = sys_get_param_str($option_name);
75 75
         } else {
76 76
           $user[$option_name] = $option_value;
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 
82 82
 
83 83
     $player_options = sys_get_param('options');
84
-    if(!empty($player_options)) {
85
-      array_walk($player_options, function (&$value) {
84
+    if (!empty($player_options)) {
85
+      array_walk($player_options, function(&$value) {
86 86
         // TODO - Когда будет больше параметров - сделать больше проверок
87 87
         $value = intval($value);
88 88
       });
@@ -93,15 +93,15 @@  discard block
 block discarded – undo
93 93
 
94 94
     $username = substr(sys_get_param_str_unsafe('username'), 0, 32);
95 95
     $username_safe = db_escape($username);
96
-    if($username && $user['username'] != $username && classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
96
+    if ($username && $user['username'] != $username && classSupernova::$config->game_user_changename != SERVER_PLAYER_NAME_CHANGE_NONE && sys_get_param_int('username_confirm') && !strpbrk($username, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
97 97
       // проверка на корректность
98 98
       sn_db_transaction_start();
99 99
       $name_check = db_player_name_history_get_name_by_name($username_safe);
100
-      if(!$name_check || $name_check['player_id'] == $user['id']) {
100
+      if (!$name_check || $name_check['player_id'] == $user['id']) {
101 101
         $user = db_user_by_id($user['id'], true);
102
-        switch(classSupernova::$config->game_user_changename) {
102
+        switch (classSupernova::$config->game_user_changename) {
103 103
           case SERVER_PLAYER_NAME_CHANGE_PAY:
104
-            if(mrc_get_level($user, $planetrow, RES_DARK_MATTER) < classSupernova::$config->game_user_changename_cost) {
104
+            if (mrc_get_level($user, $planetrow, RES_DARK_MATTER) < classSupernova::$config->game_user_changename_cost) {
105 105
               $template_result['.']['result'][] = array(
106 106
                 'STATUS'  => ERR_ERROR,
107 107
                 'MESSAGE' => classLocale::$lang['opt_msg_name_change_err_no_dm'],
@@ -131,18 +131,18 @@  discard block
 block discarded – undo
131 131
       sn_db_transaction_commit();
132 132
     }
133 133
 
134
-    if($new_password = sys_get_param('newpass1')) {
134
+    if ($new_password = sys_get_param('newpass1')) {
135 135
       try {
136
-        if($new_password != sys_get_param('newpass2')) {
136
+        if ($new_password != sys_get_param('newpass2')) {
137 137
           throw new Exception(classLocale::$lang['opt_err_pass_unmatched'], ERR_WARNING);
138 138
         }
139 139
 
140
-        if(!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) {
140
+        if (!classSupernova::$auth->password_change(sys_get_param('db_password'), $new_password)) {
141 141
           throw new Exception(classLocale::$lang['opt_err_pass_wrong'], ERR_WARNING);
142 142
         }
143 143
 
144 144
         throw new Exception(classLocale::$lang['opt_msg_pass_changed'], ERR_NONE);
145
-      } catch(Exception $e) {
145
+      } catch (Exception $e) {
146 146
         $template_result['.']['result'][] = array(
147 147
           'STATUS'  => in_array($e->getCode(), array(ERR_NONE, ERR_WARNING, ERR_ERROR)) ? $e->getCode() : ERR_ERROR,
148 148
           'MESSAGE' => $e->getMessage()
@@ -164,12 +164,12 @@  discard block
 block discarded – undo
164 164
     $user['gender'] = $user['gender'] == GENDER_UNKNOWN ? $gender : $user['gender'];
165 165
 
166 166
     try {
167
-      if($user['birthday']) {
167
+      if ($user['birthday']) {
168 168
         throw new exception();
169 169
       }
170 170
 
171 171
       $user_birthday = sys_get_param_str_unsafe('user_birthday');
172
-      if(!$user_birthday || $user_birthday == $FMT_DATE) {
172
+      if (!$user_birthday || $user_birthday == $FMT_DATE) {
173 173
         throw new exception();
174 174
       }
175 175
 
@@ -179,16 +179,16 @@  discard block
 block discarded – undo
179 179
       $pos['Y'] = strpos(FMT_DATE, 'Y');
180 180
       asort($pos);
181 181
       $i = 0;
182
-      foreach($pos as &$position) {
182
+      foreach ($pos as &$position) {
183 183
         $position = ++$i;
184 184
       }
185 185
 
186 186
       $regexp = "/" . preg_replace(array('/\\\\/', '/\//', '/\./', '/\-/', '/d/', '/m/', '/Y/'), array('\\\\\\', '\/', '\.', '\-', '(\d?\d)', '(\d?\d)', '(\d{4})'), FMT_DATE) . "/";
187
-      if(!preg_match($regexp, $user_birthday, $match)) {
187
+      if (!preg_match($regexp, $user_birthday, $match)) {
188 188
         throw new exception();
189 189
       }
190 190
 
191
-      if(!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) {
191
+      if (!checkdate($match[$pos['m']], $match[$pos['d']], $match[$pos['Y']])) {
192 192
         throw new exception();
193 193
       }
194 194
 
@@ -196,13 +196,13 @@  discard block
 block discarded – undo
196 196
       // EOF black magic! Now we have valid SQL date in $user['user_birthday'] - independent of date format
197 197
 
198 198
       $year = date('Y', SN_TIME_NOW);
199
-      if(mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) {
199
+      if (mktime(0, 0, 0, $match[$pos['m']], $match[$pos['d']], $year) > SN_TIME_NOW) {
200 200
         $year--;
201 201
       }
202 202
       $user['user_birthday_celebrated'] = db_escape("{$year}-{$match[$pos['m']]}-{$match[$pos['d']]}");
203 203
 
204 204
       $user_birthday = ", `user_birthday` = '{$user['user_birthday']}', `user_birthday_celebrated` = '{$user['user_birthday_celebrated']}'";
205
-    } catch(exception $e) {
205
+    } catch (exception $e) {
206 206
       $user_birthday = '';
207 207
     }
208 208
 
@@ -212,14 +212,14 @@  discard block
 block discarded – undo
212 212
     $template_result['.']['result'][] = $avatar_upload_result;
213 213
 
214 214
     $user_time_diff = playerTimeDiff::user_time_diff_get();
215
-    if(sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) {
215
+    if (sys_get_param_int('PLAYER_OPTION_TIME_DIFF_FORCED')) {
216 216
       playerTimeDiff::user_time_diff_set(array(
217 217
         PLAYER_OPTION_TIME_DIFF              => sys_get_param_int('PLAYER_OPTION_TIME_DIFF'),
218 218
         PLAYER_OPTION_TIME_DIFF_UTC_OFFSET   => 0,
219 219
         PLAYER_OPTION_TIME_DIFF_FORCED       => 1,
220 220
         PLAYER_OPTION_TIME_DIFF_MEASURE_TIME => SN_TIME_SQL,
221 221
       ));
222
-    } elseif(sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) {
222
+    } elseif (sys_get_param_int('opt_time_diff_clear') || $user_time_diff[PLAYER_OPTION_TIME_DIFF_FORCED]) {
223 223
       playerTimeDiff::user_time_diff_set(array(
224 224
         PLAYER_OPTION_TIME_DIFF              => '',
225 225
         PLAYER_OPTION_TIME_DIFF_UTC_OFFSET   => 0,
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
       'STATUS'  => ERR_NONE,
240 240
       'MESSAGE' => classLocale::$lang['opt_msg_saved']
241 241
     );
242
-  } elseif(sys_get_param_str('result') == 'ok') {
242
+  } elseif (sys_get_param_str('result') == 'ok') {
243 243
     $template_result['.']['result'][] = array(
244 244
       'STATUS'  => ERR_NONE,
245 245
       'MESSAGE' => classLocale::$lang['opt_msg_saved']
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
   $template = gettemplate('options', $template);
264 264
 
265 265
   $dir = dir(SN_ROOT_PHYSICAL . 'skins');
266
-  while(($entry = $dir->read()) !== false) {
267
-    if(is_dir("skins/{$entry}") && $entry[0] != '.') {
266
+  while (($entry = $dir->read()) !== false) {
267
+    if (is_dir("skins/{$entry}") && $entry[0] != '.') {
268 268
       $template_result['.']['skin_list'][] = array(
269 269
         'VALUE'    => $entry,
270 270
         'NAME'     => $entry,
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
   }
275 275
   $dir->close();
276 276
 
277
-  foreach(classLocale::$lang['opt_planet_sort_options'] as $key => &$value) {
277
+  foreach (classLocale::$lang['opt_planet_sort_options'] as $key => &$value) {
278 278
     $template_result['.']['planet_sort_options'][] = array(
279 279
       'VALUE'    => $key,
280 280
       'NAME'     => $value,
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
     );
283 283
   }
284 284
 
285
-  foreach(classLocale::$lang['sys_gender_list'] as $key => $value) {
285
+  foreach (classLocale::$lang['sys_gender_list'] as $key => $value) {
286 286
     $template_result['.']['gender_list'][] = array(
287 287
       'VALUE'    => $key,
288 288
       'NAME'     => $value,
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
   }
292 292
 
293 293
   $lang_list = lng_get_list();
294
-  foreach($lang_list as $lang_id => $lang_data) {
294
+  foreach ($lang_list as $lang_id => $lang_data) {
295 295
     $template_result['.']['languages'][] = array(
296 296
       'VALUE'    => $lang_id,
297 297
       'NAME'     => $lang_data['LANG_NAME_NATIVE'],
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
   }
301 301
 
302 302
 
303
-  if(isset(classLocale::$lang['menu_customize_show_hide_button_state'])) {
304
-    foreach(classLocale::$lang['menu_customize_show_hide_button_state'] as $key => $value) {
303
+  if (isset(classLocale::$lang['menu_customize_show_hide_button_state'])) {
304
+    foreach (classLocale::$lang['menu_customize_show_hide_button_state'] as $key => $value) {
305 305
       $template->assign_block_vars('menu_customize_show_hide_button_state', array(
306 306
         'ID'   => $key,
307 307
         'NAME' => $value,
@@ -408,10 +408,10 @@  discard block
 block discarded – undo
408 408
     'PAGE_HEADER' => classLocale::$lang['opt_header'],
409 409
   ));
410 410
 
411
-  foreach($user_option_list as $option_group_id => $option_group) {
412
-    if($option_group_id == OPT_MESSAGE) {
413
-      foreach($sn_message_class_list as $message_class_id => $message_class_data) {
414
-        if($message_class_data['switchable'] || ($message_class_data['email'] && classSupernova::$config->game_email_pm)) {
411
+  foreach ($user_option_list as $option_group_id => $option_group) {
412
+    if ($option_group_id == OPT_MESSAGE) {
413
+      foreach ($sn_message_class_list as $message_class_id => $message_class_data) {
414
+        if ($message_class_data['switchable'] || ($message_class_data['email'] && classSupernova::$config->game_email_pm)) {
415 415
           $option_name = $message_class_data['name'];
416 416
 
417 417
           $template->assign_block_vars("options_{$option_group_id}", array(
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
         }
424 424
       }
425 425
     } else {
426
-      foreach($option_group as $option_name => $option_value) {
427
-        if(array_key_exists($option_name, $user_option_types)) {
426
+      foreach ($option_group as $option_name => $option_value) {
427
+        if (array_key_exists($option_name, $user_option_types)) {
428 428
           $option_type = $user_option_types[$option_name];
429 429
         } else {
430 430
           $option_type = 'switch';
Please login to merge, or discard this patch.
includes/pages/chat.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
   $user_auth_level = isset($user['authlevel']) ? $user['authlevel'] : AUTH_LEVEL_ANONYMOUS;
37 37
 
38 38
   $mode = sys_get_param_int('mode');
39
-  switch($mode) {
39
+  switch ($mode) {
40 40
     case CHAT_MODE_ALLY:
41 41
       $template_result['ALLY'] = intval($user['ally_id']);
42 42
       $page_title = classLocale::$lang['chat_ally'];
@@ -49,12 +49,12 @@  discard block
 block discarded – undo
49 49
   }
50 50
 
51 51
   $template_result['.']['smiles'] = array();
52
-  foreach($supernova->design['smiles'] as $auth_level => $replaces) {
53
-    if($auth_level > $user_auth_level) {
52
+  foreach ($supernova->design['smiles'] as $auth_level => $replaces) {
53
+    if ($auth_level > $user_auth_level) {
54 54
       continue;
55 55
     }
56 56
 
57
-    foreach($replaces as $bbcode => $filename) {
57
+    foreach ($replaces as $bbcode => $filename) {
58 58
       $template_result['.']['smiles'][] = array(
59 59
         'BBCODE'   => $bbcode,
60 60
         'FILENAME' => $filename,
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
   define('IN_AJAX', true);
78 78
   $skip_fleet_update = true;
79 79
 
80
-  if(classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) {
80
+  if (classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) {
81 81
     die();
82 82
   }
83 83
 
84
-  if(($message = sys_get_param_str('message')) && $user['username']) {
84
+  if (($message = sys_get_param_str('message')) && $user['username']) {
85 85
     $ally_id = sys_get_param('ally') && $user['ally_id'] ? $user['ally_id'] : 0;
86 86
     $nick = db_escape(player_nick_compact(player_nick_render_current_to_array($user, array('color' => true, 'icons' => true, 'ally' => !$ally_id))));
87 87
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
   $skip_fleet_update = true;
104 104
 
105 105
   $history = sys_get_param_str('history');
106
-  if(!$history) {
106
+  if (!$history) {
107 107
     classSupernova::$config->array_set('users', $user['id'], 'chat_last_refresh', SN_TIME_MICRO);
108 108
   }
109 109
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
   $last_message = '';
112 112
   $alliance = 0;
113 113
   $template_result['.']['chat'] = array();
114
-  if(!$history && classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) {
114
+  if (!$history && classSupernova::$config->_MODE != CACHER_NO_CACHE && classSupernova::$config->chat_timeout && SN_TIME_MICRO - classSupernova::$config->array_get('users', $user['id'], 'chat_last_activity') > classSupernova::$config->chat_timeout) {
115 115
     $result['disable'] = true;
116 116
     $template_result['.']['chat'][] = array(
117 117
       'TIME'    => date(FMT_DATE_TIME, htmlentities(SN_CLIENT_TIME_LOCAL, ENT_QUOTES, 'utf-8')),
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
 
125 125
     $where_add = '';
126 126
     $last_message = 0;
127
-    if($history) {
127
+    if ($history) {
128 128
       $rows = db_chat_message_count_by_ally($alliance);
129 129
       $page_count = ceil($rows['CNT'] / $page_limit);
130 130
 
131
-      for($i = 0; $i < $page_count; $i++) {
131
+      for ($i = 0; $i < $page_count; $i++) {
132 132
         $template_result['.']['page'][] = array(
133 133
           'NUMBER' => $i
134 134
         );
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
 
143 143
     $start_row = $page * $page_limit;
144 144
     $query = db_chat_message_get_page($alliance, $where_add, $start_row, $page_limit);
145
-    while($chat_row = db_fetch($query)) {
145
+    while ($chat_row = db_fetch($query)) {
146 146
       // Little magik here - to retain HTML codes from DB and stripping HTML codes from nick
147 147
       $chat_row['user'] = player_nick_render_to_html($chat_row['user']);
148 148
       $nick_stripped = htmlentities(strip_tags($chat_row['user']), ENT_QUOTES, 'utf-8');
149 149
       $nick = str_replace(strip_tags($chat_row['user']), $nick_stripped, $chat_row['user']);
150
-      if(!$history) {
150
+      if (!$history) {
151 151
         $nick = "<span style=\"cursor: pointer;\" onclick=\"addSmiley('({$nick_stripped})');\">{$nick}</span>";
152 152
       }
153 153
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
   $template = gettemplate('chat_messages', $template);
173 173
   $template->assign_recursive($template_result);
174 174
 
175
-  if($history) {
175
+  if ($history) {
176 176
     display($template, "{$classLocale['chat_history']} - {$classLocale[$alliance ? 'chat_ally' : 'chat_common']}", true, '', false, true);
177 177
   } else {
178 178
     $result['last_message'] = $last_message;
Please login to merge, or discard this patch.
includes/general.php 1 patch
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -14,24 +14,24 @@  discard block
 block discarded – undo
14 14
 function sn_function_call($func_name, $func_arg = array()) {
15 15
   // All data in classSupernova::$functions should be normalized to valid 'callable' state: '<function_name>'|array('<object_name>', '<method_name>')
16 16
 
17
-  if(is_array(classSupernova::$functions[$func_name]) && !is_callable(classSupernova::$functions[$func_name])) {
17
+  if (is_array(classSupernova::$functions[$func_name]) && !is_callable(classSupernova::$functions[$func_name])) {
18 18
     // Chain-callable functions should be made as following:
19 19
     // 1. Never use incomplete calls with parameters "by default"
20 20
     // 2. Reserve last parameter for cumulative result
21 21
     // 3. Use same format for original value and cumulative result (if there is original value)
22 22
     // 4. Honor cumulative result
23 23
     // 5. Return cumulative result
24
-    foreach(classSupernova::$functions[$func_name] as $func_chain_name) {
24
+    foreach (classSupernova::$functions[$func_name] as $func_chain_name) {
25 25
       // По идее - это уже тут не нужно, потому что оно все должно быть callable к этому моменту
26 26
       // Но для старых модулей...
27
-      if(is_callable($func_chain_name)) {
27
+      if (is_callable($func_chain_name)) {
28 28
         $result = call_user_func_array($func_chain_name, $func_arg);
29 29
       }
30 30
     }
31 31
   } else {
32 32
     // TODO: This is left for backward compatibility. Appropriate code should be rewrote!
33 33
     $func_name = isset(classSupernova::$functions[$func_name]) && is_callable(classSupernova::$functions[$func_name]) ? classSupernova::$functions[$func_name] : ('sn_' . $func_name);
34
-    if(is_callable($func_name)) {
34
+    if (is_callable($func_name)) {
35 35
       $result = call_user_func_array($func_name, $func_arg);
36 36
     }
37 37
   }
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
  * @param string $page_name - имя страницы, для которого должен был быть выполнен хук
47 47
  */
48 48
 function execute_hooks(&$hook_list, &$template, $hook_type = null, $page_name = null) {
49
-  if(!empty($hook_list)) {
50
-    foreach($hook_list as $hook) {
51
-      if(is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) {
49
+  if (!empty($hook_list)) {
50
+    foreach ($hook_list as $hook) {
51
+      if (is_callable($hook_call = (is_string($hook) ? $hook : (is_array($hook) ? $hook['callable'] : $hook->callable)))) {
52 52
         $template = call_user_func($hook_call, $template, $hook_type, $page_name);
53 53
       }
54 54
     }
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 
139 139
 function pretty_number($n, $floor = true, $color = false, $limit = false, $style = null) {
140 140
   $n = floatval($n);
141
-  if(is_int($floor)) {
141
+  if (is_int($floor)) {
142 142
     $n = round($n, $floor); // , PHP_ROUND_HALF_DOWN
143
-  } elseif($floor === true) {
143
+  } elseif ($floor === true) {
144 144
     $n = floor($n);
145 145
     $floor = 0;
146 146
   } else {
@@ -150,14 +150,14 @@  discard block
 block discarded – undo
150 150
   $ret = $n;
151 151
 
152 152
   $suffix = '';
153
-  if($limit) {
154
-    if($ret > 0) {
155
-      while($ret > $limit) {
153
+  if ($limit) {
154
+    if ($ret > 0) {
155
+      while ($ret > $limit) {
156 156
         $suffix .= 'k';
157 157
         $ret = round($ret / 1000);
158 158
       }
159 159
     } else {
160
-      while($ret < -$limit) {
160
+      while ($ret < -$limit) {
161 161
         $suffix .= 'k';
162 162
         $ret = round($ret / 1000);
163 163
       }
@@ -167,16 +167,16 @@  discard block
 block discarded – undo
167 167
   $ret = number_format($ret, $floor, ',', '.');
168 168
   $ret .= $suffix;
169 169
 
170
-  if($color !== false) {
171
-    if($color === true) {
170
+  if ($color !== false) {
171
+    if ($color === true) {
172 172
       $class = $n == 0 ? 'zero' : ($n > 0 ? 'positive' : 'negative');
173
-    } elseif($color >= 0) {
173
+    } elseif ($color >= 0) {
174 174
       $class = $n == $color ? 'zero' : ($n < $color ? 'positive' : 'negative');
175 175
     } else {
176 176
       $class = ($n == -$color) ? 'zero' : ($n < -$color ? 'negative' : 'positive');
177 177
     }
178 178
 
179
-    if(!isset($style)) {
179
+    if (!isset($style)) {
180 180
       $ret = "<span class='{$class}'>{$ret}</span>";
181 181
     } else {
182 182
       $ret = $style ? $ret = $class : $ret = array('text' => $ret, 'class' => $class);
@@ -301,11 +301,11 @@  discard block
 block discarded – undo
301 301
 
302 302
 function sys_get_param_phone($param_name, $default = '') {
303 303
   $phone_raw = sys_get_param_str_unsafe($param_name, $default = '');
304
-  if($phone_raw) {
304
+  if ($phone_raw) {
305 305
     $phone = $phone_raw[0] == '+' ? '+' : '';
306
-    for($i = 0; $i < strlen($phone_raw); $i++) {
306
+    for ($i = 0; $i < strlen($phone_raw); $i++) {
307 307
       $ord = ord($phone_raw[$i]);
308
-      if($ord >= 48 && $ord <= 57) {
308
+      if ($ord >= 48 && $ord <= 57) {
309 309
         $phone .= $phone_raw[$i];
310 310
       }
311 311
     }
@@ -322,14 +322,14 @@  discard block
 block discarded – undo
322 322
 }
323 323
 
324 324
 function CheckAbandonPlanetState(&$planet) {
325
-  if($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) {
325
+  if ($planet['destruyed'] && $planet['destruyed'] <= SN_TIME_NOW) {
326 326
     db_planet_delete_by_id($planet['id']);
327 327
   }
328 328
 }
329 329
 
330 330
 function eco_get_total_cost($unit_id, $unit_level) {
331 331
   static $rate, $sn_group_resources_all, $sn_group_resources_loot;
332
-  if(!$rate) {
332
+  if (!$rate) {
333 333
     $sn_group_resources_all = sn_get_groups('resources_all');
334 334
     $sn_group_resources_loot = sn_get_groups('resources_loot');
335 335
 
@@ -339,19 +339,19 @@  discard block
 block discarded – undo
339 339
   }
340 340
 
341 341
   $unit_cost_data = get_unit_param($unit_id, 'cost');
342
-  if(!is_array($unit_cost_data)) {
342
+  if (!is_array($unit_cost_data)) {
343 343
     return array('total' => 0);
344 344
   }
345 345
   $factor = isset($unit_cost_data['factor']) ? $unit_cost_data['factor'] : 1;
346 346
   $cost_array = array(BUILD_CREATE => array(), 'total' => 0);
347 347
   $unit_level = $unit_level > 0 ? $unit_level : 0;
348
-  foreach($unit_cost_data as $resource_id => $resource_amount) {
349
-    if(!in_array($resource_id, $sn_group_resources_all)) {
348
+  foreach ($unit_cost_data as $resource_id => $resource_amount) {
349
+    if (!in_array($resource_id, $sn_group_resources_all)) {
350 350
       continue;
351 351
     }
352 352
 //    $cost_array[BUILD_CREATE][$resource_id] = $resource_amount * ($factor == 1 ? $unit_level : ((pow($factor, $unit_level) - $factor) / ($factor - 1)));
353 353
     $cost_array[BUILD_CREATE][$resource_id] = round($resource_amount * ($factor == 1 ? $unit_level : ((1 - pow($factor, $unit_level)) / (1 - $factor))));
354
-    if(in_array($resource_id, $sn_group_resources_loot)) {
354
+    if (in_array($resource_id, $sn_group_resources_loot)) {
355 355
       $cost_array['total'] += $cost_array[BUILD_CREATE][$resource_id] * $rate[$resource_id];
356 356
     }
357 357
   }
@@ -435,19 +435,19 @@  discard block
 block discarded – undo
435 435
   $mercenary_level = 0;
436 436
   $unit_db_name = pname_resource_name($unit_id);
437 437
 
438
-  if(in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) {
438
+  if (in_array($unit_id, sn_get_groups(array('plans', 'mercenaries', 'tech', 'artifacts')))) {
439 439
     $unit = classSupernova::db_get_unit_by_location($user['id'], LOC_USER, $user['id'], $unit_id);
440 440
     $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0;
441
-  } elseif(in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) {
441
+  } elseif (in_array($unit_id, sn_get_groups(array('structures', 'fleet', 'defense')))) {
442 442
     $unit = classSupernova::db_get_unit_by_location(is_array($user) ? $user['id'] : $planet['id_owner'], LOC_PLANET, $planet['id'], $unit_id);
443 443
     $mercenary_level = is_array($unit) && $unit['unit_level'] ? $unit['unit_level'] : 0;
444
-  } elseif(in_array($unit_id, sn_get_groups('governors'))) {
444
+  } elseif (in_array($unit_id, sn_get_groups('governors'))) {
445 445
     $mercenary_level = $unit_id == $planet['PLANET_GOVERNOR_ID'] ? $planet['PLANET_GOVERNOR_LEVEL'] : 0;
446
-  } elseif($unit_id == RES_DARK_MATTER) {
446
+  } elseif ($unit_id == RES_DARK_MATTER) {
447 447
     $mercenary_level = $user[$unit_db_name] + ($plain || $user['user_as_ally'] ? 0 : classSupernova::$auth->account->account_metamatter);
448
-  } elseif($unit_id == RES_METAMATTER) {
448
+  } elseif ($unit_id == RES_METAMATTER) {
449 449
     $mercenary_level = classSupernova::$auth->account->account_metamatter; //$user[$unit_db_name];
450
-  } elseif(in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) {
450
+  } elseif (in_array($unit_id, sn_get_groups(array('resources_loot'))) || $unit_id == UNIT_SECTOR) {
451 451
     $mercenary_level = !empty($planet) ? $planet[$unit_db_name] : $user[$unit_db_name];
452 452
   }
453 453
 
@@ -457,19 +457,19 @@  discard block
 block discarded – undo
457 457
 function mrc_modify_value(&$user, $planet = array(), $mercenaries, $value) { return sn_function_call(__FUNCTION__, array(&$user, $planet, $mercenaries, $value)); }
458 458
 
459 459
 function sn_mrc_modify_value(&$user, $planet = array(), $mercenaries, $value, $base_value = null) {
460
-  if(!is_array($mercenaries)) {
460
+  if (!is_array($mercenaries)) {
461 461
     $mercenaries = array($mercenaries);
462 462
   }
463 463
 
464 464
   $base_value = isset($base_value) ? $base_value : $value;
465 465
 
466
-  foreach($mercenaries as $mercenary_id) {
466
+  foreach ($mercenaries as $mercenary_id) {
467 467
     $mercenary_level = mrc_get_level($user, $planet, $mercenary_id);
468 468
 
469 469
     $mercenary = get_unit_param($mercenary_id);
470 470
     $mercenary_bonus = $mercenary['bonus'];
471 471
 
472
-    switch($mercenary['bonus_type']) {
472
+    switch ($mercenary['bonus_type']) {
473 473
       case BONUS_PERCENT_CUMULATIVE:
474 474
         $value *= 1 + $mercenary_level * $mercenary_bonus / 100;
475 475
       break;
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
   $allowed_length = strlen($allowed_chars);
501 501
 
502 502
   $random_string = '';
503
-  for($i = 0; $i < $length; $i++) {
503
+  for ($i = 0; $i < $length; $i++) {
504 504
     $random_string .= $allowed_chars[mt_rand(0, $allowed_length - 1)];
505 505
   }
506 506
 
@@ -520,12 +520,12 @@  discard block
 block discarded – undo
520 520
 
521 521
   $options = '';
522 522
   $option_list = array();
523
-  foreach($user_option_list as $option_group_id => $option_group) {
523
+  foreach ($user_option_list as $option_group_id => $option_group) {
524 524
     $option_list[$option_group_id] = array();
525
-    foreach($option_group as $option_name => $option_value) {
526
-      if(!isset($user[$option_name])) {
525
+    foreach ($option_group as $option_name => $option_value) {
526
+      if (!isset($user[$option_name])) {
527 527
         $user[$option_name] = $option_value;
528
-      } elseif($user[$option_name] == '') {
528
+      } elseif ($user[$option_name] == '') {
529 529
         $user[$option_name] = 0;
530 530
       }
531 531
       $options .= "{$option_name}^{$user[$option_name]}|";
@@ -545,16 +545,16 @@  discard block
 block discarded – undo
545 545
   $option_list = array();
546 546
   $option_string_list = explode('|', $user['options']);
547 547
 
548
-  foreach($option_string_list as $option_string) {
548
+  foreach ($option_string_list as $option_string) {
549 549
     list($option_name, $option_value) = explode('^', $option_string);
550 550
     $option_list[$option_name] = $option_value;
551 551
   }
552 552
 
553 553
   $final_list = array();
554
-  foreach($user_option_list as $option_group_id => $option_group) {
554
+  foreach ($user_option_list as $option_group_id => $option_group) {
555 555
     $final_list[$option_group_id] = array();
556
-    foreach($option_group as $option_name => $option_value) {
557
-      if(!isset($option_list[$option_name])) {
556
+    foreach ($option_group as $option_name => $option_value) {
557
+      if (!isset($option_list[$option_name])) {
558 558
         $option_list[$option_name] = $option_value;
559 559
       }
560 560
       $user[$option_name] = $final_list[$option_group_id][$option_name] = $option_list[$option_name];
@@ -568,12 +568,12 @@  discard block
 block discarded – undo
568 568
 
569 569
 function sys_unit_str2arr($fleet_string) {
570 570
   $fleet_array = array();
571
-  if(!empty($fleet_string)) {
571
+  if (!empty($fleet_string)) {
572 572
     $arrTemp = explode(';', $fleet_string);
573
-    foreach($arrTemp as $temp) {
574
-      if($temp) {
573
+    foreach ($arrTemp as $temp) {
574
+      if ($temp) {
575 575
         $temp = explode(',', $temp);
576
-        if(!empty($temp[0]) && !empty($temp[1])) {
576
+        if (!empty($temp[0]) && !empty($temp[1])) {
577 577
           $fleet_array[$temp[0]] += $temp[1];
578 578
         }
579 579
       }
@@ -585,13 +585,13 @@  discard block
 block discarded – undo
585 585
 
586 586
 function sys_unit_arr2str($unit_list) {
587 587
   $fleet_string = array();
588
-  if(isset($unit_list)) {
589
-    if(!is_array($unit_list)) {
588
+  if (isset($unit_list)) {
589
+    if (!is_array($unit_list)) {
590 590
       $unit_list = array($unit_list => 1);
591 591
     }
592 592
 
593
-    foreach($unit_list as $unit_id => $unit_count) {
594
-      if($unit_id && $unit_count) {
593
+    foreach ($unit_list as $unit_id => $unit_count) {
594
+      if ($unit_id && $unit_count) {
595 595
         $fleet_string[] = "{$unit_id},{$unit_count}";
596 596
       }
597 597
     }
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
   $body = str_replace("\r\n", "\n", $body);
618 618
   $body = str_replace("\n", "\r\n", $body);
619 619
 
620
-  if($html) {
620
+  if ($html) {
621 621
     $body = '<html><head><base href="' . SN_ROOT_VIRTUAL . '"></head><body>' . nl2br($body) . '</body></html>';
622 622
   }
623 623
 
@@ -661,21 +661,21 @@  discard block
 block discarded – undo
661 661
 }
662 662
 
663 663
 function sn_ali_fill_user_ally(&$user) {
664
-  if(!$user['ally_id']) {
664
+  if (!$user['ally_id']) {
665 665
     return;
666 666
   }
667 667
 
668
-  if(!isset($user['ally'])) {
668
+  if (!isset($user['ally'])) {
669 669
     $user['ally'] = db_ally_get_by_id($user['ally_id']);
670 670
   }
671 671
 
672
-  if(!isset($user['ally']['player'])) {
672
+  if (!isset($user['ally']['player'])) {
673 673
     $user['ally']['player'] = db_user_by_id($user['ally']['ally_user_id'], true, '*', false);
674 674
   }
675 675
 }
676 676
 
677 677
 function sn_get_url_contents($url) {
678
-  if(function_exists('curl_init')) {
678
+  if (function_exists('curl_init')) {
679 679
     $crl = curl_init();
680 680
     $timeout = 5;
681 681
     curl_setopt($crl, CURLOPT_URL, $url);
@@ -710,10 +710,10 @@  discard block
 block discarded – undo
710 710
 
711 711
 function get_ship_data($ship_id, $user) {
712 712
   $ship_data = array();
713
-  if(in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) {
714
-    foreach(get_unit_param($ship_id, 'engine') as $engine_info) {
713
+  if (in_array($ship_id, sn_get_groups(array('fleet', 'missile')))) {
714
+    foreach (get_unit_param($ship_id, 'engine') as $engine_info) {
715 715
       $tech_level = intval(mrc_get_level($user, null, $engine_info['tech']));
716
-      if(empty($ship_data) || $tech_level >= $engine_info['min_level']) {
716
+      if (empty($ship_data) || $tech_level >= $engine_info['min_level']) {
717 717
         $ship_data = $engine_info;
718 718
         $ship_data['tech_level'] = $tech_level;
719 719
       }
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
   return $ship_data;
726 726
 }
727 727
 
728
-if(!function_exists('strptime')) {
728
+if (!function_exists('strptime')) {
729 729
   function strptime($date, $format) {
730 730
     $masks = array(
731 731
       '%d' => '(?P<d>[0-9]{2})',
@@ -738,12 +738,12 @@  discard block
 block discarded – undo
738 738
     );
739 739
 
740 740
     $rexep = "#" . strtr(preg_quote($format), $masks) . "#";
741
-    if(preg_match($rexep, $date, $out)) {
741
+    if (preg_match($rexep, $date, $out)) {
742 742
       $ret = array(
743
-        "tm_sec"  => (int)$out['S'],
744
-        "tm_min"  => (int)$out['M'],
745
-        "tm_hour" => (int)$out['H'],
746
-        "tm_mday" => (int)$out['d'],
743
+        "tm_sec"  => (int) $out['S'],
744
+        "tm_min"  => (int) $out['M'],
745
+        "tm_hour" => (int) $out['H'],
746
+        "tm_mday" => (int) $out['d'],
747 747
         "tm_mon"  => $out['m'] ? $out['m'] - 1 : 0,
748 748
         "tm_year" => $out['Y'] > 1900 ? $out['Y'] - 1900 : 0,
749 749
       );
@@ -758,7 +758,7 @@  discard block
 block discarded – undo
758 758
 function sn_sys_sector_buy($redirect = 'overview.php') {
759 759
   global $user, $planetrow;
760 760
 
761
-  if(!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) {
761
+  if (!sys_get_param_str('sector_buy') || $planetrow['planet_type'] != PT_PLANET) {
762 762
     return;
763 763
   }
764 764
 
@@ -771,9 +771,9 @@  discard block
 block discarded – undo
771 771
 //  $planetrow = $planetrow['planet'];
772 772
   $sector_cost = eco_get_build_data($user, $planetrow, UNIT_SECTOR, mrc_get_level($user, $planetrow, UNIT_SECTOR), true);
773 773
   $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER];
774
-  if($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) {
774
+  if ($sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER)) {
775 775
     $planet_name_text = uni_render_planet($planetrow);
776
-    if(rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf(classLocale::$lang['sys_sector_purchase_log'],
776
+    if (rpg_points_change($user['id'], RPG_SECTOR, -$sector_cost, sprintf(classLocale::$lang['sys_sector_purchase_log'],
777 777
         $user['username'], $user['id'], $planet_name_text, classLocale::$lang['sys_planet_type'][$planetrow['planet_type']], $planetrow['id'], $sector_cost)
778 778
     )) {
779 779
       $sector_db_name = pname_resource_name(UNIT_SECTOR);
@@ -788,30 +788,30 @@  discard block
 block discarded – undo
788 788
 }
789 789
 
790 790
 function sn_sys_handler_add(&$functions, $handler_list, $class_module_name = '', $sub_type = '') {
791
-  if(isset($handler_list) && is_array($handler_list) && !empty($handler_list)) {
792
-    foreach($handler_list as $function_name => $function_data) {
793
-      if(is_string($function_data)) {
791
+  if (isset($handler_list) && is_array($handler_list) && !empty($handler_list)) {
792
+    foreach ($handler_list as $function_name => $function_data) {
793
+      if (is_string($function_data)) {
794 794
         $override_with = &$function_data;
795
-      } elseif(isset($function_data['callable'])) {
795
+      } elseif (isset($function_data['callable'])) {
796 796
         $override_with = &$function_data['callable'];
797 797
       }
798 798
 
799 799
       $overwrite = $override_with[0] == '*';
800
-      if($overwrite) {
800
+      if ($overwrite) {
801 801
         $override_with = substr($override_with, 1);
802 802
       }
803 803
 
804
-      if(($point_position = strpos($override_with, '.')) === false && $class_module_name) {
804
+      if (($point_position = strpos($override_with, '.')) === false && $class_module_name) {
805 805
         $override_with = array($class_module_name, $override_with);
806
-      } elseif($point_position == 0) {
806
+      } elseif ($point_position == 0) {
807 807
         $override_with = substr($override_with, 1);
808
-      } elseif($point_position > 0) {
808
+      } elseif ($point_position > 0) {
809 809
         $override_with = array(substr($override_with, 0, $point_position), substr($override_with, $point_position + 1));
810 810
       }
811 811
 
812
-      if($overwrite) {
812
+      if ($overwrite) {
813 813
         $functions[$function_name] = array();
814
-      } elseif(!isset($functions[$function_name])) {
814
+      } elseif (!isset($functions[$function_name])) {
815 815
         $functions[$function_name] = array();
816 816
         $sn_function_name = 'sn_' . $function_name . ($sub_type ? '_' . $sub_type : '');
817 817
         $functions[$function_name][] = $sn_function_name;
@@ -827,15 +827,15 @@  discard block
 block discarded – undo
827 827
 function player_nick_render_to_html($result, $options = false) {
828 828
   // TODO - обрабатывать разные случаи: $user, $render_nick_array, $string
829 829
 
830
-  if(is_string($result) && strpos($result, ':{i:')) {
830
+  if (is_string($result) && strpos($result, ':{i:')) {
831 831
     $result = player_nick_uncompact($result);
832 832
   }
833 833
 
834
-  if(is_array($result)) {
835
-    if(isset($result['id'])) {
834
+  if (is_array($result)) {
835
+    if (isset($result['id'])) {
836 836
       $result = player_nick_render_current_to_array($result, $options);
837 837
     }
838
-    if(!isset($result[NICK_HTML])) {
838
+    if (!isset($result[NICK_HTML])) {
839 839
       $result = player_nick_render_array_to_html($result);
840 840
     }
841 841
     unset($result[NICK_HTML]);
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
   try {
859 859
     $result = unserialize($nick_string);
860 860
     // ksort($result); // Всегда ksort-ый в player_nick_compact()
861
-  } catch(exception $e) {
861
+  } catch (exception $e) {
862 862
     $result = strpos($nick_string, ':{i:') ? null : $nick_string; // fallback if it is already string - for old chat strings, for example
863 863
   }
864 864
 
@@ -871,20 +871,20 @@  discard block
 block discarded – undo
871 871
   global $user;
872 872
 
873 873
   // ALL STRING ARE UNSAFE!!!
874
-  if(isset($nick_array[NICK_BIRTHSDAY])) {
874
+  if (isset($nick_array[NICK_BIRTHSDAY])) {
875 875
     $result[NICK_BIRTHSDAY] = '<img src="design/images/birthday.png" />';
876 876
   }
877 877
 
878
-  if(isset($nick_array[NICK_VACATION])) {
878
+  if (isset($nick_array[NICK_VACATION])) {
879 879
     $result[NICK_VACATION] = '<img src="design/images/icon_vacation.png" />';
880 880
   }
881 881
 
882
-  if(isset($nick_array[NICK_GENDER])) {
882
+  if (isset($nick_array[NICK_GENDER])) {
883 883
     $result[NICK_GENDER] = '<img src="' . ($user['dpath'] ? $user['dpath'] : DEFAULT_SKINPATH) . 'images/gender_' . $nick_array[NICK_GENDER] . '.png" />';
884 884
   }
885 885
 
886
-  if(isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) {
887
-    switch($nick_array[NICK_AUTH_LEVEL]) {
886
+  if (isset($nick_array[NICK_AUTH_LEVEL]) || isset($nick_array[NICK_PREMIUM])) {
887
+    switch ($nick_array[NICK_AUTH_LEVEL]) {
888 888
       case 4:
889 889
         $highlight = classSupernova::$config->chat_highlight_developer;
890 890
       break;
@@ -905,20 +905,20 @@  discard block
 block discarded – undo
905 905
         $highlight = isset($nick_array[NICK_PREMIUM]) ? classSupernova::$config->chat_highlight_premium : '';
906 906
     }
907 907
 
908
-    if($highlight) {
908
+    if ($highlight) {
909 909
       list($result[NICK_HIGHLIGHT], $result[NICK_HIGHLIGHT_END]) = explode('$1', $highlight);
910 910
     }
911 911
     // $result = preg_replace("#(.+)#", $highlight, $result);
912 912
   }
913 913
 
914
-  if(isset($nick_array[NICK_CLASS])) {
914
+  if (isset($nick_array[NICK_CLASS])) {
915 915
     $result[NICK_CLASS] = '<span ' . $nick_array[NICK_CLASS] . '>';
916 916
     $result[NICK_CLASS_END] = '</span>';
917 917
   }
918 918
 
919 919
   $result[NICK_NICK] = sys_safe_output($nick_array[NICK_NICK]);
920 920
 
921
-  if(isset($nick_array[NICK_ALLY])) {
921
+  if (isset($nick_array[NICK_ALLY])) {
922 922
     $result[NICK_ALLY] = '[' . sys_safe_output($nick_array[NICK_ALLY]) . ']';
923 923
   }
924 924
 
@@ -942,32 +942,32 @@  discard block
 block discarded – undo
942 942
   */
943 943
 
944 944
 
945
-  if($render_user['user_birthday'] && ($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) {
945
+  if ($render_user['user_birthday'] && ($options === true || isset($options['icons']) || isset($options['birthday'])) && (date('Y', SN_TIME_NOW) . date('-m-d', strtotime($render_user['user_birthday'])) == date('Y-m-d', SN_TIME_NOW))) {
946 946
     $result[NICK_BIRTHSDAY] = '';
947 947
   }
948 948
 
949
-  if($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) {
949
+  if ($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['gender']) && $options['gender'])) {
950 950
     $result[NICK_GENDER] = $render_user['gender'] == GENDER_UNKNOWN ? 'unknown' : ($render_user['gender'] == GENDER_FEMALE ? 'female' : 'male');
951 951
   }
952 952
 
953
-  if(($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) {
953
+  if (($options === true || (isset($options['icons']) && $options['icons']) || (isset($options['vacancy']) && $options['vacancy'])) && $render_user['vacation']) {
954 954
     $result[NICK_VACATION] = $render_user['vacation'];
955 955
   }
956 956
 
957
-  if($options === true || (isset($options['color']) && $options['color'])) {
958
-    if($user_auth_level = $render_user['authlevel']) {
957
+  if ($options === true || (isset($options['color']) && $options['color'])) {
958
+    if ($user_auth_level = $render_user['authlevel']) {
959 959
       $result[NICK_AUTH_LEVEL] = $user_auth_level;
960 960
     }
961
-    if($user_premium = mrc_get_level($render_user, null, UNIT_PREMIUM)) {
961
+    if ($user_premium = mrc_get_level($render_user, null, UNIT_PREMIUM)) {
962 962
       $result[NICK_PREMIUM] = $user_premium;
963 963
     }
964 964
   }
965 965
 
966
-  if((isset($options['class']) && $options['class'])) {
966
+  if ((isset($options['class']) && $options['class'])) {
967 967
     $result[NICK_CLASS] = (isset($result_options[NICK_CLASS]) ? ' ' . $result_options[NICK_CLASS] : '') . $options['class'];
968 968
   }
969 969
 
970
-  if($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) {
970
+  if ($render_user['ally_tag'] && ($options === true || (isset($options['ally']) && $options['ally']))) {
971 971
     $result[NICK_ALLY] = $render_user['ally_tag'];
972 972
   }
973 973
 
@@ -983,25 +983,25 @@  discard block
 block discarded – undo
983 983
 
984 984
   $user_skip_list = array();
985 985
 
986
-  if(classSupernova::$config->stats_hide_admins) {
986
+  if (classSupernova::$config->stats_hide_admins) {
987 987
     $user_skip_list[] = '`authlevel` > 0';
988 988
   }
989 989
 
990
-  if(classSupernova::$config->stats_hide_player_list) {
990
+  if (classSupernova::$config->stats_hide_player_list) {
991 991
     $temp = explode(',', classSupernova::$config->stats_hide_player_list);
992
-    foreach($temp as $user_id) {
992
+    foreach ($temp as $user_id) {
993 993
       $user_id = floatval($user_id);
994
-      if($user_id) {
994
+      if ($user_id) {
995 995
         $user_skip_list[] = '`id` = ' . $user_id;
996 996
       }
997 997
     }
998 998
   }
999 999
 
1000
-  if(!empty($user_skip_list)) {
1000
+  if (!empty($user_skip_list)) {
1001 1001
     $user_skip_list = implode(' OR ', $user_skip_list);
1002 1002
     $user_skip_query = db_user_list($user_skip_list);
1003
-    if(!empty($user_skip_query)) {
1004
-      foreach($user_skip_query as $user_skip_row) {
1003
+    if (!empty($user_skip_query)) {
1004
+      foreach ($user_skip_query as $user_skip_row) {
1005 1005
         $result[$user_skip_row['id']] = $user_skip_row['id'];
1006 1006
       }
1007 1007
     }
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
 
1033 1033
 function sn_sn_get_groups($groups, &$result) {
1034 1034
   $result = is_array($result) ? $result : array();
1035
-  foreach($groups = is_array($groups) ? $groups : array($groups) as $group_name) {
1035
+  foreach ($groups = is_array($groups) ? $groups : array($groups) as $group_name) {
1036 1036
     $result += is_array($a_group = get_unit_param(UNIT_GROUP, $group_name)) ? $a_group : array();
1037 1037
   }
1038 1038
 
@@ -1058,8 +1058,8 @@  discard block
 block discarded – undo
1058 1058
   $sn_data_unit = get_unit_param($unit_id);
1059 1059
 
1060 1060
   $result = is_array($result) ? $result : array();
1061
-  if($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && classSupernova::$config->empire_mercenary_temporary)) {
1062
-    foreach($sn_data_unit[$field] as $require_id => $require_level) {
1061
+  if ($sn_data_unit[$field] && !($sn_data_unit[P_UNIT_TYPE] == UNIT_MERCENARIES && classSupernova::$config->empire_mercenary_temporary)) {
1062
+    foreach ($sn_data_unit[$field] as $require_id => $require_level) {
1063 1063
       $level_got = mrc_get_level($user, $planetrow, $require_id);
1064 1064
       $level_basic = mrc_get_level($user, $planetrow, $require_id, false, true);
1065 1065
       $result[] = array(
@@ -1083,16 +1083,16 @@  discard block
 block discarded – undo
1083 1083
 
1084 1084
   $ranks = array();
1085 1085
 
1086
-  if($ally['ranklist']) {
1086
+  if ($ally['ranklist']) {
1087 1087
     $str_ranks = explode(';', $ally['ranklist']);
1088
-    foreach($str_ranks as $str_rank) {
1089
-      if(!$str_rank) {
1088
+    foreach ($str_ranks as $str_rank) {
1089
+      if (!$str_rank) {
1090 1090
         continue;
1091 1091
       }
1092 1092
 
1093 1093
       $tmp = explode(',', $str_rank);
1094 1094
       $rank_id = count($ranks);
1095
-      foreach($ally_rights as $key => $value) {
1095
+      foreach ($ally_rights as $key => $value) {
1096 1096
         $ranks[$rank_id][$value] = $tmp[$key];
1097 1097
       }
1098 1098
     }
@@ -1108,8 +1108,8 @@  discard block
 block discarded – undo
1108 1108
 }
1109 1109
 
1110 1110
 function array_merge_recursive_numeric($array1, $array2) {
1111
-  if(!empty($array2) && is_array($array2)) {
1112
-    foreach($array2 as $key => $value) {
1111
+  if (!empty($array2) && is_array($array2)) {
1112
+    foreach ($array2 as $key => $value) {
1113 1113
 //    if(!isset($array1[$key]) || !is_array($array1[$key])) {
1114 1114
 //      $array1[$key] = $value;
1115 1115
 //    } else {
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
 
1125 1125
 function sn_sys_array_cumulative_sum(&$array) {
1126 1126
   $accum = 0;
1127
-  foreach($array as &$value) {
1127
+  foreach ($array as &$value) {
1128 1128
     $accum += $value;
1129 1129
     $value = $accum;
1130 1130
   }
@@ -1134,7 +1134,7 @@  discard block
 block discarded – undo
1134 1134
   $sn_data_density = sn_get_groups('planet_density');
1135 1135
   $density_price_chart = array();
1136 1136
 
1137
-  foreach($sn_data_density as $density_id => $density_data) {
1137
+  foreach ($sn_data_density as $density_id => $density_data) {
1138 1138
     // Отсекаем записи с RARITY = 0 - служебные записи и супер-ядра
1139 1139
     $density_data[UNIT_PLANET_DENSITY_RARITY] ? $density_price_chart[$density_id] = $density_data[UNIT_PLANET_DENSITY_RARITY] : false;
1140 1140
   }
@@ -1142,7 +1142,7 @@  discard block
 block discarded – undo
1142 1142
 
1143 1143
   $total_rarity = array_sum($density_price_chart);
1144 1144
 
1145
-  foreach($density_price_chart as &$density_data) {
1145
+  foreach ($density_price_chart as &$density_data) {
1146 1146
     $density_data = ceil($total_rarity / $density_data * $planet_row['field_max'] * PLANET_DENSITY_TO_DARK_MATTER_RATE);
1147 1147
   }
1148 1148
 
@@ -1150,16 +1150,16 @@  discard block
 block discarded – undo
1150 1150
 }
1151 1151
 
1152 1152
 function sn_sys_planet_core_transmute(&$user, &$planetrow) {
1153
-  if(!sys_get_param_str('transmute')) {
1153
+  if (!sys_get_param_str('transmute')) {
1154 1154
     return array();
1155 1155
   }
1156 1156
 
1157 1157
   try {
1158
-    if($planetrow['planet_type'] != PT_PLANET) {
1158
+    if ($planetrow['planet_type'] != PT_PLANET) {
1159 1159
       throw new exception(classLocale::$lang['ov_core_err_not_a_planet'], ERR_ERROR);
1160 1160
     }
1161 1161
 
1162
-    if($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) {
1162
+    if ($planetrow['density_index'] == ($new_density_index = sys_get_param_id('density_type'))) {
1163 1163
       throw new exception(classLocale::$lang['ov_core_err_same_density'], ERR_WARNING);
1164 1164
     }
1165 1165
 
@@ -1173,7 +1173,7 @@  discard block
 block discarded – undo
1173 1173
     $planet_density_index = $planetrow['density_index'];
1174 1174
 
1175 1175
     $density_price_chart = planet_density_price_chart($planetrow);
1176
-    if(!isset($density_price_chart[$new_density_index])) {
1176
+    if (!isset($density_price_chart[$new_density_index])) {
1177 1177
       // Hack attempt
1178 1178
       throw new exception(classLocale::$lang['ov_core_err_denisty_type_wrong'], ERR_ERROR);
1179 1179
     }
@@ -1182,13 +1182,13 @@  discard block
 block discarded – undo
1182 1182
     // $transmute_cost = get_unit_param(UNIT_PLANET_DENSITY, 'cost');
1183 1183
     // $transmute_cost = $transmute_cost[RES_DARK_MATTER] * $density_price_chart[$new_density_index];
1184 1184
     $transmute_cost = $density_price_chart[$new_density_index];
1185
-    if($user_dark_matter < $transmute_cost) {
1185
+    if ($user_dark_matter < $transmute_cost) {
1186 1186
       throw new exception(classLocale::$lang['ov_core_err_no_dark_matter'], ERR_ERROR);
1187 1187
     }
1188 1188
 
1189 1189
     $sn_data_planet_density = sn_get_groups('planet_density');
1190
-    foreach($sn_data_planet_density as $key => $value) {
1191
-      if($key == $new_density_index) {
1190
+    foreach ($sn_data_planet_density as $key => $value) {
1191
+      if ($key == $new_density_index) {
1192 1192
         break;
1193 1193
       }
1194 1194
       $prev_density_index = $key;
@@ -1219,7 +1219,7 @@  discard block
 block discarded – undo
1219 1219
       'STATUS'  => ERR_NONE,
1220 1220
       'MESSAGE' => sprintf(classLocale::$lang['ov_core_err_none'], classLocale::$lang['uni_planet_density_types'][$planet_density_index], classLocale::$lang['uni_planet_density_types'][$new_density_index], $new_density),
1221 1221
     );
1222
-  } catch(exception $e) {
1222
+  } catch (exception $e) {
1223 1223
     sn_db_transaction_rollback();
1224 1224
     $result = array(
1225 1225
       'STATUS'  => $e->getCode(),
@@ -1232,8 +1232,8 @@  discard block
 block discarded – undo
1232 1232
 
1233 1233
 function sn_module_get_active_count($group = '*') {
1234 1234
   $active_modules = 0;
1235
-  if(isset(sn_module::$sn_module_list[$group]) && is_array(sn_module::$sn_module_list[$group])) {
1236
-    foreach(sn_module::$sn_module_list[$group] as $payment_module) {
1235
+  if (isset(sn_module::$sn_module_list[$group]) && is_array(sn_module::$sn_module_list[$group])) {
1236
+    foreach (sn_module::$sn_module_list[$group] as $payment_module) {
1237 1237
       $active_modules += $payment_module->manifest['active'];
1238 1238
     }
1239 1239
   }
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 function get_resource_exchange() {
1245 1245
   static $rates;
1246 1246
 
1247
-  if(!$rates) {
1247
+  if (!$rates) {
1248 1248
     $rates = array(
1249 1249
       RES_METAL       => 'rpg_exchange_metal',
1250 1250
       RES_CRYSTAL     => 'rpg_exchange_crystal',
@@ -1252,7 +1252,7 @@  discard block
 block discarded – undo
1252 1252
       RES_DARK_MATTER => 'rpg_exchange_darkMatter',
1253 1253
     );
1254 1254
 
1255
-    foreach($rates as &$rate) {
1255
+    foreach ($rates as &$rate) {
1256 1256
       $rate = classSupernova::$config->$rate;
1257 1257
     }
1258 1258
   }
@@ -1263,12 +1263,12 @@  discard block
 block discarded – undo
1263 1263
 function get_unit_cost_in(&$cost, $in_resource = RES_METAL) {
1264 1264
   static $rates;
1265 1265
 
1266
-  if(!$rates) {
1266
+  if (!$rates) {
1267 1267
     $rates = get_resource_exchange();
1268 1268
   }
1269 1269
 
1270 1270
   $metal_cost = 0;
1271
-  foreach($cost as $resource_id => $resource_value) {
1271
+  foreach ($cost as $resource_id => $resource_value) {
1272 1272
     $metal_cost += $rates[$resource_id] * $resource_value;
1273 1273
   }
1274 1274
 
@@ -1278,8 +1278,8 @@  discard block
 block discarded – undo
1278 1278
 function get_player_max_expeditons(&$user, $astrotech = -1) { return sn_function_call(__FUNCTION__, array(&$user, $astrotech, &$result)); }
1279 1279
 
1280 1280
 function sn_get_player_max_expeditons(&$user, $astrotech = -1, &$result = 0) {
1281
-  if($astrotech == -1) {
1282
-    if(!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) {
1281
+  if ($astrotech == -1) {
1282
+    if (!isset($user[UNIT_PLAYER_EXPEDITIONS_MAX])) {
1283 1283
       $astrotech = mrc_get_level($user, null, TECH_ASTROTECH);
1284 1284
       $user[UNIT_PLAYER_EXPEDITIONS_MAX] = $astrotech >= 1 ? floor(sqrt($astrotech - 1)) : 0;
1285 1285
     }
@@ -1295,8 +1295,8 @@  discard block
 block discarded – undo
1295 1295
 }
1296 1296
 
1297 1297
 function get_player_max_colonies(&$user, $astrotech = -1) {
1298
-  if($astrotech == -1) {
1299
-    if(!isset($user[UNIT_PLAYER_COLONIES_MAX])) {
1298
+  if ($astrotech == -1) {
1299
+    if (!isset($user[UNIT_PLAYER_COLONIES_MAX])) {
1300 1300
 
1301 1301
       $expeditions = get_player_max_expeditons($user);
1302 1302
       $astrotech = mrc_get_level($user, null, TECH_ASTROTECH);
@@ -1341,10 +1341,10 @@  discard block
 block discarded – undo
1341 1341
 
1342 1342
   // pdump($powerup_unit, '$powerup_unit');
1343 1343
   $level_current = $term_original = $time_left = 0;
1344
-  if($is_upgrade) {
1344
+  if ($is_upgrade) {
1345 1345
     $time_finish = strtotime($powerup_unit['unit_time_finish']);
1346 1346
     $time_left = max(0, $time_finish - SN_TIME_NOW);
1347
-    if($time_left > 0) {
1347
+    if ($time_left > 0) {
1348 1348
       $term_original = $time_finish - strtotime($powerup_unit['unit_time_start']);
1349 1349
       $level_current = $powerup_unit['unit_level'];
1350 1350
     }
@@ -1352,22 +1352,22 @@  discard block
 block discarded – undo
1352 1352
 
1353 1353
   $level_max = $level_max > $powerup_data[P_MAX_STACK] ? $level_max : $powerup_data[P_MAX_STACK];
1354 1354
   $original_cost = 0;
1355
-  for($i = 1; $i <= $level_max; $i++) {
1355
+  for ($i = 1; $i <= $level_max; $i++) {
1356 1356
     $base_cost = eco_get_total_cost($powerup_id, $i);
1357 1357
     $base_cost = $base_cost[BUILD_CREATE][RES_DARK_MATTER];
1358
-    foreach($sn_powerup_buy_discounts as $period => $discount) {
1358
+    foreach ($sn_powerup_buy_discounts as $period => $discount) {
1359 1359
       $upgrade_price = floor($base_cost * $discount * $period / PERIOD_MONTH);
1360 1360
       $result[$i][$period] = $upgrade_price;
1361 1361
       $original_cost = $is_upgrade && $i == $level_current && $period <= $term_original ? $upgrade_price : $original_cost;
1362 1362
     }
1363 1363
   }
1364 1364
 
1365
-  if($is_upgrade && $time_left) {
1365
+  if ($is_upgrade && $time_left) {
1366 1366
     $term_original = round($term_original / PERIOD_DAY);
1367 1367
     $time_left = min(floor($time_left / PERIOD_DAY), $term_original);
1368 1368
     $cost_left = $term_original > 0 ? ceil($time_left / $term_original * $original_cost) : 0;
1369 1369
 
1370
-    array_walk_recursive($result, function (&$value) use ($cost_left) {
1370
+    array_walk_recursive($result, function(&$value) use ($cost_left) {
1371 1371
       $value -= $cost_left;
1372 1372
     });
1373 1373
   }
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
 
1424 1424
 function print_rr($var, $capture = false) {
1425 1425
   $print = '<pre>' . htmlspecialchars(print_r($var, true)) . '</pre>';
1426
-  if($capture) {
1426
+  if ($capture) {
1427 1427
     return $print;
1428 1428
   } else {
1429 1429
     print($print);
Please login to merge, or discard this patch.
includes/init_secondary.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -2,19 +2,19 @@  discard block
 block discarded – undo
2 2
 
3 3
 $classLocale = classLocale::$lang;
4 4
 
5
-if(classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) {
5
+if (classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) {
6 6
   include(SN_ROOT_PHYSICAL . 'ajax_version_check' . DOT_PHP_EX);
7 7
 }
8 8
 
9
-if(classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) {
9
+if (classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) {
10 10
   require_once(SN_ROOT_PHYSICAL . "includes/includes/user_birthday_celebrate" . DOT_PHP_EX);
11 11
   sn_user_birthday_celebrate();
12 12
 }
13 13
 
14
-if(!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) {
14
+if (!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) {
15 15
   classSupernova::$config->db_saveItem('var_online_user_count', db_user_count(true));
16 16
   classSupernova::$config->db_saveItem('var_online_user_time', SN_TIME_NOW);
17
-  if(classSupernova::$config->server_log_online) {
17
+  if (classSupernova::$config->server_log_online) {
18 18
     db_log_online_insert();
19 19
   }
20 20
 }
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id'];
42 42
 //pdump($template_result[F_ACCOUNT_IS_AUTHORIZED]);die();
43 43
 
44
-if(!empty($user['id'])) {
44
+if (!empty($user['id'])) {
45 45
   classSupernova::$user_options->user_change($user['id']);
46 46
 }
47 47
 
@@ -54,15 +54,15 @@  discard block
 block discarded – undo
54 54
     : false
55 55
   );
56 56
 
57
-if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
58
-  $prohibited_characters = array_map(function ($value) {
57
+if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
58
+  $prohibited_characters = array_map(function($value) {
59 59
     return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
60 60
   }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
61 61
   $template_result[F_LOGIN_MESSAGE] .= implode(', ', $prohibited_characters);
62 62
 }
63 63
 
64 64
 
65
-if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
65
+if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
66 66
   pdump("Отключи отладку перед продакшном!");
67 67
 }
68 68
 
@@ -76,17 +76,17 @@  discard block
 block discarded – undo
76 76
   ? define('INSTALL_MODE', GAME_DISABLE_INSTALL)
77 77
   : false;
78 78
 
79
-if($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) {
79
+if ($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) {
80 80
   $template_result[F_GAME_DISABLE_REASON] = sys_bbcodeParse(
81 81
     classSupernova::$config->game_disable == GAME_DISABLE_REASON
82 82
       ? classSupernova::$config->game_disable_reason
83 83
       : classLocale::$lang['sys_game_disable_reason'][classSupernova::$config->game_disable]
84 84
   );
85
-  if(defined('IN_API')) {
85
+  if (defined('IN_API')) {
86 86
     return;
87 87
   }
88 88
 
89
-  if(
89
+  if (
90 90
     ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN))
91 91
     &&
92 92
     !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT'))
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 
101 101
 // TODO ban
102 102
 // TODO $skip_ban_check
103
-if($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
104
-  if(defined('IN_API')) {
103
+if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
104
+  if (defined('IN_API')) {
105 105
     return;
106 106
   }
107 107
 
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 // pdump($allow_anonymous, '$allow_anonymous');
120 120
 // pdump($sys_user_logged_in, '$sys_user_logged_in');
121 121
 
122
-if($sys_user_logged_in && INITIAL_PAGE == 'login') {
122
+if ($sys_user_logged_in && INITIAL_PAGE == 'login') {
123 123
   sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
124
-} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
124
+} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
125 125
 //  pdump($sn_page_name);
126 126
 //  pdump(INITIAL_PAGE);
127 127
 //  die('{Тут должна быть ваша реклама. Точнее - ввод имени игрока}');
128
-} elseif(!$allow_anonymous && !$sys_user_logged_in) {
128
+} elseif (!$allow_anonymous && !$sys_user_logged_in) {
129 129
   // sn_setcookie(SN_COOKIE, '', time() - PERIOD_WEEK, SN_ROOT_RELATIVE);
130 130
   sys_redirect(SN_ROOT_VIRTUAL . 'login.php');
131 131
 }
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
 global $skip_fleet_update;
148 148
 $skip_fleet_update = $skip_fleet_update || $supernova->options['fleet_update_skip'] || defined('IN_ADMIN');
149
-if(
149
+if (
150 150
   !$skip_fleet_update
151 151
   && !(defined('IN_AJAX') && IN_AJAX === true)
152 152
   && SN_TIME_NOW - strtotime(classSupernova::$config->fleet_update_last) > classSupernova::$config->fleet_update_interval
Please login to merge, or discard this patch.
includes/classes/Account.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
     $this->reset();
80 80
     $this->db = is_object($db) ? $db : classSupernova::$db;
81 81
 
82
-    foreach($this->table_check as $table_name) {
83
-      if(empty($this->db->table_list[$table_name])) {
82
+    foreach ($this->table_check as $table_name) {
83
+      if (empty($this->db->table_list[$table_name])) {
84 84
         die('Если вы видите это сообщение первый раз после обновления релиза - просто перегрузите страницу.<br />
85 85
               В противном случае - сообщите Администрации сервера об ошибке.<br/>
86 86
               Не хватает таблицы для работы системы авторизации: ' . $table_name);
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
    */
105 105
   // OK v4.6
106 106
   public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) {
107
-    if(!$this->password_check($old_password_unsafe)) {
107
+    if (!$this->password_check($old_password_unsafe)) {
108 108
       return false;
109 109
     }
110 110
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
   // OK v4.5
126 126
   public function assign_from_db_row($row) {
127 127
     $this->reset();
128
-    if(empty($row) || !is_array($row)) {
128
+    if (empty($row) || !is_array($row)) {
129 129
       return false;
130 130
     }
131 131
     $this->account_id = $row['account_id'];
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
         `account_email` = LOWER('{$email_safe}'),
243 243
         `account_language` = '{$language_safe}'"
244 244
     );
245
-    if(!$result) {
245
+    if (!$result) {
246 246
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
247 247
     }
248 248
 
249
-    if(!($account_id = $this->db->db_insert_id())) {
249
+    if (!($account_id = $this->db->db_insert_id())) {
250 250
       throw new Exception(REGISTER_ERROR_ACCOUNT_CREATE, ERR_ERROR);
251 251
     }
252 252
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
       WHERE `account_id` = '{$account_id_safe}'"
277 277
     ) ? true : false;
278 278
 
279
-    if($result) {
279
+    if ($result) {
280 280
       $result = $this->db_get_by_id($this->account_id);
281 281
     }
282 282
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
   public function metamatter_change($change_type, $metamatter, $comment = '', $already_changed = false) {
364 364
     global $debug, $mm_change_legit;
365 365
 
366
-    if(!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
366
+    if (!$this->is_exists || !($metamatter = round(floatval($metamatter)))) {
367 367
       $debug->error('Ошибка при попытке манипуляции с ММ');
368 368
 
369 369
       return false;
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 
374 374
     $mm_change_legit = true;
375 375
     // $sn_data_metamatter_db_name = pname_resource_name(RES_METAMATTER);
376
-    if($already_changed) {
376
+    if ($already_changed) {
377 377
       $metamatter_total_delta = 0;
378 378
       $result = -1;
379 379
     } else {
@@ -387,13 +387,13 @@  discard block
 block discarded – undo
387 387
         ($metamatter_total_delta ? ", `account_immortal` = IF(`account_metamatter_total` + '{$metamatter_total_delta}' >= {$classConfig->player_metamatter_immortal}, NOW(), `account_immortal`), `account_metamatter_total` = `account_metamatter_total` + '{$metamatter_total_delta}'" : '') .
388 388
         " WHERE `account_id` = {$account_id_safe}"
389 389
       );
390
-      if(!$result) {
390
+      if (!$result) {
391 391
         $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
392 392
       }
393 393
       $result = classSupernova::$db->db_affected_rows();
394 394
     }
395 395
 
396
-    if(empty(core_auth::$user['id'])) {
396
+    if (empty(core_auth::$user['id'])) {
397 397
       $user_list = PlayerToAccountTranslate::db_translate_get_users_from_account_list(core_auth::$main_provider->provider_id, $this->account_id);
398 398
       reset($user_list);
399 399
       $user_id_unsafe = key($user_list);
@@ -402,30 +402,30 @@  discard block
 block discarded – undo
402 402
     }
403 403
     $user_id_safe = $this->db->db_escape($user_id_unsafe);
404 404
 
405
-    if(!$result) {
405
+    if (!$result) {
406 406
       $debug->error("Error adjusting Metamatter for player ID {$this->account_id} (Player Not Found?) with {$metamatter}. Reason: {$comment}", 'Metamatter Change', 402);
407 407
     }
408 408
 
409
-    if(!$already_changed) {
409
+    if (!$already_changed) {
410 410
       $this->account_metamatter += $metamatter;
411 411
       $this->account_metamatter_total += $metamatter_total_delta;
412 412
     }
413 413
 
414
-    if(is_array($comment)) {
414
+    if (is_array($comment)) {
415 415
       $comment = call_user_func_array('sprintf', $comment);
416 416
     }
417 417
 
418 418
     $result = $this->db_mm_log_insert($comment, $change_type, $metamatter, $user_id_unsafe);
419 419
 
420
-    if($metamatter > 0 && !empty($user_id_safe)) {
420
+    if ($metamatter > 0 && !empty($user_id_safe)) {
421 421
       $old_referral = db_referral_get_by_id($user_id_safe);
422
-      if($old_referral['id']) {
422
+      if ($old_referral['id']) {
423 423
         $dark_matter_from_metamatter = $metamatter * AFFILIATE_MM_TO_REFERRAL_DM;
424 424
         db_referral_update_dm($user_id_safe, $dark_matter_from_metamatter);
425 425
         $new_referral = db_referral_get_by_id($user_id_safe);
426 426
 
427 427
         $partner_bonus = floor($new_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) - ($old_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum ? floor($old_referral['dark_matter'] / classSupernova::$config->rpg_bonus_divisor) : 0);
428
-        if($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) {
428
+        if ($partner_bonus > 0 && $new_referral['dark_matter'] >= classSupernova::$config->rpg_bonus_minimum) {
429 429
           rpg_points_change($new_referral['id_partner'], RPG_REFERRAL_BOUGHT_MM, $partner_bonus, "Incoming MM From Referral ID {$user_id_safe}");
430 430
         }
431 431
       }
Please login to merge, or discard this patch.
includes/classes/db_mysql.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -76,23 +76,23 @@  discard block
 block discarded – undo
76 76
   function sn_db_connect($external_db_settings = null) {
77 77
     $this->db_disconnect();
78 78
 
79
-    if(!empty($external_db_settings) && is_array($external_db_settings)) {
79
+    if (!empty($external_db_settings) && is_array($external_db_settings)) {
80 80
       $this->dbsettings = $external_db_settings;
81 81
     }
82 82
 
83
-    if(empty($this->dbsettings)) {
83
+    if (empty($this->dbsettings)) {
84 84
       $this->load_db_settings();
85 85
     }
86 86
 
87 87
     // TODO - фатальные (?) ошибки на каждом шагу. Хотя - скорее Эксепшны
88
-    if(!empty($this->dbsettings)) {
88
+    if (!empty($this->dbsettings)) {
89 89
       $driver_name = empty($this->dbsettings['sn_driver']) ? 'db_mysql_v5' : $this->dbsettings['sn_driver'];
90 90
       $this->driver = new $driver_name();
91 91
       $this->db_prefix = $this->dbsettings['prefix'];
92 92
 
93 93
       $this->connected = $this->connected || $this->driver_connect();
94 94
 
95
-      if($this->connected) {
95
+      if ($this->connected) {
96 96
         $this->table_list = $this->db_get_table_list();
97 97
         // TODO Проверка на пустоту
98 98
       }
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
   function driver_connect() {
107 107
     global $debug;
108 108
 
109
-    if(!is_object($this->driver)) {
109
+    if (!is_object($this->driver)) {
110 110
       $debug->error_fatal('DB Error - No driver for MySQL found!');
111 111
     }
112 112
 
113
-    if(!method_exists($this->driver, 'mysql_connect')) {
113
+    if (!method_exists($this->driver, 'mysql_connect')) {
114 114
       $debug->error_fatal('DB Error - WRONG MySQL driver!');
115 115
     }
116 116
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
   }
119 119
 
120 120
   function db_disconnect() {
121
-    if($this->connected) {
121
+    if ($this->connected) {
122 122
       $this->connected = !$this->driver_disconnect();
123 123
       $this->connected = false;
124 124
     }
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
   function doquery($query, $table = '', $fetch = false, $skip_query_check = false) {
130 130
     global $numqueries, $debug;
131 131
 
132
-    if(!is_string($table)) {
132
+    if (!is_string($table)) {
133 133
       $fetch = $table;
134 134
     }
135 135
 
136
-    if(!$this->connected) {
136
+    if (!$this->connected) {
137 137
       $this->sn_db_connect();
138 138
     }
139 139
 
@@ -142,30 +142,30 @@  discard block
 block discarded – undo
142 142
     !$skip_query_check ? $this->security_query_check_bad_words($query) : false;
143 143
 
144 144
     $sql = $query;
145
-    if(strpos($sql, '{{') !== false) {
146
-      foreach($this->table_list as $tableName) {
145
+    if (strpos($sql, '{{') !== false) {
146
+      foreach ($this->table_list as $tableName) {
147 147
         $sql = str_replace("{{{$tableName}}}", $this->db_prefix . $tableName, $sql);
148 148
       }
149 149
     }
150 150
 
151
-    if(classSupernova::$config->debug) {
151
+    if (classSupernova::$config->debug) {
152 152
       $numqueries++;
153 153
       $arr = debug_backtrace();
154
-      $file = end(explode('/',$arr[0]['file']));
154
+      $file = end(explode('/', $arr[0]['file']));
155 155
       $line = $arr[0]['line'];
156 156
       $debug->add("<tr><th>Query $numqueries: </th><th>$query</th><th>$file($line)</th><th>$table</th><th>$fetch</th></tr>");
157 157
     }
158 158
 
159
-    if(defined('DEBUG_SQL_COMMENT')) {
159
+    if (defined('DEBUG_SQL_COMMENT')) {
160 160
       $backtrace = debug_backtrace();
161 161
       $sql_comment = $debug->compact_backtrace($backtrace, defined('DEBUG_SQL_COMMENT_LONG'));
162 162
 
163 163
       $sql_commented = '/* ' . implode("<br />", $sql_comment) . '<br /> */ ' . preg_replace("/\s+/", ' ', $sql);
164
-      if(defined('DEBUG_SQL_ONLINE')) {
164
+      if (defined('DEBUG_SQL_ONLINE')) {
165 165
         $debug->warning($sql_commented, 'SQL Debug', LOG_DEBUG_SQL);
166 166
       }
167 167
 
168
-      if(defined('DEBUG_SQL_ERROR')) {
168
+      if (defined('DEBUG_SQL_ERROR')) {
169 169
         array_unshift($sql_comment, preg_replace("/\s+/", ' ', $sql));
170 170
         $debug->add_to_array($sql_comment);
171 171
         // $debug->add_to_array($sql_comment . preg_replace("/\s+/", ' ', $sql));
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
       $sql = $sql_commented;
174 174
     }
175 175
 
176
-    $sqlquery = $this->db_sql_query($sql) or $debug->error(db_error()."<br />$sql<br />",'SQL Error');
176
+    $sqlquery = $this->db_sql_query($sql) or $debug->error(db_error() . "<br />$sql<br />", 'SQL Error');
177 177
 
178 178
     return $fetch ? $this->db_fetch($sqlquery) : $sqlquery;
179 179
   }
@@ -183,16 +183,16 @@  discard block
 block discarded – undo
183 183
     // TODO Заменить это на новый логгер
184 184
     global $is_watching, $user, $debug;
185 185
 
186
-    if(!$is_watching && classSupernova::$config->game_watchlist_array && in_array($user['id'], classSupernova::$config->game_watchlist_array))
186
+    if (!$is_watching && classSupernova::$config->game_watchlist_array && in_array($user['id'], classSupernova::$config->game_watchlist_array))
187 187
     {
188
-      if(!preg_match('/^(select|commit|rollback|start transaction)/i', $query)) {
188
+      if (!preg_match('/^(select|commit|rollback|start transaction)/i', $query)) {
189 189
         $is_watching = true;
190 190
         $msg = "\$query = \"{$query}\"\n\r";
191
-        if(!empty($_POST)) {
192
-          $msg .= "\n\r" . dump($_POST,'$_POST');
191
+        if (!empty($_POST)) {
192
+          $msg .= "\n\r" . dump($_POST, '$_POST');
193 193
         }
194
-        if(!empty($_GET)) {
195
-          $msg .= "\n\r" . dump($_GET,'$_GET');
194
+        if (!empty($_GET)) {
195
+          $msg .= "\n\r" . dump($_GET, '$_GET');
196 196
         }
197 197
         $debug->warning($msg, "Watching user {$user['id']}", 399, array('base_dump' => true));
198 198
         $is_watching = false;
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
   function security_query_check_bad_words($query) {
205 205
     global $user, $dm_change_legit, $mm_change_legit;
206 206
 
207
-    switch(true) {
207
+    switch (true) {
208 208
       case stripos($query, 'RUNCATE TABL') != false:
209 209
       case stripos($query, 'ROP TABL') != false:
210 210
       case stripos($query, 'ENAME TABL') != false:
@@ -215,33 +215,33 @@  discard block
 block discarded – undo
215 215
       case stripos($query, 'RPG_POINTS') != false && stripos(trim($query), 'UPDATE ') === 0 && !$dm_change_legit:
216 216
       case stripos($query, 'METAMATTER') != false && stripos(trim($query), 'UPDATE ') === 0 && !$mm_change_legit:
217 217
       case stripos($query, 'AUTHLEVEL') != false && $user['authlevel'] < 3 && stripos($query, 'SELECT') !== 0:
218
-        $report  = "Hacking attempt (".date("d.m.Y H:i:s")." - [".time()."]):\n";
218
+        $report  = "Hacking attempt (" . date("d.m.Y H:i:s") . " - [" . time() . "]):\n";
219 219
         $report .= ">Database Inforamation\n";
220
-        $report .= "\tID - ".$user['id']."\n";
221
-        $report .= "\tUser - ".$user['username']."\n";
222
-        $report .= "\tAuth level - ".$user['authlevel']."\n";
223
-        $report .= "\tAdmin Notes - ".$user['adminNotes']."\n";
224
-        $report .= "\tCurrent Planet - ".$user['current_planet']."\n";
225
-        $report .= "\tUser IP - ".$user['user_lastip']."\n";
226
-        $report .= "\tUser IP at Reg - ".$user['ip_at_reg']."\n";
227
-        $report .= "\tUser Agent- ".$_SERVER['HTTP_USER_AGENT']."\n";
228
-        $report .= "\tCurrent Page - ".$user['current_page']."\n";
229
-        $report .= "\tRegister Time - ".$user['register_time']."\n";
220
+        $report .= "\tID - " . $user['id'] . "\n";
221
+        $report .= "\tUser - " . $user['username'] . "\n";
222
+        $report .= "\tAuth level - " . $user['authlevel'] . "\n";
223
+        $report .= "\tAdmin Notes - " . $user['adminNotes'] . "\n";
224
+        $report .= "\tCurrent Planet - " . $user['current_planet'] . "\n";
225
+        $report .= "\tUser IP - " . $user['user_lastip'] . "\n";
226
+        $report .= "\tUser IP at Reg - " . $user['ip_at_reg'] . "\n";
227
+        $report .= "\tUser Agent- " . $_SERVER['HTTP_USER_AGENT'] . "\n";
228
+        $report .= "\tCurrent Page - " . $user['current_page'] . "\n";
229
+        $report .= "\tRegister Time - " . $user['register_time'] . "\n";
230 230
         $report .= "\n";
231 231
 
232 232
         $report .= ">Query Information\n";
233
-        $report .= "\tQuery - ".$query."\n";
233
+        $report .= "\tQuery - " . $query . "\n";
234 234
         $report .= "\n";
235 235
 
236 236
         $report .= ">\$_SERVER Information\n";
237
-        $report .= "\tIP - ".$_SERVER['REMOTE_ADDR']."\n";
238
-        $report .= "\tHost Name - ".$_SERVER['HTTP_HOST']."\n";
239
-        $report .= "\tUser Agent - ".$_SERVER['HTTP_USER_AGENT']."\n";
240
-        $report .= "\tRequest Method - ".$_SERVER['REQUEST_METHOD']."\n";
241
-        $report .= "\tCame From - ".$_SERVER['HTTP_REFERER']."\n";
242
-        $report .= "\tPage is - ".$_SERVER['SCRIPT_NAME']."\n";
243
-        $report .= "\tUses Port - ".$_SERVER['REMOTE_PORT']."\n";
244
-        $report .= "\tServer Protocol - ".$_SERVER['SERVER_PROTOCOL']."\n";
237
+        $report .= "\tIP - " . $_SERVER['REMOTE_ADDR'] . "\n";
238
+        $report .= "\tHost Name - " . $_SERVER['HTTP_HOST'] . "\n";
239
+        $report .= "\tUser Agent - " . $_SERVER['HTTP_USER_AGENT'] . "\n";
240
+        $report .= "\tRequest Method - " . $_SERVER['REQUEST_METHOD'] . "\n";
241
+        $report .= "\tCame From - " . $_SERVER['HTTP_REFERER'] . "\n";
242
+        $report .= "\tPage is - " . $_SERVER['SCRIPT_NAME'] . "\n";
243
+        $report .= "\tUses Port - " . $_SERVER['REMOTE_PORT'] . "\n";
244
+        $report .= "\tServer Protocol - " . $_SERVER['SERVER_PROTOCOL'] . "\n";
245 245
 
246 246
         $report .= "\n--------------------------------------------------------------------------------------------------\n";
247 247
 
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
     $prefix_length = strlen($this->db_prefix);
262 262
 
263 263
     $tl = array();
264
-    while($row = $this->db_fetch($query)) {
265
-      foreach($row as $table_name) {
266
-        if(strpos($table_name, $this->db_prefix) === 0) {
264
+    while ($row = $this->db_fetch($query)) {
265
+      foreach ($row as $table_name) {
266
+        if (strpos($table_name, $this->db_prefix) === 0) {
267 267
           $table_name = substr($table_name, $prefix_length);
268
-        } elseif($prefixed_only) {
268
+        } elseif ($prefixed_only) {
269 269
           continue;
270 270
         }
271 271
         // $table_name = str_replace($db_prefix, '', $table_name);
Please login to merge, or discard this patch.
includes/classes/core_auth.php 1 patch
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -199,18 +199,18 @@  discard block
 block discarded – undo
199 199
     // TODO Хотя тут может получится вечный цикл - ПОДУМАТЬ
200 200
     // TODO Тут же можно пробовать провести попытку слияния аккаунтов - хотя это и очень небезопасно
201 201
 
202
-    if(sys_get_param('login_player_register_logout')) {
202
+    if (sys_get_param('login_player_register_logout')) {
203 203
       $this->logout();
204 204
     }
205 205
 
206 206
     $original_suggest = '';
207 207
     // Смотрим - есть ли у нас данные от пользователя
208
-    if(($player_name_submitted = sys_get_param('submit_player_name'))) {
208
+    if (($player_name_submitted = sys_get_param('submit_player_name'))) {
209 209
       // Попытка регистрации нового игрока из данных, введенных пользователем
210 210
       $this->player_suggested_name = sys_get_param_str_unsafe('player_suggested_name');
211 211
     } else {
212
-      foreach($this->providers_authorised as $provider) {
213
-        if($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5
212
+      foreach ($this->providers_authorised as $provider) {
213
+        if ($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5
214 214
           $original_suggest = $provider->player_name_suggest();
215 215
           break;
216 216
         }
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
     }
219 219
 
220 220
     // Если у нас провайдеры не дают имени и пользователь не дал свой вариант - это у нас первый логин в игру
221
-    if(!$this->player_suggested_name) {
221
+    if (!$this->player_suggested_name) {
222 222
       $max_user_id = db_player_get_max_id(); // 4.5
223 223
       // TODO - предлагать имя игрока по локали
224 224
 
@@ -227,15 +227,15 @@  discard block
 block discarded – undo
227 227
         sn_db_transaction_rollback();
228 228
         $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000);
229 229
         sn_db_transaction_start();
230
-      } while(db_player_name_exists($this->player_suggested_name));
230
+      } while (db_player_name_exists($this->player_suggested_name));
231 231
 
232 232
     }
233 233
 
234
-    if($player_name_submitted) {
234
+    if ($player_name_submitted) {
235 235
       $this->register_player_db_create($this->player_suggested_name); // OK 4.5
236
-      if($this->register_status == LOGIN_SUCCESS) {
236
+      if ($this->register_status == LOGIN_SUCCESS) {
237 237
         sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
238
-      } elseif($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
238
+      } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
239 239
         // self::$player_suggested_name .= ' ' . $this->account->account_id;
240 240
       }
241 241
 //      if(self::$login_status != LOGIN_SUCCESS) {
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
         : false
260 260
       );
261 261
 
262
-    if($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
262
+    if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
263 263
       $prohibited_characters = array_map(function($value) {
264 264
         return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
265 265
       }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
@@ -289,27 +289,27 @@  discard block
 block discarded – undo
289 289
    * @param null $result
290 290
    */
291 291
   public function login() {
292
-    if(empty(sn_module::$sn_module_list['auth'])) {
292
+    if (empty(sn_module::$sn_module_list['auth'])) {
293 293
       die('{Не обнаружено ни одного провайдера авторизации в core_auth::login()!}');
294 294
     }
295 295
 
296 296
     !empty($_POST) ? self::flog(dump($_POST, '$_POST')) : false;
297 297
     !empty($_GET) ? self::flog(dump($_GET, '$_GET')) : false;
298
-    !empty($_COOKIE) ? self::flog(dump($_COOKIE,'$_COOKIE')) : false;
298
+    !empty($_COOKIE) ? self::flog(dump($_COOKIE, '$_COOKIE')) : false;
299 299
 
300 300
     $this->auth_reset(); // OK v4.5
301 301
 
302 302
     $this->providers = array();
303
-    foreach(sn_module::$sn_module_list['auth'] as $module_name => $module) {
303
+    foreach (sn_module::$sn_module_list['auth'] as $module_name => $module) {
304 304
       $this->providers[$module->provider_id] = $module;
305 305
     }
306 306
 
307 307
     // $this->providers = array_reverse($this->providers, true); // НИНАДА! СН-аккаунт должен всегда авторизироваться первым!
308 308
 
309
-    foreach($this->providers as $provider_id => $provider) {
309
+    foreach ($this->providers as $provider_id => $provider) {
310 310
       $login_status = $provider->login(); // OK v4.5
311 311
       self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? classLocale::$lang['sys_login_messages'][$provider->account_login_status] : dump($provider)));
312
-      if($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
312
+      if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
313 313
         $this->providers_authorised[$provider_id] = &$this->providers[$provider_id];
314 314
 
315 315
         $this->user_id_to_provider = array_replace_recursive(
@@ -317,15 +317,15 @@  discard block
 block discarded – undo
317 317
           // static::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5
318 318
           PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5
319 319
         );
320
-      } elseif($login_status != LOGIN_UNDEFINED) {
320
+      } elseif ($login_status != LOGIN_UNDEFINED) {
321 321
         $this->provider_error_list[$provider_id] = $login_status;
322 322
       }
323 323
     }
324 324
 
325
-    if(empty($this->providers_authorised)) {
325
+    if (empty($this->providers_authorised)) {
326 326
       // Ни один аккаунт не авторизирован
327 327
       // Проверяем - есть ли у нас ошибки в аккаунтах?
328
-      if(!empty($this->provider_error_list)) {
328
+      if (!empty($this->provider_error_list)) {
329 329
         // Если есть - выводим их
330 330
         self::$login_status = reset($this->provider_error_list);
331 331
       }
@@ -340,12 +340,12 @@  discard block
 block discarded – undo
340 340
       // В self::$accessible_user_row_list - список доступных игроков для данных аккаунтов с соответствующими записями из таблицы `users`
341 341
 
342 342
       // Остались ли у нас в списке доступные игроки?
343
-      if(empty($this->accessible_user_row_list)) {
343
+      if (empty($this->accessible_user_row_list)) {
344 344
         // Нет ни одного игрока ни на одном авторизированном аккаунте
345 345
         // Надо регать нового игрока
346 346
 
347 347
         // Сейчас происходит процесс регистрации игрока?
348
-        if(!$this->is_player_register) {
348
+        if (!$this->is_player_register) {
349 349
           // Нет - отправляем на процесс регистрации
350 350
           $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id'));
351 351
           sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : ''));
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
         // Да, есть доступные игроки, которые так же прописаны в базе
355 355
         $this->get_active_user(); // 4.5
356 356
 
357
-        if($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) {
357
+        if ($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) {
358 358
           $a_user = db_user_by_id($this->is_impersonating);
359 359
           $this->impersonator_username = $a_user['username'];
360 360
         }
@@ -362,9 +362,9 @@  discard block
 block discarded – undo
362 362
 
363 363
         //Прописываем текущего игрока на все авторизированные аккаунты
364 364
         // TODO - ИЛИ ВСЕХ ИГРОКОВ??
365
-        if(empty($this->is_impersonating)) {
366
-          foreach($this->providers_authorised as $provider_id => $provider) {
367
-            if(empty($this->user_id_to_provider[self::$user['id']][$provider_id])) {
365
+        if (empty($this->is_impersonating)) {
366
+          foreach ($this->providers_authorised as $provider_id => $provider) {
367
+            if (empty($this->user_id_to_provider[self::$user['id']][$provider_id])) {
368 368
               // self::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']);
369 369
               PlayerToAccountTranslate::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']);
370 370
               $this->user_id_to_provider[self::$user['id']][$provider_id][$provider->account->account_id] = true;
@@ -374,9 +374,9 @@  discard block
 block discarded – undo
374 374
       }
375 375
     }
376 376
 
377
-    if(empty(self::$user['id'])) {
377
+    if (empty(self::$user['id'])) {
378 378
       self::cookie_set(''); // OK 4.5
379
-    } elseif(self::$user['id'] != $_COOKIE[SN_COOKIE_U]) {
379
+    } elseif (self::$user['id'] != $_COOKIE[SN_COOKIE_U]) {
380 380
       self::cookie_set(self::$user['id']); // OK 4.5
381 381
     }
382 382
 
@@ -395,21 +395,21 @@  discard block
 block discarded – undo
395 395
    */
396 396
   // OK v4.7
397 397
   public function logout($redirect = true) {
398
-    if(!empty($_COOKIE[SN_COOKIE_U_I])) {
398
+    if (!empty($_COOKIE[SN_COOKIE_U_I])) {
399 399
       self::cookie_set($_COOKIE[SN_COOKIE_U_I]);
400 400
       self::cookie_set(0, true);
401 401
       self::$main_provider->logout();
402 402
     } else {
403
-      foreach($this->providers as $provider_name => $provider) {
403
+      foreach ($this->providers as $provider_name => $provider) {
404 404
         $provider->logout();
405 405
       }
406 406
 
407 407
       self::cookie_set(0);
408 408
     }
409 409
 
410
-    if($redirect === true) {
410
+    if ($redirect === true) {
411 411
       sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php'));
412
-    } elseif($redirect !== false) {
412
+    } elseif ($redirect !== false) {
413 413
       sys_redirect($redirect);
414 414
     }
415 415
   }
@@ -420,15 +420,15 @@  discard block
 block discarded – undo
420 420
    * @param $user_selected
421 421
    */
422 422
   public function impersonate($user_selected) {
423
-    if($_COOKIE[SN_COOKIE_U_I]) {
423
+    if ($_COOKIE[SN_COOKIE_U_I]) {
424 424
       die('You already impersonating someone. Go back to living other\'s life! Or clear your cookies and try again'); // TODO: Log it
425 425
     }
426 426
 
427
-    if($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) {
427
+    if ($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) {
428 428
       die('You can\'t impersonate - too low level'); // TODO: Log it
429 429
     }
430 430
 
431
-    if($this->auth_level_max_local <= $user_selected['authlevel']) {
431
+    if ($this->auth_level_max_local <= $user_selected['authlevel']) {
432 432
       die('You can\'t impersonate this account - level is greater or equal to yours'); // TODO: Log it
433 433
     }
434 434
 
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
     $account_translate = reset($account_translate[$user_selected['id']][self::$main_provider->provider_id]);
437 437
     $account_to_impersonate = new Account(self::$main_provider->db);
438 438
     $account_to_impersonate->db_get_by_id($account_translate['provider_account_id']);
439
-    if(!$account_to_impersonate->is_exists) {
439
+    if (!$account_to_impersonate->is_exists) {
440 440
       die('Какая-то ошибка - не могу найти аккаунт для имперсонации'); // TODO: Log it
441 441
     }
442 442
     self::$main_provider->impersonate($account_to_impersonate);
@@ -462,12 +462,12 @@  discard block
 block discarded – undo
462 462
   public function password_check($password_unsafe) {
463 463
     $result = false;
464 464
 
465
-    if(empty($this->providers_authorised)) {
465
+    if (empty($this->providers_authorised)) {
466 466
       // TODO - такого быть не может!
467 467
       self::flog("password_check: Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true);
468 468
     } else {
469
-      foreach($this->providers_authorised as $provider_id => $provider) {
470
-        if($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) {
469
+      foreach ($this->providers_authorised as $provider_id => $provider) {
470
+        if ($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) {
471 471
           $result = $result || $provider->password_check($password_unsafe);
472 472
         }
473 473
       }
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
    */
487 487
   // OK v4.6
488 488
   public function password_change($old_password_unsafe, $new_password_unsafe) {
489
-    if(empty($this->providers_authorised)) {
489
+    if (empty($this->providers_authorised)) {
490 490
       // TODO - такого быть не может!
491 491
       self::flog("Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true);
492 492
       return false;
@@ -499,8 +499,8 @@  discard block
 block discarded – undo
499 499
     $salt_unsafe = self::password_salt_generate();
500 500
 
501 501
     $providers_changed_password = array();
502
-    foreach($this->providers_authorised as $provider_id => $provider) {
503
-      if(
502
+    foreach ($this->providers_authorised as $provider_id => $provider) {
503
+      if (
504 504
         !$provider->is_feature_supported(AUTH_FEATURE_PASSWORD_CHANGE)
505 505
         || !$provider->password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe)
506 506
       ) {
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
       $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id);
513 513
 
514 514
       // Рассылаем уведомления о смене пароля в ЛС
515
-      foreach($account_translation as $user_id => $provider_info) {
515
+      foreach ($account_translation as $user_id => $provider_info) {
516 516
         // TODO - УКазывать тип аккаунта, на котором сменён пароль
517 517
         msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN,
518 518
           classLocale::$lang['sys_administration'], classLocale::$lang['sys_login_register_message_title'],
@@ -559,7 +559,7 @@  discard block
 block discarded – undo
559 559
       sn_db_transaction_start();
560 560
       // Проверить наличие такого имени в истории имён
561 561
 
562
-      if(db_player_name_exists($player_name_unsafe)) {
562
+      if (db_player_name_exists($player_name_unsafe)) {
563 563
         throw new Exception(REGISTER_ERROR_PLAYER_NAME_EXISTS, ERR_ERROR);
564 564
       }
565 565
 
@@ -567,11 +567,11 @@  discard block
 block discarded – undo
567 567
       $player_language = '';
568 568
       $player_email = '';
569 569
       // TODO - порнография - работа должна происходить над списком аккаунтов, а не только на одном аккаунте...
570
-      foreach($this->providers_authorised as $provider) {
571
-        if(!$player_language && $provider->account->account_language) {
570
+      foreach ($this->providers_authorised as $provider) {
571
+        if (!$player_language && $provider->account->account_language) {
572 572
           $player_language = $provider->account->account_language;
573 573
         }
574
-        if(!$player_email && $provider->account->account_email) {
574
+        if (!$player_email && $provider->account->account_email) {
575 575
           $player_email = $provider->account->account_email;
576 576
         }
577 577
       }
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
       ));
588 588
       // Зарегестрировать на него аккаунты из self::$accounts_authorised
589 589
       $a_user = self::$user;
590
-      foreach($this->providers_authorised as $provider) {
590
+      foreach ($this->providers_authorised as $provider) {
591 591
         // TODO - порнография. Должен быть отдельный класс трансляторов - в т.ч. и кэширующий транслятор
592 592
         // TODO - ну и работа должна происходить над списком аккаунтов, а не только на одном аккаунте...
593 593
         // self::db_translate_register_user($provider->provider_id, $provider->account->account_id, $a_user['id']);
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 
600 600
       sn_db_transaction_commit();
601 601
       $this->register_status = LOGIN_SUCCESS;
602
-    } catch(Exception $e) {
602
+    } catch (Exception $e) {
603 603
       sn_db_transaction_rollback();
604 604
 
605 605
       // Если старое имя занято
@@ -618,10 +618,10 @@  discard block
 block discarded – undo
618 618
     // Пробиваем все ИД игроков по базе - есть ли вообще такие записи
619 619
     // Вообще-то это не особо нужно - у нас по определению стоят констраинты
620 620
     // Зато так мы узнаем максимальный authlevel, проверим права имперсонейта и вытащим все записи юзеров
621
-    foreach($this->user_id_to_provider as $user_id => $cork) {
621
+    foreach ($this->user_id_to_provider as $user_id => $cork) {
622 622
       $user = db_user_by_id($user_id);
623 623
       // Если записи игрока в БД не существует?
624
-      if(empty($user['id'])) {
624
+      if (empty($user['id'])) {
625 625
         // Удаляем этого и переходим к следующему
626 626
         unset($this->user_id_to_provider[$user_id]);
627 627
         // Де-регистрируем игрока из таблицы трансляции игроков
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
   // OK v4.5
643 643
   protected function get_active_user() {
644 644
     // Проверяем куку "текущего игрока" из браузера
645
-    if(
645
+    if (
646 646
       // Кука не пустая
647 647
       ($_COOKIE[SN_COOKIE_U] = trim($_COOKIE[SN_COOKIE_U])) && !empty($_COOKIE[SN_COOKIE_U])
648 648
       // И в куке находится ID
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
     }
668 668
 
669 669
     // В куке нет валидного ИД записи игрока, доступной с текущих аккаунтов
670
-    if(empty(self::$user['id'])) {
670
+    if (empty(self::$user['id'])) {
671 671
       // Берем первого из доступных
672 672
       // TODO - default_user
673 673
       self::$user = reset($this->accessible_user_row_list);
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 
690 690
     $result = array();
691 691
 
692
-    if($user_id && empty($this->is_impersonating)) {
692
+    if ($user_id && empty($this->is_impersonating)) {
693 693
       // self::db_counter_insert();
694 694
       self::$device->db_counter_insert($user_id);
695 695
 
@@ -697,12 +697,12 @@  discard block
 block discarded – undo
697 697
 
698 698
       sys_user_options_unpack($user);
699 699
 
700
-      if($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) {
700
+      if ($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) {
701 701
         $user['banaday'] = 0;
702 702
         $user['vacation'] = SN_TIME_NOW;
703 703
       }
704 704
 
705
-      $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip'];
705
+      $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip'];
706 706
       $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain'];
707 707
 
708 708
       $result[F_BANNED_STATUS] = $user['banaday'];
@@ -716,9 +716,9 @@  discard block
 block discarded – undo
716 716
       );
717 717
     }
718 718
 
719
-    if($extra = classSupernova::$config->security_ban_extra) {
719
+    if ($extra = classSupernova::$config->security_ban_extra) {
720 720
       $extra = explode(',', $extra);
721
-      array_walk($extra,'trim');
721
+      array_walk($extra, 'trim');
722 722
       in_array(self::$device->device_id, $extra) and die();
723 723
     }
724 724
 
@@ -754,21 +754,21 @@  discard block
 block discarded – undo
754 754
   protected function register_player_name_validate($player_name_unsafe) {
755 755
     // TODO - переделать под RAW-строки
756 756
     // Если имя игрока пустое - NO GO!
757
-    if(trim($player_name_unsafe) == '') {
757
+    if (trim($player_name_unsafe) == '') {
758 758
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_EMPTY, ERR_ERROR);
759 759
     }
760 760
     // Проверяем, что бы в начале и конце не было пустых символов
761
-    if($player_name_unsafe != trim($player_name_unsafe)) {
761
+    if ($player_name_unsafe != trim($player_name_unsafe)) {
762 762
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_TRIMMED, ERR_ERROR);
763 763
     }
764 764
     // Если логин имеет запрещенные символы - NO GO!
765
-    if(strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
765
+    if (strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
766 766
       // TODO - выдавать в сообщение об ошибке список запрещенных символов
767 767
       // TODO - заранее извещать игрока, какие символы являются запрещенными
768 768
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_RESTRICTED_CHARACTERS, ERR_ERROR);
769 769
     }
770 770
     // Если логин меньше минимальной длины - NO GO!
771
-    if(strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) {
771
+    if (strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) {
772 772
       // TODO - выдавать в сообщение об ошибке минимальную длину имени игрока
773 773
       // TODO - заранее извещать игрока, какая минимальная и максимальная длина имени
774 774
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_SHORT, ERR_ERROR);
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
   }
827 827
 
828 828
   protected static function flog($message, $die = false) {
829
-    if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
829
+    if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
830 830
       return;
831 831
     }
832 832
     list($called, $caller) = debug_backtrace(false);
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
     $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false;
840 840
 
841 841
     classSupernova::log_file("$message - $caller_name");
842
-    if($die) {
842
+    if ($die) {
843 843
       // pdump($caller);
844 844
       // pdump(debug_backtrace(false));
845 845
       $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
Please login to merge, or discard this patch.
includes/classes/UBE/UBEDebris.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
    */
31 31
   public function debris_add_resource($resource_id, $resource_amount) {
32 32
     // В обломках может быть только металл или кристалл
33
-    if($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) {
33
+    if ($resource_id != RES_METAL && $resource_id != RES_CRYSTAL) {
34 34
       return;
35 35
     }
36 36
     $this->debris[$resource_id] += $resource_amount;
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
    * @param bool  $is_simulator
42 42
    */
43 43
   public function add_wrecks(array $wreckage, $is_simulator) {
44
-    foreach($wreckage as $resource_id => $resource_amount) {
44
+    foreach ($wreckage as $resource_id => $resource_amount) {
45 45
       $this->debris_add_resource($resource_id, floor($resource_amount *
46 46
         ($is_simulator
47 47
           ? UBE_SHIP_WRECKS_TO_DEBRIS_AVG
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
    * @param bool  $is_simulator
58 58
    */
59 59
   public function add_cargo_drop(array $dropped_resources, $is_simulator) {
60
-    foreach($dropped_resources as $resource_id => $resource_amount) {
60
+    foreach ($dropped_resources as $resource_id => $resource_amount) {
61 61
       $this->debris_add_resource($resource_id, floor($resource_amount *
62 62
         ($is_simulator
63 63
           ? UBE_CARGO_DROPPED_TO_DEBRIS_AVG
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
    * @param $moon_debris_left_part
97 97
    */
98 98
   public function debris_adjust_proportional($moon_debris_left_part) {
99
-    foreach($this->debris as $resource_id => &$resource_amount) {
99
+    foreach ($this->debris as $resource_id => &$resource_amount) {
100 100
       $resource_amount = floor($resource_amount * $moon_debris_left_part);
101 101
     }
102 102
   }
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
    */
118 118
   public function report_generate_sql() {
119 119
     return "
120
-      `ube_report_debris_metal` = " . (float)$this->debris_get_resource(RES_METAL) . ",
121
-      `ube_report_debris_crystal` = " . (float)$this->debris_get_resource(RES_CRYSTAL) . ",
122
-      `ube_report_debris_total_in_metal` = " . (float)$this->debris_in_metal() . ", ";
120
+      `ube_report_debris_metal` = " . (float) $this->debris_get_resource(RES_METAL) . ",
121
+      `ube_report_debris_crystal` = " . (float) $this->debris_get_resource(RES_CRYSTAL) . ",
122
+      `ube_report_debris_total_in_metal` = " . (float) $this->debris_in_metal() . ", ";
123 123
   }
124 124
 
125 125
   /**
Please login to merge, or discard this patch.