Completed
Push — work-fleets ( 45d3a1...6724fd )
by SuperNova.WS
09:14 queued 03:18
created

overview.php (4 issues)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * index.php - overview.php
4
 *
5
 * 2.4 - copyright (c) 2010 by Gorlum for http://supernova.ws
6
 *     [-] Removed News frame
7
 *     [-] Time & Usersonline moved to Top-Frame
8
 * 2.3 - copyright (c) 2010 by Gorlum for http://supernova.ws
9
 *     [*] Complying with PCG
10
 * 2.2 - copyright (c) 2010 by Gorlum for http://supernova.ws
11
 *     [+] Redo flying fleet list
12
 * 2.1 - copyright (c) 2010 by Gorlum for http://supernova.ws
13
 *     [+] Planets on planet list now have indication of planet fill
14
 *     [+] Planets on planet list now have indication when there is enemy fleet flying to planet
15
 * 2.0 - copyright (c) 2010 by Gorlum for http://supernova.ws
16
 *     [+] Now there is full planet list on right side of screen a-la oGame
17
 *     [+] Planet list now include icons for buildings/tech/fleet on progress
18
 * 1.5 - copyright (c) 2010 by Gorlum for http://supernova.ws
19
 *     [*] Subplanet timers now use sn_timer.js library
20
 * 1.4 - copyright (c) 2010 by Gorlum for http://supernova.ws
21
 *     [*] All mainplanet timers now use new sn_timer.js library
22
 * 1.3 - copyright (c) 2010 by Gorlum for http://supernova.ws
23
 *     [*] Adjusted layouts of player infos
24
 * 1.2 - copyright (c) 2010 by Gorlum for http://supernova.ws
25
 *     [*] Adjusted layouts of planet infos
26
 * 1.1 - Security checks by Gorlum for http://supernova.ws
27
 * @version 1
28
 * @copyright 2008 By Chlorel for XNova
29
 */
