Issues (1369)

admin/settings.php (2 issues)

1
<?php
2
3
/** @noinspection PhpDefineCanBeReplacedWithConstInspection */
4
/** @noinspection PhpRedundantOptionalArgumentInspection */
5
6
/**
7
 * settings.php
8
 *
9
 * @version 2.0 Full rewrite copyright (c) Gorlum 2009-2010 for http://supernova.ws
10
 * @version 1.0
11
 * @copyright 2008 by ??????? for XNova
12
 */
13
14
use Unit\DBStaticUnit;
15
16
define('INSIDE'  , true);
17
define('INSTALL' , false);
18
define('IN_ADMIN', true);
19
require('../common.' . substr(strrchr(__FILE__, '.'), 1));
20
21
global $lang, $user, $sn_version_check_class;
22
23
SnTemplate::messageBoxAdminAccessDenied(AUTH_LEVEL_ADMINISTRATOR);
24
25
$template = SnTemplate::gettemplate('admin/settings', true);
0 ignored issues
show
true of type true is incompatible with the type null|template expected by parameter $template of SnTemplate::gettemplate(). ( Ignorable by Annotation )

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

25
$template = SnTemplate::gettemplate('admin/settings', /** @scrutinizer ignore-type */ true);
Loading history...
26
27
if(sys_get_param('save')) {
28
  SN::$config->game_name               = sys_get_param_str_unsafe('game_name');
29
  SN::$config->game_mode               = sys_get_param_int('game_mode');
30
  SN::$config->game_speed              = sys_get_param_float('game_speed', 1);
31
  SN::$config->fleet_speed             = sys_get_param_float('fleet_speed', 1);
32
  SN::$config->resource_multiplier     = sys_get_param_float('resource_multiplier', 1);
33
  SN::$config->user_vacation_disable   = sys_get_param_int('user_vacation_disable', 0);
34
  SN::$config->url_faq                 = sys_get_param_str_unsafe('url_faq');
35
  SN::$config->url_forum               = sys_get_param_str_unsafe('url_forum');
36
  SN::$config->url_rules               = sys_get_param_str_unsafe('url_rules');
37
  SN::$config->url_purchase_metamatter         = sys_get_param_str_unsafe('url_purchase_metamatter');
38
  SN::$config->game_disable            = sys_get_param_int('game_disable');
39
  SN::$config->game_disable_reason     = sys_get_param_str_unsafe('game_disable_reason');
40
  SN::$config->server_updater_check_auto = sys_get_param_int('server_updater_check_auto');
41
42
  SN::$config->game_user_changename      = sys_get_param_int('game_user_changename', SN::$config->game_user_changename);
43
  SN::$config->game_user_changename_cost = sys_get_param_int('game_user_changename_cost', SN::$config->game_user_changename_cost);
44
45
  SN::$config->eco_scale_storage       = sys_get_param_int('eco_scale_storage');
46
47
  SN::$config->game_default_language   = sys_get_param_str_unsafe('game_default_language', DEFAULT_LANG);
48
  SN::$config->game_default_skin       = sys_get_param_str_unsafe('game_default_skin', DEFAULT_SKINPATH);
49
  SN::$config->game_default_template   = sys_get_param_str_unsafe('game_default_template', SnTemplate::getServerDefaultTemplateName());
50
51
  SN::$config->game_maxGalaxy          = sys_get_param_int('game_maxGalaxy', 5);
52
  SN::$config->game_maxSystem          = sys_get_param_int('game_maxSystem', 199);
53
  SN::$config->game_maxPlanet          = sys_get_param_int('game_maxPlanet', 16);
54
55
  SN::$config->player_max_colonies     = sys_get_param_int('player_max_colonies', -1);
56
57
  SN::$config->fleet_bashing_attacks   = sys_get_param_int('fleet_bashing_attacks', 3);
58
  SN::$config->fleet_bashing_interval  = sys_get_param_int('fleet_bashing_interval', 30 * 60);
59
  SN::$config->fleet_bashing_scope     = sys_get_param_int('fleet_bashing_scope', 24 * 60 * 60);
60
  SN::$config->fleet_bashing_war_delay = sys_get_param_int('fleet_bashing_war_delay', 12 * 60 * 60);
61
  SN::$config->fleet_bashing_waves     = sys_get_param_int('fleet_bashing_waves', 3);
62
63
  SN::$config->allow_buffing           = sys_get_param_int('allow_buffing');
64
  SN::$config->ally_help_weak          = sys_get_param_int('ally_help_weak');
65
  SN::$config->game_email_pm           = sys_get_param_int('game_email_pm');
66
67
  SN::$config->rpg_exchange_metal      = sys_get_param_int('rpg_exchange_metal', 1);
68
  SN::$config->rpg_exchange_crystal    = sys_get_param_int('rpg_exchange_crystal', 2);
69
  SN::$config->rpg_exchange_deuterium  = sys_get_param_int('rpg_exchange_deuterium', 4);
70
  SN::$config->rpg_exchange_darkMatter = sys_get_param_int('rpg_exchange_darkMatter', 400);
71
72
  SN::$config->tpl_minifier            = sys_get_param_int('tpl_minifier', 0);
73
74
  SN::$config->initial_fields          = sys_get_param_int('initial_fields', 200);
75
  SN::$config->eco_planet_starting_metal = sys_get_param_float('eco_planet_starting_metal', 500);
76
  SN::$config->eco_planet_starting_crystal = sys_get_param_float('eco_planet_starting_crystal', 500);
77
  SN::$config->eco_planet_starting_deuterium = sys_get_param_float('eco_planet_starting_deuterium', 0);
78
  SN::$config->metal_basic_income      = sys_get_param_float('metal_basic_income', 40);
79
  SN::$config->crystal_basic_income    = sys_get_param_float('crystal_basic_income', 20);
80
  SN::$config->deuterium_basic_income  = sys_get_param_float('deuterium_basic_income', 10);
81
  SN::$config->energy_basic_income     = sys_get_param_float('energy_basic_income', 0);
82
  SN::$config->eco_planet_storage_metal = sys_get_param_float('eco_planet_storage_metal', BASE_STORAGE_SIZE);
83
  SN::$config->eco_planet_storage_crystal = sys_get_param_float('eco_planet_storage_crystal', BASE_STORAGE_SIZE);
84
  SN::$config->eco_planet_storage_deuterium = sys_get_param_float('eco_planet_storage_deuterium', BASE_STORAGE_SIZE);
85
86
  SN::$config->chat_timeout            = sys_get_param_int('chat_timeout', 5);
87
88
  SN::$config->game_news_overview      = sys_get_param_int('game_news_overview', 5);
89
  SN::$config->advGoogleLeftMenuIsOn   = sys_get_param_int('advGoogleLeftMenuIsOn');
90
  SN::$config->advGoogleLeftMenuCode   = sys_get_param('advGoogleLeftMenuCode');
0 ignored issues
show
Documentation Bug introduced by
It seems like sys_get_param('advGoogleLeftMenuCode') can also be of type array. However, the property $advGoogleLeftMenuCode is declared as type string. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
91
  SN::$config->debug                   = sys_get_param_int('debug');
92
  SN::$config->game_counter            = sys_get_param_int('game_counter');
93
  SN::$config->geoip_whois_url         = sys_get_param_str('geoip_whois_url');
94
95
  SN::$config->uni_price_galaxy        = sys_get_param_float('uni_price_galaxy');
96
  SN::$config->uni_price_system        = sys_get_param_float('uni_price_system');
97
98
  SN::$config->user_birthday_gift      = sys_get_param_float('user_birthday_gift');
99
  SN::$config->user_birthday_range     = sys_get_param_int('user_birthday_range');
100
101
  SN::$config->stats_hide_admins       = sys_get_param_int('stats_hide_admins');
102
  SN::$config->stats_hide_player_list  = sys_get_param_str('stats_hide_player_list');
103
  SN::$config->stats_hide_pm_link      = sys_get_param_int('stats_hide_pm_link');
104
  SN::$config->stats_schedule          = sys_get_param_str('stats_schedule');
105
106
  SN::$config->empire_mercenary_base_period = sys_get_param_int('empire_mercenary_base_period');
107
  if(SN::$config->empire_mercenary_temporary != sys_get_param_int('empire_mercenary_temporary')) {
108
    if(SN::$config->empire_mercenary_temporary) {
109
      DBStaticUnit::db_unit_list_admin_delete_mercenaries_finished();
110
    } else {
111
      DBStaticUnit::db_unit_list_admin_set_mercenaries_expire_time(SN::$config->empire_mercenary_base_period);
112
    }
113
114
    SN::$config->empire_mercenary_temporary = sys_get_param_int('empire_mercenary_temporary');
115
  }
116
117
  SN::$config->db_saveAll();
118
119
  $template->assign_var('MESSAGE', $lang['adm_opt_saved']);
120
}
121
122
$template->assign_vars([
123
  'ALLOW_BUFFING' => SN::$config->allow_buffing,
124
  'ALLY_HELP_WEAK' => SN::$config->ally_help_weak,
125
  'GAME_EMAIL_PM' => SN::$config->game_email_pm,
126
  'game_mode' => SN::$config->game_mode,
127
  'game_language' => SN::$config->game_default_language,
128
  'ECO_SCALE_STORAGE' => SN::$config->eco_scale_storage,
129
  'USER_VACATION_DISABLE' => SN::$config->user_vacation_disable,
130
  'ADV_LEFT_MENU' => SN::$config->advGoogleLeftMenuIsOn,
131
  'GAME_DISABLE' => SN::$config->game_disable,
132
  'GAME_DEBUG' => SN::$config->debug,
133
  'GAME_COUNTER' => SN::$config->game_counter,
134
  'TPL_MINIFIER' => SN::$config->tpl_minifier,
135
  'EMPIRE_MERCENARY_TEMPORARY' => SN::$config->empire_mercenary_temporary,
136
137
  'SERVER_UPDATE_CHECK_AUTO' => SN::$config->server_updater_check_auto,
138
  'CHECK_DATE' => SN::$config->server_updater_check_last ? date(FMT_DATE_TIME, SN::$config->server_updater_check_last) : 0,
139
  'CHECK_RESULT' => isset($lang['adm_opt_ver_response'][SN::$config->server_updater_check_result]) ? $lang['adm_opt_ver_response'][SN::$config->server_updater_check_result] : $lang['adm_opt_ver_response'][SNC_VER_UNKNOWN_RESPONSE],
140
  'CHECK_CLASS' => isset($sn_version_check_class[SN::$config->server_updater_check_result]) ? $sn_version_check_class[SN::$config->server_updater_check_result] : $sn_version_check_class[SNC_VER_UNKNOWN_RESPONSE],
141
142
  'SERVER_UPDATE_ID' => SN::$config->server_updater_id,
143
  'SERVER_UPDATE_KEY' => SN::$config->server_updater_key,
144
145
  'STATS_HIDE_ADMINS' => SN::$config->stats_hide_admins,
146
  'STATS_HIDE_PM_LINK' => SN::$config->stats_hide_pm_link,
147
148
  'GAME_CHANGE_NAME'      => SN::$config->game_user_changename,
149
  'GAME_CHANGE_NAME_COST' => SN::$config->game_user_changename_cost,
150
]);
151
152
SnTemplate::tpl_assign_select($template, 'change_name_options', SN::$lang['adm_opt_player_change_name_options']);
153
SnTemplate::tpl_assign_select($template, 'sys_game_disable_reason', SN::$lang['sys_game_disable_reason'], 'ID', 'NAME');
154
SnTemplate::tpl_assign_select($template, 'game_modes', SN::$lang['sys_game_mode'], 'ID', 'NAME');
155
SnTemplate::tpl_assign_select($template, 'ver_response', SN::$lang['adm_opt_ver_response'], 'ID', 'NAME');
156
157
$lang_list = lng_get_list();
158
foreach($lang_list as $lang_id => $lang_data) {
159
  $template->assign_block_vars('game_languages', array(
160
    'ID'   => $lang_id,
161
    'NAME' => "{$lang_data['LANG_NAME_NATIVE']} ({$lang_data['LANG_NAME_ENGLISH']})",
162
  ));
163
}
164
165
SnTemplate::display($template, $lang['adm_opt_title']);
166