Passed
Branch trunk (7dc288)
by SuperNova.WS
06:07
created
scheduler.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@
 block discarded – undo
22 22
 
23 23
 define('IN_AJAX', true);
24 24
 
25
-if(($result = StatUpdateLauncher::scheduler_process()) && !defined('IN_ADMIN')) {
25
+if (($result = StatUpdateLauncher::scheduler_process()) && !defined('IN_ADMIN')) {
26 26
   $result = htmlspecialchars($result, ENT_QUOTES, 'UTF-8');
27 27
   print(json_encode($result));
28 28
 }
29 29
 
30
-if(!defined('IN_ADMIN')) {
30
+if (!defined('IN_ADMIN')) {
31 31
   die();
32 32
 }
Please login to merge, or discard this patch.
classes/auth_local.php 1 patch
Spacing   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
     $this->prepare();
97 97
 
98 98
     $this->manifest['active'] = false;
99
-    if(!empty($this->config) && is_array($this->config['db'])) {
99
+    if (!empty($this->config) && is_array($this->config['db'])) {
100 100
       // БД, отличная от стандартной
101 101
       $this->db = new db_mysql();
102 102
 
103 103
       $this->db->sn_db_connect($this->config['db']);
104
-      if($this->manifest['active'] = $this->db->connected) {
104
+      if ($this->manifest['active'] = $this->db->connected) {
105 105
         $this->provider_id = ACCOUNT_PROVIDER_CENTRAL;
106 106
 
107 107
         $this->domain = $this->config['domain'];
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
     }
116 116
 
117 117
     // Fallback to local DB
118
-    if(!$this->manifest['active']) {
118
+    if (!$this->manifest['active']) {
119 119
       $this->db = classSupernova::$db;
120 120
 
121 121
       $this->provider_id = ACCOUNT_PROVIDER_LOCAL;
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
    */
170 170
   public function password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe = null) {
171 171
     $result = parent::password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe);
172
-    if($result) {
172
+    if ($result) {
173 173
       $this->cookie_set();
174 174
     }
175 175
 
@@ -198,12 +198,12 @@  discard block
 block discarded – undo
198 198
   protected function password_reset_send_code() {
199 199
     global $lang, $config;
200 200
 
201
-    if(!$this->is_password_reset) {
201
+    if (!$this->is_password_reset) {
202 202
       return $this->account_login_status;
203 203
     }
204 204
 
205 205
     // Проверяем поддержку сброса пароля
206
-    if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
206
+    if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
207 207
       return $this->account_login_status;
208 208
     }
209 209
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
       unset($this->account);
214 214
       $this->account = new Account($this->db);
215 215
 
216
-      if(!$this->account->db_get_by_email($email_unsafe)) {
216
+      if (!$this->account->db_get_by_email($email_unsafe)) {
217 217
         throw new Exception(PASSWORD_RESTORE_ERROR_EMAIL_NOT_EXISTS, ERR_ERROR);
218 218
         // return $this->account_login_status;
219 219
       }
@@ -223,14 +223,14 @@  discard block
 block discarded – undo
223 223
 
224 224
       // TODO - Проверять уровень доступа аккаунта!
225 225
       // Аккаунты с АУТЛЕВЕЛ больше 0 - НЕ СБРАСЫВАЮТ ПАРОЛИ!
226
-      foreach($user_list as $user_id => $user_data) {
227
-        if($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) {
226
+      foreach ($user_list as $user_id => $user_data) {
227
+        if ($user_data['authlevel'] > AUTH_LEVEL_REGISTERED) {
228 228
           throw new Exception(PASSWORD_RESTORE_ERROR_ADMIN_ACCOUNT, ERR_ERROR);
229 229
         }
230 230
       }
231 231
 
232 232
       $confirmation = $this->confirmation->db_confirmation_get_latest_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5
233
-      if(isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) {
233
+      if (isset($confirmation['create_time']) && SN_TIME_NOW - strtotime($confirmation['create_time']) < PERIOD_MINUTE_10) {
234 234
         throw new Exception(PASSWORD_RESTORE_ERROR_TOO_OFTEN, ERR_ERROR);
235 235
       }
236 236
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
       $confirm_code_unsafe = $this->confirmation->db_confirmation_get_unique_code_by_type_and_email(CONFIRM_PASSWORD_RESET, $email_unsafe); // OK 4.5
242 242
       sn_db_transaction_commit();
243 243
 
244
-      if(!is_email($email_unsafe)) {
244
+      if (!is_email($email_unsafe)) {
245 245
         classSupernova::$debug->error("Email is invalid: '{$email_unsafe}'", 'Invalid email for password restoration');
246 246
       }
247 247
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
       );
252 252
 
253 253
       $result = $result ? PASSWORD_RESTORE_SUCCESS_CODE_SENT : PASSWORD_RESTORE_ERROR_SENDING;
254
-    } catch(Exception $e) {
254
+    } catch (Exception $e) {
255 255
       sn_db_transaction_rollback();
256 256
       $result = $e->getMessage();
257 257
     }
@@ -266,46 +266,46 @@  discard block
 block discarded – undo
266 266
   protected function password_reset_confirm() {
267 267
     global $lang, $config;
268 268
 
269
-    if(!$this->is_password_reset_confirm) {
269
+    if (!$this->is_password_reset_confirm) {
270 270
       return $this->account_login_status;
271 271
     }
272 272
 
273
-    if($this->account_login_status != LOGIN_UNDEFINED) {
273
+    if ($this->account_login_status != LOGIN_UNDEFINED) {
274 274
       return $this->account_login_status;
275 275
     }
276 276
 
277 277
     // Проверяем поддержку сброса пароля
278
-    if(!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
278
+    if (!$this->is_feature_supported(AUTH_FEATURE_PASSWORD_RESET)) {
279 279
       return $this->account_login_status;
280 280
     }
281 281
 
282 282
     try {
283 283
       $code_unsafe = sys_get_param_str_unsafe('password_reset_code');
284
-      if(empty($code_unsafe)) {
284
+      if (empty($code_unsafe)) {
285 285
         throw new Exception(PASSWORD_RESTORE_ERROR_CODE_EMPTY, ERR_ERROR);
286 286
       }
287 287
 
288 288
       sn_db_transaction_start();
289 289
       $confirmation = $this->confirmation->db_confirmation_get_by_type_and_code(CONFIRM_PASSWORD_RESET, $code_unsafe); // OK 4.5
290 290
 
291
-      if(empty($confirmation)) {
291
+      if (empty($confirmation)) {
292 292
         throw new Exception(PASSWORD_RESTORE_ERROR_CODE_WRONG, ERR_ERROR);
293 293
       }
294 294
 
295
-      if(SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) {
295
+      if (SN_TIME_NOW - strtotime($confirmation['create_time']) > AUTH_PASSWORD_RESET_CONFIRMATION_EXPIRE) {
296 296
         throw new Exception(PASSWORD_RESTORE_ERROR_CODE_TOO_OLD, ERR_ERROR);
297 297
       }
298 298
 
299 299
       unset($this->account);
300 300
       $this->account = new Account($this->db);
301 301
 
302
-      if(!$this->account->db_get_by_email($confirmation['email'])) {
302
+      if (!$this->account->db_get_by_email($confirmation['email'])) {
303 303
         throw new Exception(PASSWORD_RESTORE_ERROR_CODE_OK_BUT_NO_ACCOUNT_FOR_EMAIL, ERR_ERROR);
304 304
       }
305 305
 
306 306
       $new_password_unsafe = $this->make_random_password();
307 307
       $salt_unsafe = $this->password_salt_generate();
308
-      if(!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) {
308
+      if (!$this->account->db_set_password($new_password_unsafe, $salt_unsafe)) {
309 309
         // Ошибка смены пароля
310 310
         throw new Exception(AUTH_ERROR_INTERNAL_PASSWORD_CHANGE_ON_RESTORE, ERR_ERROR);
311 311
       }
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
       $this->cookie_set();
316 316
       $this->login_cookie();
317 317
 
318
-      if($this->account_login_status == LOGIN_SUCCESS) {
318
+      if ($this->account_login_status == LOGIN_SUCCESS) {
319 319
         // TODO - НЕ ОБЯЗАТЕЛЬНО ОТПРАВЛЯТЬ ЧЕРЕЗ ЕМЕЙЛ! ЕСЛИ ЭТО ФЕЙСБУЧЕК ИЛИ ВКШЕЧКА - МОЖНО ЧЕРЕЗ ЛС ПИСАТЬ!!
320 320
         $message_header = sprintf($lang['log_lost_email_title'], $config->game_name);
321 321
         $message = sprintf($lang['log_lost_email_pass'], $config->game_name, $this->account->account_name, $new_password_unsafe);
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
 
324 324
         // $users_translated = classSupernova::$auth->db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5
325 325
         $users_translated = PlayerToAccountTranslate::db_translate_get_users_from_account_list($this->provider_id, $this->account->account_id); // OK 4.5
326
-        if(!empty($users_translated)) {
326
+        if (!empty($users_translated)) {
327 327
           // Отправляем в лички письмо о сбросе пароля
328 328
 
329 329
           // ПО ОПРЕДЕЛЕНИЮ в $users_translated только
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
           $message = HelperString::nl2br($message) . '<br><br>';
336 336
           // msg_send_simple_message($found_provider->data[F_USER_ID], 0, SN_TIME_NOW, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['sys_login_register_message_title'], $message);
337 337
 
338
-          foreach($users_translated as $user_id => $providers_list) {
338
+          foreach ($users_translated as $user_id => $providers_list) {
339 339
             msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN, $lang['sys_administration'], $lang['sys_login_register_message_title'], $message);
340 340
           }
341 341
         } else {
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
     $this->flog('Регистрация: начинаем. Провайдер ' . $this->provider_id);
389 389
 
390 390
     try {
391
-      if(!$this->is_register) {
391
+      if (!$this->is_register) {
392 392
         $this->flog('Регистрация: не выставлен флаг регистрации - пропускаем');
393 393
         throw new Exception(LOGIN_UNDEFINED, ERR_ERROR);
394 394
       }
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
       // $this->account_check_duplicate_name_or_email($this->input_login_unsafe, $this->input_email_unsafe);
401 401
 
402 402
       $this->account->db_get_by_name_or_email($this->input_login_unsafe, $this->input_email_unsafe);
403
-      if($this->account->is_exists) {
404
-        if($this->account->account_email == $this->input_email_unsafe) {
403
+      if ($this->account->is_exists) {
404
+        if ($this->account->account_email == $this->input_email_unsafe) {
405 405
           throw new Exception(REGISTER_ERROR_EMAIL_EXISTS, ERR_ERROR);
406 406
         } else {
407 407
           throw new Exception(REGISTER_ERROR_ACCOUNT_NAME_EXISTS, ERR_ERROR);
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
       // А вот это пока не нужно. Трансляцией аккаунтов в юзеров и созданием новых юзеров для новозашедших аккаунтов занимается Auth
441 441
       // $this->register_account();
442 442
       sn_db_transaction_commit();
443
-    } catch(Exception $e) {
443
+    } catch (Exception $e) {
444 444
       sn_db_transaction_rollback();
445 445
       $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false;
446 446
     }
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
    * @return int Результат попытки
456 456
    */
457 457
   protected function login_cookie() {
458
-    if($this->account_login_status != LOGIN_UNDEFINED) {
458
+    if ($this->account_login_status != LOGIN_UNDEFINED) {
459 459
       return $this->account_login_status;
460 460
     }
461 461
 
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 //      $this->cookie_clear();
482 482
 //    }
483 483
 
484
-    if($this->account->cookieLogin($rememberMe)) {
484
+    if ($this->account->cookieLogin($rememberMe)) {
485 485
         $this->account_login_status = LOGIN_SUCCESS;
486 486
         $this->remember_me = intval($rememberMe);
487 487
     }
@@ -498,13 +498,13 @@  discard block
 block discarded – undo
498 498
   protected function login_username() {
499 499
     // TODO - Логин по старым именам
500 500
     try {
501
-      if(!$this->is_login) {
501
+      if (!$this->is_login) {
502 502
         $this->flog('Логин: не выставлен флаг входа в игру - это не логин');
503 503
         throw new Exception(LOGIN_UNDEFINED, ERR_ERROR);
504 504
       }
505 505
 
506 506
       // TODO Пустое имя аккаунта
507
-      if(!$this->input_login_unsafe) {
507
+      if (!$this->input_login_unsafe) {
508 508
         throw new Exception(LOGIN_UNDEFINED, ERR_ERROR);
509 509
       }
510 510
 
@@ -514,11 +514,11 @@  discard block
 block discarded – undo
514 514
 //      if(empty($account)) {
515 515
 //        throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR);
516 516
 //      }
517
-      if(!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) {
517
+      if (!$this->account->db_get_by_name($this->input_login_unsafe) && !$this->account->db_get_by_email($this->input_login_unsafe)) {
518 518
         throw new Exception(LOGIN_ERROR_USERNAME, ERR_ERROR);
519 519
       }
520 520
 
521
-      if(!$this->account->password_check($this->input_login_password_raw)) {
521
+      if (!$this->account->password_check($this->input_login_password_raw)) {
522 522
         throw new Exception(LOGIN_ERROR_PASSWORD, ERR_ERROR);
523 523
       }
524 524
 
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
 
527 527
       $this->cookie_set();
528 528
       $this->account_login_status = LOGIN_SUCCESS;
529
-    } catch(Exception $e) {
529
+    } catch (Exception $e) {
530 530
       $this->account_login_status == LOGIN_UNDEFINED ? $this->account_login_status = $e->getMessage() : false;
531 531
     }
532 532
 
@@ -547,11 +547,11 @@  discard block
 block discarded – undo
547 547
   protected function cookie_set($account_to_impersonate = null) {
548 548
     $this_account = is_object($account_to_impersonate) ? $account_to_impersonate : $this->account;
549 549
 
550
-    if(!is_object($this_account) || !$this_account->is_exists) {
550
+    if (!is_object($this_account) || !$this_account->is_exists) {
551 551
       throw new Exception(LOGIN_ERROR_NO_ACCOUNT_FOR_COOKIE_SET, ERR_ERROR);
552 552
     }
553 553
 
554
-    if(is_object($account_to_impersonate) && $account_to_impersonate->is_exists) {
554
+    if (is_object($account_to_impersonate) && $account_to_impersonate->is_exists) {
555 555
       sn_setcookie($this->cookie_name_impersonate, $_COOKIE[$this->cookie_name], SN_TIME_NOW + PERIOD_YEAR, $this->sn_root_path, $this->domain);
556 556
     }
557 557
 
@@ -588,10 +588,10 @@  discard block
 block discarded – undo
588 588
   protected function login_validate_input() {
589 589
     // Проверяем, что бы в начале и конце не было пустых символов
590 590
     // TODO - при копировании Эксель -> Опера - в конце образуются пустые места. Это не должно быть проблемой! Вынести проверку пароля в регистрацию!
591
-    if($this->input_login_password_raw != trim($this->input_login_password_raw)) {
591
+    if ($this->input_login_password_raw != trim($this->input_login_password_raw)) {
592 592
       throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR);
593 593
     }
594
-    if(!$this->input_login_password_raw) {
594
+    if (!$this->input_login_password_raw) {
595 595
       throw new Exception(LOGIN_ERROR_PASSWORD_EMPTY, ERR_ERROR);
596 596
     }
597 597
   }
@@ -606,37 +606,37 @@  discard block
 block discarded – undo
606 606
     $this->login_validate_input();
607 607
 
608 608
     // Если нет имени пользователя - NO GO!
609
-    if(!$this->input_login_unsafe) {
609
+    if (!$this->input_login_unsafe) {
610 610
       throw new Exception(LOGIN_ERROR_USERNAME_EMPTY, ERR_ERROR);
611 611
     }
612 612
     // Если логин имеет запрещенные символы - NO GO!
613
-    if(strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
613
+    if (strpbrk($this->input_login_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
614 614
       throw new Exception(LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS, ERR_ERROR);
615 615
     }
616 616
     // Если логин меньше минимальной длины - NO GO!
617
-    if(strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) {
617
+    if (strlen($this->input_login_unsafe) < LOGIN_LENGTH_MIN) {
618 618
       throw new Exception(REGISTER_ERROR_USERNAME_SHORT, ERR_ERROR);
619 619
     }
620 620
     // Если пароль меньше минимальной длины - NO GO!
621
-    if(strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) {
621
+    if (strlen($this->input_login_password_raw) < PASSWORD_LENGTH_MIN) {
622 622
       throw new Exception(REGISTER_ERROR_PASSWORD_INSECURE, ERR_ERROR);
623 623
     }
624 624
     // Если пароль имеет пробельные символы в начале или конце - NO GO!
625
-    if($this->input_login_password_raw != trim($this->input_login_password_raw)) {
625
+    if ($this->input_login_password_raw != trim($this->input_login_password_raw)) {
626 626
       throw new Exception(LOGIN_ERROR_PASSWORD_TRIMMED, ERR_ERROR);
627 627
     }
628 628
     // Если пароль не совпадает с подтверждением - NO GO! То, что у пароля нет пробельных символов в начале/конце - мы уже проверили выше
629 629
     //Если они есть у повтора - значит пароль и повтор не совпадут
630
-    if($this->input_login_password_raw <> $this->input_login_password_raw_repeat) {
630
+    if ($this->input_login_password_raw <> $this->input_login_password_raw_repeat) {
631 631
       throw new Exception(REGISTER_ERROR_PASSWORD_DIFFERENT, ERR_ERROR);
632 632
     }
633 633
     // Если нет емейла - NO GO!
634 634
     // TODO - регистрация без емейла
635
-    if(!$this->input_email_unsafe) {
635
+    if (!$this->input_email_unsafe) {
636 636
       throw new Exception(REGISTER_ERROR_EMAIL_EMPTY, ERR_ERROR);
637 637
     }
638 638
     // Если емейл не является емейлом - NO GO!
639
-    if(!is_email($this->input_email_unsafe)) {
639
+    if (!is_email($this->input_email_unsafe)) {
640 640
       throw new Exception(REGISTER_ERROR_EMAIL_WRONG, ERR_ERROR);
641 641
     }
642 642
   }
@@ -667,7 +667,7 @@  discard block
 block discarded – undo
667 667
     return core_auth::make_random_password();
668 668
   }
669 669
   protected function flog($message, $die = false) {
670
-    if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
670
+    if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
671 671
       return;
672 672
     }
673 673
     list($called, $caller) = debug_backtrace(false);
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
     $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false;
682 682
 
683 683
     classSupernova::log_file("$message - $caller_name");
684
-    if($die) {
684
+    if ($die) {
685 685
       $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
686 686
     }
687 687
   }
Please login to merge, or discard this patch.
admin/admin_locale.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -7,9 +7,9 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-define('INSIDE'  , true);
11
-define('INSTALL' , false);
12
-define('IN_ADMIN'  , true);
10
+define('INSIDE', true);
11
+define('INSTALL', false);
12
+define('IN_ADMIN', true);
13 13
 
14 14
 require('../common.' . substr(strrchr(__FILE__, '.'), 1));
15 15
 
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
 function adm_lng_assign_string($lang_id, $locale_string_name, $value) {
21 21
   global $locale_string_template, $languages_info, $languages, $domain;
22 22
 
23
-  if(is_array($value)) {
24
-    foreach($value as $sub_key => $sub_value) {
23
+  if (is_array($value)) {
24
+    foreach ($value as $sub_key => $sub_value) {
25 25
       adm_lng_assign_string($lang_id, "{$locale_string_name}[{$sub_key}]", $sub_value);
26 26
     }
27
-  } elseif($value) {
28
-    if(!isset($locale_string_template[$locale_string_name])) {
27
+  } elseif ($value) {
28
+    if (!isset($locale_string_template[$locale_string_name])) {
29 29
       $locale_string_template[$locale_string_name] = array();
30 30
     }
31 31
     $locale_string_template[$locale_string_name] = array_merge($locale_string_template[$locale_string_name], array("[{$lang_id}]" => htmlentities($value, ENT_COMPAT, 'utf-8')));
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
   global $domain, $lang_id;
47 47
 
48 48
   $return = "{$ident}'{$string_name}' => ";
49
-  if(isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) {
49
+  if (isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) {
50 50
     $return .= "'" . str_replace(array("\\", "'"), array('\\\\', "\\'"), $string_value[$lang_id]) . "',";
51 51
   } else {
52 52
     $return .= "array(\r\n";
53
-    foreach($string_value as $arr_name => $arr_data) {
53
+    foreach ($string_value as $arr_name => $arr_data) {
54 54
       $return .= adm_lng_parse_string($arr_name, $arr_data, $ident . '  ');
55 55
     }
56 56
     $return .= "{$ident}),\r\n";
@@ -103,12 +103,12 @@  discard block
 block discarded – undo
103 103
 
104 104
   $string_name_new = false;
105 105
 
106
-  if(isset($honor_constants[$domain][$string_name_prefix])) {
106
+  if (isset($honor_constants[$domain][$string_name_prefix])) {
107 107
     $found_constants = array_keys($constants, $string_name);
108
-    foreach($found_constants as $constant_name) {
108
+    foreach ($found_constants as $constant_name) {
109 109
       $honor_prefix_list = is_array($honor_constants[$domain][$string_name_prefix]) ? $honor_constants[$domain][$string_name_prefix] : array($honor_constants[$domain][$string_name_prefix]);
110
-      foreach($honor_prefix_list as $honor_prefix) {
111
-        if(strpos($constant_name, $honor_prefix) === 0) {
110
+      foreach ($honor_prefix_list as $honor_prefix) {
111
+        if (strpos($constant_name, $honor_prefix) === 0) {
112 112
           $string_name_new = $constant_name;
113 113
           break;
114 114
         }
@@ -118,13 +118,13 @@  discard block
 block discarded – undo
118 118
 
119 119
   $string_name_new = $string_name_new ? $string_name_new : "'{$string_name}'";
120 120
   fwrite($file_handler, "{$ident}{$string_name_new} => ");
121
-  if(isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) {
121
+  if (isset($string_value[$lang_id]) && !is_array($string_value[$lang_id])) {
122 122
     fwrite($file_handler, "'" . str_replace(array("\\", "'"), array('\\\\', "\\'"), $string_value[$lang_id]) . "',");
123 123
 //    fwrite($file_handler, "'" . addslashes($string_value[$lang_id]) . "',");
124 124
   } else {
125 125
     $string_name_prefix = $string_name_prefix . "[{$string_name}]";
126 126
     fwrite($file_handler, "array(\r\n");
127
-    foreach($string_value as $arr_name => $arr_data) {
127
+    foreach ($string_value as $arr_name => $arr_data) {
128 128
       adm_lng_write_string($arr_name, $arr_data, $ident . '  ', $string_name_prefix);
129 129
     }
130 130
     fwrite($file_handler, "{$ident}),\r\n");
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
 $languages_info = lng_get_list();
145 145
 $domain = sys_get_param_str('domain');
146 146
 
147
-if($domain) {
147
+if ($domain) {
148 148
   $lang_new = sys_get_param('lang_new');
149
-  if(!empty($lang_new) && is_array($lang_new)) {
149
+  if (!empty($lang_new) && is_array($lang_new)) {
150 150
     $constants = get_defined_constants(true);
151 151
     $constants = $constants['user'];
152 152
     ksort($constants);
153
-    foreach($languages_info as $lang_id => $land_data) {
153
+    foreach ($languages_info as $lang_id => $land_data) {
154 154
       $file_handler = fopen(SN_ROOT_PHYSICAL . "language/{$lang_id}/{$domain}.mo.php.new", 'w');
155 155
       fwrite($file_handler, "<?php\r\n\r\n/*\r\n#############################################################################
156 156
 #  Filename: {$domain}.mo.php
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 #  Website: http://www.supernova.ws
159 159
 #  Description: Massive Multiplayer Online Browser Space Startegy Game\r\n#\r\n");
160 160
 
161
-      foreach($land_data['LANG_COPYRIGHT'] as $lang_copyright) {
161
+      foreach ($land_data['LANG_COPYRIGHT'] as $lang_copyright) {
162 162
         $lang_copyright = str_replace(array('&copy;', '&quot;', '&lt;', '&gt;'), array('©', '"', '<', '>'), $lang_copyright);
163 163
         fwrite($file_handler, "#  {$lang_copyright}\r\n");
164 164
       }
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 /**\r\n*\r\n* @package language\r\n* @system [{$land_data['LANG_NAME_ENGLISH']}]\r\n* @version " . SN_VERSION . "\r\n*\r\n*/\r\n
167 167
 /**\r\n* DO NOT CHANGE\r\n*/\r\n\r\nif (!defined('INSIDE')) die();\r\n
168 168
 \$a_lang_array = array(\r\n");
169
-      foreach($lang_new as $string_name => $string_value) {
169
+      foreach ($lang_new as $string_name => $string_value) {
170 170
         adm_lng_write_string($string_name, $string_value);
171 171
       }
172 172
       fwrite($file_handler, ");\r\n");
@@ -176,21 +176,21 @@  discard block
 block discarded – undo
176 176
     sys_redirect("admin_locale.php?domain={$domain}");
177 177
   }
178 178
 
179
-  foreach($languages_info as $lang_id => $lang_data) {
179
+  foreach ($languages_info as $lang_id => $lang_data) {
180 180
     $template->assign_block_vars('language', $lang_data);
181 181
     $full_filename = SN_ROOT_PHYSICAL . "language/{$lang_id}/{$domain}.mo.php";
182 182
     $languages[$lang_id] = adm_lng_load($full_filename . (file_exists($full_filename . '.new') ? '.new' : ''));
183
-    foreach($languages[$lang_id] as $locale_string_name => $cork) {
183
+    foreach ($languages[$lang_id] as $locale_string_name => $cork) {
184 184
       adm_lng_assign_string($lang_id, "[{$locale_string_name}]", $languages[$lang_id][$locale_string_name]);
185 185
     }
186 186
   }
187 187
 
188
-  foreach($locale_string_template as $locale_string_name => $locale_string_list) {
188
+  foreach ($locale_string_template as $locale_string_name => $locale_string_list) {
189 189
     $template->assign_block_vars('string', array(
190 190
       'NAME' => $locale_string_name,
191 191
     ));
192 192
 
193
-    foreach($languages_info as $lang_id => $cork2) {
193
+    foreach ($languages_info as $lang_id => $cork2) {
194 194
       $template->assign_block_vars('string.locale', array(
195 195
         'LANG' => $lang_id,
196 196
         'VALUE' => $locale_string_list["[{$lang_id}]"],
@@ -206,17 +206,17 @@  discard block
 block discarded – undo
206 206
   $dir = dir($path);
207 207
   while (false !== ($lang_id = $dir->read())) {
208 208
     $full_path = $path . $lang_id;
209
-    if($lang_id[0] != "." && is_dir($full_path)) {
209
+    if ($lang_id[0] != "." && is_dir($full_path)) {
210 210
       $lang_file_list = dir($full_path);
211 211
       while (false !== ($filename = $lang_file_list->read())) {
212 212
         $lang_domain = strtolower(substr($filename, 0, strpos($filename, '.')));
213
-        if(!$lang_domain) {
213
+        if (!$lang_domain) {
214 214
           continue;
215 215
         }
216 216
 
217 217
         $file_ext = strtolower(substr($filename, strpos($filename, '.')));
218
-        if($lang_domain != 'language') {
219
-          if($file_ext == '.mo.php.new' || ($file_ext == '.mo.php' && empty($languages[$lang_id][$lang_domain]))) {
218
+        if ($lang_domain != 'language') {
219
+          if ($file_ext == '.mo.php.new' || ($file_ext == '.mo.php' && empty($languages[$lang_id][$lang_domain]))) {
220 220
             $language_domains[$lang_domain] = $lang_domain;
221 221
             $languages[$lang_id][$lang_domain] = $lang_domain;
222 222
           }
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
   }
227 227
   $dir->close();
228 228
 
229
-  foreach($language_domains as $lang_domain) {
229
+  foreach ($language_domains as $lang_domain) {
230 230
     $template->assign_block_vars('domain', array(
231 231
       'NAME' => $lang_domain,
232 232
     ));
Please login to merge, or discard this patch.
includes/includes/flt_page2.inc 1 patch
Spacing   +10 added lines, -11 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     'START_NAME'         => $planetrow['name'],
28 28
   );
29 29
 
30
-  if(!empty($TargetPlanet)) {
30
+  if (!empty($TargetPlanet)) {
31 31
     $template_route += array(
32 32
       'END_TYPE_TEXT_SH' => $lang['sys_planet_type_sh'][$TargetPlanet['planet_type']],
33 33
       'END_COORDS'       => uni_render_coordinates($TargetPlanet),
@@ -38,8 +38,8 @@  discard block
 block discarded – undo
38 38
   $template->assign_block_vars('fleets', $template_route);
39 39
 
40 40
   $sn_groups_fleet = sn_get_groups('fleet');
41
-  foreach($fleetarray as $ship_id => $ship_count) {
42
-    if(in_array($ship_id, $sn_groups_fleet) && $ship_count) {
41
+  foreach ($fleetarray as $ship_id => $ship_count) {
42
+    if (in_array($ship_id, $sn_groups_fleet) && $ship_count) {
43 43
 //      $ship_base_data = get_ship_data($ship_id, $user);
44 44
       $template->assign_block_vars('fleets.ships', array(
45 45
         'ID'          => $ship_id,
@@ -57,11 +57,10 @@  discard block
 block discarded – undo
57 57
     $fleet_capacity += get_unit_param($Ship, P_CAPACITY) * $Count;
58 58
   }
59 59
 
60
-  $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) :
61
-    (isset($missiontype[MT_HOLD]) ? 12 : 0);
62
-  if($max_duration) {
60
+  $max_duration = $target_mission == MT_EXPLORE ? get_player_max_expedition_duration($user) : (isset($missiontype[MT_HOLD]) ? 12 : 0);
61
+  if ($max_duration) {
63 62
     $config_game_speed_expedition = ($target_mission == MT_EXPLORE && $config->game_speed_expedition ? $config->game_speed_expedition : 1);
64
-    for($i = 1; $i <= $max_duration; $i++) {
63
+    for ($i = 1; $i <= $max_duration; $i++) {
65 64
       $template->assign_block_vars('duration', array(
66 65
         'ID' => $i,
67 66
         'TIME' => pretty_time(ceil($i * 3600 / $config_game_speed_expedition)),
@@ -80,7 +79,7 @@  discard block
 block discarded – undo
80 79
   // $TableTitle = uni_render_planet_full($planetrow) . '&nbsp;=&gt;&nbsp;' . uni_render_planet_full($temp);
81 80
 
82 81
   $sn_group_resources = sn_get_groups('resources');
83
-  for($i = 0; $i<3; $i++) {
82
+  for ($i = 0; $i < 3; $i++) {
84 83
     $amount = $planetrow[$sn_group_resources[$i]] - ($i == 2 ? $consumption : 0);
85 84
     $template->assign_block_vars('resources', array(
86 85
       'ID' => $i,
@@ -90,7 +89,7 @@  discard block
 block discarded – undo
90 89
     ));
91 90
   }
92 91
 
93
-  if($sn_module['unit_captain']->manifest['active'] && ($captain = $sn_module['unit_captain']->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) {
92
+  if ($sn_module['unit_captain']->manifest['active'] && ($captain = $sn_module['unit_captain']->unit_captain_get($planetrow['id'])) && $captain['unit_location_type'] == LOC_PLANET) {
94 93
     $template->assign_vars(array(
95 94
       'CAPTAIN_ID' => $captain['unit_id'],
96 95
       'CAPTAIN_LEVEL' => $captain['captain_level'],
@@ -112,9 +111,9 @@  discard block
 block discarded – undo
112 111
 
113 112
 
114 113
     'speedallsmin' => sys_get_param_float('speedallsmin'),
115
-    'speed' => sys_get_param_int('speed') ,
114
+    'speed' => sys_get_param_int('speed'),
116 115
 
117
-    'fleet_group' => sys_get_param_id('fleet_group') ,
116
+    'fleet_group' => sys_get_param_id('fleet_group'),
118 117
     'acs_target_mr' => sys_get_param_str('acs_target_mr'),
119 118
 
120 119
     'MAX_DURATION' => $max_duration,
Please login to merge, or discard this patch.
fleet.php 2 patches
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 $planet = sys_get_param_int('planet', $planetrow['planet']);
40 40
 
41 41
 $target_mission = sys_get_param_int('target_mission');
42
-if($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) {
42
+if ($target_mission == MT_COLONIZE || $target_mission == MT_EXPLORE) {
43 43
   $planet_type = PT_PLANET;
44
-} elseif($target_mission == MT_RECYCLE) {
44
+} elseif ($target_mission == MT_RECYCLE) {
45 45
   $planet_type = PT_DEBRIS;
46
-} elseif($target_mission == MT_DESTROY) {
46
+} elseif ($target_mission == MT_DESTROY) {
47 47
   $planet_type = PT_MOON;
48 48
 } else {
49 49
   $planet_type = sys_get_param_int('planet_type');
@@ -59,15 +59,15 @@  discard block
 block discarded – undo
59 59
 //$FlyingFleets = doquery("SELECT COUNT(fleet_id) as Number FROM {{fleets}} WHERE `fleet_owner`='{$user['id']}'", true);
60 60
 //$FlyingFleets = $FlyingFleets['Number'];
61 61
 $FlyingFleets = fleet_count_flying($user['id']);
62
-if($MaxFleets <= $FlyingFleets && $fleet_page && $fleet_page != 4) {
62
+if ($MaxFleets <= $FlyingFleets && $fleet_page && $fleet_page != 4) {
63 63
   messageBox($lang['fl_noslotfree'], $lang['fl_error'], "fleet." . PHP_EX, 5);
64 64
 }
65 65
 
66 66
 $MaxExpeditions = get_player_max_expeditons($user);
67
-if($MaxExpeditions) {
67
+if ($MaxExpeditions) {
68 68
 //  $FlyingExpeditions  = doquery("SELECT COUNT(fleet_owner) AS `expedi` FROM {{fleets}} WHERE `fleet_owner` = {$user['id']} AND `fleet_mission` = '" . MT_EXPLORE . "';", '', true);
69 69
 //  $FlyingExpeditions  = $FlyingExpeditions['expedi'];
70
-  $FlyingExpeditions  = fleet_count_flying($user['id'], MT_EXPLORE);
70
+  $FlyingExpeditions = fleet_count_flying($user['id'], MT_EXPLORE);
71 71
 } else {
72 72
   $FlyingExpeditions = 0;
73 73
 }
@@ -80,8 +80,8 @@  discard block
 block discarded – undo
80 80
     $fleetarray     = json_decode(base64_decode(str_rot13(sys_get_param('usedfleet'))), true);
81 81
     $fleetarray = is_array($fleetarray) ? $fleetarray : array();
82 82
 
83
-    foreach($fleetarray as $ship_id => &$ship_amount) {
84
-      if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) {
83
+    foreach ($fleetarray as $ship_id => &$ship_amount) {
84
+      if (!in_array($ship_id, sn_get_groups('fleet')) || (string) floatval($ship_amount) != $ship_amount || $ship_amount < 1) {
85 85
         $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true));
86 86
         die();
87 87
       }
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
           $target_mission = MT_COLONIZE;
113 113
           $planet_type = PT_PLANET;
114 114
         } else {
115
-          messageBox ("<font color=\"red\"><b>". $lang['fl_no_planet_type'] ."</b></font>", $lang['fl_error']);
115
+          messageBox("<font color=\"red\"><b>" . $lang['fl_no_planet_type'] . "</b></font>", $lang['fl_error']);
116 116
         }
117 117
       } else {
118 118
         $recyclers = 0;
119
-        foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
119
+        foreach (sn_get_groups('flt_recyclers') as $recycler_id) {
120 120
           $recyclers += $fleetarray[$recycler_id];
121 121
         }
122 122
         if ($recyclers > 0 && $planet_type == PT_DEBRIS) {
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 
142 142
                 $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD];
143 143
 
144
-                if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
144
+                if ($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
145 145
                   $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY];
146 146
                 }
147 147
               }
@@ -201,14 +201,14 @@  discard block
 block discarded – undo
201 201
 );
202 202
 
203 203
 $is_transport_missions = false;
204
-if($missiontype) {
204
+if ($missiontype) {
205 205
   $sn_group_missions = sn_get_groups('missions');
206
-  foreach($missiontype as $mission_data_id => $mission_data) {
206
+  foreach ($missiontype as $mission_data_id => $mission_data) {
207 207
     $is_transport_missions = $is_transport_missions || (isset($sn_group_missions[$mission_data_id]['transport']) && $sn_group_missions[$mission_data_id]['transport']);
208 208
   }
209 209
 }
210 210
 
211
-switch($fleet_page) {
211
+switch ($fleet_page) {
212 212
   case 1:
213 213
     require('includes/includes/flt_page1.inc');
214 214
   break;
Please login to merge, or discard this patch.
Switch Indentation   +131 added lines, -131 removed lines patch added patch discarded remove patch
@@ -75,121 +75,121 @@  discard block
 block discarded – undo
75 75
 }
76 76
 
77 77
 switch ($fleet_page) {
78
-  case 3:
78
+    case 3:
79 79
 
80
-  case 2:
81
-    $fleet_group_mr = sys_get_param_id('fleet_group');
82
-    $fleetarray     = json_decode(base64_decode(str_rot13(sys_get_param('usedfleet'))), true);
83
-    $fleetarray = is_array($fleetarray) ? $fleetarray : array();
80
+    case 2:
81
+      $fleet_group_mr = sys_get_param_id('fleet_group');
82
+      $fleetarray     = json_decode(base64_decode(str_rot13(sys_get_param('usedfleet'))), true);
83
+      $fleetarray = is_array($fleetarray) ? $fleetarray : array();
84 84
 
85
-    foreach($fleetarray as $ship_id => &$ship_amount) {
86
-      if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) {
87
-        $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true));
88
-        die();
89
-      }
90
-      $ship_amount = floatval($ship_amount);
91
-    }
92
-
93
-    $UsedPlanet = false;
94
-    $YourPlanet = false;
95
-    $missiontype = array();
96
-    if ($planet > classSupernova::$config->game_maxPlanet) {
97
-      $target_mission = MT_EXPLORE;
98
-      $missiontype[MT_EXPLORE] = $lang['type_mission'][MT_EXPLORE];
99
-    } elseif ($galaxy && $system && $planet) {
100
-      $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
101
-
102
-      $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type);
103
-
104
-      if ($TargetPlanet['id_owner']) {
105
-        $UsedPlanet = true;
106
-        if ($TargetPlanet['id_owner'] == $user['id']) {
107
-          $YourPlanet = true;
85
+      foreach($fleetarray as $ship_id => &$ship_amount) {
86
+        if(!in_array($ship_id, sn_get_groups('fleet')) || (string)floatval($ship_amount) != $ship_amount || $ship_amount < 1) {
87
+          $debug->warning('Supplying wrong ship in ship list on fleet page', 'Hack attempt', 302, array('base_dump' => true));
88
+          die();
108 89
         }
90
+        $ship_amount = floatval($ship_amount);
109 91
       }
110 92
 
111
-      if (!$UsedPlanet) {
112
-        if ($fleetarray[SHIP_COLONIZER]) {
113
-          $missiontype[MT_COLONIZE] = $lang['type_mission'][MT_COLONIZE];
114
-          $target_mission = MT_COLONIZE;
115
-          $planet_type = PT_PLANET;
116
-        } else {
117
-          messageBox ("<font color=\"red\"><b>". $lang['fl_no_planet_type'] ."</b></font>", $lang['fl_error']);
118
-        }
119
-      } else {
120
-        $recyclers = 0;
121
-        foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
122
-          $recyclers += $fleetarray[$recycler_id];
93
+      $UsedPlanet = false;
94
+      $YourPlanet = false;
95
+      $missiontype = array();
96
+      if ($planet > classSupernova::$config->game_maxPlanet) {
97
+        $target_mission = MT_EXPLORE;
98
+        $missiontype[MT_EXPLORE] = $lang['type_mission'][MT_EXPLORE];
99
+      } elseif ($galaxy && $system && $planet) {
100
+        $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
101
+
102
+        $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type);
103
+
104
+        if ($TargetPlanet['id_owner']) {
105
+          $UsedPlanet = true;
106
+          if ($TargetPlanet['id_owner'] == $user['id']) {
107
+            $YourPlanet = true;
108
+          }
123 109
         }
124
-        if ($recyclers > 0 && $planet_type == PT_DEBRIS) {
125
-          $target_mission = MT_RECYCLE;
126
-          $missiontype[MT_RECYCLE] = $lang['type_mission'][MT_RECYCLE];
127
-        } elseif ($planet_type == PT_PLANET || $planet_type == PT_MOON) {
128
-          if ($YourPlanet) {
129
-            $missiontype[MT_RELOCATE] = $lang['type_mission'][MT_RELOCATE];
130
-            $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT];
110
+
111
+        if (!$UsedPlanet) {
112
+          if ($fleetarray[SHIP_COLONIZER]) {
113
+            $missiontype[MT_COLONIZE] = $lang['type_mission'][MT_COLONIZE];
114
+            $target_mission = MT_COLONIZE;
115
+            $planet_type = PT_PLANET;
131 116
           } else {
132
-            // Not Your Planet
133
-            if ($fleetarray[SHIP_SPY]) {
134
-              // Only spy missions if any spy
135
-              $missiontype[MT_SPY] = $lang['type_mission'][MT_SPY];
117
+            messageBox ("<font color=\"red\"><b>". $lang['fl_no_planet_type'] ."</b></font>", $lang['fl_error']);
118
+          }
119
+        } else {
120
+          $recyclers = 0;
121
+          foreach(sn_get_groups('flt_recyclers') as $recycler_id) {
122
+            $recyclers += $fleetarray[$recycler_id];
123
+          }
124
+          if ($recyclers > 0 && $planet_type == PT_DEBRIS) {
125
+            $target_mission = MT_RECYCLE;
126
+            $missiontype[MT_RECYCLE] = $lang['type_mission'][MT_RECYCLE];
127
+          } elseif ($planet_type == PT_PLANET || $planet_type == PT_MOON) {
128
+            if ($YourPlanet) {
129
+              $missiontype[MT_RELOCATE] = $lang['type_mission'][MT_RELOCATE];
130
+              $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT];
136 131
             } else {
137
-              // If no spies...
138
-              if ($fleet_group_mr) {
139
-                $missiontype[MT_AKS] = $lang['type_mission'][MT_AKS];
132
+              // Not Your Planet
133
+              if ($fleetarray[SHIP_SPY]) {
134
+                // Only spy missions if any spy
135
+                $missiontype[MT_SPY] = $lang['type_mission'][MT_SPY];
140 136
               } else {
141
-                $missiontype[MT_ATTACK] = $lang['type_mission'][MT_ATTACK];
142
-                $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT];
143
-
144
-                $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD];
145
-
146
-                if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
147
-                  $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY];
137
+                // If no spies...
138
+                if ($fleet_group_mr) {
139
+                  $missiontype[MT_AKS] = $lang['type_mission'][MT_AKS];
140
+                } else {
141
+                  $missiontype[MT_ATTACK] = $lang['type_mission'][MT_ATTACK];
142
+                  $missiontype[MT_TRANSPORT] = $lang['type_mission'][MT_TRANSPORT];
143
+
144
+                  $missiontype[MT_HOLD] = $lang['type_mission'][MT_HOLD];
145
+
146
+                  if($planet_type == PT_MOON && $fleetarray[SHIP_HUGE_DEATH_STAR]) {
147
+                    $missiontype[MT_DESTROY] = $lang['type_mission'][MT_DESTROY];
148
+                  }
148 149
                 }
149 150
               }
150 151
             }
151 152
           }
152 153
         }
153 154
       }
154
-    }
155
-
156
-    if (!$target_mission && is_array($missiontype)) {
157
-      $target_mission = MT_ATTACK;
158
-    }
159
-
160
-//    $sn_group_missions = sn_get_groups('missions');
161
-//    foreach($sn_group_missions as $mission_id => $cork) {
162
-//      $missiontype[$mission_id] = $lang['type_mission'][$mission_id];
163
-//    }
164
-//
165
-//
166
-    ksort($missiontype);
167
-
168
-    $speed_percent = sys_get_param_int('speed', 10);
169
-    $travel_data   = flt_travel_data($user, $planetrow, array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet), $fleetarray, $speed_percent);
170
-
171
-//    $fleet_speed   = flt_fleet_speed($user, $fleetarray);
172
-    $fleet_speed   = $travel_data['fleet_speed'];
173
-    $distance      = $travel_data['distance'];
174
-    $duration      = $travel_data['duration'];
175
-    $consumption   = $travel_data['consumption'];
176
-  // No Break
177
-
178
-  case 1:
179
-    if ($galaxy && $system && $planet) {
180
-      $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
181
-
182
-      $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type);
183
-    }
184
-
185
-  case 0:
186
-    $template_result += array(
187
-      'thisgalaxy'      => $planetrow['galaxy'],
188
-      'thissystem'      => $planetrow['system'],
189
-      'thisplanet'      => $planetrow['planet'],
190
-      'thisplanet_type' => $planetrow['planet_type'],
191
-    );
192
-  // no break
155
+
156
+      if (!$target_mission && is_array($missiontype)) {
157
+        $target_mission = MT_ATTACK;
158
+      }
159
+
160
+  //    $sn_group_missions = sn_get_groups('missions');
161
+  //    foreach($sn_group_missions as $mission_id => $cork) {
162
+  //      $missiontype[$mission_id] = $lang['type_mission'][$mission_id];
163
+  //    }
164
+  //
165
+  //
166
+      ksort($missiontype);
167
+
168
+      $speed_percent = sys_get_param_int('speed', 10);
169
+      $travel_data   = flt_travel_data($user, $planetrow, array('galaxy' => $galaxy, 'system' => $system, 'planet' => $planet), $fleetarray, $speed_percent);
170
+
171
+  //    $fleet_speed   = flt_fleet_speed($user, $fleetarray);
172
+      $fleet_speed   = $travel_data['fleet_speed'];
173
+      $distance      = $travel_data['distance'];
174
+      $duration      = $travel_data['duration'];
175
+      $consumption   = $travel_data['consumption'];
176
+    // No Break
177
+
178
+    case 1:
179
+      if ($galaxy && $system && $planet) {
180
+        $check_type = $planet_type == PT_MOON ? PT_MOON : PT_PLANET;
181
+
182
+        $TargetPlanet = DBStaticPlanet::db_planet_by_gspt($galaxy, $system, $planet, $check_type);
183
+      }
184
+
185
+    case 0:
186
+      $template_result += array(
187
+        'thisgalaxy'      => $planetrow['galaxy'],
188
+        'thissystem'      => $planetrow['system'],
189
+        'thisplanet'      => $planetrow['planet'],
190
+        'thisplanet_type' => $planetrow['planet_type'],
191
+      );
192
+    // no break
193 193
 
194 194
 }
195 195
 
@@ -211,35 +211,35 @@  discard block
 block discarded – undo
211 211
 }
212 212
 
213 213
 switch($fleet_page) {
214
-  case 1:
215
-    require('includes/includes/flt_page1.inc');
216
-  break;
217
-
218
-  case 2:
219
-    require_once('includes/includes/flt_page2.inc');
220
-    sn_fleet_page2();
221
-  break;
222
-
223
-  case 3:
224
-    require_once('includes/includes/flt_page3.inc');
225
-    sn_fleet_page3();
226
-  break;
227
-
228
-  case 4:
229
-    require('includes/includes/flt_page4.inc');
230
-  break;
231
-
232
-  case 5:
233
-    $template = gettemplate('fleet5', true);
234
-    $pageFleet5Gathering = new \Deprecated\PageFleet5Gathering();
235
-    $pageFleet5Gathering->modelFleet5Gathering($user, $planetrow, $template);
236
-    // Building list of own planets & moons
237
-    $pageFleet5Gathering->viewPage5Gathering($user, $planetrow, $template);
238
-  break;
239
-
240
-  default:
241
-    define('SN_RENDER_NAVBAR_PLANET', true);
242
-
243
-    require('includes/includes/flt_page0.inc');
244
-  break;
214
+    case 1:
215
+      require('includes/includes/flt_page1.inc');
216
+    break;
217
+
218
+    case 2:
219
+      require_once('includes/includes/flt_page2.inc');
220
+      sn_fleet_page2();
221
+    break;
222
+
223
+    case 3:
224
+      require_once('includes/includes/flt_page3.inc');
225
+      sn_fleet_page3();
226
+    break;
227
+
228
+    case 4:
229
+      require('includes/includes/flt_page4.inc');
230
+    break;
231
+
232
+    case 5:
233
+      $template = gettemplate('fleet5', true);
234
+      $pageFleet5Gathering = new \Deprecated\PageFleet5Gathering();
235
+      $pageFleet5Gathering->modelFleet5Gathering($user, $planetrow, $template);
236
+      // Building list of own planets & moons
237
+      $pageFleet5Gathering->viewPage5Gathering($user, $planetrow, $template);
238
+    break;
239
+
240
+    default:
241
+      define('SN_RENDER_NAVBAR_PLANET', true);
242
+
243
+      require('includes/includes/flt_page0.inc');
244
+    break;
245 245
 }
Please login to merge, or discard this patch.
classes/Meta/Economic/EconomicHelper.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -75,11 +75,11 @@
 block discarded – undo
75 75
    * @return float[] - [int resourceId] -> [float ratesNormalizedToResourceCost]
76 76
    */
77 77
   public function getResourceExchangeIn($resourceId) {
78
-    if(empty($this->resourceExchangeRates[$resourceId])) {
78
+    if (empty($this->resourceExchangeRates[$resourceId])) {
79 79
       $defaultRates = $this->getResourcesExchange();
80 80
 
81 81
       $this->resourceExchangeRates[$resourceId] = [];
82
-      foreach($defaultRates as $defaultResourceId => $defaultRate) {
82
+      foreach ($defaultRates as $defaultResourceId => $defaultRate) {
83 83
         $this->resourceExchangeRates[$resourceId][$defaultResourceId] = $defaultRate / $defaultRates[$resourceId];
84 84
       }
85 85
     }
Please login to merge, or discard this patch.
includes/init.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use \Core\SnBootstrap;
4 4
 
5 5
 // Защита от двойного инита
6
-if(defined('INIT')) {
6
+if (defined('INIT')) {
7 7
   return;
8 8
 }
9 9
 
@@ -116,18 +116,18 @@  discard block
 block discarded – undo
116 116
 // Но нужно, пока у нас есть не MVC-страницы
117 117
 $sn_page_data = $sn_mvc['pages'][$sn_page_name];
118 118
 $sn_page_name_file = 'includes/pages/' . $sn_page_data['filename'] . DOT_PHP_EX;
119
-if($sn_page_name) {
119
+if ($sn_page_name) {
120 120
   // Merging page options to global option pull
121
-  if(is_array($sn_page_data['options'])) {
121
+  if (is_array($sn_page_data['options'])) {
122 122
     classSupernova::$options = array_merge(classSupernova::$options, $sn_page_data['options']);
123 123
   }
124 124
 
125
-  if(isset($sn_page_data) && file_exists($sn_page_name_file)) {
125
+  if (isset($sn_page_data) && file_exists($sn_page_name_file)) {
126 126
     require_once($sn_page_name_file);
127 127
   }
128 128
 }
129 129
 
130
-if((defined('IN_AJAX') && IN_AJAX === true) || (defined('IN_ADMIN') && IN_ADMIN === true)) {
130
+if ((defined('IN_AJAX') && IN_AJAX === true) || (defined('IN_ADMIN') && IN_ADMIN === true)) {
131 131
   classSupernova::$options['fleet_update_skip'] = true;
132 132
 }
133 133
 
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
 $load_order = array();
142 142
 $sn_req = array();
143 143
 
144
-foreach($sn_module as $loaded_module_name => $module_data) {
144
+foreach ($sn_module as $loaded_module_name => $module_data) {
145 145
   $load_order[$loaded_module_name] = isset($module_data->manifest['load_order']) && !empty($module_data->manifest['load_order']) ? $module_data->manifest['load_order'] : 100000;
146
-  if(isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) {
147
-    foreach($module_data->manifest['require'] as $require_name) {
146
+  if (isset($module_data->manifest['require']) && !empty($module_data->manifest['require'])) {
147
+    foreach ($module_data->manifest['require'] as $require_name) {
148 148
       $sn_req[$loaded_module_name][$require_name] = 0;
149 149
     }
150 150
   }
@@ -155,10 +155,10 @@  discard block
 block discarded – undo
155 155
 do {
156 156
   $prev_order = $load_order;
157 157
 
158
-  foreach($sn_req as $loaded_module_name => &$req_data) {
158
+  foreach ($sn_req as $loaded_module_name => &$req_data) {
159 159
     $level = 1;
160
-    foreach($req_data as $req_name => &$req_level) {
161
-      if($load_order[$req_name] == -1 || !isset($load_order[$req_name])) {
160
+    foreach ($req_data as $req_name => &$req_level) {
161
+      if ($load_order[$req_name] == -1 || !isset($load_order[$req_name])) {
162 162
         $level = $req_level = -1;
163 163
         break;
164 164
       } else {
@@ -166,21 +166,21 @@  discard block
 block discarded – undo
166 166
       }
167 167
       $req_level = $load_order[$req_name];
168 168
     }
169
-    if($level > $load_order[$loaded_module_name] || $level == -1) {
169
+    if ($level > $load_order[$loaded_module_name] || $level == -1) {
170 170
       $load_order[$loaded_module_name] = $level;
171 171
     }
172 172
   }
173 173
 }
174
-while($prev_order != $load_order);
174
+while ($prev_order != $load_order);
175 175
 
176 176
 asort($load_order);
177 177
 
178 178
 // Инициализируем модули
179 179
 // По нормальным делам это должна быть загрузка модулей и лишь затем инициализация - что бы минимизировать размер процесса в памяти
180
-foreach($load_order as $loaded_module_name => $load_order_order) {
181
-  if($load_order_order >= 0) {
180
+foreach ($load_order as $loaded_module_name => $load_order_order) {
181
+  if ($load_order_order >= 0) {
182 182
     $sn_module[$loaded_module_name]->check_status();
183
-    if(!$sn_module[$loaded_module_name]->manifest['active']) {
183
+    if (!$sn_module[$loaded_module_name]->manifest['active']) {
184 184
       unset($sn_module[$loaded_module_name]);
185 185
       continue;
186 186
     }
@@ -198,29 +198,29 @@  discard block
 block discarded – undo
198 198
 
199 199
 // А теперь проверяем - поддерживают ли у нас загруженный код такую страницу
200 200
 // TODO - костыль, что бы работали старые модули. Убрать!
201
-if(is_array($sn_data['pages'])) {
201
+if (is_array($sn_data['pages'])) {
202 202
   $sn_mvc['pages'] = array_merge($sn_mvc['pages'], $sn_data['pages']);
203 203
 }
204
-if(!isset($sn_mvc['pages'][$sn_page_name])) {
204
+if (!isset($sn_mvc['pages'][$sn_page_name])) {
205 205
   $sn_page_name = '';
206 206
 }
207 207
 
208 208
 $lang->lng_switch(sys_get_param_str('lang'));
209 209
 
210 210
 
211
-if(classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) {
211
+if (classSupernova::$config->server_updater_check_auto && classSupernova::$config->server_updater_check_last + classSupernova::$config->server_updater_check_period <= SN_TIME_NOW) {
212 212
   \Tools\VersionCheckerDeprecated::performCheckVersion();
213 213
 }
214 214
 
215
-if(classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) {
215
+if (classSupernova::$config->user_birthday_gift && SN_TIME_NOW - classSupernova::$config->user_birthday_celebrate > PERIOD_DAY) {
216 216
   require_once(SN_ROOT_PHYSICAL . 'includes/includes/user_birthday_celebrate.php');
217 217
   sn_user_birthday_celebrate();
218 218
 }
219 219
 
220
-if(!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) {
220
+if (!classSupernova::$config->var_online_user_count || classSupernova::$config->var_online_user_time + 30 < SN_TIME_NOW) {
221 221
   classSupernova::$config->db_saveItem('var_online_user_count', db_user_count(true));
222 222
   classSupernova::$config->db_saveItem('var_online_user_time', SN_TIME_NOW);
223
-  if(classSupernova::$config->server_log_online) {
223
+  if (classSupernova::$config->server_log_online) {
224 224
     doquery("INSERT IGNORE INTO {{log_users_online}} SET online_count = " . classSupernova::$config->var_online_user_count . ";");
225 225
   }
226 226
 }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
 $template_result[F_ACCOUNT_IS_AUTHORIZED] = $sys_user_logged_in = !empty($user) && isset($user['id']) && $user['id'];
245 245
 
246
-if(!empty($user['id'])) {
246
+if (!empty($user['id'])) {
247 247
   classSupernova::$user_options->user_change($user['id']);
248 248
 }
249 249
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         : false
257 257
       );
258 258
 
259
-if($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
259
+if ($template_result[F_LOGIN_STATUS] == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
260 260
   $prohibited_characters = array_map(function($value) {
261 261
     return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
262 262
   }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 }
265 265
 
266 266
 
267
-if(defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
267
+if (defined('DEBUG_AUTH') && DEBUG_AUTH && !defined('IN_AJAX')) {
268 268
   pdump('Отключи отладку перед продакшном!');
269 269
 }
270 270
 
@@ -278,17 +278,17 @@  discard block
 block discarded – undo
278 278
 
279 279
 StatUpdateLauncher::unlock();
280 280
 
281
-if($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) {
281
+if ($template_result[F_GAME_DISABLE] = classSupernova::$config->game_disable) {
282 282
   $template_result[F_GAME_DISABLE_REASON] = HelperString::nl2br(
283 283
     classSupernova::$config->game_disable == GAME_DISABLE_REASON
284 284
       ? classSupernova::$config->game_disable_reason
285 285
       : $lang['sys_game_disable_reason'][classSupernova::$config->game_disable]
286 286
   );
287
-  if(defined('IN_API')) {
287
+  if (defined('IN_API')) {
288 288
     return;
289 289
   }
290 290
 
291
-  if(
291
+  if (
292 292
     ($user['authlevel'] < 1 || !(defined('IN_ADMIN') && IN_ADMIN))
293 293
     &&
294 294
     !(defined('INSTALL_MODE') && defined('LOGIN_LOGOUT'))
@@ -301,8 +301,8 @@  discard block
 block discarded – undo
301 301
 
302 302
 // TODO ban
303 303
 // TODO $skip_ban_check
304
-if($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
305
-  if(defined('IN_API')) {
304
+if ($template_result[F_BANNED_STATUS] && !$skip_ban_check) {
305
+  if (defined('IN_API')) {
306 306
     return;
307 307
   }
308 308
 
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
 $allow_anonymous = $allow_anonymous || (isset($sn_page_data['allow_anonymous']) && $sn_page_data['allow_anonymous']);
317 317
 
318 318
 
319
-if($sys_user_logged_in && INITIAL_PAGE == 'login') {
319
+if ($sys_user_logged_in && INITIAL_PAGE == 'login') {
320 320
   sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
321
-} elseif($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
322
-} elseif(!$allow_anonymous && !$sys_user_logged_in) {
321
+} elseif ($account_logged_in && !$sys_user_logged_in) { // empty(core_auth::$user['id'])
322
+} elseif (!$allow_anonymous && !$sys_user_logged_in) {
323 323
   sys_redirect(SN_ROOT_VIRTUAL . 'login.php');
324 324
 }
325 325
 
@@ -343,7 +343,7 @@  discard block
 block discarded – undo
343 343
   'fleet_update_last',
344 344
   classSupernova::$config->fleet_update_interval,
345 345
   // Promise
346
-  function () {classSupernova::$gc->fleetDispatcher->dispatch();},
346
+  function() {classSupernova::$gc->fleetDispatcher->dispatch(); },
347 347
   WATCHDOG_TIME_SQL,
348 348
   false
349 349
 );
Please login to merge, or discard this patch.
classes/phpbb_hook.php 3 patches
Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 */
17 17
 if (!defined('IN_PHPBB'))
18 18
 {
19
-	exit;
19
+  exit;
20 20
 }
21 21
 
22 22
 /**
@@ -24,227 +24,227 @@  discard block
 block discarded – undo
24 24
 */
25 25
 class phpbb_hook
26 26
 {
27
-	/**
28
-	* Registered hooks
29
-	*/
30
-	var $hooks = array();
31
-
32
-	/**
33
-	* Results returned by functions called
34
-	*/
35
-	var $hook_result = array();
36
-
37
-	/**
38
-	* internal pointer
39
-	*/
40
-	var $current_hook = NULL;
41
-
42
-	/**
43
-	* Initialize hook class.
44
-	*
45
-	* @param array $valid_hooks array containing the hookable functions/methods
46
-	*/
47
-	function phpbb_hook($valid_hooks)
48
-	{
49
-		foreach ($valid_hooks as $_null => $method)
50
-		{
51
-			$this->add_hook($method);
52
-		}
53
-
54
-		if (function_exists('phpbb_hook_register'))
55
-		{
56
-			phpbb_hook_register($this);
57
-		}
58
-	}
59
-
60
-	/**
61
-	* Register function/method to be called within hook
62
-	* This function is normally called by the modification/application to attach/register the functions.
63
-	*
64
-	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
65
-	* @param mixed $hook The replacement function/method to be called. Passing function name or array with object/class definition
66
-	* @param string $mode Specify the priority/chain mode. 'normal' -> hook gets appended to the chain. 'standalone' -> only the specified hook gets called - later hooks are not able to overwrite this (E_NOTICE is triggered then). 'first' -> hook is called as the first one within the chain. 'last' -> hook is called as the last one within the chain.
67
-	*/
68
-	function register($definition, $hook, $mode = 'normal')
69
-	{
70
-		$class = (!is_array($definition)) ? '__global' : $definition[0];
71
-		$function = (!is_array($definition)) ? $definition : $definition[1];
72
-
73
-		// Method able to be hooked?
74
-		if (isset($this->hooks[$class][$function]))
75
-		{
76
-			switch ($mode)
77
-			{
78
-				case 'standalone':
79
-					if (!isset($this->hooks[$class][$function]['standalone']))
80
-					{
81
-						$this->hooks[$class][$function] = array('standalone' => $hook);
82
-					}
83
-					else
84
-					{
85
-						trigger_error('Hook not able to be called standalone, previous hook already standalone.', E_NOTICE);
86
-					}
87
-				break;
88
-
89
-				case 'first':
90
-				case 'last':
91
-					$this->hooks[$class][$function][$mode][] = $hook;
92
-				break;
93
-
94
-				case 'normal':
95
-				default:
96
-					$this->hooks[$class][$function]['normal'][] = $hook;
97
-				break;
98
-			}
99
-		}
100
-	}
101
-
102
-	/**
103
-	* Calling all functions/methods attached to a specified hook.
104
-	* Called by the function allowing hooks...
105
-	*
106
-	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
107
-	* @return bool False if no hook got executed, true otherwise
108
-	*/
109
-	function call_hook($definition)
110
-	{
111
-		$class = (!is_array($definition)) ? '__global' : $definition[0];
112
-		$function = (!is_array($definition)) ? $definition : $definition[1];
113
-
114
-		if (!empty($this->hooks[$class][$function]))
115
-		{
116
-			// Developer tries to call a hooked function within the hooked function...
117
-			if ($this->current_hook !== NULL && $this->current_hook['class'] === $class && $this->current_hook['function'] === $function)
118
-			{
119
-				return false;
120
-			}
121
-
122
-			// Call the hook with the arguments attached and store result
123
-			$arguments = func_get_args();
124
-			$this->current_hook = array('class' => $class, 'function' => $function);
125
-			$arguments[0] = &$this;
126
-
127
-			// Call the hook chain...
128
-			if (isset($this->hooks[$class][$function]['standalone']))
129
-			{
130
-				$this->hook_result[$class][$function] = call_user_func_array($this->hooks[$class][$function]['standalone'], $arguments);
131
-			}
132
-			else
133
-			{
134
-				foreach (array('first', 'normal', 'last') as $mode)
135
-				{
136
-					if (!isset($this->hooks[$class][$function][$mode]))
137
-					{
138
-						continue;
139
-					}
140
-
141
-					foreach ($this->hooks[$class][$function][$mode] as $hook)
142
-					{
143
-						$this->hook_result[$class][$function] = call_user_func_array($hook, $arguments);
144
-					}
145
-				}
146
-			}
147
-
148
-			$this->current_hook = NULL;
149
-			return true;
150
-		}
151
-
152
-		$this->current_hook = NULL;
153
-		return false;
154
-	}
155
-
156
-	/**
157
-	* Get result from previously called functions/methods for the same hook
158
-	*
159
-	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
160
-	* @return mixed False if nothing returned if there is no result, else array('result' => ... )
161
-	*/
162
-	function previous_hook_result($definition)
163
-	{
164
-		$class = (!is_array($definition)) ? '__global' : $definition[0];
165
-		$function = (!is_array($definition)) ? $definition : $definition[1];
166
-
167
-		if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
168
-		{
169
-			return array('result' => $this->hook_result[$class][$function]);
170
-		}
171
-
172
-		return false;
173
-	}
174
-
175
-	/**
176
-	* Check if the called functions/methods returned something.
177
-	*
178
-	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
179
-	* @return bool True if results are there, false if not
180
-	*/
181
-	function hook_return($definition)
182
-	{
183
-		$class = (!is_array($definition)) ? '__global' : $definition[0];
184
-		$function = (!is_array($definition)) ? $definition : $definition[1];
185
-
186
-		if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
187
-		{
188
-			return true;
189
-		}
190
-
191
-		return false;
192
-	}
193
-
194
-	/**
195
-	* Give actual result from called functions/methods back.
196
-	*
197
-	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
198
-	* @return mixed The result
199
-	*/
200
-	function hook_return_result($definition)
201
-	{
202
-		$class = (!is_array($definition)) ? '__global' : $definition[0];
203
-		$function = (!is_array($definition)) ? $definition : $definition[1];
204
-
205
-		if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
206
-		{
207
-			$result = $this->hook_result[$class][$function];
208
-			unset($this->hook_result[$class][$function]);
209
-			return $result;
210
-		}
211
-
212
-		return;
213
-	}
214
-
215
-	/**
216
-	* Add new function to the allowed hooks.
217
-	*
218
-	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
219
-	*/
220
-	function add_hook($definition)
221
-	{
222
-		if (!is_array($definition))
223
-		{
224
-			$definition = array('__global', $definition);
225
-		}
226
-
227
-		$this->hooks[$definition[0]][$definition[1]] = array();
228
-	}
229
-
230
-	/**
231
-	* Remove function from the allowed hooks.
232
-	*
233
-	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
234
-	*/
235
-	function remove_hook($definition)
236
-	{
237
-		$class = (!is_array($definition)) ? '__global' : $definition[0];
238
-		$function = (!is_array($definition)) ? $definition : $definition[1];
239
-
240
-		if (isset($this->hooks[$class][$function]))
241
-		{
242
-			unset($this->hooks[$class][$function]);
243
-
244
-			if (isset($this->hook_result[$class][$function]))
245
-			{
246
-				unset($this->hook_result[$class][$function]);
247
-			}
248
-		}
249
-	}
27
+  /**
28
+   * Registered hooks
29
+   */
30
+  var $hooks = array();
31
+
32
+  /**
33
+   * Results returned by functions called
34
+   */
35
+  var $hook_result = array();
36
+
37
+  /**
38
+   * internal pointer
39
+   */
40
+  var $current_hook = NULL;
41
+
42
+  /**
43
+   * Initialize hook class.
44
+   *
45
+   * @param array $valid_hooks array containing the hookable functions/methods
46
+   */
47
+  function phpbb_hook($valid_hooks)
48
+  {
49
+    foreach ($valid_hooks as $_null => $method)
50
+    {
51
+      $this->add_hook($method);
52
+    }
53
+
54
+    if (function_exists('phpbb_hook_register'))
55
+    {
56
+      phpbb_hook_register($this);
57
+    }
58
+  }
59
+
60
+  /**
61
+   * Register function/method to be called within hook
62
+   * This function is normally called by the modification/application to attach/register the functions.
63
+   *
64
+   * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
65
+   * @param mixed $hook The replacement function/method to be called. Passing function name or array with object/class definition
66
+   * @param string $mode Specify the priority/chain mode. 'normal' -> hook gets appended to the chain. 'standalone' -> only the specified hook gets called - later hooks are not able to overwrite this (E_NOTICE is triggered then). 'first' -> hook is called as the first one within the chain. 'last' -> hook is called as the last one within the chain.
67
+   */
68
+  function register($definition, $hook, $mode = 'normal')
69
+  {
70
+    $class = (!is_array($definition)) ? '__global' : $definition[0];
71
+    $function = (!is_array($definition)) ? $definition : $definition[1];
72
+
73
+    // Method able to be hooked?
74
+    if (isset($this->hooks[$class][$function]))
75
+    {
76
+      switch ($mode)
77
+      {
78
+        case 'standalone':
79
+          if (!isset($this->hooks[$class][$function]['standalone']))
80
+          {
81
+            $this->hooks[$class][$function] = array('standalone' => $hook);
82
+          }
83
+          else
84
+          {
85
+            trigger_error('Hook not able to be called standalone, previous hook already standalone.', E_NOTICE);
86
+          }
87
+        break;
88
+
89
+        case 'first':
90
+        case 'last':
91
+          $this->hooks[$class][$function][$mode][] = $hook;
92
+        break;
93
+
94
+        case 'normal':
95
+        default:
96
+          $this->hooks[$class][$function]['normal'][] = $hook;
97
+        break;
98
+      }
99
+    }
100
+  }
101
+
102
+  /**
103
+   * Calling all functions/methods attached to a specified hook.
104
+   * Called by the function allowing hooks...
105
+   *
106
+   * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
107
+   * @return bool False if no hook got executed, true otherwise
108
+   */
109
+  function call_hook($definition)
110
+  {
111
+    $class = (!is_array($definition)) ? '__global' : $definition[0];
112
+    $function = (!is_array($definition)) ? $definition : $definition[1];
113
+
114
+    if (!empty($this->hooks[$class][$function]))
115
+    {
116
+      // Developer tries to call a hooked function within the hooked function...
117
+      if ($this->current_hook !== NULL && $this->current_hook['class'] === $class && $this->current_hook['function'] === $function)
118
+      {
119
+        return false;
120
+      }
121
+
122
+      // Call the hook with the arguments attached and store result
123
+      $arguments = func_get_args();
124
+      $this->current_hook = array('class' => $class, 'function' => $function);
125
+      $arguments[0] = &$this;
126
+
127
+      // Call the hook chain...
128
+      if (isset($this->hooks[$class][$function]['standalone']))
129
+      {
130
+        $this->hook_result[$class][$function] = call_user_func_array($this->hooks[$class][$function]['standalone'], $arguments);
131
+      }
132
+      else
133
+      {
134
+        foreach (array('first', 'normal', 'last') as $mode)
135
+        {
136
+          if (!isset($this->hooks[$class][$function][$mode]))
137
+          {
138
+            continue;
139
+          }
140
+
141
+          foreach ($this->hooks[$class][$function][$mode] as $hook)
142
+          {
143
+            $this->hook_result[$class][$function] = call_user_func_array($hook, $arguments);
144
+          }
145
+        }
146
+      }
147
+
148
+      $this->current_hook = NULL;
149
+      return true;
150
+    }
151
+
152
+    $this->current_hook = NULL;
153
+    return false;
154
+  }
155
+
156
+  /**
157
+   * Get result from previously called functions/methods for the same hook
158
+   *
159
+   * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
160
+   * @return mixed False if nothing returned if there is no result, else array('result' => ... )
161
+   */
162
+  function previous_hook_result($definition)
163
+  {
164
+    $class = (!is_array($definition)) ? '__global' : $definition[0];
165
+    $function = (!is_array($definition)) ? $definition : $definition[1];
166
+
167
+    if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
168
+    {
169
+      return array('result' => $this->hook_result[$class][$function]);
170
+    }
171
+
172
+    return false;
173
+  }
174
+
175
+  /**
176
+   * Check if the called functions/methods returned something.
177
+   *
178
+   * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
179
+   * @return bool True if results are there, false if not
180
+   */
181
+  function hook_return($definition)
182
+  {
183
+    $class = (!is_array($definition)) ? '__global' : $definition[0];
184
+    $function = (!is_array($definition)) ? $definition : $definition[1];
185
+
186
+    if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
187
+    {
188
+      return true;
189
+    }
190
+
191
+    return false;
192
+  }
193
+
194
+  /**
195
+   * Give actual result from called functions/methods back.
196
+   *
197
+   * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
198
+   * @return mixed The result
199
+   */
200
+  function hook_return_result($definition)
201
+  {
202
+    $class = (!is_array($definition)) ? '__global' : $definition[0];
203
+    $function = (!is_array($definition)) ? $definition : $definition[1];
204
+
205
+    if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
206
+    {
207
+      $result = $this->hook_result[$class][$function];
208
+      unset($this->hook_result[$class][$function]);
209
+      return $result;
210
+    }
211
+
212
+    return;
213
+  }
214
+
215
+  /**
216
+   * Add new function to the allowed hooks.
217
+   *
218
+   * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
219
+   */
220
+  function add_hook($definition)
221
+  {
222
+    if (!is_array($definition))
223
+    {
224
+      $definition = array('__global', $definition);
225
+    }
226
+
227
+    $this->hooks[$definition[0]][$definition[1]] = array();
228
+  }
229
+
230
+  /**
231
+   * Remove function from the allowed hooks.
232
+   *
233
+   * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
234
+   */
235
+  function remove_hook($definition)
236
+  {
237
+    $class = (!is_array($definition)) ? '__global' : $definition[0];
238
+    $function = (!is_array($definition)) ? $definition : $definition[1];
239
+
240
+    if (isset($this->hooks[$class][$function]))
241
+    {
242
+      unset($this->hooks[$class][$function]);
243
+
244
+      if (isset($this->hook_result[$class][$function]))
245
+      {
246
+        unset($this->hook_result[$class][$function]);
247
+      }
248
+    }
249
+  }
250 250
 }
Please login to merge, or discard this patch.
Braces   +11 added lines, -22 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
22 22
 /**
23 23
 * phpBB Hook Class
24 24
 */
25
-class phpbb_hook
26
-{
25
+class phpbb_hook {
27 26
 	/**
28 27
 	* Registered hooks
29 28
 	*/
@@ -44,8 +43,7 @@  discard block
 block discarded – undo
44 43
 	*
45 44
 	* @param array $valid_hooks array containing the hookable functions/methods
46 45
 	*/
47
-	function phpbb_hook($valid_hooks)
48
-	{
46
+	function phpbb_hook($valid_hooks) {
49 47
 		foreach ($valid_hooks as $_null => $method)
50 48
 		{
51 49
 			$this->add_hook($method);
@@ -65,8 +63,7 @@  discard block
 block discarded – undo
65 63
 	* @param mixed $hook The replacement function/method to be called. Passing function name or array with object/class definition
66 64
 	* @param string $mode Specify the priority/chain mode. 'normal' -> hook gets appended to the chain. 'standalone' -> only the specified hook gets called - later hooks are not able to overwrite this (E_NOTICE is triggered then). 'first' -> hook is called as the first one within the chain. 'last' -> hook is called as the last one within the chain.
67 65
 	*/
68
-	function register($definition, $hook, $mode = 'normal')
69
-	{
66
+	function register($definition, $hook, $mode = 'normal') {
70 67
 		$class = (!is_array($definition)) ? '__global' : $definition[0];
71 68
 		$function = (!is_array($definition)) ? $definition : $definition[1];
72 69
 
@@ -79,8 +76,7 @@  discard block
 block discarded – undo
79 76
 					if (!isset($this->hooks[$class][$function]['standalone']))
80 77
 					{
81 78
 						$this->hooks[$class][$function] = array('standalone' => $hook);
82
-					}
83
-					else
79
+					} else
84 80
 					{
85 81
 						trigger_error('Hook not able to be called standalone, previous hook already standalone.', E_NOTICE);
86 82
 					}
@@ -106,8 +102,7 @@  discard block
 block discarded – undo
106 102
 	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
107 103
 	* @return bool False if no hook got executed, true otherwise
108 104
 	*/
109
-	function call_hook($definition)
110
-	{
105
+	function call_hook($definition) {
111 106
 		$class = (!is_array($definition)) ? '__global' : $definition[0];
112 107
 		$function = (!is_array($definition)) ? $definition : $definition[1];
113 108
 
@@ -128,8 +123,7 @@  discard block
 block discarded – undo
128 123
 			if (isset($this->hooks[$class][$function]['standalone']))
129 124
 			{
130 125
 				$this->hook_result[$class][$function] = call_user_func_array($this->hooks[$class][$function]['standalone'], $arguments);
131
-			}
132
-			else
126
+			} else
133 127
 			{
134 128
 				foreach (array('first', 'normal', 'last') as $mode)
135 129
 				{
@@ -159,8 +153,7 @@  discard block
 block discarded – undo
159 153
 	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
160 154
 	* @return mixed False if nothing returned if there is no result, else array('result' => ... )
161 155
 	*/
162
-	function previous_hook_result($definition)
163
-	{
156
+	function previous_hook_result($definition) {
164 157
 		$class = (!is_array($definition)) ? '__global' : $definition[0];
165 158
 		$function = (!is_array($definition)) ? $definition : $definition[1];
166 159
 
@@ -178,8 +171,7 @@  discard block
 block discarded – undo
178 171
 	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
179 172
 	* @return bool True if results are there, false if not
180 173
 	*/
181
-	function hook_return($definition)
182
-	{
174
+	function hook_return($definition) {
183 175
 		$class = (!is_array($definition)) ? '__global' : $definition[0];
184 176
 		$function = (!is_array($definition)) ? $definition : $definition[1];
185 177
 
@@ -197,8 +189,7 @@  discard block
 block discarded – undo
197 189
 	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
198 190
 	* @return mixed The result
199 191
 	*/
200
-	function hook_return_result($definition)
201
-	{
192
+	function hook_return_result($definition) {
202 193
 		$class = (!is_array($definition)) ? '__global' : $definition[0];
203 194
 		$function = (!is_array($definition)) ? $definition : $definition[1];
204 195
 
@@ -217,8 +208,7 @@  discard block
 block discarded – undo
217 208
 	*
218 209
 	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
219 210
 	*/
220
-	function add_hook($definition)
221
-	{
211
+	function add_hook($definition) {
222 212
 		if (!is_array($definition))
223 213
 		{
224 214
 			$definition = array('__global', $definition);
@@ -232,8 +222,7 @@  discard block
 block discarded – undo
232 222
 	*
233 223
 	* @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
234 224
 	*/
235
-	function remove_hook($definition)
236
-	{
225
+	function remove_hook($definition) {
237 226
 		$class = (!is_array($definition)) ? '__global' : $definition[0];
238 227
 		$function = (!is_array($definition)) ? $definition : $definition[1];
239 228
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	/**
38 38
 	* internal pointer
39 39
 	*/
40
-	var $current_hook = NULL;
40
+	var $current_hook = null;
41 41
 
42 42
 	/**
43 43
 	* Initialize hook class.
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 		if (!empty($this->hooks[$class][$function]))
115 115
 		{
116 116
 			// Developer tries to call a hooked function within the hooked function...
117
-			if ($this->current_hook !== NULL && $this->current_hook['class'] === $class && $this->current_hook['function'] === $function)
117
+			if ($this->current_hook !== null && $this->current_hook['class'] === $class && $this->current_hook['function'] === $function)
118 118
 			{
119 119
 				return false;
120 120
 			}
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
 				}
146 146
 			}
147 147
 
148
-			$this->current_hook = NULL;
148
+			$this->current_hook = null;
149 149
 			return true;
150 150
 		}
151 151
 
152
-		$this->current_hook = NULL;
152
+		$this->current_hook = null;
153 153
 		return false;
154 154
 	}
155 155
 
Please login to merge, or discard this patch.
admin/admin_analyze_matter.php 1 patch
Spacing   +8 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 
16 16
 $constants = get_defined_constants(true);
17 17
 $rpgConstants = array();
18
-foreach($constants['user'] as $constantName => $constantValue) {
19
-  if(substr($constantName, 0, 4) == 'RPG_') {
18
+foreach ($constants['user'] as $constantName => $constantValue) {
19
+  if (substr($constantName, 0, 4) == 'RPG_') {
20 20
     $rpgConstants[$constantValue] = $constantName;
21 21
   }
22 22
 }
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 GROUP BY log_dark_matter_reason, IF(sign((log_dark_matter_amount)) > 0, 1, -1) ORDER BY sum(log_dark_matter_amount) DESC;
34 34
 ");
35 35
 
36
-while($row = classSupernova::$db->db_fetch($result)) {
36
+while ($row = classSupernova::$db->db_fetch($result)) {
37 37
   $row['CONSTANT'] = $rpgConstants[$row['REASON']];
38 38
 
39 39
   $row['DM_AMOUNT_TEXT'] = HelperString::numberFloorAndFormat($row['DM_AMOUNT']);
@@ -55,8 +55,8 @@  discard block
 block discarded – undo
55 55
 GROUP BY reason, if(sign((amount)) > 0, 1, -1) ORDER BY sum(amount) DESC;
56 56
 ");
57 57
 
58
-while($row = classSupernova::$db->db_fetch($result)) {
59
-  if(empty($spent[$row['BALANCE']])) {
58
+while ($row = classSupernova::$db->db_fetch($result)) {
59
+  if (empty($spent[$row['BALANCE']])) {
60 60
     $spent[$row['BALANCE']] = array();
61 61
   }
62 62
 
@@ -66,16 +66,15 @@  discard block
 block discarded – undo
66 66
   $spent[$row['BALANCE']] = array_merge_recursive_numeric($spent[$row['BALANCE']], $row);
67 67
 }
68 68
 
69
-foreach($spent as &$row) {
69
+foreach ($spent as &$row) {
70 70
   @$row['TOTAL_COUNT'] = $row['MM_COUNT'] + $row['DM_COUNT'];
71 71
   @$row['TOTAL_AMOUNT'] = $row['MM_AMOUNT'] + $row['DM_AMOUNT'];
72 72
   @$row['TOTAL_AMOUNT_TEXT'] = HelperString::numberFloorAndFormat($row['TOTAL_AMOUNT']);
73 73
   @$row['TOTAL_COUNT_TEXT'] = HelperString::numberFloorAndFormat($row['TOTAL_COUNT']);
74 74
 }
75 75
 
76
-usort($spent, function ($a, $b) {
77
-  return $a['TOTAL_AMOUNT'] < $b['TOTAL_AMOUNT'] ? -1 :
78
-    ($a['TOTAL_AMOUNT'] > $b['TOTAL_AMOUNT'] ? 1 : 0);
76
+usort($spent, function($a, $b) {
77
+  return $a['TOTAL_AMOUNT'] < $b['TOTAL_AMOUNT'] ? -1 : ($a['TOTAL_AMOUNT'] > $b['TOTAL_AMOUNT'] ? 1 : 0);
79 78
 });
80 79
 
81 80
 
Please login to merge, or discard this patch.