30
31
//define('SN_RENDER_NAVBAR_PLANET', false);
32
33
include('common.' . substr(strrchr(__FILE__, '.'), 1));
34
35
//$ccc = 0;
36
//foreach(DBStaticUser::db_user_list_non_bots() as $ip) {
37
//  $ccc++;
38
//}
39
//pdump($ccc);
40
//
41
//foreach(DBStaticUser::db_user_list_non_bots() as $ip) {
42
//  pdump($ip['id']);
43
//  $ccc++;
44
//}
45
//
46
//pdump(DBStaticUser::db_user_list_non_bots());
47
48
lng_include('overview');
49
50
$result = array();
51
52
switch($mode = sys_get_param_str('mode')) {
53
  case 'manage':
54
    sn_sys_sector_buy('overview.php?mode=manage');
55
56
    $user_dark_matter = mrc_get_level($user, null, RES_DARK_MATTER);
57
    $result[] = sn_sys_planet_core_transmute($user, $planetrow);
58
59
    $template  = gettemplate('planet_manage', true);
60
    $planet_id = sys_get_param_id('planet_id');
61
62
    if(sys_get_param_str('rename') && ($new_name_unsafe = sys_get_param_str_unsafe('new_name'))) {
63
      $planetrow['name'] = $new_name_unsafe;
64
      DBStaticPlanet::db_planet_update_set_by_id(
65
        $planetrow['id'],
66
        array(
0 ignored issues
show
array('name' => $new_name_unsafe) is of type array<string,string,{"name":"string"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
67
          'name' => $new_name_unsafe,
68
        )
69
      );
70
    } elseif(sys_get_param_str('action') == 'make_capital') {
71
      try {
72
        sn_db_transaction_start();
73
        $user = DBStaticUser::db_user_by_id($user['id'], true, '*');
74
        $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true, '*');
75
76 View Code Duplication
        if($planetrow['planet_type'] != PT_PLANET) {
77
          throw new exception(classLocale::$lang['ov_capital_err_not_a_planet'], ERR_ERROR);
78
        }
79
80
        if($planetrow['id'] == $user['id_planet']) {
81
          throw new exception(classLocale::$lang['ov_capital_err_capital_already'], ERR_ERROR);
82
        }
83
84
        if($user_dark_matter < classSupernova::$config->planet_capital_cost) {
85
          throw new exception(classLocale::$lang['ov_capital_err_no_dark_matter'], ERR_ERROR);
86
        }
87
88
        rpg_points_change($user['id'], RPG_CAPITAL, -classSupernova::$config->planet_capital_cost,
89
          array('Planet %s ID %d at coordinates %s now become Empire Capital', $planetrow['name'], $planetrow['id'], uni_render_coordinates($planetrow))
90
        );
91
92
        DBStaticUser::db_user_set_by_id(
93
          $user['id'],
94
          array(
95
            'id_planet' => $planetrow['id'],
96
            'galaxy'    => $planetrow['galaxy'],
97
            'system'    => $planetrow['system'],
98
            'planet'    => $planetrow['planet'],
99
          )
100
        );
101
102
        $user['id_planet'] = $planetrow['id'];
103
        $result[] = array(
104
          'STATUS'  => ERR_NONE,
105
          'MESSAGE' => classLocale::$lang['ov_capital_err_none'],
106
        );
107
        sn_db_transaction_commit();
108
        sys_redirect('overview.php?mode=manage');
109
      } catch(exception $e) {
110
        sn_db_transaction_rollback();
111
        $result[] = array(
112
          'STATUS'  => $e->getCode(),
113
          'MESSAGE' => $e->getMessage(),
114
        );
115
      }
116
    } elseif(sys_get_param_str('action') == 'planet_teleport') {
117
      try {
118
        if(!uni_coordinates_valid($new_coordinates = array(
119
          'galaxy' => sys_get_param_int('new_galaxy'),
120
          'system' => sys_get_param_int('new_system'),
121
          'planet' => sys_get_param_int('new_planet')))
122
        ) {
123
          throw new exception(classLocale::$lang['ov_teleport_err_wrong_coordinates'], ERR_ERROR);
124
        }
125
126
        sn_db_transaction_start();
127
        // При телепорте обновлять данные не надо - просто получить текущие данные и залочить их
128
        $user = DBStaticUser::db_user_by_id($user['id'], true, '*');
129
        $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true, '*');
130
//        $global_data = sys_o_get_updated($user, $planetrow['id'], SN_TIME_NOW);
131
//        $user = $global_data['user'];
132
//        $planetrow = $global_data['planet'];
133
134
        $can_teleport = uni_planet_teleport_check($user, $planetrow, $new_coordinates);
135
        if($can_teleport['result'] != ERR_NONE) {
136
          throw new exception($can_teleport['message'], $can_teleport['result']);
137
        }
138
139
        rpg_points_change($user['id'], RPG_TELEPORT, -classSupernova::$config->planet_teleport_cost,
140
          array(&classLocale::$lang['ov_teleport_log_record'], $planetrow['name'], $planetrow['id'], uni_render_coordinates($planetrow), uni_render_coordinates($new_coordinates))
141
        );
142
        $planet_teleport_next = SN_TIME_NOW + classSupernova::$config->planet_teleport_timeout;
143
        DBStaticPlanet::db_planet_update_by_gspt(
144
          $planetrow['galaxy'], $planetrow['system'], $planetrow['planet'], PT_ALL,
145
          array(
146
            'galaxy'               => $new_coordinates['galaxy'],
147
            'system'               => $new_coordinates['system'],
148
            'planet'               => $new_coordinates['planet'],
149
            'planet_teleport_next' => $planet_teleport_next,
150
          ),
151
          array()
152
        );
153
154
        if($planetrow['id'] == $user['id_planet']) {
155
          DBStaticUser::db_user_set_by_id(
156
            $user['id'],
157
            array(
158
              'galaxy' => $new_coordinates['galaxy'],
159
              'system' => $new_coordinates['system'],
160
              'planet' => $new_coordinates['planet'],
161
            )
162
          );
163
        }
164
165
        // $global_data = sys_o_get_updated($user, $planetrow['id'], SN_TIME_NOW);
166
        sn_db_transaction_commit();
167
        $user = DBStaticUser::db_user_by_id($user['id'], true, '*');
168
        $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true, '*');
169
        $result[] = array(
170
          'STATUS'  => ERR_NONE,
171
          'MESSAGE' => classLocale::$lang['ov_teleport_err_none'],
172
        );
173
        sys_redirect('overview.php?mode=manage');
174
      } catch(exception $e) {
175
        sn_db_transaction_rollback();
176
        $result[] = array(
177
          'STATUS'  => $e->getCode(),
178
          'MESSAGE' => $e->getMessage(),
179
        );
180
      }
