Completed
Push — work-fleets ( 006942...3604bd )
by SuperNova.WS
06:54
created
classes/debug.php 1 patch
Spacing   +75 added lines, -76 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
 
33 33
 defined('INSIDE') || die();
34 34
 
35
-if(php_sapi_name() == "cli") {
35
+if (php_sapi_name() == "cli") {
36 36
   // In cli-mode
37 37
   define('__DEBUG_CRLF', "\r\n");
38
-  define('__DEBUG_LINE', '-------------------------------------------------' . __DEBUG_CRLF);
38
+  define('__DEBUG_LINE', '-------------------------------------------------'.__DEBUG_CRLF);
39 39
 } else {
40 40
   // Not in cli-mode
41 41
   define('__DEBUG_CRLF', '<br />');
@@ -52,17 +52,17 @@  discard block
 block discarded – undo
52 52
   public function log_file($message, $ident_change = 0) {
53 53
     static $ident = 0;
54 54
 
55
-    if(!defined('SN_DEBUG_LOG')) {
55
+    if (!defined('SN_DEBUG_LOG')) {
56 56
       return;
57 57
     }
58 58
 
59
-    if($this->log_file_handler === null) {
60
-      $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL . '/.logs/supernova.log', 'a+');
59
+    if ($this->log_file_handler === null) {
60
+      $this->log_file_handler = @fopen(SN_ROOT_PHYSICAL.'/.logs/supernova.log', 'a+');
61 61
       @fwrite($this->log_file_handler, "\r\n\r\n");
62 62
     }
63 63
     $ident_change < 0 ? $ident += $ident_change * 2 : false;
64
-    if($this->log_file_handler) {
65
-      @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()) . str_repeat(' ', $ident + 1) . $message . "\r\n");
64
+    if ($this->log_file_handler) {
65
+      @fwrite($this->log_file_handler, date(FMT_DATE_TIME_SQL, time()).str_repeat(' ', $ident + 1).$message."\r\n");
66 66
     }
67 67
     $ident_change > 0 ? $ident += $ident_change * 2 : false;
68 68
   }
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
   }
83 83
 
84 84
   public function echo_log() {
85
-    echo '<br><table><tr><td class=k colspan=4><a href="' . SN_ROOT_PHYSICAL . "admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>";
85
+    echo '<br><table><tr><td class=k colspan=4><a href="'.SN_ROOT_PHYSICAL."admin/settings.php\">Debug Log</a>:</td></tr>{$this->log}</table>";
86 86
     die();
87 87
   }
88 88
 
@@ -92,25 +92,25 @@  discard block
 block discarded – undo
92 92
     $result = array();
93 93
     $transaction_id = classSupernova::$db->getTransaction()->getNextQueryTransactionId();
94 94
     $result[] = "tID {$transaction_id}";
95
-    foreach($backtrace as $a_trace) {
96
-      if(in_array($a_trace['function'], $exclude_functions)) {
95
+    foreach ($backtrace as $a_trace) {
96
+      if (in_array($a_trace['function'], $exclude_functions)) {
97 97
         continue;
98 98
       }
99 99
       $function =
100 100
         ($a_trace['type']
101 101
           ? ($a_trace['type'] == '->'
102
-            ? "({$a_trace['class']})" . get_class($a_trace['object'])
102
+            ? "({$a_trace['class']})".get_class($a_trace['object'])
103 103
             : $a_trace['class']
104
-          ) . $a_trace['type']
104
+          ).$a_trace['type']
105 105
           : ''
106
-        ) . $a_trace['function'] . '()';
106
+        ).$a_trace['function'].'()';
107 107
 
108 108
       $file = str_replace(SN_ROOT_PHYSICAL, '', str_replace('\\', '/', $a_trace['file']));
109 109
 
110 110
       // $result[] = "{$function} ({$a_trace['line']})'{$file}'";
111 111
       $result[] = "{$function} - '{$file}' Line {$a_trace['line']}";
112 112
 
113
-      if(!$long_comment) {
113
+      if (!$long_comment) {
114 114
         break;
115 115
       }
116 116
     }
@@ -124,26 +124,26 @@  discard block
 block discarded – undo
124 124
   public function dump($dump = false, $force_base = false, $deadlock = false) {
125 125
     global $user, $planetrow;
126 126
 
127
-    if($dump === false) {
127
+    if ($dump === false) {
128 128
       return;
129 129
     }
130 130
 
131 131
     $error_backtrace = array();
132 132
     $base_dump = false;
133 133
 
134
-    if($force_base === true) {
134
+    if ($force_base === true) {
135 135
       $base_dump = true;
136 136
     }
137 137
 
138
-    if($dump === true) {
138
+    if ($dump === true) {
139 139
       $base_dump = true;
140 140
     } else {
141
-      if(!is_array($dump)) {
141
+      if (!is_array($dump)) {
142 142
         $dump = array('var' => $dump);
143 143
       }
144 144
 
145
-      foreach($dump as $dump_var_name => $dump_var) {
146
-        if($dump_var_name == 'base_dump') {
145
+      foreach ($dump as $dump_var_name => $dump_var) {
146
+        if ($dump_var_name == 'base_dump') {
147 147
           $base_dump = $dump_var;
148 148
         } else {
149 149
           $error_backtrace[$dump_var_name] = $dump_var;
@@ -151,22 +151,21 @@  discard block
 block discarded – undo
151 151
       }
152 152
     }
153 153
 
154
-    if($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
154
+    if ($deadlock && ($q = db_fetch(classSupernova::$db->mysql_get_innodb_status()))) {
155 155
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
156 156
       $error_backtrace['locks'] = classSupernova::$gc->snCache->getLocks();
157 157
       $error_backtrace['cSN_data'] = classSupernova::$gc->snCache->getData();
158
-      foreach($error_backtrace['cSN_data'] as &$location) {
159
-        foreach($location as $location_id => &$location_data) {
160
-          $location_data = isset($location_data['username']) ? $location_data['username'] :
161
-            (isset($location_data['name']) ? $location_data['name'] : $location_id);
158
+      foreach ($error_backtrace['cSN_data'] as &$location) {
159
+        foreach ($location as $location_id => &$location_data) {
160
+          $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id);
162 161
         }
163 162
       }
164 163
       $error_backtrace['cSN_queries'] = classSupernova::$gc->snCache->getQueries();
165 164
     }
166 165
 
167
-    if($base_dump) {
168
-      if(is_array($this->log_array) && count($this->log_array) > 0) {
169
-        foreach($this->log_array as $log) {
166
+    if ($base_dump) {
167
+      if (is_array($this->log_array) && count($this->log_array) > 0) {
168
+        foreach ($this->log_array as $log) {
170 169
           $error_backtrace['queries'][] = $log;
171 170
         }
172 171
       }
@@ -195,14 +194,14 @@  discard block
 block discarded – undo
195 194
   public function error($message = 'There is a error on page', $title = 'Internal Error', $error_code = 500, $dump = true) {
196 195
     global $sys_stop_log_hit, $sys_log_disabled, $user;
197 196
 
198
-    if(empty(classSupernova::$db->connected)) {
197
+    if (empty(classSupernova::$db->connected)) {
199 198
       // TODO - писать ошибку в файл
200 199
       die('SQL server currently unavailable. Please contact Administration...');
201 200
     }
202 201
 
203 202
     sn_db_transaction_rollback();
204 203
 
205
-    if(classSupernova::$config->debug == 1) {
204
+    if (classSupernova::$config->debug == 1) {
206 205
       echo "<h2>{$title}</h2><br><font color=red>{$message}</font><br><hr>";
207 206
       echo "<table>{$this->log}</table>";
208 207
     }
@@ -214,16 +213,16 @@  discard block
 block discarded – undo
214 213
 
215 214
     $userId = empty($user['id']) ? 0 : $user['id'];
216 215
 
217
-    if(!$sys_log_disabled) {
216
+    if (!$sys_log_disabled) {
218 217
       $query = "INSERT INTO `{{logs}}` SET
219
-        `log_time` = '" . time() . "', `log_code` = '" . db_escape($error_code) . "', `log_sender` = '" . db_escape($userId) . "',
220
-        `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
221
-        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" .
218
+        `log_time` = '" . time()."', `log_code` = '".db_escape($error_code)."', `log_sender` = '".db_escape($userId)."',
219
+        `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."',  `log_text` = '".db_escape($message)."',
220
+        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'".
222 221
 //        ($error_backtrace ? ", `log_dump` = '" . db_escape(serialize($error_backtrace)) . "'" : '') . ";";
223
-      ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";";
224
-      classSupernova::$db->doSql($query, true) or die($fatal_error . classSupernova::$db->db_error());
222
+      ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";";
223
+      classSupernova::$db->doSql($query, true) or die($fatal_error.classSupernova::$db->db_error());
225 224
 
226
-      $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>" . classSupernova::$db->db_insert_id() . "</b>";
225
+      $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>".classSupernova::$db->db_insert_id()."</b>";
227 226
 
228 227
       $sys_stop_log_hit = true;
229 228
       $sys_log_disabled = true;
@@ -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,7 +244,7 @@  discard block
 block discarded – undo
245 244
   public 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
     }
@@ -254,12 +253,12 @@  discard block
 block discarded – undo
254 253
 
255 254
     $userId = empty($user['id']) ? 0 : $user['id'];
256 255
 
257
-    if(!$sys_log_disabled) {
256
+    if (!$sys_log_disabled) {
258 257
       $query = "INSERT INTO `{{logs}}` SET
259
-        `log_time` = '" . time() . "', `log_code` = '" . db_escape($log_code) . "', `log_sender` = '" . db_escape($userId) . "',
260
-        `log_username` = '" . db_escape($user['user_name']) . "', `log_title` = '" . db_escape($title) . "',  `log_text` = '" . db_escape($message) . "',
261
-        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE))) . "'" .
262
-        ", `log_dump` = '" . ($error_backtrace ? db_escape(serialize($error_backtrace)) : '') . "'" . ";";
258
+        `log_time` = '" . time()."', `log_code` = '".db_escape($log_code)."', `log_sender` = '".db_escape($userId)."',
259
+        `log_username` = '" . db_escape($user['user_name'])."', `log_title` = '".db_escape($title)."',  `log_text` = '".db_escape($message)."',
260
+        `log_page` = '" . db_escape(strpos($_SERVER['SCRIPT_NAME'], SN_ROOT_RELATIVE) === false ? $_SERVER['SCRIPT_NAME'] : substr($_SERVER['SCRIPT_NAME'], strlen(SN_ROOT_RELATIVE)))."'".
261
+        ", `log_dump` = '".($error_backtrace ? db_escape(serialize($error_backtrace)) : '')."'".";";
263 262
       classSupernova::$db->doSql($query, true);
264 263
     } else {
265 264
 //        // TODO Здесь надо писать в файло
@@ -272,11 +271,11 @@  discard block
 block discarded – undo
272 271
 // Dump variables nicer then var_dump()
273 272
 
274 273
 function dump($value, $varname = null, $level = 0, $dumper = '') {
275
-  if(isset($varname)) {
274
+  if (isset($varname)) {
276 275
     $varname .= " = ";
277 276
   }
278 277
 
279
-  if($level == -1) {
278
+  if ($level == -1) {
280 279
     $trans[' '] = '&there4;';
281 280
     $trans["\t"] = '&rArr;';
282 281
     $trans["\n"] = '&para;;';
@@ -285,31 +284,31 @@  discard block
 block discarded – undo
285 284
 
286 285
     return strtr(htmlspecialchars($value), $trans);
287 286
   }
288
-  if($level == 0) {
287
+  if ($level == 0) {
289 288
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
290
-    $dumper = mt_rand(10, 99) . '|' . $varname;
289
+    $dumper = mt_rand(10, 99).'|'.$varname;
291 290
   }
292 291
 
293 292
   $type = gettype($value);
294 293
   $dumper .= $type;
295 294
 
296
-  if($type == TYPE_STRING) {
297
-    $dumper .= '(' . strlen($value) . ')';
295
+  if ($type == TYPE_STRING) {
296
+    $dumper .= '('.strlen($value).')';
298 297
     $value = dump($value, '', -1);
299
-  } elseif($type == TYPE_BOOLEAN) {
298
+  } elseif ($type == TYPE_BOOLEAN) {
300 299
     $value = ($value ? 'true' : 'false');
301
-  } elseif($type == 'object') {
300
+  } elseif ($type == 'object') {
302 301
     $props = get_class_vars(get_class($value));
303
-    $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
304
-    foreach($props as $key => $val) {
305
-      $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
302
+    $dumper .= '('.count($props).') <u>'.get_class($value).'</u>';
303
+    foreach ($props as $key => $val) {
304
+      $dumper .= "\n".str_repeat("\t", $level + 1).$key.' => ';
306 305
       $dumper .= dump($value->$key, '', $level + 1);
307 306
     }
308 307
     $value = '';
309
-  } elseif($type == TYPE_ARRAY) {
310
-    $dumper .= '(' . count($value) . ')';
311
-    foreach($value as $key => $val) {
312
-      $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
308
+  } elseif ($type == TYPE_ARRAY) {
309
+    $dumper .= '('.count($value).')';
310
+    foreach ($value as $key => $val) {
311
+      $dumper .= "\n".str_repeat("\t", $level + 1).dump($key, '', -1).' => ';
313 312
       $dumper .= dump($val, '', $level + 1);
314 313
     }
315 314
     $value = '';
@@ -328,24 +327,24 @@  discard block
 block discarded – undo
328 327
 //  $backtrace = $backtrace[1];
329 328
 
330 329
   $caller = '';
331
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
332
-    $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
333
-      (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
334
-      $backtrace[1]['function'] .
330
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
331
+    $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '').
332
+      (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '').
333
+      $backtrace[1]['function'].
335 334
       (!empty($backtrace[0]['file'])
336 335
         ? (
337
-          ' (' . substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN) .
338
-          (!empty($backtrace[0]['line']) ? ':' . $backtrace[0]['line'] : '') .
336
+          ' ('.substr($backtrace[0]['file'], SN_ROOT_PHYSICAL_STR_LEN).
337
+          (!empty($backtrace[0]['line']) ? ':'.$backtrace[0]['line'] : '').
339 338
           ')'
340 339
         )
341 340
         : ''
342 341
       );
343
-    $caller = "\r\n" . $caller;
342
+    $caller = "\r\n".$caller;
344 343
   }
345 344
 
346
-  print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">' .
347
-    dump($value, $varname) .
348
-    $caller .
345
+  print('<pre style="text-align: left; background-color: #111111; color: #0A0; font-family: Courier, monospace !important; padding: 1em 0; font-weight: 800; font-size: 14px;">'.
346
+    dump($value, $varname).
347
+    $caller.
349 348
     '</pre>'
350 349
   );
351 350
 }
@@ -355,24 +354,24 @@  discard block
 block discarded – undo
355 354
 }
356 355
 
357 356
 function pr($prePrint = false) {
358
-  if($prePrint) {
357
+  if ($prePrint) {
359 358
     print(__DEBUG_CRLF);
360 359
   }
361
-  print(mt_rand() . __DEBUG_CRLF);
360
+  print(mt_rand().__DEBUG_CRLF);
362 361
 }
363 362
 
364 363
 function pc($prePrint = false) {
365 364
   global $_PRINT_COUNT_VALUE;
366 365
   $_PRINT_COUNT_VALUE++;
367 366
 
368
-  if($prePrint) {
367
+  if ($prePrint) {
369 368
     print(__DEBUG_CRLF);
370 369
   }
371
-  print($_PRINT_COUNT_VALUE . __DEBUG_CRLF);
370
+  print($_PRINT_COUNT_VALUE.__DEBUG_CRLF);
372 371
 }
373 372
 
374 373
 function prep($message) {
375
-  print('<pre>' . $message . '</pre>');
374
+  print('<pre>'.$message.'</pre>');
376 375
 }
377 376
 
378 377
 function backtrace_no_arg() {
@@ -396,9 +395,9 @@  discard block
 block discarded – undo
396 395
  */
397 396
 function pdie($message = '', $level = 0) {
398 397
   $backtrace = debug_backtrace();
399
-  for($i = 0; $i < $level; $i++) {
398
+  for ($i = 0; $i < $level; $i++) {
400 399
     array_pop($backtrace);
401 400
   }
402 401
 
403
-  die(__DEBUG_LINE . ($message ? $message . ' @ ' : '') . $backtrace[0]['file'] . ':' . $backtrace[0]['line']);
402
+  die(__DEBUG_LINE.($message ? $message.' @ ' : '').$backtrace[0]['file'].':'.$backtrace[0]['line']);
404 403
 }
Please login to merge, or discard this patch.
classes/DbSqlAware.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,8 +45,8 @@
 block discarded – undo
45 45
    */
46 46
   protected function quoteStringAsFieldByRef(&$string) {
47 47
     $string = $this->stringEscape($string);
48
-    if ((string)$string && '*' != $string) {
49
-      $string = '`' . $string . '`';
48
+    if ((string) $string && '*' != $string) {
49
+      $string = '`'.$string.'`';
50 50
     }
51 51
   }
52 52
 
Please login to merge, or discard this patch.
classes/FleetValidator.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
     'checkSpeedPercentOld'       => FLIGHT_FLEET_SPEED_WRONG,
15 15
     'checkTargetInUniverse'      => FLIGHT_VECTOR_BEYOND_UNIVERSE,
16 16
     'checkTargetNotSource'       => FLIGHT_VECTOR_SAME_SOURCE,
17
-    'checkSenderNoVacation'      => FLIGHT_PLAYER_VACATION_OWN,  // tODO
17
+    'checkSenderNoVacation'      => FLIGHT_PLAYER_VACATION_OWN, // tODO
18 18
     'checkTargetNoVacation'      => FLIGHT_PLAYER_VACATION,
19 19
     'checkFleetNotEmpty'         => FLIGHT_SHIPS_NO_SHIPS,
20 20
     // 'checkUnitsPositive'         => FLIGHT_SHIPS_NEGATIVE, // Unused - 'cause it's not allowed to put negative units into Unit class
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
       $checkResult = call_user_func(array($this, $condition));
135 135
       defined('DEBUG_FLEET_MISSION_VALIDATE_DUMP_STEPS')
136
-        ? pdump($action, $condition . ' ' . ($checkResult ? 'TRUE' : 'FALSE')) : false;
136
+        ? pdump($action, $condition.' '.($checkResult ? 'TRUE' : 'FALSE')) : false;
137 137
 
138 138
       // If check failed and there no alternative actions - throw exception
139 139
       // Shortcut ACTION => FAIL_STATUS instead of ACTION => array(false => FAIL_STATUS)
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
         $this->checkMissionRestrictions($action);
157 157
       } else {
158 158
         // No - then just performing action
159
-        if($exception) {
159
+        if ($exception) {
160 160
           throw new ExceptionFleetInvalid($action, $action);
161 161
         } else {
162 162
           return $action;
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
   protected function checkMissionPrefix($name, $prefix) {
599 599
     $result = false;
600 600
     if (strpos($name, $prefix) === 0) {
601
-      $mission = 'MT_' . strtoupper(substr($name, strlen($prefix)));
601
+      $mission = 'MT_'.strtoupper(substr($name, strlen($prefix)));
602 602
       if (!defined($mission)) {
603 603
         // TODO - Ну, как-то получше это обделать
604
-        throw new Exception('Mission type "' . $mission . '" is not defined', FLIGHT_MISSION_UNKNOWN);
604
+        throw new Exception('Mission type "'.$mission.'" is not defined', FLIGHT_MISSION_UNKNOWN);
605 605
       }
606 606
 
607 607
       $result = constant($mission);
Please login to merge, or discard this patch.
classes/oldArrayAccessNd.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
     !is_array($offset) ? $offset = array($offset) : false;
39 39
 
40 40
     $current_leaf = $this->__get(reset($offset));
41
-    while(($leaf_index = next($offset)) !== false) {
42
-      if(!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) {
41
+    while (($leaf_index = next($offset)) !== false) {
42
+      if (!isset($current_leaf) || !is_array($current_leaf) || !isset($current_leaf[$leaf_index])) {
43 43
         unset($current_leaf);
44 44
         break;
45 45
       }
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
 
65 65
     !is_array($offset) ? $offset = array($offset) : false;
66 66
 
67
-    if($this->offsetExists($offset)) {
67
+    if ($this->offsetExists($offset)) {
68 68
       $result = $this->__get(reset($offset));
69
-      while(($leaf_index = next($offset)) !== false) {
69
+      while (($leaf_index = next($offset)) !== false) {
70 70
         $result = $result[$leaf_index];
71 71
       }
72 72
     }
@@ -91,12 +91,12 @@  discard block
 block discarded – undo
91 91
    */
92 92
   public function offsetSet($offset, $value = null) {
93 93
     // Если нет никакого индекса - значит нечего записывать
94
-    if(!isset($offset) || (is_array($offset) && empty($offset))) {
94
+    if (!isset($offset) || (is_array($offset) && empty($offset))) {
95 95
       return;
96 96
     }
97 97
 
98 98
     // Если в массиве индекса только один элемент - значит это просто индекс
99
-    if(is_array($offset) && count($offset) == 1) {
99
+    if (is_array($offset) && count($offset) == 1) {
100 100
       // Разворачиваем его в индекс
101 101
       $offset = array(reset($offset) => $value);
102 102
       unset($value);
@@ -104,20 +104,20 @@  discard block
 block discarded – undo
104 104
     }
105 105
 
106 106
     // Адресация многомерного массива через массив индексов в $option
107
-    if(is_array($offset) && isset($value)) {
107
+    if (is_array($offset) && isset($value)) {
108 108
       // TODO - а не переделать ли это всё на __isset() ??
109 109
 //pdump($offset, '$offset');
110 110
 //pdump($value, '$value');
111 111
       // Вытаскиваем корневой элемент
112 112
       $root = $this->__get(reset($offset));
113 113
       $current_leaf = &$root;
114
-      while(($leaf_index = next($offset)) !== false) {
114
+      while (($leaf_index = next($offset)) !== false) {
115 115
         !is_array($current_leaf[$leaf_index]) ? $current_leaf[$leaf_index] = array() : false;
116 116
         $current_leaf = &$current_leaf[$leaf_index];
117 117
       }
118 118
 //pdump($current_leaf, '$current_leaf');
119 119
 //pdump($value, '$value');
120
-      if($current_leaf != $value) {
120
+      if ($current_leaf != $value) {
121 121
         $current_leaf = $value;
122 122
 //pdump(reset($offset), 'reset($offset)');
123 123
 //pdump($root, '$root');
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
       // Пакетная запись из массива ключ -> значение
129 129
       !is_array($offset) ? $offset = array($offset => $value) : false;
130 130
 
131
-      foreach($offset as $key => $value) {
131
+      foreach ($offset as $key => $value) {
132 132
         $this->__get($key) !== $value ? $this->__set($key, $value) : false;
133 133
       }
134 134
     }
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
    */
150 150
   public function offsetUnset($offset) {
151 151
     // Если нет никакого индекса - значит нечего записывать
152
-    if(!isset($offset) || (is_array($offset) && empty($offset))) {
152
+    if (!isset($offset) || (is_array($offset) && empty($offset))) {
153 153
       return;
154 154
     }
155 155
 
156 156
     !is_array($offset) ? $offset = array($offset) : false;
157 157
 
158
-    if($this->offsetExists($offset)) {
158
+    if ($this->offsetExists($offset)) {
159 159
 //pdump($offset);
160 160
       // Перематываем массив в конец
161 161
       $key_to_delete = end($offset);
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 //pdump($key_to_delete, '$key_to_delete');
164 164
       $parent_offset = $offset;
165 165
       array_pop($parent_offset);
166
-      if(!count($parent_offset)) {
166
+      if (!count($parent_offset)) {
167 167
         // В массиве был один элемент - мы удаляем в корне. Просто удаляем элемент
168 168
         $this->__unset($key_to_delete);
169 169
       } else {
Please login to merge, or discard this patch.
classes/auth_abstract.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
    */
36 36
   // OK 4.9
37 37
   public function __construct($filename = __FILE__) {
38
-    if($this->provider_id == ACCOUNT_PROVIDER_NONE) {
38
+    if ($this->provider_id == ACCOUNT_PROVIDER_NONE) {
39 39
       die('У всех провайдеров должен быть $provider_id!');
40 40
     }
41 41
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
   // OK 4.6
134 134
   public function player_name_suggest() {
135 135
     $name = '';
136
-    if(is_object($this->account) && !empty($this->account->account_email)) {
136
+    if (is_object($this->account) && !empty($this->account->account_email)) {
137 137
       list($name) = explode('@', $this->account->account_email);
138 138
     }
139 139
 
Please login to merge, or discard this patch.
classes/Confirmation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@
 block discarded – undo
41 41
       // $query = static::$db->doquery("SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' AND `type` = {$confirmation_type_safe} FOR UPDATE", true);
42 42
       // Тип не нужен для проверки - код подтверждения должен быть уникален от слова "совсем"
43 43
       $query = $this->db->doquery("SELECT `id` FROM {{confirmations}} WHERE `code` = '{$confirm_code_safe}' FOR UPDATE", true);
44
-    } while($query);
44
+    } while ($query);
45 45
 
46 46
     $this->db->doquery(
47 47
       "REPLACE INTO {{confirmations}}
Please login to merge, or discard this patch.
classes/Player.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
    * @return int|mixed
229 229
    */
230 230
   public function calcColonyMaxCount($astrotech = -1) {
231
-    if($astrotech == -1) {
232
-      if(!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) {
231
+    if ($astrotech == -1) {
232
+      if (!isset($this->_dbRow[UNIT_PLAYER_COLONIES_MAX])) {
233 233
 
234 234
         $expeditions = get_player_max_expeditons($this->_dbRow);
235 235
         $astrotech = mrc_get_level($this->_dbRow, null, TECH_ASTROTECH);
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
 
303 303
 
304 304
   public function expeditionsMax() {
305
-    if($this->expeditionsMax === null) {
305
+    if ($this->expeditionsMax === null) {
306 306
       $this->expeditionsMax = get_player_max_expeditons($this->_dbRow);
307 307
     }
308 308
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
   }
311 311
 
312 312
   public function expeditionsFlying() {
313
-    if($this->expeditionsFlying === null) {
313
+    if ($this->expeditionsFlying === null) {
314 314
       $this->expeditionsFlying = FleetList::fleet_count_flying($this->_dbId, MT_EXPLORE);
315 315
     }
316 316
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 
320 320
 
321 321
   public function fleetsMax() {
322
-    if($this->fleetMax === null) {
322
+    if ($this->fleetMax === null) {
323 323
       $this->fleetMax = GetMaxFleets($this->_dbRow);
324 324
     }
325 325
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
   }
328 328
 
329 329
   public function fleetsFlying() {
330
-    if($this->fleetFlying === null) {
330
+    if ($this->fleetFlying === null) {
331 331
       $this->fleetFlying = FleetList::fleet_count_flying($this->_dbId);
332 332
     }
333 333
 
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
 
337 337
 
338 338
   public function coloniesMax() {
339
-    if($this->coloniesMax === null) {
339
+    if ($this->coloniesMax === null) {
340 340
       $this->coloniesMax = get_player_max_colonies($this->_dbRow);
341 341
     }
342 342
 
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
   }
345 345
 
346 346
   public function coloniesCurrent() {
347
-    if($this->coloniesCurrent === null) {
347
+    if ($this->coloniesCurrent === null) {
348 348
       $this->coloniesCurrent = get_player_current_colonies($this->_dbRow);
349 349
     }
350 350
 
Please login to merge, or discard this patch.
classes/PlayerToAccountTranslate.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
   protected static $is_init = false;
20 20
 
21 21
   protected static function init() {
22
-    if(!empty(static::$db)) {
22
+    if (!empty(static::$db)) {
23 23
       return;
24 24
     }
25 25
     static::$db = classSupernova::$db;
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
     $provider_id_safe = intval($provider_id_unsafe);
67 67
     !is_array($account_list) ? $account_list = array($account_list) : false;
68 68
 
69
-    foreach($account_list as $provider_account_id_unsafe) {
69
+    foreach ($account_list as $provider_account_id_unsafe) {
70 70
       $provider_account_id_safe = intval($provider_account_id_unsafe);
71 71
 
72 72
       // TODO - Здесь могут отсутствовать аккаунты - проверять провайдером
73 73
       $query = static::$db->doquery("SELECT `user_id` FROM {{account_translate}} WHERE `provider_id` = {$provider_id_safe} AND `provider_account_id` = {$provider_account_id_safe} FOR UPDATE");
74
-      while($row = static::$db->db_fetch($query)) {
74
+      while ($row = static::$db->db_fetch($query)) {
75 75
         $account_translation[$row['user_id']][$provider_id_unsafe][$provider_account_id_unsafe] = true;
76 76
       }
77 77
     }
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
     $account_translation = array();
89 89
 
90 90
     $query = static::$db->doquery(
91
-      "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} " .
92
-      ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '') .
91
+      "SELECT * FROM {{account_translate}} WHERE `user_id` = {$user_id_safe} ".
92
+      ($provider_id_unsafe ? "AND `provider_id` = {$provider_id_safe} " : '').
93 93
       "ORDER BY `timestamp` FOR UPDATE");
94
-    while($row = static::$db->db_fetch($query)) {
94
+    while ($row = static::$db->db_fetch($query)) {
95 95
       $account_translation[$row['user_id']][$row['provider_id']][$row['provider_account_id']] = $row;
96 96
     }
97 97
 
Please login to merge, or discard this patch.
classes/Bonus.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,12 +28,12 @@  discard block
 block discarded – undo
28 28
    * @param $unit_level
29 29
    */
30 30
   public function add_unit_by_snid($unit_id, $unit_level) {
31
-    if(!$unit_level) {
31
+    if (!$unit_level) {
32 32
       return;
33 33
     }
34 34
 
35
-    foreach(static::$_bonus_group as $param_name => $unit_list) {
36
-      if(!empty($unit_list[$unit_id])) {
35
+    foreach (static::$_bonus_group as $param_name => $unit_list) {
36
+      if (!empty($unit_list[$unit_id])) {
37 37
         // Простейший вариант - мультипликатор по базе
38 38
         // Общий мультипликатор добавляется в конец
39 39
         $this->grants[$param_name][$unit_id] = $unit_level;
@@ -82,16 +82,16 @@  discard block
 block discarded – undo
82 82
 //    $this->grants[$param_name][$unit_id] = $unit_level * get_unit_param($unit_id, P_BONUS_VALUE) / 100;;
83 83
     $value_add = floatval($base_value);
84 84
     $cumulative = 1.0; // Для случая BONUS_PERCENT
85
-    if(!empty($this->grants[$param]) && is_array($this->grants[$param])) {
86
-      foreach($this->grants[$param] as $unit_id => $unit_level) {
85
+    if (!empty($this->grants[$param]) && is_array($this->grants[$param])) {
86
+      foreach ($this->grants[$param] as $unit_id => $unit_level) {
87 87
         $unit_bonus = 0;
88
-        if($unit_id < 0) {
88
+        if ($unit_id < 0) {
89 89
           // Meta-unit - leave as is
90 90
         } else {
91 91
           // TODO - Подумать, что будет при смешивании разных бонусов и как этого избежать
92 92
           $bonus_value = get_unit_param($unit_id, P_BONUS_VALUE);
93 93
           $bonus_type = get_unit_param($unit_id, P_BONUS_TYPE);
94
-          switch($bonus_type) {
94
+          switch ($bonus_type) {
95 95
             case BONUS_PERCENT:
96 96
               $unit_bonus = $unit_level * $bonus_value / 100;
97 97
               $cumulative += $unit_bonus;
Please login to merge, or discard this patch.