Completed
Push — work-fleets ( 3cd948...da4c88 )
by SuperNova.WS
07:01
created

classConfig::repackExistsOptionPlayerIdString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 7
rs 9.4285
1
<?php
2
3
/**
4
 *
5
 * This class is used to handle server configuration
6
 *
7
 * @package supernova
8
 *
9
 * @property string db_prefix
10
 *
11
 * @property string advGoogleLeftMenuCode
12
 * @property int    advGoogleLeftMenuIsOn
13
 * @property string adv_conversion_code_payment
14
 * @property string adv_conversion_code_register
15
 * @property string adv_seo_javascript
16
 * @property string adv_seo_meta_description
17
 * @property string adv_seo_meta_keywords
18
 * @property int    ali_bonus_algorithm   // Bonus calculation algorithm
19
 * @property int    ali_bonus_brackets  // Brackets count for ALI_BONUS_BY_RANK
20
 * @property int    ali_bonus_brackets_divisor // Bonus divisor for ALI_BONUS_BY_RANK
21
 * @property int    ali_bonus_divisor  // Rank divisor for ALI_BONUS_BY_POINTS
22
 * @property int    ali_bonus_members  // Minumum alliace size to start using bonus
23
 * @property int    allow_buffing  // Disable buffing check for TRANSPORT missions
24
 * @property int    ally_help_weak  // Allow strong players to HOLD on weak co-ally planets
25
 * @property int    avatar_max_height  // Maximum height
26
 * @property int    avatar_max_width  // Maximum width
27
 * @property int    BuildLabWhileRun
28
 * @property string chat_highlight_admin  // Admin nick
29
 * @property string chat_highlight_developer  // Developer nick
30
 * @property string chat_highlight_moderator  // Moderator nick
31
 * @property string chat_highlight_operator  // Operator nick
32
 * @property string chat_highlight_premium  // Premium nick
33
 * @property int    chat_refresh_rate  // in seconds. Chat AJAX refresh rate
34
 * @property int    chat_timeout  // in seconds. Default = 15 min
35
 * @property string COOKIE_NAME
36
 * @property int    crystal_basic_income
37
 * @property int    db_manual_lock_enabled
38
 * @property int    db_version
39
 * @property int    debug
40
 * @property int    Defs_Cdr
41
 * @property int    deuterium_basic_income
42
 * @property int    eco_scale_storage
43
 * @property string eco_stockman_fleet  // Black Market - Starting amount of s/h ship merchant to sell
44
 * @property int    eco_stockman_fleet_populate   // Populate empty Stockman fleet with ships or not
45
 * @property int    empire_mercenary_base_period  // Base
46
 * @property int    empire_mercenary_temporary  // Temporary empire-wide mercenaries
47
 * @property int    energy_basic_income
48
 * @property int    fleet_bashing_attacks       // Max amount of attack per wave - 3 by default
49
 * @property int    fleet_bashing_interval    // Maximum interval between attacks when they still count as one wave - 3intm by default
50
 * @property int    fleet_bashing_scope   // Interval on which bashing waves counts - 24h by default
51
 * @property int    fleet_bashing_war_delay   // Delay before start bashing after declaring war to alliance - 12h by default
52
 * @property int    fleet_bashing_waves       // Max amount of waves per day - 3 by default
53
 * @property int    Fleet_Cdr
54
 * @property int    fleet_speed
55
 * @property int    fleet_update_interval
56
 * @property string game_adminEmail     // Admin's email to show to users
57
 * @property int    game_blitz_register   // Blitz registration status - see BLITZ_REGISTER_xxx constants
58
 * @property int    game_counter   // Does built-in page hit counter is on?
59
 * @property string game_default_language
60
 * @property string game_default_skin
61
 * @property string game_default_template
62
 * @property int    game_disable
63
 * @property string game_disable_reason
64
 * @property int    game_email_pm  // Is allowed forwarding messages from PM to e-mail?
65
 * @property int    game_maxGalaxy
66
 * @property int    game_maxPlanet
67
 * @property int    game_maxSystem
68
 * @property int    game_mode            // int - SuperNova, 1 - oGame
69
 * @property int    game_multiaccount_enabled  // 1 - allow interactions for players with same IP (multiaccounts)
70
 * @property string game_name  // Server name (would be on banners and on top of left menu)
71
 * @property int    game_news_actual  // How long announcement would be marked as "New". In seconds. Default - 3 days
72
 * @property int    game_news_overview     // How much last news to show in Overview page
73
 * @property int    game_noob_factor     // Multiplier to divide "stronger" and "weaker" users
74
 * @property int    game_noob_points  // Below this point user threated as noob. int to disable
75
 * @property int    game_speed  // Game speed
76
 * @property float  game_speed_expedition // Expedition speed. 1 means "normal"
77
 * @property int    game_user_changename  // Is user allowed to change name after registration?
78
 * @property int    game_user_changename_cost  // Change name cost for paid changename
79
 * @property string game_watchlist
80
 * @property array  game_watchlist_array
81
 * @property int    initial_fields
82
 * @property string int_banner_background
83
 * @property string int_banner_fontInfo
84
 * @property string int_banner_fontRaids
85
 * @property string int_banner_fontUniverse
86
 * @property int    int_banner_showInOverview
87
 * @property string int_banner_URL
88
 * @property string int_format_date  // Date default format
89
 * @property string int_format_time  // Time default format
90
 * @property string int_userbar_background
91
 * @property string int_userbar_font
92
 * @property int    int_userbar_showInOverview
93
 * @property string int_userbar_URL
94
 * @property int    LastSettedGalaxyPos
95
 * @property int    LastSettedPlanetPos
96
 * @property int    LastSettedSystemPos
97
 * @property int    locale_cache_disable  // Disable locale caching
98
 * @property int    metal_basic_income
99
 * @property string payment_currency_default
100
 * @property int    payment_currency_exchange_dm_
101
 * @property int    payment_currency_exchange_eur
102
 * @property int    payment_currency_exchange_mm_
103
 * @property int    payment_currency_exchange_rub
104
 * @property int    payment_currency_exchange_uah
105
 * @property int    payment_currency_exchange_usd
106
 * @property int    payment_currency_exchange_wmb
107
 * @property int    payment_currency_exchange_wme
108
 * @property int    payment_currency_exchange_wmr
109
 * @property int    payment_currency_exchange_wmu
110
 * @property int    payment_currency_exchange_wmz
111
 * @property int    payment_lot_price      // Lot price in default currency
112
 * @property int    payment_lot_size   // Lot size. Also service as minimum amount of DM that could be bought with one transaction
113
 * @property int    planet_teleport_cost  //
114
 * @property int    planet_teleport_timeout  //
115
 * @property int    player_delete_time  //
116
 * @property int    player_max_colonies  // Max player planet count (NOT including main planet)
117
 * @property int    player_metamatter_immortal
118
 * @property int    player_vacation_time  //
119
 * @property int    player_vacation_timeout  //
120
 * @property int    quest_total  // Total number of quests
121
 * @property int    resource_multiplier
122
 * @property int    rpg_bonus_divisor     // Amount of DM referral shoud get for partner have 1 DM bonus
123
 * @property int    rpg_bonus_minimum  // Minimum DM ammount for starting paying bonuses to affiliate
124
 * @property int    rpg_cost_banker  // Banker can hold some resources
125
 * @property int    rpg_cost_exchange  // Exchange allows resource trade between players
126
 * @property int    rpg_cost_info  // Infotrader sells valuable information about users, alliances and universe
127
 * @property int    rpg_cost_pawnshop  // You can get loan in pawnshop
128
 * @property int    rpg_cost_scraper  // Scrapper buys ship for fraction of cost
129
 * @property int    rpg_cost_stockman  // Stockman resells ship that was scrapped
130
 * @property int    rpg_cost_trader  // Trader trades between resources
131
 * @property int    rpg_exchange_crystal
132
 * @property int    rpg_exchange_darkMatter
133
 * @property int    rpg_exchange_deuterium
134
 * @property int    rpg_exchange_metal
135
 * @property int    rpg_flt_explore  // DM reward for finding Supernova in expedition
136
 * @property int    rpg_scrape_crystal
137
 * @property int    rpg_scrape_deuterium
138
 * @property int    rpg_scrape_metal
139
 * @property string security_ban_extra
140
 * @property int    security_write_full_url_disabled  // Disables writing full URLs to counter table
141
 * @property int    server_log_online  //
142
 * @property int    server_que_length_hangar  //
143
 * @property int    server_que_length_research  //
144
 * @property int    server_que_length_structures  //
145
 * @property string server_start_date  //
146
 * @property int    server_updater_check_auto  // Server autocheck version
147
 * @property int    server_updater_check_last  // Server last check time
148
 * @property int    server_updater_check_period  // Server autocheck period
149
 * @property int    server_updater_check_result  // Server last check result
150
 * @property int    server_updater_id  // Server ID on update server
151
 * @property string server_updater_key  // Server key on update server
152
 * @property int    stats_hide_admins
153
 * @property string stats_hide_player_list
154
 * @property int    stats_hide_pm_link
155
 * @property int    stats_history_days  // За сколько дней хранить статистику в базе
156
 * @property string stats_schedule
157
 * @property bool   tpl_allow_php // Allow template to include PHP code. SHOULD BE ALWAYS DISABLE!!!!!!!!
158
 * @property bool   tpl_minifier // Template minifier
159
 * @property int    uni_price_galaxy
160
 * @property int    uni_price_system
161
 * @property int    upd_lock_time  // How long update will lock table. Also update increment time when it requires
162
 * @property string url_faq
163
 * @property string url_forum
164
 * @property string url_purchase_metamatter
165
 * @property string url_rules
166
 * @property float  uni_galaxy_distance
167
 * @property int    users_amount
168
 * @property int    user_birthday_celebrate  // When last time celebrations (i.e. giftgiving) was made
169
 * @property int    user_birthday_gift  // User birthday gift
170
 * @property int    user_birthday_range  // How far in past can be user birthday for giving him gift
171
 * @property int    user_vacation_disable
172
 * @property int    var_db_update  // Time of last DB update
173
 * @property int    var_db_update_end  // Time when last DB update should end. Need to prevent duplicate update
174
 * @property int    var_news_last  // Last news post time
175
 * @property int    var_stat_update
176
 * @property int    var_stat_update_end
177
 * @property string var_stat_update_msg
178
 */