181
    } elseif(sys_get_param_str('action') == 'planet_abandon') {
182
      // if(sec_password_check($user['id'], sys_get_param('abandon_confirm'))) {
183
      if(classSupernova::$auth->password_check(sys_get_param('abandon_confirm'))) {
184
        if($user['id_planet'] != $user['current_planet'] && $user['current_planet'] == $planet_id) {
185
          $destroyed = SN_TIME_NOW + 60 * 60 * 24;
186
          DBStaticPlanet::db_planet_update_set_by_id(
187
            $user['current_planet'],
188
            array(
0 ignored issues
show
array('destruyed' => $destroyed, 'id_owner' => 0) is of type array<string,integer,{"d...,"id_owner":"integer"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
189
              'destruyed' => $destroyed,
190
              'id_owner'  => 0,
191
            )
192
          );
193
194
          DBStaticPlanet::db_planet_set_by_parent(
195
            $user['current_planet'],
196
            array(
197
              'destruyed' => $destroyed,
198
              'id_owner'  => 0,
199
            )
200
          );
201
          DBStaticUser::db_user_set_by_id(
202
            $user['id'],
203
            array('current_planet' => $user['id_planet'])
204
          );
205
          message(classLocale::$lang['ov_delete_ok'], classLocale::$lang['colony_abandon'], 'overview.php?mode=manage');
206
        } else {
207
          message(classLocale::$lang['ov_delete_wrong_planet'], classLocale::$lang['colony_abandon'], 'overview.php?mode=manage');
208
        }
209
      } else {
210
        message(classLocale::$lang['ov_delete_wrong_pass'] , classLocale::$lang['colony_abandon'], 'overview.php?mode=manage');
211
      }
212
    } elseif(
213
      ($hire = sys_get_param_int('hire')) && in_array($hire, sn_get_groups('governors'))
214
      && (
215
        !get_unit_param($hire, P_MAX_STACK) ||
216
        ($planetrow['PLANET_GOVERNOR_ID'] != $hire) ||
217
        (
218
          $planetrow['PLANET_GOVERNOR_ID'] == $hire &&
219
          $planetrow['PLANET_GOVERNOR_LEVEL'] < get_unit_param($hire, P_MAX_STACK)
220
        )
221
      )
222
    ) {
223
      sn_db_transaction_start();
224
      $user = DBStaticUser::db_user_by_id($user['id'], true);
225
      $planetrow = DBStaticPlanet::db_planet_by_id($planetrow['id'], true);
226
      $build_data = eco_get_build_data($user, $planetrow, $hire, $planetrow['PLANET_GOVERNOR_ID'] == $hire ? $planetrow['PLANET_GOVERNOR_LEVEL'] : 0);
227
      if($build_data['CAN'][BUILD_CREATE]) {
228
        if($planetrow['PLANET_GOVERNOR_ID'] == $hire) {
229
          $planetrow['PLANET_GOVERNOR_LEVEL']++;
230
        } else {
231
          $planetrow['PLANET_GOVERNOR_LEVEL'] = 1;
232
          $planetrow['PLANET_GOVERNOR_ID'] = $hire;
233
        }
234
        DBStaticPlanet::db_planet_update_set_by_id(
235
          $planetrow['id'],
236
          array(
0 ignored issues
show
array('PLANET_GOVERNOR_I...LANET_GOVERNOR_LEVEL']) is of type array<string,?,{"PLANET_...T_GOVERNOR_LEVEL":"?"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
237
            'PLANET_GOVERNOR_ID' => $hire,
238
            // TODO - change it
239
            'PLANET_GOVERNOR_LEVEL' => $planetrow['PLANET_GOVERNOR_LEVEL'],
240
          )
241
        );
242
243
        rpg_points_change(
244
          $user['id'],
245
          RPG_GOVERNOR,
246
          -$build_data[BUILD_CREATE][RES_DARK_MATTER],
247
          sprintf(classLocale::$lang['ov_governor_purchase'], classLocale::$lang['tech'][$hire], $hire, $planetrow['PLANET_GOVERNOR_LEVEL'], uni_render_planet_full($planetrow, '', false, true))
248
        );
249
250
        //  => 'Игрок купил Губернатора %1$s ID %2$d уровня %3$d на планету %4$s',
251
        // die();
252
      }
253
      sn_db_transaction_commit();
254
      sys_redirect('overview.php?mode=manage');
255
      die();
256
    }
257
258
    lng_include('mrc_mercenary');
259
    int_planet_pretemplate($planetrow, $template);
260
    foreach(sn_get_groups('governors') as $governor_id) {
261
      if($planetrow['planet_type'] == PT_MOON && $governor_id == MRC_TECHNOLOGIST) {
262
        continue;
263
      }
264
265
      $governor_level = $planetrow['PLANET_GOVERNOR_ID'] == $governor_id ? $planetrow['PLANET_GOVERNOR_LEVEL'] : 0;
266
      $build_data = eco_get_build_data($user, $planetrow, $governor_id, $governor_level);
267
      $template->assign_block_vars('governors', array(
268
        'ID'         => $governor_id,
269
        'NAME'       => classLocale::$lang['tech'][$governor_id],
270
        'COST'       => $build_data[BUILD_CREATE][RES_DARK_MATTER],
271
        'MAX'        => get_unit_param($governor_id, P_MAX_STACK),
272
        'LEVEL'      => $governor_level,
273
        'LEVEL_PLUS' => mrc_get_level($user, $planetrow, $governor_id) - $governor_level,
274
      ));
275
    }
276
277
    $user_dark_matter = mrc_get_level($user, null, RES_DARK_MATTER);
278
    $planet_density_index = $planetrow['density_index'];
279
    $density_price_chart = planet_density_price_chart($planetrow);
280
    tpl_planet_density_info($template, $density_price_chart, $user_dark_matter);
281
282
    $sector_cost = eco_get_build_data($user, $planetrow, UNIT_SECTOR, mrc_get_level($user, $planetrow, UNIT_SECTOR), true);
283
    $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER];
