Completed
Push — work-fleets ( 4d76fa...c97fe0 )
by SuperNova.WS
05:17
created

flying_fleets.php (1 issue)

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
include('common.' . substr(strrchr(__FILE__, '.'), 1));
4
5
global $user, $planetrow;
6
7
if(!empty($_POST['return']) && is_array($_POST['return'])) {
8
  foreach($_POST['return'] as $fleet_id) {
9
    if($fleet_id = idval($fleet_id)) {
10
      sn_db_transaction_start();
11
      $objFleet = new Fleet();
12
      $objFleet->dbLoad($fleet_id);
13
14
      if ($objFleet->playerOwnerId == $user['id'] && !$objFleet->isReturning()) {
15
        $objFleet->commandReturn();
16
      } elseif ($objFleet->dbId && $objFleet->playerOwnerId != $user['id']) {
17
        sn_db_transaction_rollback();
18
        classSupernova::$debug->warning('Trying to return fleet that not belong to user', 'Hack attempt', 302, array(
0 ignored issues
show
array('base_dump' => tru...ser_id' => $user['id']) is of type array<string,?,{"base_du...nteger","user_id":"?"}>, but the function expects a boolean.

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...
19
          'base_dump' => true,
20
          'fleet_owner_id' => $objFleet->playerOwnerId,
21
          'user_id' => $user['id'])
22
        );
23
        die('Hack attempt 302');
24
      }
25
      sn_db_transaction_commit();
26
    }
27
  }
28
}
29
30
lng_include('overview');
31
lng_include('fleet');
32
33
if(!$planetrow) {
34
  message(classLocale::$lang['fl_noplanetrow'], classLocale::$lang['fl_error']);
35
}
36
37
$template = gettemplate('flying_fleets', true);
38
39
$i = 0;
40
$objFleetList = FleetList::dbGetFleetListByOwnerId($user['id']);
41
if(!empty($objFleetList)) {
42
  foreach($objFleetList->_container as $fleet_id => $objFleet) {
43
    $i++;
44
    $fleet_data = tplParseFleetObject($objFleet, $i, $user);
45
46
    $template->assign_block_vars('fleets', $fleet_data['fleet']);
47
48
    foreach($fleet_data['ships'] as $ship_data) {
49
      $template->assign_block_vars('fleets.ships', $ship_data);
50
    }
51
  }
52
}
53
54
$MaxExpeditions = get_player_max_expeditons($user);
55
$FlyingExpeditions = FleetList::fleet_count_flying($user['id'], MT_EXPLORE);
56
$fleet_flying_amount = FleetList::fleet_count_flying($user['id'], MT_EXPLORE);
57
58
$template->assign_vars(array(
59
  'FLEETS_FLYING'      => $fleet_flying_amount,
60
  'FLEETS_MAX'         => GetMaxFleets($user),
61
  'EXPEDITIONS_FLYING' => $FlyingExpeditions,
62
  'EXPEDITIONS_MAX'    => $MaxExpeditions,
63
));
64
65
display($template, classLocale::$lang['fl_title']);
66