179
class classConfig extends classPersistent {
180
  protected $defaults = array(
181
    // SEO meta
182
    'adv_conversion_code_payment'  => '',
183
    'adv_conversion_code_register' => '',
184
    'adv_seo_meta_description'     => '',
185
    'adv_seo_meta_keywords'        => '',
186
    'adv_seo_javascript'           => '',
187
188
    // Advert banner
189
    'advGoogleLeftMenuIsOn'        => 0,
190
    'advGoogleLeftMenuCode'        => '(Place here code for banner)',
191
192
    // Alliance bonus calculations
193
    'ali_bonus_algorithm'          => 0,  // Bonus calculation algorithm
194
    'ali_bonus_brackets'           => 10, // Brackets count for ALI_BONUS_BY_RANK
195
    'ali_bonus_brackets_divisor'   => 10,// Bonus divisor for ALI_BONUS_BY_RANK
196
    'ali_bonus_divisor'            => 10000000, // Rank divisor for ALI_BONUS_BY_POINTS
197
    'ali_bonus_members'            => 10, // Minumum alliace size to start using bonus
198
199
    'allow_buffing'     => 0, // Disable buffing check for TRANSPORT missions
200
    'ally_help_weak'    => 0, // Allow strong players to HOLD on weak co-ally planets
201
202
    // User avatar and alliance logo
203
    'avatar_max_height' => 128, // Maximum height
204
    'avatar_max_width'  => 128, // Maximum width
205
206
    'BuildLabWhileRun'         => 0,
207
208
    // Chat settings
209
    // Nick highliting
210
    'chat_highlight_developer' => '<span class=\"nick_developer\">$1</span>', // Developer nick
211
    'chat_highlight_admin'     => '<span class=\"nick_admin\">$1</span>', // Admin nick
212
    'chat_highlight_moderator' => '<span class=\"nick_moderator\">$1</span>', // Moderator nick
213
    'chat_highlight_operator'  => '<span class=\"nick_operator\">$1</span>', // Operator nick
214
    'chat_highlight_premium'   => '<span class=\"nick_premium\">$1</span>', // Premium nick
215
    // Other chat settings
216
    'chat_refresh_rate'        => 5, // in seconds. Chat AJAX refresh rate
217
    'chat_timeout'             => 900, // in seconds. Default = 15 min
218
219
    'COOKIE_NAME'                  => 'SuperNova',
220
    'crystal_basic_income'         => 20,
221
    'debug'                        => 0,
222
    'Defs_Cdr'                     => 30,
223
    'deuterium_basic_income'       => 0,
224
    'eco_scale_storage'            => 1,
225
    'eco_stockman_fleet'           => '', // Black Market - Starting amount of s/h ship merchant to sell
226
    'eco_stockman_fleet_populate'  => 1,  // Populate empty Stockman fleet with ships or not
227
    'empire_mercenary_base_period' => PERIOD_MONTH, // Base
228
    'empire_mercenary_temporary'   => 0, // Temporary empire-wide mercenaries
229
    'energy_basic_income'          => 0,
230
231
    // Bashing protection settings
232
    'fleet_bashing_attacks'        => 3,      // Max amount of attack per wave - 3 by default
233
    'fleet_bashing_interval'       => 1800,   // Maximum interval between attacks when they still count as one wave - 30m by default
234
    'fleet_bashing_scope'          => 86400,  // Interval on which bashing waves counts - 24h by default
235
    'fleet_bashing_war_delay'      => 43200,  // Delay before start bashing after declaring war to alliance - 12h by default
236
    'fleet_bashing_waves'          => 3,      // Max amount of waves per day - 3 by default
237
238
    'Fleet_Cdr'   => 30,
239
    'fleet_speed' => 1,
240
241
    'fleet_update_interval' => 4,
242
243
    'game_adminEmail'       => 'root@localhost',    // Admin's email to show to users
244
    'game_counter'          => 0,  // Does built-in page hit counter is on?
245
    // Defaults
246
    'game_default_language' => 'ru',
247
    'game_default_skin'     => 'skins/EpicBlue/',
248
    'game_default_template' => 'OpenGame',
249
250
    'game_disable'        => GAME_DISABLE_INSTALL,
251
    'game_disable_reason' => 'SuperNova is in maintenance mode! Please return later!',
252
    'game_email_pm'       => 0, // Is allowed forwarding messages from PM to e-mail?
253
    // Universe size
254
    'game_maxGalaxy'      => 5,
255
    'game_maxSystem'      => 199,
256
    'game_maxPlanet'      => 15,
257
    // Game global settings
258
    'game_mode'           => 0,           // 0 - SuperNova, 1 - oGame
259
    'game_name'           => 'SuperNova', // Server name (would be on banners and on top of left menu)
260
261
    'game_news_actual'   => 259200, // How long announcement would be marked as "New". In seconds. Default - 3 days
262
    'game_news_overview' => 3,    // How much last news to show in Overview page
263
    // Noob protection
264
    'game_noob_factor'   => 5,    // Multiplier to divide "stronger" and "weaker" users
265
    'game_noob_points'   => 5000, // Below this point user threated as noob. 0 to disable
266
267
    'game_multiaccount_enabled' => 0, // 1 - allow interactions for players with same IP (multiaccounts)
268
269
    'game_speed'                => 1, // Game speed
270
    'game_speed_expedition'     => 1, // Expedition speed. 1 means "normal"
271
    'game_user_changename'      => 2, // Is user allowed to change name after registration?
272
    'game_user_changename_cost' => 100000, // Change name cost for paid changename
273
274
    'initial_fields'            => 163,
275
276
    // Interface - UserBanner
277
    'int_banner_background'     => 'design/images/banner.png',
278
    'int_banner_fontInfo'       => 'terminator.ttf',
279
    'int_banner_fontRaids'      => 'klmnfp2005.ttf',
280
    'int_banner_fontUniverse'   => 'cristal.ttf',
281
    'int_banner_showInOverview' => 1,
282
    'int_banner_URL'            => '/banner.php?type=banner',
283
284
    'int_format_date'            => 'd.m.Y', // Date default format
285
    'int_format_time'            => 'H:i:s', // Time default format
286
287
    // Interface - UserBar
288
    'int_userbar_background'     => 'design/images/userbar.png',
289
    'int_userbar_font'           => 'arialbd.ttf',
290
    'int_userbar_showInOverview' => 1,
291
    'int_userbar_URL'            => '/banner.php?type=userbar',
292
293
    'LastSettedGalaxyPos' => 1,
294
    'LastSettedPlanetPos' => 1,
295
    'LastSettedSystemPos' => 1,
296
297
    'locale_cache_disable' => 0, // Disable locale caching
298
299
    'metal_basic_income' => 40,
300
301
    'payment_currency_default'      => 'USD',
302
    'payment_currency_exchange_dm_' => METAMATTER_DEFAULT_LOT_SIZE,
303
    'payment_currency_exchange_mm_' => METAMATTER_DEFAULT_LOT_SIZE,
304
    'payment_currency_exchange_eur' => 0.90,
305
    'payment_currency_exchange_rub' => 60,
306
    'payment_currency_exchange_uah' => 30,
307
    'payment_currency_exchange_usd' => 1,
308
    'payment_currency_exchange_wmb' => 18000,
309
    'payment_currency_exchange_wme' => 0.9,
310
    'payment_currency_exchange_wmr' => 60,
311
    'payment_currency_exchange_wmu' => 30,
312
    'payment_currency_exchange_wmz' => 1,
313
314
    'payment_lot_price' => 1,     // Lot price in default currency
315
    'payment_lot_size'  => 2500,  // Lot size. Also service as minimum amount of DM that could be bought with one transaction
316
317
    'planet_teleport_cost'    => 50000, //
318
    'planet_teleport_timeout' => 86400, //
319
320
    'player_delete_time'      => 3888000, //
321
    'player_max_colonies'     => -1, // Max player planet count (NOT including main planet)
322
    'player_vacation_time'    => PERIOD_WEEK, //
323
    'player_vacation_timeout' => PERIOD_WEEK, //
324
325
    'player_metamatter_immortal' => 100000,
326
327
    // Quests
328
    'quest_total'                => 0, // Total number of quests
329
330
    'resource_multiplier'     => 1,
331
332
    //Roleplay system
333
    'rpg_bonus_divisor'       => 10,    // Amount of DM referral shoud get for partner have 1 DM bonus
334
    'rpg_bonus_minimum'       => 10000, // Minimum DM ammount for starting paying bonuses to affiliate
335
336
    // Black Market - General
337
    'rpg_cost_banker'         => 1000, // Banker can hold some resources
338
    'rpg_cost_exchange'       => 1000, // Exchange allows resource trade between players
339
    'rpg_cost_info'           => 10000, // Infotrader sells valuable information about users, alliances and universe
340
    'rpg_cost_pawnshop'       => 1000, // You can get loan in pawnshop
341
    'rpg_cost_scraper'        => 1000, // Scrapper buys ship for fraction of cost
342
    'rpg_cost_stockman'       => 1000, // Stockman resells ship that was scrapped
343
    'rpg_cost_trader'         => 1000, // Trader trades between resources
344
345
    // Black Market - Resource exachange rates
346
    'rpg_exchange_metal'      => 1,
347
    'rpg_exchange_crystal'    => 2,
348
    'rpg_exchange_deuterium'  => 4,
349
    'rpg_exchange_darkMatter' => 400,
350
351
    'rpg_flt_explore'      => 1000, // DM reward for finding Supernova in expedition
352
353
    // Black Market - Scraper rates for ship pre resource
354
    'rpg_scrape_crystal'   => 0.50,
355
    'rpg_scrape_deuterium' => 0.25,
356
    'rpg_scrape_metal'     => 0.75,
357
358
    'security_ban_extra'               => '',
359
    'security_write_full_url_disabled' => 1, // Disables writing full URLs to counter table
360
361
    'server_log_online' => 0, //
362
363
    'server_que_length_hangar'     => '5', //
364
    'server_que_length_research'   => '1', //
365
    'server_que_length_structures' => '5', //
366
367
    'server_start_date' => '', //
368
369
    'server_updater_check_auto'   => 0, // Server autocheck version
370
    'server_updater_check_last'   => 0, // Server last check time
371
    'server_updater_check_period' => PERIOD_DAY, // Server autocheck period
372
    'server_updater_check_result' => SNC_VER_NEVER, // Server last check result
373
    'server_updater_id'           => 0, // Server ID on update server
374
    'server_updater_key'          => '', // Server key on update server
375
376
    'stats_history_days'     => 14, // За сколько дней хранить статистику в базе
377
    'stats_hide_admins'      => 1,
378
    'stats_hide_player_list' => '',
379
    'stats_hide_pm_link'     => 0,
380
    'stats_schedule'         => '04:00:00',
381
382
    'tpl_allow_php' => 0, // Allow template to include PHP code. SHOULD BE ALWAYS DISABLE!!!!!!!!
383
    'tpl_minifier'  => 1, // Template minifier
384
385
    'uni_price_galaxy' => 10000,
386
    'uni_price_system' => 1000,
387
388
    'upd_lock_time' => 60, // How long update will lock table. Also update increment time when it requires
389
390
    'url_faq'                 => '',
391
    'url_forum'               => '',
392
    'url_purchase_metamatter' => '',
393
    'url_rules'               => '',
394
395
    'users_amount' => 1,
396
397
    'user_birthday_celebrate' => 0, // When last time celebrations (i.e. giftgiving) was made
398
    'user_birthday_gift'      => 0, // User birthday gift
399
    'user_birthday_range'     => PERIOD_MONTH, // How far in past can be user birthday for giving him gift
400
401
    'user_vacation_disable' => 0,
402
403
    'var_db_update'     => 0, // Time of last DB update
404
    'var_db_update_end' => 0, // Time when last DB update should end. Need to prevent duplicate update
405
406
    'var_news_last'       => 0, // Last news post time
407
408
    // Statistic
409
    'var_stat_update'     => 0,
410
    'var_stat_update_end' => 0,
411
    'var_stat_update_msg' => 'Update never started',
412
413
  );
414
415
  public function __construct($gamePrefix = 'sn_') {
416
    parent::__construct($gamePrefix, 'config');
417
  }
418
419 View Code Duplication
  public static function getInstance($gamePrefix = 'sn_', $table_name = 'config') {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
420
    if (!isset(self::$cacheObject)) {
421
      $className = get_class();
422
      self::$cacheObject = new $className($gamePrefix, $table_name);
423
    }
424
425
    return self::$cacheObject;
426
  }
427
428
  /**
429
   * Repacks option with players ID so only exists ID left
430
   *
431
   * @param string $optionName
432
   */
433
  public function repackExistsOptionPlayerIdString($optionName) {
434
    sn_db_transaction_start();
435
    $this->db_loadItem($optionName);
436
    $this->db_saveItem($optionName, DBStaticUser::filterIdListStringRepack($this->db_loadItem($optionName)));
437
    classSupernova::$debug->warning('Repacked game_watchlist', 'System maintenance', LOG_INFO_MAINTENANCE);
438
    sn_db_transaction_commit();
439
  }
440
441
}
442