Completed
Push — master ( 72d96f...36cc69 )
by Yannick
16:46 queued 04:01
created

ident-statistics-time.php (2 issues)

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.Spotter.php');
4
require_once('require/class.Language.php');
5
if (!isset($_GET['ident'])) {
6
        header('Location: '.$globalURL.'/ident');
7
        die();
8
}
9
$Spotter = new Spotter();
10
$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
11
$ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
12
$spotter_array = $Spotter->getSpotterDataByIdent($ident,"0,1", $sort);
13
14
if (!empty($spotter_array))
15
{
16
	$title = sprintf(_("Most Common Time of Day of %s"),$spotter_array[0]['ident']);
17
	require_once('header.php');
18
	print '<div class="info column">';
19
	print '<h1>'.$spotter_array[0]['ident'].'</h1>';
20
	print '<div><span class="label">'._("Ident").'</span>'.$spotter_array[0]['ident'].'</div>';
21
	print '<div><span class="label">'._("Airline").'</span><a href="'.$globalURL.'/airline/'.$spotter_array[0]['airline_icao'].'">'.$spotter_array[0]['airline_name'].'</a></div>'; 
22
	print '</div>';
23
24
	include('ident-sub-menu.php');
25
	print '<div class="column">';
26
	print '<h2>'._("Most Common Time of Day").'</h2>';
27
	print '<p>'.sprintf(_("The statistic below shows the most common time of day of flights with the ident/callsign <strong>%s</strong>."),$spotter_array[0]['ident']).'</p>';
28
29
	$hour_array = $Spotter->countAllHoursByIdent($ident);
30
	print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>';
31
	print '<div id="chartHour" class="chart" width="100%"></div>
32
      	<script> 
33
      		google.load("visualization", "1", {packages:["corechart"]});
34
          google.setOnLoadCallback(drawChart);
35
          function drawChart() {
36
            var data = google.visualization.arrayToDataTable([
37
            	["'._("Hour").'", "'._("# of Flights").'"], ';
38
	$hour_data = '';
39 View Code Duplication
	foreach($hour_array as $hour_item)
1 ignored issue
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
	{
41
		$hour_data .= '[ "'.date("ga", strtotime($hour_item['hour_name'].":00")).'",'.$hour_item['hour_count'].'],';
42
	}
43
	$hour_data = substr($hour_data, 0, -1);
44
	print $hour_data;
45
	print ']);
46
    
47
            var options = {
48
            	legend: {position: "none"},
49
            	chartArea: {"width": "80%", "height": "60%"},
50
            	vAxis: {title: "'._("# of Flights").'"},
51
            	hAxis: {showTextEvery: 2},
52
            	height:300,
53
            	colors: ["#1a3151"]
54
            };
55
    
56
            var chart = new google.visualization.AreaChart(document.getElementById("chartHour"));
57
            chart.draw(data, options);
58
          }
59
          $(window).resize(function(){
60
    			  drawChart();
61
    			});
62
      </script>';
63
	print '</div>';
64
} else {
65
	$title = _("Ident");
66
	require_once('header.php');
67
	print '<h1>'._("Error").'</h1>';
68
	print '<p>'._("Sorry, this ident/callsign is not in the database. :(").'</p>';
69
}
70
71
require_once('footer.php');
72
?>
1 ignored issue
show
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...