Completed
Push — trunk ( d06df9...f48ee3 )
by SuperNova.WS
11:23
created

common.php (2 issues)

1
<?php
2
/*
3
 * common.php
4
 *
5
 * Common init file
6
 *
7
 * @version 1.1 Security checks by Gorlum for http://supernova.ws
8
 */
9
10
require_once('includes/init.php');
11
12
global $debug, $template_result, $user, $lang, $planetrow;
13
14
// Напоминание для Администрации, что игра отключена
15
if($template_result[F_GAME_DISABLE]) {
16
  echo '<div class="global_admin_warning">', $template_result[F_GAME_DISABLE_REASON], '</div>';
17
}
18
unset($disable_reason);
19
20
21
if(defined('IN_ADMIN') && IN_ADMIN === true) {
22
  lng_include('admin');
23
} elseif($sys_user_logged_in) {
24
  sys_user_vacation($user);
25
26
  $planet_id = SetSelectedPlanet($user);
27
28
  // TODO НЕ НУЖНО АЛЬЯНС КАЖДЫЙ РАЗ ОБНОВЛЯТЬ!!!
29
  if($user['ally_id']) {
30
    sn_db_transaction_start();
31
    \Alliance\Alliance::sn_ali_fill_user_ally($user);
32
    if(!$user['ally']['player']['id']) {
33
      // sn_sys_logout(false, true);
34
      // core_auth::logout(false);
35
      SN::$auth->logout(false);
36
      $debug->error("User ID {$user['id']} has ally ID {$user['ally_id']} but no ally info", 'User record error', 502);
37
    }
38
    // TODO UNCOMMENT
39
    que_process($user['ally']['player']);
40
    db_user_set_by_id($user['ally']['player']['id'], '`onlinetime` = ' . SN_TIME_NOW);
0 ignored issues
show
Deprecated Code introduced by
The function db_user_set_by_id() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

40
    /** @scrutinizer ignore-deprecated */ db_user_set_by_id($user['ally']['player']['id'], '`onlinetime` = ' . SN_TIME_NOW);
Loading history...
41
    sn_db_transaction_commit();
42
  }
43
44
45
  // TODO - в режиме эмуляции, на самом деле!
46
  sn_db_transaction_start();
47
  $global_data = sys_o_get_updated($user['id'], $planet_id, SN_TIME_NOW);
48
  sn_db_transaction_commit();
49
50
  $planetrow = $global_data['planet'];
51
  if(!($planetrow && isset($planetrow['id']) && $planetrow['id'])) {
52
    // sn_sys_logout(false, true);
53
    // core_auth::logout(false);
54
    SN::$auth->logout(false);
55
    $debug->error("User ID {$user['id']} has no current planet and no homeworld", 'User record error', 502);
56
  }
57
58
  $que = $global_data['que'];
59
}
60
61
require_once('includes/vars_menu.php');
62
63
sys_user_options_unpack($user);
64
65
global $sn_page_name, $sn_mvc;
66
if(!empty($sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_EARLY_HEADER])) {
67
  $title = !empty($sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_TITLE]) ? $sn_mvc['pages'][INITIAL_PAGE][PAGE_OPTION_TITLE] : '';
68
  SnTemplate::renderHeader($page, $title, $template_result, false, $user, SN::$config, $lang, $planetrow);
0 ignored issues
show
The call to SnTemplate::renderHeader() has too few arguments starting with renderedContent. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

68
  SnTemplate::/** @scrutinizer ignore-call */ 
69
              renderHeader($page, $title, $template_result, false, $user, SN::$config, $lang, $planetrow);

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
69
}
70