Test Failed
Push — trunk ( cc4c01...dc8fe4 )
by SuperNova.WS
13:09
created
classes/_SnCacheInternal.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
     //print("<br />CACHE CLEAR {$cache_id} " . ($hard ? 'HARD' : 'SOFT') . "<br />");
53 53
     if ($hard && !empty(_SnCacheInternal::$data[$location_type])) {
54 54
       // Здесь нельзя делать unset - надо записывать NULL, что бы это отразилось на зависимых записях
55
-      array_walk(_SnCacheInternal::$data[$location_type], function (&$item) { $item = null; });
55
+      array_walk(_SnCacheInternal::$data[$location_type], function(&$item) { $item = null; });
56 56
     }
57 57
     _SnCacheInternal::$locator[$location_type] = [];
58 58
     _SnCacheInternal::cache_repack($location_type); // Перепаковываем внутренние структуры, если нужно
Please login to merge, or discard this patch.
classes/core_auth.php 1 patch
Spacing   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -192,18 +192,18 @@  discard block
 block discarded – undo
192 192
     // TODO Хотя тут может получится вечный цикл - ПОДУМАТЬ
193 193
     // TODO Тут же можно пробовать провести попытку слияния аккаунтов - хотя это и очень небезопасно
194 194
 
195
-    if(sys_get_param('login_player_register_logout')) {
195
+    if (sys_get_param('login_player_register_logout')) {
196 196
       $this->logout();
197 197
     }
198 198
 
199 199
     $original_suggest = '';
200 200
     // Смотрим - есть ли у нас данные от пользователя
201
-    if(($player_name_submitted = sys_get_param('submit_player_name'))) {
201
+    if (($player_name_submitted = sys_get_param('submit_player_name'))) {
202 202
       // Попытка регистрации нового игрока из данных, введенных пользователем
203 203
       $this->player_suggested_name = sys_get_param_str_unsafe('player_suggested_name');
204 204
     } else {
205
-      foreach($this->providers_authorised as $provider) {
206
-        if($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5
205
+      foreach ($this->providers_authorised as $provider) {
206
+        if ($this->player_suggested_name = $provider->player_name_suggest()) { // OK 4.5
207 207
           $original_suggest = $provider->player_name_suggest();
208 208
           break;
209 209
         }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     }
212 212
 
213 213
     // Если у нас провайдеры не дают имени и пользователь не дал свой вариант - это у нас первый логин в игру
214
-    if(!$this->player_suggested_name) {
214
+    if (!$this->player_suggested_name) {
215 215
       $max_user_id = db_player_get_max_id(); // 4.5
216 216
       // TODO - предлагать имя игрока по локали
217 217
 
@@ -220,15 +220,15 @@  discard block
 block discarded – undo
220 220
         SN::db_transaction_rollback();
221 221
         $this->player_suggested_name = 'Emperor ' . mt_rand($max_user_id + 1, $max_user_id + 1000);
222 222
         SN::db_transaction_start();
223
-      } while(db_player_name_exists($this->player_suggested_name));
223
+      } while (db_player_name_exists($this->player_suggested_name));
224 224
 
225 225
     }
226 226
 
227
-    if($player_name_submitted) {
227
+    if ($player_name_submitted) {
228 228
       $this->register_player_db_create($this->player_suggested_name); // OK 4.5
229
-      if($this->register_status == LOGIN_SUCCESS) {
229
+      if ($this->register_status == LOGIN_SUCCESS) {
230 230
         sys_redirect(SN_ROOT_VIRTUAL . 'overview.php');
231
-      } elseif($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
231
+      } elseif ($this->register_status == REGISTER_ERROR_PLAYER_NAME_EXISTS && $original_suggest == $this->player_suggested_name) {
232 232
         // self::$player_suggested_name .= ' ' . $this->account->account_id;
233 233
       }
234 234
 //      if(self::$login_status != LOGIN_SUCCESS) {
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
         : false
253 253
       );
254 254
 
255
-    if($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
255
+    if ($this->register_status == LOGIN_ERROR_USERNAME_RESTRICTED_CHARACTERS) {
256 256
       $prohibited_characters = array_map(function($value) {
257 257
         return "'" . htmlentities($value, ENT_QUOTES, 'UTF-8') . "'";
258 258
       }, str_split(LOGIN_REGISTER_CHARACTERS_PROHIBITED));
@@ -285,18 +285,18 @@  discard block
 block discarded – undo
285 285
 
286 286
     // !self::$is_init ? self::init() : false;
287 287
 
288
-    if(!SN::$gc->modules->countModulesInGroup('auth')) {
288
+    if (!SN::$gc->modules->countModulesInGroup('auth')) {
289 289
       die('{Не обнаружено ни одного провайдера авторизации в core_auth::login()!}');
290 290
     }
291 291
 
292 292
     !empty($_POST) ? self::flog(dump($_POST, '$_POST')) : false;
293 293
     !empty($_GET) ? self::flog(dump($_GET, '$_GET')) : false;
294
-    !empty($_COOKIE) ? self::flog(dump($_COOKIE,'$_COOKIE')) : false;
294
+    !empty($_COOKIE) ? self::flog(dump($_COOKIE, '$_COOKIE')) : false;
295 295
 
296 296
     $this->auth_reset(); // OK v4.5
297 297
 
298 298
     $this->providers = array();
299
-    foreach(SN::$gc->modules->getModulesInGroup('auth', true) as $module_name => $module) {
299
+    foreach (SN::$gc->modules->getModulesInGroup('auth', true) as $module_name => $module) {
300 300
       /**
301 301
        * @var auth_abstract $module
302 302
        */
@@ -305,10 +305,10 @@  discard block
 block discarded – undo
305 305
 
306 306
     // $this->providers = array_reverse($this->providers, true); // НИНАДА! СН-аккаунт должен всегда авторизироваться первым!
307 307
 //pdump($this->providers);
308
-    foreach($this->providers as $provider_id => $provider) {
308
+    foreach ($this->providers as $provider_id => $provider) {
309 309
       $login_status = $provider->login(); // OK v4.5
310 310
       self::flog(($provider->manifest['name'] . '->' . 'login_try - ') . (empty($provider->account->account_id) ? $lang['sys_login_messages'][$provider->account_login_status] : dump($provider)));
311
-      if($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
311
+      if ($login_status == LOGIN_SUCCESS && is_object($provider->account) && $provider->account instanceof Account && $provider->account->account_id) {
312 312
         $this->providers_authorised[$provider_id] = &$this->providers[$provider_id];
313 313
 
314 314
         $this->user_id_to_provider = array_replace_recursive(
@@ -316,20 +316,20 @@  discard block
 block discarded – undo
316 316
           // static::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5
317 317
           PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id) // OK 4.5
318 318
         );
319
-      } elseif($login_status != LOGIN_UNDEFINED) {
319
+      } elseif ($login_status != LOGIN_UNDEFINED) {
320 320
         $this->provider_error_list[$provider_id] = $login_status;
321 321
       }
322 322
     }
323 323
 
324
-    if(empty($this->providers_authorised)) {
324
+    if (empty($this->providers_authorised)) {
325 325
       // Ни один аккаунт не авторизирован
326 326
       // Проверяем - есть ли у нас ошибки в аккаунтах?
327
-      if(!empty($this->provider_error_list)) {
327
+      if (!empty($this->provider_error_list)) {
328 328
         // Если есть - выводим их
329 329
         self::$login_status = reset($this->provider_error_list);
330 330
         $providerError = $this->providers[key($this->provider_error_list)]->account_login_message;
331 331
 
332
-        if(!empty($providerError)) {
332
+        if (!empty($providerError)) {
333 333
           self::$login_message = $providerError;
334 334
         }
335 335
       }
@@ -344,12 +344,12 @@  discard block
 block discarded – undo
344 344
       // В self::$accessible_user_row_list - список доступных игроков для данных аккаунтов с соответствующими записями из таблицы `users`
345 345
 
346 346
       // Остались ли у нас в списке доступные игроки?
347
-      if(empty($this->accessible_user_row_list)) {
347
+      if (empty($this->accessible_user_row_list)) {
348 348
         // Нет ни одного игрока ни на одном авторизированном аккаунте
349 349
         // Надо регать нового игрока
350 350
 
351 351
         // Сейчас происходит процесс регистрации игрока?
352
-        if(!$this->is_player_register) {
352
+        if (!$this->is_player_register) {
353 353
           // Нет - отправляем на процесс регистрации
354 354
           $partner_id = sys_get_param_int('id_ref', sys_get_param_int('partner_id'));
355 355
           sys_redirect(SN_ROOT_VIRTUAL . 'index.php?page=player_register&player_register=1' . ($partner_id ? '&id_ref=' . $partner_id : ''));
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
         // Да, есть доступные игроки, которые так же прописаны в базе
359 359
         $this->get_active_user(); // 4.5
360 360
 
361
-        if($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) {
361
+        if ($this->is_impersonating = !empty($_COOKIE[SN_COOKIE_U_I]) ? $_COOKIE[SN_COOKIE_U_I] : 0) {
362 362
           $a_user = db_user_by_id($this->is_impersonating);
363 363
           $this->impersonator_username = $a_user['username'];
364 364
         }
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
 
367 367
         //Прописываем текущего игрока на все авторизированные аккаунты
368 368
         // TODO - ИЛИ ВСЕХ ИГРОКОВ??
369
-        if(empty($this->is_impersonating)) {
370
-          foreach($this->providers_authorised as $provider_id => $provider) {
371
-            if(empty($this->user_id_to_provider[self::$user['id']][$provider_id])) {
369
+        if (empty($this->is_impersonating)) {
370
+          foreach ($this->providers_authorised as $provider_id => $provider) {
371
+            if (empty($this->user_id_to_provider[self::$user['id']][$provider_id])) {
372 372
               // self::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']);
373 373
               PlayerToAccountTranslate::db_translate_register_user($provider_id, $provider->account->account_id, self::$user['id']);
374 374
               $this->user_id_to_provider[self::$user['id']][$provider_id][$provider->account->account_id] = true;
@@ -378,9 +378,9 @@  discard block
 block discarded – undo
378 378
       }
379 379
     }
380 380
 
381
-    if(empty(self::$user['id'])) {
381
+    if (empty(self::$user['id'])) {
382 382
       self::cookie_set(''); // OK 4.5
383
-    } elseif(self::$user['id'] != $_COOKIE[SN_COOKIE_U]) {
383
+    } elseif (self::$user['id'] != $_COOKIE[SN_COOKIE_U]) {
384 384
       self::cookie_set(self::$user['id']); // OK 4.5
385 385
     }
386 386
 
@@ -399,21 +399,21 @@  discard block
 block discarded – undo
399 399
    */
400 400
   // OK v4.7
401 401
   public function logout($redirect = true) {
402
-    if(!empty($_COOKIE[SN_COOKIE_U_I])) {
402
+    if (!empty($_COOKIE[SN_COOKIE_U_I])) {
403 403
       self::cookie_set($_COOKIE[SN_COOKIE_U_I]);
404 404
       self::cookie_set(0, true);
405 405
       self::$main_provider->logout();
406 406
     } else {
407
-      foreach($this->providers as $provider_name => $provider) {
407
+      foreach ($this->providers as $provider_name => $provider) {
408 408
         $provider->logout();
409 409
       }
410 410
 
411 411
       self::cookie_set(0);
412 412
     }
413 413
 
414
-    if($redirect === true) {
414
+    if ($redirect === true) {
415 415
       sys_redirect(SN_ROOT_RELATIVE . (empty($_COOKIE[SN_COOKIE_U]) ? 'login.php' : 'admin/overview.php'));
416
-    } elseif($redirect !== false) {
416
+    } elseif ($redirect !== false) {
417 417
       sys_redirect($redirect);
418 418
     }
419 419
   }
@@ -424,15 +424,15 @@  discard block
 block discarded – undo
424 424
    * @param $user_selected
425 425
    */
426 426
   public function impersonate($user_selected) {
427
-    if($_COOKIE[SN_COOKIE_U_I]) {
427
+    if ($_COOKIE[SN_COOKIE_U_I]) {
428 428
       die('You already impersonating someone. Go back to living other\'s life! Or clear your cookies and try again'); // TODO: Log it
429 429
     }
430 430
 
431
-    if($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) {
431
+    if ($this->auth_level_max_local < AUTH_LEVEL_ADMINISTRATOR) {
432 432
       die('You can\'t impersonate - too low level'); // TODO: Log it
433 433
     }
434 434
 
435
-    if($this->auth_level_max_local <= $user_selected['authlevel']) {
435
+    if ($this->auth_level_max_local <= $user_selected['authlevel']) {
436 436
       die('You can\'t impersonate this account - level is greater or equal to yours'); // TODO: Log it
437 437
     }
438 438
 
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
     $account_translate = reset($account_translate[$user_selected['id']][self::$main_provider->provider_id]);
441 441
     $account_to_impersonate = new Account(self::$main_provider->db);
442 442
     $account_to_impersonate->db_get_by_id($account_translate['provider_account_id']);
443
-    if(!$account_to_impersonate->is_exists) {
443
+    if (!$account_to_impersonate->is_exists) {
444 444
       die('Какая-то ошибка - не могу найти аккаунт для имперсонации'); // TODO: Log it
445 445
     }
446 446
     self::$main_provider->impersonate($account_to_impersonate);
@@ -466,12 +466,12 @@  discard block
 block discarded – undo
466 466
   public function password_check($password_unsafe) {
467 467
     $result = false;
468 468
 
469
-    if(empty($this->providers_authorised)) {
469
+    if (empty($this->providers_authorised)) {
470 470
       // TODO - такого быть не может!
471 471
       self::flog("password_check: Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true);
472 472
     } else {
473
-      foreach($this->providers_authorised as $provider_id => $provider) {
474
-        if($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) {
473
+      foreach ($this->providers_authorised as $provider_id => $provider) {
474
+        if ($provider->is_feature_supported(AUTH_FEATURE_HAS_PASSWORD)) {
475 475
           $result = $result || $provider->password_check($password_unsafe);
476 476
         }
477 477
       }
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
   public function password_change($old_password_unsafe, $new_password_unsafe) {
493 493
     global $lang;
494 494
 
495
-    if(empty($this->providers_authorised)) {
495
+    if (empty($this->providers_authorised)) {
496 496
       // TODO - такого быть не может!
497 497
       self::flog("Не найдено ни одного авторизированного провайдера в self::\$providers_authorised", true);
498 498
       return false;
@@ -505,8 +505,8 @@  discard block
 block discarded – undo
505 505
     $salt_unsafe = self::password_salt_generate();
506 506
 
507 507
     $providers_changed_password = array();
508
-    foreach($this->providers_authorised as $provider_id => $provider) {
509
-      if(
508
+    foreach ($this->providers_authorised as $provider_id => $provider) {
509
+      if (
510 510
         !$provider->is_feature_supported(AUTH_FEATURE_PASSWORD_CHANGE)
511 511
         || !$provider->password_change($old_password_unsafe, $new_password_unsafe, $salt_unsafe)
512 512
       ) {
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
       $account_translation = PlayerToAccountTranslate::db_translate_get_users_from_account_list($provider_id, $provider->account->account_id);
519 519
 
520 520
       // Рассылаем уведомления о смене пароля в ЛС
521
-      foreach($account_translation as $user_id => $provider_info) {
521
+      foreach ($account_translation as $user_id => $provider_info) {
522 522
         // TODO - УКазывать тип аккаунта, на котором сменён пароль
523 523
         msg_send_simple_message($user_id, 0, SN_TIME_NOW, MSG_TYPE_ADMIN,
524 524
           $lang['sys_administration'], $lang['sys_login_register_message_title'],
@@ -565,7 +565,7 @@  discard block
 block discarded – undo
565 565
       SN::db_transaction_start();
566 566
       // Проверить наличие такого имени в истории имён
567 567
 
568
-      if(db_player_name_exists($player_name_unsafe)) {
568
+      if (db_player_name_exists($player_name_unsafe)) {
569 569
         throw new Exception(REGISTER_ERROR_PLAYER_NAME_EXISTS, ERR_ERROR);
570 570
       }
571 571
 
@@ -573,11 +573,11 @@  discard block
 block discarded – undo
573 573
       $player_language = '';
574 574
       $player_email = '';
575 575
       // TODO - порнография - работа должна происходить над списком аккаунтов, а не только на одном аккаунте...
576
-      foreach($this->providers_authorised as $provider) {
577
-        if(!$player_language && $provider->account->account_language) {
576
+      foreach ($this->providers_authorised as $provider) {
577
+        if (!$player_language && $provider->account->account_language) {
578 578
           $player_language = $provider->account->account_language;
579 579
         }
580
-        if(!$player_email && $provider->account->account_email) {
580
+        if (!$player_email && $provider->account->account_email) {
581 581
           $player_email = $provider->account->account_email;
582 582
         }
583 583
       }
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
       ));
594 594
       // Зарегестрировать на него аккаунты из self::$accounts_authorised
595 595
       $a_user = self::$user;
596
-      foreach($this->providers_authorised as $provider) {
596
+      foreach ($this->providers_authorised as $provider) {
597 597
         // TODO - порнография. Должен быть отдельный класс трансляторов - в т.ч. и кэширующий транслятор
598 598
         // TODO - ну и работа должна происходить над списком аккаунтов, а не только на одном аккаунте...
599 599
         // self::db_translate_register_user($provider->provider_id, $provider->account->account_id, $a_user['id']);
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
 
606 606
       SN::db_transaction_commit();
607 607
       $this->register_status = LOGIN_SUCCESS;
608
-    } catch(Exception $e) {
608
+    } catch (Exception $e) {
609 609
       SN::db_transaction_rollback();
610 610
 
611 611
       // Если старое имя занято
@@ -624,10 +624,10 @@  discard block
 block discarded – undo
624 624
     // Пробиваем все ИД игроков по базе - есть ли вообще такие записи
625 625
     // Вообще-то это не особо нужно - у нас по определению стоят констраинты
626 626
     // Зато так мы узнаем максимальный authlevel, проверим права имперсонейта и вытащим все записи юзеров
627
-    foreach($this->user_id_to_provider as $user_id => $cork) {
627
+    foreach ($this->user_id_to_provider as $user_id => $cork) {
628 628
       $user = db_user_by_id($user_id);
629 629
       // Если записи игрока в БД не существует?
630
-      if(empty($user['id'])) {
630
+      if (empty($user['id'])) {
631 631
         // Удаляем этого и переходим к следующему
632 632
         unset($this->user_id_to_provider[$user_id]);
633 633
         // Де-регистрируем игрока из таблицы трансляции игроков
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
   // OK v4.5
649 649
   protected function get_active_user() {
650 650
     // Проверяем куку "текущего игрока" из браузера
651
-    if(
651
+    if (
652 652
       // Кука не пустая
653 653
       ($_COOKIE[SN_COOKIE_U] = trim($_COOKIE[SN_COOKIE_U])) && !empty($_COOKIE[SN_COOKIE_U])
654 654
       // И в куке находится ID
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
     }
674 674
 
675 675
     // В куке нет валидного ИД записи игрока, доступной с текущих аккаунтов
676
-    if(empty(self::$user['id'])) {
676
+    if (empty(self::$user['id'])) {
677 677
       // Берем первого из доступных
678 678
       // TODO - default_user
679 679
       self::$user = reset($this->accessible_user_row_list);
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 
698 698
     $result = array();
699 699
 
700
-    if($user_id && empty($this->is_impersonating)) {
700
+    if ($user_id && empty($this->is_impersonating)) {
701 701
       // self::db_counter_insert();
702 702
       self::$device->db_counter_insert($user_id);
703 703
 
@@ -705,12 +705,12 @@  discard block
 block discarded – undo
705 705
 
706 706
       sys_user_options_unpack($user);
707 707
 
708
-      if($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) {
708
+      if ($user['banaday'] && $user['banaday'] <= SN_TIME_NOW) {
709 709
         $user['banaday'] = 0;
710 710
         $user['vacation'] = SN_TIME_NOW;
711 711
       }
712 712
 
713
-      $user['user_lastip'] = self::$device->ip_v4_string;// $ip['ip'];
713
+      $user['user_lastip'] = self::$device->ip_v4_string; // $ip['ip'];
714 714
       $user['user_proxy'] = self::$device->ip_v4_proxy_chain; //$ip['proxy_chain'];
715 715
 
716 716
       $result[F_BANNED_STATUS] = $user['banaday'];
@@ -724,13 +724,13 @@  discard block
 block discarded – undo
724 724
       );
725 725
     }
726 726
 
727
-    if($extra = $config->security_ban_extra) {
727
+    if ($extra = $config->security_ban_extra) {
728 728
       $extra = explode(',', $extra);
729
-      array_walk($extra,'trim');
729
+      array_walk($extra, 'trim');
730 730
       in_array(self::$device->device_id, $extra) and die();
731 731
     }
732 732
 
733
-    if(self::$login_message) {
733
+    if (self::$login_message) {
734 734
       $result[F_LOGIN_MESSAGE] = self::$login_message;
735 735
     }
736 736
 
@@ -766,21 +766,21 @@  discard block
 block discarded – undo
766 766
   protected function register_player_name_validate($player_name_unsafe) {
767 767
     // TODO - переделать под RAW-строки
768 768
     // Если имя игрока пустое - NO GO!
769
-    if(trim($player_name_unsafe) == '') {
769
+    if (trim($player_name_unsafe) == '') {
770 770
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_EMPTY, ERR_ERROR);
771 771
     }
772 772
     // Проверяем, что бы в начале и конце не было пустых символов
773
-    if($player_name_unsafe != trim($player_name_unsafe)) {
773
+    if ($player_name_unsafe != trim($player_name_unsafe)) {
774 774
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_TRIMMED, ERR_ERROR);
775 775
     }
776 776
     // Если логин имеет запрещенные символы - NO GO!
777
-    if(strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
777
+    if (strpbrk($player_name_unsafe, LOGIN_REGISTER_CHARACTERS_PROHIBITED)) {
778 778
       // TODO - выдавать в сообщение об ошибке список запрещенных символов
779 779
       // TODO - заранее извещать игрока, какие символы являются запрещенными
780 780
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_RESTRICTED_CHARACTERS, ERR_ERROR);
781 781
     }
782 782
     // Если логин меньше минимальной длины - NO GO!
783
-    if(strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) {
783
+    if (strlen($player_name_unsafe) < LOGIN_LENGTH_MIN) {
784 784
       // TODO - выдавать в сообщение об ошибке минимальную длину имени игрока
785 785
       // TODO - заранее извещать игрока, какая минимальная и максимальная длина имени
786 786
       throw new Exception(REGISTER_ERROR_PLAYER_NAME_SHORT, ERR_ERROR);
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
   }
839 839
 
840 840
   protected static function flog($message, $die = false) {
841
-    if(!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
841
+    if (!defined('DEBUG_AUTH') || !DEBUG_AUTH) {
842 842
       return;
843 843
     }
844 844
     list($called, $caller) = debug_backtrace(false);
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
     $_SERVER['SERVER_NAME'] == 'localhost' ? print("<div class='debug'>$message - $caller_name\r\n</div>") : false;
852 852
 
853 853
     SN::log_file("$message - $caller_name");
854
-    if($die) {
854
+    if ($die) {
855 855
       $die && die("<div class='negative'>СТОП! Функция {$caller_name} при вызове в " . get_called_class() . " (располагается в " . get_class() . "). СООБЩИТЕ АДМИНИСТРАЦИИ!</div>");
856 856
     }
857 857
   }
Please login to merge, or discard this patch.
classes/debug.php 1 patch
Spacing   +39 added lines, -40 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * que esperabas!!! soy newbie!!! D':<
26 26
 */
27 27
 
28
-if(!defined('INSIDE')) {
28
+if (!defined('INSIDE')) {
29 29
   die("attemp hacking");
30 30
 }
31 31
 
@@ -84,8 +84,8 @@  discard block
 block discarded – undo
84 84
     $result = array();
85 85
     $transaction_id = SN::db_transaction_check(false) ? SN::$transaction_id : SN::$transaction_id++;
86 86
     $result[] = "tID {$transaction_id}";
87
-    foreach($backtrace as $a_trace) {
88
-      if(in_array($a_trace['function'], $exclude_functions)) {
87
+    foreach ($backtrace as $a_trace) {
88
+      if (in_array($a_trace['function'], $exclude_functions)) {
89 89
         continue;
90 90
       }
91 91
       $function =
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
       $line = !empty($a_trace['line']) ? $a_trace['line'] : '_UNDEFINED_';
103 103
       $result[] = "{$function} - '{$file}' Line {$line}";
104 104
 
105
-      if(!$long_comment) {
105
+      if (!$long_comment) {
106 106
         break;
107 107
       }
108 108
     }
@@ -111,26 +111,26 @@  discard block
 block discarded – undo
111 111
   }
112 112
 
113 113
   function dump($dump = false, $force_base = false, $deadlock = false) {
114
-    if($dump === false) {
114
+    if ($dump === false) {
115 115
       return [];
116 116
     }
117 117
 
118 118
     $error_backtrace = array();
119 119
     $base_dump = false;
120 120
 
121
-    if($force_base === true) {
121
+    if ($force_base === true) {
122 122
       $base_dump = true;
123 123
     }
124 124
 
125
-    if($dump === true) {
125
+    if ($dump === true) {
126 126
       $base_dump = true;
127 127
     } else {
128
-      if(!is_array($dump)) {
128
+      if (!is_array($dump)) {
129 129
         $dump = array('var' => $dump);
130 130
       }
131 131
 
132
-      foreach($dump as $dump_var_name => $dump_var) {
133
-        if($dump_var_name == 'base_dump') {
132
+      foreach ($dump as $dump_var_name => $dump_var) {
133
+        if ($dump_var_name == 'base_dump') {
134 134
           $base_dump = $dump_var;
135 135
         } else {
136 136
           $error_backtrace[$dump_var_name] = $dump_var;
@@ -138,24 +138,23 @@  discard block
 block discarded – undo
138 138
       }
139 139
     }
140 140
 
141
-    if($deadlock && ($q = SN::$db->mysql_get_innodb_status())) {
141
+    if ($deadlock && ($q = SN::$db->mysql_get_innodb_status())) {
142 142
       $error_backtrace['deadlock'] = explode("\n", $q['Status']);
143 143
       $error_backtrace['locks'] = _SnCacheInternal::$locks;
144 144
       $error_backtrace['cSN_data'] = _SnCacheInternal::$data;
145
-      foreach($error_backtrace['cSN_data'] as &$location) {
146
-        foreach($location as $location_id => &$location_data) //          $location_data = $location_id;
145
+      foreach ($error_backtrace['cSN_data'] as &$location) {
146
+        foreach ($location as $location_id => &$location_data) //          $location_data = $location_id;
147 147
         {
148
-          $location_data = isset($location_data['username']) ? $location_data['username'] :
149
-            (isset($location_data['name']) ? $location_data['name'] : $location_id);
148
+          $location_data = isset($location_data['username']) ? $location_data['username'] : (isset($location_data['name']) ? $location_data['name'] : $location_id);
150 149
         }
151 150
       }
152 151
     }
153 152
 
154
-    if($base_dump) {
155
-      if(!is_array($this->log_array) || empty($this->log_array)) {
153
+    if ($base_dump) {
154
+      if (!is_array($this->log_array) || empty($this->log_array)) {
156 155
         $this->log_array = [];
157 156
       } else {
158
-        foreach($this->log_array as $log) {
157
+        foreach ($this->log_array as $log) {
159 158
           $error_backtrace['queries'][] = $log;
160 159
         }
161 160
       }
@@ -167,17 +166,17 @@  discard block
 block discarded – undo
167 166
       // Converting object instances to object names
168 167
 
169 168
       foreach ($error_backtrace['backtrace'] as &$backtrace) {
170
-        if(is_object($backtrace['object'])) {
169
+        if (is_object($backtrace['object'])) {
171 170
           $backtrace['object'] = get_class($backtrace['object']);
172 171
         }
173 172
 
174
-        if(empty($backtrace['args'])) {
173
+        if (empty($backtrace['args'])) {
175 174
           continue;
176 175
         }
177 176
 
178 177
         // Doing same conversion for backtrace params
179
-        foreach($backtrace['args'] as &$arg) {
180
-          if(is_object($arg)) {
178
+        foreach ($backtrace['args'] as &$arg) {
179
+          if (is_object($arg)) {
181 180
             $arg = 'object::' . get_class($arg);
182 181
           }
183 182
         }
@@ -206,14 +205,14 @@  discard block
 block discarded – undo
206 205
   function error($message = 'There is a error on page', $title = 'Internal Error', $httpCode = 500, $dump = true) {
207 206
     global $config, $sys_stop_log_hit, $lang, $sys_log_disabled, $user;
208 207
 
209
-    if(empty(SN::$db->connected)) {
208
+    if (empty(SN::$db->connected)) {
210 209
       // TODO - писать ошибку в файл
211 210
       die('SQL server currently unavailable. Please contact Administration...');
212 211
     }
213 212
 
214 213
     SN::db_transaction_rollback();
215 214
 
216
-    if(SN::$config->debug == 1) {
215
+    if (SN::$config->debug == 1) {
217 216
       /** @noinspection HtmlDeprecatedTag */
218 217
       /** @noinspection XmlDeprecatedElement */
219 218
       /** @noinspection HtmlDeprecatedAttribute */
@@ -226,7 +225,7 @@  discard block
 block discarded – undo
226 225
     $error_text = SN::$db->db_escape($message);
227 226
     $error_backtrace = $this->dump($dump, true, strpos($message, 'Deadlock') !== false);
228 227
 
229
-    if(!$sys_log_disabled) {
228
+    if (!$sys_log_disabled) {
230 229
       $this->_writeLogMessage($httpCode, $user, $title, $message, $error_backtrace, $fatal_error);
231 230
 
232 231
       $message = "Пожалуйста, свяжитесь с админом, если ошибка повторится. Ошибка №: <b>" . SN::$db->db_insert_id() . "</b>";
@@ -239,7 +238,7 @@  discard block
 block discarded – undo
239 238
       ob_start();
240 239
       print("<hr>User ID {$user['id']} raised error code {$httpCode} titled '{$title}' with text '{$error_text}' on page {$_SERVER['SCRIPT_NAME']}");
241 240
 
242
-      foreach($error_backtrace as $name => $value) {
241
+      foreach ($error_backtrace as $name => $value) {
243 242
         print('<hr>');
244 243
         pdump($value, $name);
245 244
       }
@@ -251,7 +250,7 @@  discard block
 block discarded – undo
251 250
   function warning($message, $title = 'System Message', $httpCode = 300, $dump = false) {
252 251
     global $user, $lang, $sys_log_disabled;
253 252
 
254
-    if(empty(SN::$db->connected)) {
253
+    if (empty(SN::$db->connected)) {
255 254
       // TODO - писать ошибку в файл
256 255
       die('SQL server currently unavailable. Please contact Administration...');
257 256
     }
@@ -260,7 +259,7 @@  discard block
 block discarded – undo
260 259
 
261 260
     $error_backtrace = $this->dump($dump, false);
262 261
 
263
-    if(empty($sys_log_disabled)) {
262
+    if (empty($sys_log_disabled)) {
264 263
       $this->_writeLogMessage($httpCode, $user, $title, $message, $error_backtrace, $fatal_error);
265 264
     } else {
266 265
 //        // TODO Здесь надо писать в файло
@@ -297,11 +296,11 @@  discard block
 block discarded – undo
297 296
 // Dump variables nicer then var_dump()
298 297
 
299 298
 function dump($value, $varname = null, $level = 0, $dumper = '') {
300
-  if(isset($varname)) {
299
+  if (isset($varname)) {
301 300
     $varname .= " = ";
302 301
   }
303 302
 
304
-  if($level == -1) {
303
+  if ($level == -1) {
305 304
     $trans[' '] = '&there4;';
306 305
     $trans["\t"] = '&rArr;';
307 306
     $trans["\n"] = '&para;;';
@@ -310,7 +309,7 @@  discard block
 block discarded – undo
310 309
 
311 310
     return strtr(htmlspecialchars($value), $trans);
312 311
   }
313
-  if($level == 0) {
312
+  if ($level == 0) {
314 313
 //    $dumper = '<pre>' . mt_rand(10, 99) . '|' . $varname;
315 314
     $dumper = mt_rand(10, 99) . '|' . $varname;
316 315
   }
@@ -318,22 +317,22 @@  discard block
 block discarded – undo
318 317
   $type = gettype($value);
319 318
   $dumper .= $type;
320 319
 
321
-  if($type == 'string') {
320
+  if ($type == 'string') {
322 321
     $dumper .= '(' . strlen($value) . ')';
323 322
     $value = dump($value, '', -1);
324
-  } elseif($type == 'boolean') {
323
+  } elseif ($type == 'boolean') {
325 324
     $value = ($value ? 'true' : 'false');
326
-  } elseif($type == 'object') {
325
+  } elseif ($type == 'object') {
327 326
     $props = get_class_vars(get_class($value));
328 327
     $dumper .= '(' . count($props) . ') <u>' . get_class($value) . '</u>';
329
-    foreach($props as $key => $val) {
328
+    foreach ($props as $key => $val) {
330 329
       $dumper .= "\n" . str_repeat("\t", $level + 1) . $key . ' => ';
331 330
       $dumper .= dump($value->$key, '', $level + 1);
332 331
     }
333 332
     $value = '';
334
-  } elseif($type == 'array') {
333
+  } elseif ($type == 'array') {
335 334
     $dumper .= '(' . count($value) . ')';
336
-    foreach($value as $key => $val) {
335
+    foreach ($value as $key => $val) {
337 336
       $dumper .= "\n" . str_repeat("\t", $level + 1) . dump($key, '', -1) . ' => ';
338 337
       $dumper .= dump($val, '', $level + 1);
339 338
     }
@@ -353,7 +352,7 @@  discard block
 block discarded – undo
353 352
 //  $backtrace = $backtrace[1];
354 353
 
355 354
   $caller = '';
356
-  if(defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
355
+  if (defined('SN_DEBUG_PDUMP_CALLER') && SN_DEBUG_PDUMP_CALLER) {
357 356
     $caller = (!empty($backtrace[1]['class']) ? $backtrace[1]['class'] : '') .
358 357
       (!empty($backtrace[1]['type']) ? $backtrace[1]['type'] : '') .
359 358
       $backtrace[1]['function'] .
@@ -380,7 +379,7 @@  discard block
 block discarded – undo
380 379
 }
381 380
 
382 381
 function pr($prePrint = false) {
383
-  if($prePrint) {
382
+  if ($prePrint) {
384 383
     print("<br>");
385 384
   }
386 385
   print(mt_rand() . "<br>");
@@ -390,7 +389,7 @@  discard block
 block discarded – undo
390 389
   global $_PRINT_COUNT_VALUE;
391 390
   $_PRINT_COUNT_VALUE++;
392 391
 
393
-  if($prePrint) {
392
+  if ($prePrint) {
394 393
     print("<br>");
395 394
   }
396 395
   print($_PRINT_COUNT_VALUE . "<br>");
Please login to merge, or discard this patch.
classes/Template/TemplateMeta.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@
 block discarded – undo
136 136
 //    var_dump($fallBackPath);
137 137
 //    var_dump($template);
138 138
 
139
-    if(empty($fallBackPath)) {
139
+    if (empty($fallBackPath)) {
140 140
       if (!$this->parent || empty($fallbackName = $this->parent->getName()) || !$this->isTemplateExists()) {
141 141
         // If no parent template - then using default template as fallback one
142 142
         $fallbackName = SnTemplate::SN_TEMPLATE_NAME_DEFAULT;
Please login to merge, or discard this patch.
classes/classPersistent.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     $this->sql_index_field = "{$table_name}_name";
41 41
     $this->sql_value_field = "{$table_name}_value";
42 42
 
43
-    if(!$this->_DB_LOADED) {
43
+    if (!$this->_DB_LOADED) {
44 44
       $this->db_loadAll();
45 45
     }
46 46
   }
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
    */
61 61
   public function db_loadItem($index) {
62 62
     $result = null;
63
-    if($index) {
63
+    if ($index) {
64 64
       $index_safe = SN::$db->db_escape($index);
65 65
       $queryResult = doquery("SELECT `{$this->sql_value_field}` FROM `{{{$this->table_name}}}` WHERE `{$this->sql_index_field}` = '{$index_safe}' FOR UPDATE", true);
66
-      if(is_array($queryResult) && !empty($queryResult)) {
66
+      if (is_array($queryResult) && !empty($queryResult)) {
67 67
         $this->$index = $result = $queryResult[$this->sql_value_field];
68 68
       }
69 69
     }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     $this->loadDefaults();
76 76
 
77 77
     $query = doquery("SELECT * FROM {{{$this->table_name}}} FOR UPDATE;");
78
-    while($row = db_fetch($query)) {
78
+    while ($row = db_fetch($query)) {
79 79
       $this[$row[$this->sql_index_field]] = $row[$this->sql_value_field];
80 80
     }
81 81
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
   }
84 84
 
85 85
   public function loadDefaults() {
86
-    foreach($this->defaults as $defName => $defValue) {
86
+    foreach ($this->defaults as $defName => $defValue) {
87 87
       $this->$defName = $defValue;
88 88
     }
89 89
   }
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
   }
94 94
 
95 95
   public function db_saveItem($item_list, $value = NULL) {
96
-    if(empty($item_list)) {
96
+    if (empty($item_list)) {
97 97
       return;
98 98
     }
99 99
 
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 
102 102
     // Сначала записываем данные в базу - что бы поймать все блокировки
103 103
     $qry = array();
104
-    foreach($item_list as $item_name => $item_value) {
105
-      if($item_name) {
104
+    foreach ($item_list as $item_name => $item_value) {
105
+      if ($item_name) {
106 106
         $item_value = SN::$db->db_escape($item_value === NULL ? $this->$item_name : $item_value);
107 107
         $item_name = SN::$db->db_escape($item_name);
108 108
         $qry[] = "('{$item_name}', '{$item_value}')";
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
     doquery("REPLACE INTO `{{" . $this->table_name . "}}` (`{$this->sql_index_field}`, `{$this->sql_value_field}`) VALUES " . implode(',', $qry) . ";");
112 112
 
113 113
     // И только после взятия блокировок - меняем значения в кэше
114
-    foreach($item_list as $item_name => $item_value) {
115
-      if($item_name && $item_value !== null) {
114
+    foreach ($item_list as $item_name => $item_value) {
115
+      if ($item_name && $item_value !== null) {
116 116
         $this->__set($item_name, $item_value);
117 117
       }
118 118
     }
@@ -140,14 +140,14 @@  discard block
 block discarded – undo
140 140
   }
141 141
 
142 142
   public function __get($name) {
143
-    if($this->force) {
143
+    if ($this->force) {
144 144
       $this->force = false;
145 145
       $value = $this->db_loadItem($name);
146 146
     } else {
147 147
       $value = parent::__get($name);
148 148
     }
149 149
 
150
-    if(isset($this->notEmptyFields[$name]) && empty($value) && isset($this->defaults[$name])) {
150
+    if (isset($this->notEmptyFields[$name]) && empty($value) && isset($this->defaults[$name])) {
151 151
       $value = $this->defaults[$name];
152 152
     }
153 153
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
   }
156 156
 
157 157
   public function __set($name, $value) {
158
-    if($this->force) {
158
+    if ($this->force) {
159 159
       $this->force = false;
160 160
       $this->db_saveItem($name, $value);
161 161
     }
Please login to merge, or discard this patch.
classes/DBAL/OldDbChangeSet.php 1 patch
Spacing   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -142,9 +142,7 @@
 block discarded – undo
142 142
           // Простое условие - $field_id = $field_value
143 143
           if (is_string($field_id)) {
144 144
             $field_value =
145
-              $field_value === null ? 'NULL' :
146
-                (is_string($field_value) ? "'" . SN::$db->db_escape($field_value) . "'" :
147
-                  (is_bool($field_value) ? intval($field_value) : $field_value));
145
+              $field_value === null ? 'NULL' : (is_string($field_value) ? "'" . SN::$db->db_escape($field_value) . "'" : (is_bool($field_value) ? intval($field_value) : $field_value));
148 146
             $the_conditions[] = "`{$field_id}` = {$field_value}";
149 147
           } else {
150 148
             die('Неподдерживаемый тип условия');
Please login to merge, or discard this patch.
classes/DBAL/db_mysql.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 
225 225
     set_error_handler([$this, 'handlerQueryWarning']);
226 226
     $sqlquery = $this->db_sql_query($sql);
227
-    if(!$sqlquery) {
227
+    if (!$sqlquery) {
228 228
       $debug->error(SN::$db->db_error() . "<br />$sql<br />", 'SQL Error');
229 229
     }
230 230
     restore_error_handler();
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
     $q1 = $this->db_sql_query("SHOW INDEX FROM {$prefixedTableName_safe};");
397 397
     while ($r1 = db_fetch($q1)) {
398 398
       $indexName = $r1['Key_name'];
399
-      if(empty($result[$indexName])) {
399
+      if (empty($result[$indexName])) {
400 400
         $result[$indexName] = new DbIndexDescription();
401 401
       }
402 402
       $result[$indexName]->addField($r1);
Please login to merge, or discard this patch.
classes/StatUpdateLauncher.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
         $config->pass()->game_disable = GAME_DISABLE_STAT;
57 57
 
58 58
         $statMinimalInterval = intval($config->pass()->stats_minimal_interval);
59
-        $config->pass()->var_stat_update_end= date(FMT_DATE_TIME_SQL, SN_TIME_NOW + ($statMinimalInterval ? $statMinimalInterval : STATS_RUN_INTERVAL_MINIMUM));
59
+        $config->pass()->var_stat_update_end = date(FMT_DATE_TIME_SQL, SN_TIME_NOW + ($statMinimalInterval ? $statMinimalInterval : STATS_RUN_INTERVAL_MINIMUM));
60 60
         $config->pass()->var_stat_update_msg = 'Update started';
61 61
         SN::db_transaction_commit();
62 62
 
Please login to merge, or discard this patch.
classes/SnTemplate.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
         $insert_position = $is_positioned == '-' ? 0 : count($menu);
129 129
       }
130 130
 
131
-      $insert_position     += $is_positioned == '+' ? 1 : 0;
131
+      $insert_position += $is_positioned == '+' ? 1 : 0;
132 132
       $spliced             = array_splice($menu, $insert_position, count($menu) - $insert_position);
133 133
       $menu[$menu_item_id] = $menu_item;
134 134
 
@@ -648,7 +648,7 @@  discard block
 block discarded – undo
648 648
       'LANG'     => $language ? $language : '',
649 649
       'referral' => $id_ref ? '&id_ref=' . $id_ref : '',
650 650
 
651
-      'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '',// "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''),
651
+      'REQUEST_PARAMS' => !empty($url_params) ? '?' . implode('&', $url_params) : '', // "?lang={$language}" . ($id_ref ? "&id_ref={$id_ref}" : ''),
652 652
       'FILENAME'       => basename($_SERVER['PHP_SELF']),
653 653
     ));
654 654
 
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
       }
837 837
 
838 838
       $fleet_listx = flt_get_fleets_to_planet($CurPlanet);
839
-      if($CurPlanet['planet_type'] == PT_MOON) {
839
+      if ($CurPlanet['planet_type'] == PT_MOON) {
840 840
         $parentPlanet = DBStaticPlanet::db_planet_by_id($CurPlanet['parent_planet']);
841 841
       } else {
842 842
         $parentPlanet = $CurPlanet;
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
       'QUE_ID'   => QUE_RESEARCH,
882 882
       'QUE_HTML' => 'topnav',
883 883
 
884
-      'RESEARCH_ONGOING' => (boolean)$user['que'],
884
+      'RESEARCH_ONGOING' => (boolean) $user['que'],
885 885
 
886 886
       'TIME_TEXT'       => sprintf($str_date_format, $time_now_parsed['year'], $lang['months'][$time_now_parsed['mon']], $time_now_parsed['mday'],
887 887
         $time_now_parsed['hours'], $time_now_parsed['minutes'], $time_now_parsed['seconds']
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
       SnTemplate::renderFooter($page, $template_result);
1172 1172
     }
1173 1173
 
1174
-    $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false;;
1174
+    $user['authlevel'] >= 3 && $config->debug ? $debug->echo_log() : false; ;
1175 1175
 
1176 1176
     SN::$db->db_disconnect();
1177 1177
 
Please login to merge, or discard this patch.