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 | $Spotter = new Spotter(); |
||
6 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
||
7 | $spotter_array = $Spotter->getSpotterDataByDate($_GET['date'],"0,1", $sort); |
||
8 | |||
9 | if (!empty($spotter_array)) |
||
10 | { |
||
11 | $title = sprintf(_("Most Common Time of Day on %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))); |
||
12 | require_once('header.php'); |
||
13 | print '<div class="select-item">'; |
||
14 | print '<form action="'.$globalURL.'/date" method="post">'; |
||
15 | print '<label for="date">'._("Select a Date").'</label>'; |
||
16 | print '<input type="text" id="date" name="date" value="'.$_GET['date'].'" size="8" readonly="readonly" class="custom" />'; |
||
17 | print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>'; |
||
18 | print '</form>'; |
||
19 | print '</div>'; |
||
20 | print '<div class="info column">'; |
||
21 | print '<h1>'.sprintf(_("Flights from %s"),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</h1>'; |
||
22 | print '</div>'; |
||
23 | |||
24 | include('date-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 on <strong>%s</strong>."),date("l F j, Y", strtotime($spotter_array[0]['date_iso_8601']))).'</p>'; |
||
28 | |||
29 | $hour_array = $Spotter->countAllHoursByDate($_GET['date']); |
||
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 | |||
39 | $hour_data = ''; |
||
40 | View Code Duplication | foreach($hour_array as $hour_item) |
|
1 ignored issue
–
show
|
|||
41 | { |
||
42 | $hour_data .= '[ "'.date("ga", strtotime($hour_item['hour_name'].":00")).'",'.$hour_item['hour_count'].'],'; |
||
43 | } |
||
44 | $hour_data = substr($hour_data, 0, -1); |
||
45 | print $hour_data; |
||
46 | print ']); |
||
47 | |||
48 | var options = { |
||
49 | legend: {position: "none"}, |
||
50 | chartArea: {"width": "80%", "height": "60%"}, |
||
51 | vAxis: {title: "'._("# of Flights").'"}, |
||
52 | hAxis: {showTextEvery: 2}, |
||
53 | height:300, |
||
54 | colors: ["#1a3151"] |
||
55 | }; |
||
56 | |||
57 | var chart = new google.visualization.AreaChart(document.getElementById("chartHour")); |
||
58 | chart.draw(data, options); |
||
59 | } |
||
60 | $(window).resize(function(){ |
||
61 | drawChart(); |
||
62 | }); |
||
63 | </script>'; |
||
64 | print '</div>'; |
||
65 | } else { |
||
66 | $title = _("Unknown Date"); |
||
67 | require_once('header.php'); |
||
68 | print '<h1>'._("Error").'</h1>'; |
||
69 | print '<p>'._("Sorry, this date does not exist in this database. :(").'</p>'; |
||
70 | } |
||
71 | |||
72 | require_once('footer.php'); |
||
73 | ?> |
||
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. ![]() |
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.