284
    $planet_fill = floor($planetrow['field_current'] / eco_planet_fields_max($planetrow) * 100);
285
    $planet_fill = $planet_fill > 100 ? 100 : $planet_fill;
286
    $can_teleport = uni_planet_teleport_check($user, $planetrow);
287
    $template->assign_vars(array(
288
      'DARK_MATTER'           => $user_dark_matter,
289
290
      'PLANET_FILL'           => floor($planetrow['field_current'] / eco_planet_fields_max($planetrow) * 100),
291
      'PLANET_FILL_BAR'       => $planet_fill,
292
      'SECTOR_CAN_BUY'        => $sector_cost <= $user_dark_matter,
293
      'SECTOR_COST'           => $sector_cost,
294
      'SECTOR_COST_TEXT'      => pretty_number($sector_cost),
295
      'planet_field_current'  => $planetrow['field_current'],
296
      'planet_field_max'      => eco_planet_fields_max($planetrow),
297
298
      'CAN_TELEPORT'          => $can_teleport['result'] == ERR_NONE,
299
      'CAN_NOT_TELEPORT_MSG'  => $can_teleport['message'],
300
      'TELEPORT_COST_TEXT'    => pretty_number(classSupernova::$config->planet_teleport_cost, true, $user_dark_matter),
301
302
      'CAN_CAPITAL'           => $user_dark_matter >= classSupernova::$config->planet_capital_cost,
303
      'CAPITAL_COST_TEXT'     => pretty_number(classSupernova::$config->planet_capital_cost, true, $user_dark_matter),
304
305
      'PLANET_DENSITY_INDEX'  => $planet_density_index,
306
      'PLANET_CORE_TEXT'      => classLocale::$lang['uni_planet_density_types'][$planet_density_index],
307
308
      'IS_CAPITAL'            => $planetrow['id'] == $user['id_planet'],
309
310
      'PAGE_HINT'   => classLocale::$lang['ov_manage_page_hint'],
311
    ));
312
313
    foreach($result as &$a_result) {
314
      $template->assign_block_vars('result', $a_result);
315
    }
316
317
    display($template, classLocale::$lang['rename_and_abandon_planet']);
