Issues (1369)

phalanx.php (4 issues)

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
use Fleet\DbFleetStatic;
15
use Planet\DBStaticPlanet;
16
17
include('common.' . substr(strrchr(__FILE__, '.'), 1));
18
19
lng_include('overview');
20
lng_include('universe');
21
22
$sensorLevel = mrc_get_level($user, $planetrow, STRUC_MOON_PHALANX);
23
if (!intval($sensorLevel)) {
24
  SnTemplate::messageBox($lang['phalanx_nosensoravailable'], $lang['tech'][STRUC_MOON_PHALANX], '', 3);
25
}
26
27
if ($planetrow['planet_type'] != PT_MOON) {
28
  SnTemplate::messageBox($lang['phalanx_onlyformoons'], $lang['tech'][STRUC_MOON_PHALANX], '', 3);
29
}
30
31
$scan_galaxy  = sys_get_param_int('galaxy');
32
$scan_system  = sys_get_param_int('system');
33
$scan_planet  = sys_get_param_int('planet');
34
$scan_planet_type  = 1; // sys_get_param_int('planettype');
35
$id = sys_get_param_id('id');
36
37
$source_galaxy = $planetrow['galaxy'];
38
$source_system = $planetrow['system'];
39
$source_planet = $planetrow['planet'];
40
41
$sensorRange = GetPhalanxRange($sensorLevel);
42
43
$system_distance = abs($source_system - $scan_system);
44
if($system_distance > $sensorRange || $scan_galaxy != $source_galaxy)
45
{
46
  SnTemplate::messageBox($lang['phalanx_rangeerror'], $lang['tech'][STRUC_MOON_PHALANX], '', 3);
47
}
48
49
$cost = $sensorLevel * 1000;
50
51
if ($planetrow['deuterium'] < $cost)
52
{
53
  SnTemplate::messageBox($lang['phalanx_nodeuterium'], "phalanx", '', 3);
54
}
55
56
$planet_scanned = DBStaticPlanet::db_planet_by_gspt($scan_galaxy, $scan_system, $scan_planet, $scan_planet_type);
57
if(!$planet_scanned['id'])
58
{
59
  SnTemplate::messageBox($lang['phalanx_planet_not_exists'], $lang['tech'][STRUC_MOON_PHALANX], '', 3);
60
}
61
62
if($planet_scanned['destruyed'])
63
{
64
  SnTemplate::messageBox($lang['phalanx_planet_destroyed'], $lang['tech'][STRUC_MOON_PHALANX], '', 3);
65
}
66
67
DBStaticPlanet::db_planet_set_by_id($user['current_planet'], "deuterium = deuterium - {$cost}");
68
69
$template = SnTemplate::gettemplate('planet_fleet_list', 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

69
$template = SnTemplate::gettemplate('planet_fleet_list', /** @scrutinizer ignore-type */ true);
Loading history...
70
71
$fleet_list = DbFleetStatic::fleet_and_missiles_list_by_coordinates($planet_scanned, true);
0 ignored issues
show
It seems like $planet_scanned can also be of type boolean; however, parameter $coordinates of Fleet\DbFleetStatic::fle...s_list_by_coordinates() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

71
$fleet_list = DbFleetStatic::fleet_and_missiles_list_by_coordinates(/** @scrutinizer ignore-type */ $planet_scanned, true);
Loading history...
72
$fleets = flt_parse_fleets_to_events($fleet_list, $planet_scanned);
0 ignored issues
show
Are you sure the assignment to $fleets is correct as flt_parse_fleets_to_even..._list, $planet_scanned) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
73
tpl_assign_fleet($template, $fleets);
0 ignored issues
show
Deprecated Code introduced by
The function tpl_assign_fleet() has been deprecated. ( Ignorable by Annotation )

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

73
/** @scrutinizer ignore-deprecated */ tpl_assign_fleet($template, $fleets);
Loading history...
74
75
$template->assign_vars(array(
76
  'MENU' => false,
77
  'NAVBAR' => false,
78
));
79
80
SnTemplate::display($template, $lang['tech'][STRUC_MOON_PHALANX]);
81