Completed
Push — work-fleets ( ff9a05...837dd8 )
by SuperNova.WS
05:12
created

phalanx.php (1 issue)

Labels
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
/**
4
 * phalanx.php
5
 *
6
 * 2.0 copyright (c) 2009-2011 by Gorlum for http://supernova.ws
7
     [!] Full rewrote using SN functions
8
 * 1.2 - Security checks & tests by Gorlum for http://supernova.ws
9
 * @version 1.1
10
 * @original made by ????
11
 * @copyright 2008 by Pada for XNova.project.es
12
 */
13
14
include('common.' . substr(strrchr(__FILE__, '.'), 1));
15
16
lng_include('overview');
17
lng_include('universe');
18
19
$sensorLevel = mrc_get_level($user, $planetrow, STRUC_MOON_PHALANX);
20
if (!intval($sensorLevel)) {
21
  message (classLocale::$lang['phalanx_nosensoravailable'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3);
22
}
23
24
if ($planetrow['planet_type'] != PT_MOON) {
25
  message (classLocale::$lang['phalanx_onlyformoons'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3);
26
}
27
28
$scan_galaxy  = sys_get_param_int('galaxy');
29
$scan_system  = sys_get_param_int('system');
30
$scan_planet  = sys_get_param_int('planet');
31
$scan_planet_type  = 1; // sys_get_param_int('planettype');
32
$id = sys_get_param_id('id');
33
34
$source_galaxy = $planetrow['galaxy'];
35
$source_system = $planetrow['system'];
36
$source_planet = $planetrow['planet'];
37
38
$sensorRange = GetPhalanxRange($sensorLevel);
39
40
$system_distance = abs($source_system - $scan_system);
41
if($system_distance > $sensorRange || $scan_galaxy != $source_galaxy)
42
{
43
  message (classLocale::$lang['phalanx_rangeerror'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3);
44
}
45
46
$cost = $sensorLevel * 1000;
47
48
if ($planetrow['deuterium'] < $cost)
49
{
50
  message(classLocale::$lang['phalanx_nodeuterium'], "phalanx", '', 3);
51
}
52
53
$planet_scanned = DBStaticPlanet::db_planet_by_gspt($scan_galaxy, $scan_system, $scan_planet, $scan_planet_type);
54
if(!$planet_scanned['id'])
55
{
56
  message(classLocale::$lang['phalanx_planet_not_exists'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3);
57
}
58
59
if($planet_scanned['destruyed'])
60
{
61
  message (classLocale::$lang['phalanx_planet_destroyed'], classLocale::$lang['tech'][STRUC_MOON_PHALANX], '', 3);
62
}
63
64
DBStaticPlanet::db_planet_set_by_id($user['current_planet'], "deuterium = deuterium - {$cost}");
65
66
$template = gettemplate('planet_fleet_list', true);
67
68
$objFleetList = FleetList::dbGetFleetListAndMissileByCoordinates($planet_scanned, true);
69
$fleet_events = flt_parse_objFleetList_to_events($objFleetList, $planet_scanned);
0 ignored issues
show
It seems like $objFleetList defined by \FleetList::dbGetFleetLi...($planet_scanned, true) on line 68 can also be of type array; however, flt_parse_objFleetList_to_events() does only seem to accept object<FleetList>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
70
tpl_assign_fleet($template, $fleet_events);
71
72
display($template, classLocale::$lang['tech'][STRUC_MOON_PHALANX], false, '', false, false);
73