318
  break;
319
320
  default:
321
    sn_sys_sector_buy();
322
323
    if(sys_get_param_str('rename') && $new_name_unsafe = sys_get_param_str_unsafe('new_name')) {
324
      $planetrow['name'] = $new_name_unsafe;
325
      DBStaticPlanet::db_planet_update_set_by_id(
326
        $planetrow['id'],
327
        array(
0 ignored issues
show
array('name' => $new_name_unsafe) is of type array<string,string,{"name":"string"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
328
          'name' => $new_name_unsafe,
329
        )
330
      );
331
332
    }
333
334
    $result[] = sn_sys_planet_core_transmute($user, $planetrow);
335
336
    $template = gettemplate('planet_overview', true);
337
338
    $user_dark_matter = mrc_get_level($user, null, RES_DARK_MATTER);
339
340
    $planet_density_index = $planetrow['density_index'];
341
    $density_price_chart = planet_density_price_chart($planetrow);
342
    tpl_planet_density_info($template, $density_price_chart, $user_dark_matter);
343
344
    rpg_level_up($user, RPG_STRUCTURE);
345
    rpg_level_up($user, RPG_RAID);
346
    rpg_level_up($user, RPG_TECH);
347
    rpg_level_up($user, RPG_EXPLORE);
348
349
    $fleet_id = 1;
350
351
//    $fleet_and_missiles_list = FleetList::fleet_and_missiles_list_incoming($user['id']);
352
//    $fleets = flt_parse_fleets_to_events($fleet_and_missiles_list);
353
    $fleet_and_missiles_list = FleetList::dbGetFleetListAndMissileINCOMING($user['id']);
354
    $fleets = flt_parse_objFleetList_to_events($fleet_and_missiles_list);
355
356
    $planet_count = 0;
357
    $planets_query = DBStaticPlanet::db_planet_list_sorted($user, false, '*');
358
    foreach($planets_query as $an_id => $UserPlanet) {
359
      sn_db_transaction_start();
360
      $UserPlanet = sys_o_get_updated($user, $UserPlanet['id'], SN_TIME_NOW, false, true);
361
      sn_db_transaction_commit();
362
      $list_planet_que = $UserPlanet['que'];
363
      $UserPlanet = $UserPlanet['planet'];
364
365
      $template_planet = tpl_parse_planet($UserPlanet);
366
367
      $planet_fleet_id = 0;
368
      $fleet_list = $template_planet['fleet_list'];
369 View Code Duplication
      if($fleet_list['own']['count']) {
370
        $planet_fleet_id = "p{$UserPlanet['id']}";
371
        $fleets_to_planet[$UserPlanet['id']] = tpl_parse_fleet_sn($fleet_list['own']['total'], $planet_fleet_id);
372
//        $fleet_id++;tpl_parse_fleet_sn
373
      }
374
      if($UserPlanet['planet_type'] == PT_MOON) {
375
        continue;
376
      }
377
      $moon = DBStaticPlanet::db_planet_by_parent($UserPlanet['id']);
378
      if($moon) {
379
        $moon_fill = min(100, floor($moon['field_current'] / eco_planet_fields_max($moon) * 100));
380
      } else {
381
        $moon_fill = 0;
382
      }
383
384
//      $moon_fleets = flt_get_fleets_to_planet($moon);
385
      $moon_fleets = FleetList::EMULATE_flt_get_fleets_to_planet($moon);
386
//      $moon_fleets = array();
387
//      $fleet_db_list = FleetList::dbGetFleetListAndMissileByCoordinates($moon);
388
//      /**
389
//       * @var Fleet[] $array_of_Fleet
390
//       */
391
//      $array_of_Fleet = array();
392
//      if(!empty($fleet_db_list) && $fleet_db_list->count()) {
393
//        foreach($fleet_db_list->_container as $fleet_id => $objFleet) {
394
//          $array_of_Fleet[$fleet_id] = $objFleet;
395
//        }
396
//        $moon_fleets = flt_get_fleets_to_planet_by_array_of_Fleet($array_of_Fleet);
397
//      }
398
399
      $template->assign_block_vars('planet', array_merge($template_planet, array(
400
        'PLANET_FLEET_ID'  => $planet_fleet_id,
401
402
        'MOON_ID'      => $moon['id'],
403
        'MOON_NAME'    => $moon['name'],
404
        'MOON_IMG'     => $moon['image'],
405
        'MOON_FILL'    => min(100, $moon_fill),
406
        'MOON_ENEMY'   => !empty($moon_fleets['enemy']['count']) ? $moon_fleets['enemy']['count'] : 0,
407
408
        'MOON_PLANET'  => $moon['parent_planet'],
409
      )));
410
411
      $planet_count++;
412
    }
413
414
    tpl_assign_fleet($template, $fleets_to_planet);
415
    tpl_assign_fleet($template, $fleets);
416
417
    $lune = $planetrow['planet_type'] == PT_PLANET ? DBStaticPlanet::db_planet_by_parent($planetrow['id']) : DBStaticPlanet::db_planet_by_id($planetrow['parent_planet']);
418
    if($lune) {
419
      $template->assign_vars(array(
420
        'MOON_ID' => $lune['id'],
421
        'MOON_IMG' => $lune['image'],
422
        'MOON_NAME' => $lune['name'],
423
      ));
424
    }
425
426
    $planet_fill = floor($planetrow['field_current'] / eco_planet_fields_max($planetrow) * 100);
427
    $planet_fill = $planet_fill > 100 ? 100 : $planet_fill;
428
429
    $planet_recyclers_orbiting = 0;
430
    foreach(Fleet::$snGroupRecyclers as $recycler_id) {
431
      $planet_recyclers_orbiting += mrc_get_level($user, $planetrow, $recycler_id);
432
    }
433
434
    int_planet_pretemplate($planetrow, $template);
435
436
    $sn_group_ques = sn_get_groups('ques');
437
    if(!defined('GAME_STRUCTURES_DISABLED') || !GAME_STRUCTURES_DISABLED) {
438
      foreach(array(QUE_STRUCTURES => $sn_group_ques[QUE_STRUCTURES]) as $que_id => $que_type_data) {
439
        $this_que = $que['ques'][$que_id][$user['id']][$planetrow['id']];
440
        $template->assign_block_vars('ques', array(
441
          'ID'     => $que_id,
442
          'NAME'   => classLocale::$lang['sys_ques'][$que_id],
443
          'LENGTH' => empty($this_que) ? 0 : count($this_que),
444
        ));
445
446
        if(!empty($this_que)) {
447
          foreach($this_que as $que_item) {
448
            $template->assign_block_vars('que', que_tpl_parse_element($que_item));
449
          }
450
        }
451
      }
452
    }
453
454
    $que_hangar_length = tpl_assign_hangar($template, $planetrow, SUBQUE_FLEET);
455
    $template->assign_block_vars('ques', array(
456
      'ID'     => QUE_HANGAR,
457
      'NAME'   => classLocale::$lang['sys_ques'][QUE_HANGAR],
458
      'LENGTH' => $que_hangar_length,
459
    ));
460
461
    if(!defined('GAME_DEFENSE_DISABLED') || !GAME_DEFENSE_DISABLED) {
462
      $que_hangar_length = tpl_assign_hangar($template, $planetrow, SUBQUE_DEFENSE);
463
      $template->assign_block_vars('ques', array(
464
        'ID'     => SUBQUE_DEFENSE,
465
        'NAME'   => classLocale::$lang['sys_ques'][SUBQUE_DEFENSE],
466
        'LENGTH' => $que_hangar_length,
467
      ));
468
    }
469
470
    $overview_planet_rows = $user['opt_int_overview_planet_rows'];
471
    $overview_planet_columns = $user['opt_int_overview_planet_columns'];
472
473
    if($overview_planet_rows <= 0 && $overview_planet_columns <= 0) {
474
      $overview_planet_rows = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_rows'];
475
      $overview_planet_columns = $user_option_list[OPT_INTERFACE]['opt_int_overview_planet_columns'];
476
    }
477
478
    if($overview_planet_rows > 0 && $overview_planet_columns <= 0) {
479
      $overview_planet_columns = ceil($planet_count / $overview_planet_rows);
480
    }
481
482
    $sector_cost = eco_get_build_data($user, $planetrow, UNIT_SECTOR, mrc_get_level($user, $planetrow, UNIT_SECTOR), true);
483
    $sector_cost = $sector_cost[BUILD_CREATE][RES_DARK_MATTER];
484
    $governor_level = $planetrow['PLANET_GOVERNOR_ID'] ? mrc_get_level($user, $planetrow, $planetrow['PLANET_GOVERNOR_ID'], false, true) : 0;
485
    $template->assign_vars(array(
486
      'USER_ID'               => $user['id'],
487
      'user_username'         => $user['username'],
488
      'USER_AUTHLEVEL'        => $user['authlevel'],
489
490
      'NEW_MESSAGES'          => $user['new_message'],
491
      'NEW_LEVEL_MINER'       => $level_miner,
492
      'NEW_LEVEL_RAID'        => $level_raid,
493
494
      'planet_diameter'       => pretty_number($planetrow['diameter']),
495
      'planet_field_current'  => $planetrow['field_current'],
496
      'planet_field_max'      => eco_planet_fields_max($planetrow),
497
      'PLANET_FILL'           => floor($planetrow['field_current'] / eco_planet_fields_max($planetrow) * 100),
498
      'PLANET_FILL_BAR'       => $planet_fill,
499
      'metal_debris'          => pretty_number($planetrow['debris_metal']),
500
      'crystal_debris'        => pretty_number($planetrow['debris_crystal']),
501
      'PLANET_RECYCLERS'      => $planet_recyclers_orbiting,
502
      'planet_image'          => $planetrow['image'],
503
      'planet_temp_min'       => $planetrow['temp_min'],
504
      'planet_temp_avg'       => round(($planetrow['temp_min'] + $planetrow['temp_max']) / 2),
505
      'planet_temp_max'       => $planetrow['temp_max'],
506
      'planet_density'        => $planetrow['density'],
507
      'planet_density_index'  => $planetrow['density_index'],
508
      'planet_density_text'   => classLocale::$lang['uni_planet_density_types'][$planetrow['density_index']],
509
510
      'GATE_LEVEL'            => mrc_get_level($user, $planetrow, STRUC_MOON_GATE),
511
      'GATE_JUMP_REST_TIME'   => uni_get_time_to_jump($planetrow),
512
513
      'ADMIN_EMAIL'           => classSupernova::$config->game_adminEmail,
514
515
      'PLANET_GOVERNOR_ID'    => $planetrow['PLANET_GOVERNOR_ID'],
516
//      'PLANET_GOVERNOR_LEVEL' => $planetrow['PLANET_GOVERNOR_LEVEL'] mrc_get_level($user, $planetrow,),
517
      'PLANET_GOVERNOR_LEVEL' => $governor_level,
518
      'PLANET_GOVERNOR_LEVEL_PLUS' => mrc_get_level($user, $planetrow, $planetrow['PLANET_GOVERNOR_ID']) - $governor_level,
519
      'PLANET_GOVERNOR_NAME'  => classLocale::$lang['tech'][$planetrow['PLANET_GOVERNOR_ID']],
520
521
      'LIST_ROW_COUNT'        => $overview_planet_rows,
522
      'LIST_COLUMN_COUNT'     => $overview_planet_columns,
523
524
      'DARK_MATTER'           => $user_dark_matter,
525
526
      'PLANET_DENSITY_INDEX'  => $planet_density_index,
527
      'PLANET_CORE_TEXT'      => classLocale::$lang['uni_planet_density_types'][$planet_density_index],
528
529
      'SECTOR_CAN_BUY'        => $sector_cost <= mrc_get_level($user, null, RES_DARK_MATTER),
530
      'SECTOR_COST'           => $sector_cost,
531
      'SECTOR_COST_TEXT'      => pretty_number($sector_cost),
532
    ));
533
    tpl_set_resource_info($template, $planetrow, $fleets_to_planet, 2);
534
535
    foreach($result as &$a_result) {
536
      $template->assign_block_vars('result', $a_result);
537
    }
538
539
    $classLocale = classLocale::$lang;
540
    display($template, "{$classLocale['ov_overview']} - {$classLocale['sys_planet_type'][$planetrow['planet_type']]} {$planetrow['name']} [{$planetrow['galaxy']}:{$planetrow['system']}:{$planetrow['planet']}]");
541
  break;
542
}
543