Completed
Push — master ( 83aaff...7b298e )
by Yannick
32:28
created

statistics-time.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
require_once('require/class.Connection.php');
3
require_once('require/class.Stats.php');
4
require_once('require/class.Language.php');
5
$Stats = new Stats();
6
$title = _("Statistics").' - '._("Busiest Time of the Day");
7
8
$type = 'aircraft';
9
if (isset($_GET['marine'])) {
10
	$type = 'marine';
11
	require_once('require/class.Marine.php');
12
	$Marine = new Marine();
13
} elseif (isset($_GET['tracker'])) {
14
	$type = 'tracker';
15
	require_once('require/class.Tracker.php');
16
	$Tracker = new Tracker();
17
}
18
19
if (!isset($filter_name)) $filter_name = '';
20
$airline_icao = (string)filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING);
21
if ($airline_icao == '' && isset($globalFilter)) {
22
    if (isset($globalFilter['airline'])) $airline_icao = $globalFilter['airline'][0];
23
}
24
25
require_once('header.php');
26
if ($type == 'aircraft') include('statistics-sub-menu.php');
27
28
print '<link href="'.$globalURL.'/css/c3.min.css" rel="stylesheet" type="text/css">';
29
print '<script type="text/javascript" src="'.$globalURL.'/js/d3.min.js"></script>';
30
print '<script type="text/javascript" src="'.$globalURL.'/js/c3.min.js"></script>';
31
print '<div class="info">
32
	    <h1>'._("Busiest Time of the Day").'</h1>
33
	</div>
34
	<p>'._("Below is a list of the most common <strong>time of day</strong>.").'</p>';
35
36
if ($type == 'aircraft') $hour_array = $Stats->countAllHours('hour',true,$airline_icao,$filter_name);
37
elseif ($type == 'marine') $hour_array = $Marine->countAllHours('hour',true);
0 ignored issues
show
true is of type boolean, but the function expects a array.

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...
38
elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('hour',true);
0 ignored issues
show
true is of type boolean, but the function expects a array.

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...
39
print '<div id="chartHour" class="chart" width="100%"></div><script>';
40
$hour_data = '';
41
$hour_cnt = '';
42
foreach($hour_array as $hour_item)
43
{
44
	$hour_data .= '"'.$hour_item['hour_name'].':00",';
45
	$hour_cnt .= $hour_item['hour_count'].',';
46
}
47
$hour_data = "[".substr($hour_data, 0, -1)."]";
48
$hour_cnt = "['flights',".substr($hour_cnt,0,-1)."]";
49
print 'c3.generate({
50
    bindto: "#chartHour",
51
    data: {
52
    columns: ['.$hour_cnt.'], types: { flights: "area-spline"}, colors: { flights: "#1a3151"}},
53
    axis: { x: { type: "category", categories: '.$hour_data.'},y: { label: "# of Flights"}},legend: { show: false }});';
54
print '</script>';
55
56
if ($type == 'aircraft') $hour_array = $Stats->countAllHours('count',true,$airline_icao,$filter_name);
57
elseif ($type == 'marine') $hour_array = $Marine->countAllHours('count',true);
0 ignored issues
show
true is of type boolean, but the function expects a array.

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...
58
elseif ($type == 'tracker') $hour_array = $Tracker->countAllHours('count',true);
0 ignored issues
show
true is of type boolean, but the function expects a array.

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...
59
if (!empty($hour_array))
60
{
61
	print '<div class="table-responsive">';
62
	print '<table class="common-hour table-striped">';
63
	print '<thead>';
64
	print '<th></th>';
65
	print '<th>'._("Hour").'</th>';
66
	print '<th>'._("Number").'</th>';
67
	print '</thead>';
68
	print '<tbody>';
69
	$i = 1;
70
	foreach($hour_array as $hour_item)
71
	{
72
		print '<tr>';
73
		print '<td><strong>'.$i.'</strong></td>';
74
		print '<td>'.$hour_item['hour_name'].':00</td>';
75
		print '<td>'.$hour_item['hour_count'].'</td>';
76
		print '</tr>';
77
		$i++;
78
	}
79
	print '<tbody>';
80
	print '</table>';
81
	print '</div>';
82
}
83
84
require_once('footer.php');
85
?>