These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | if ($_GET['departure_airport'] == "" || $_GET['arrival_airport'] == "") |
||
3 | { |
||
4 | header('Location: /'); |
||
5 | } |
||
6 | |||
7 | require_once('require/class.Connection.php'); |
||
8 | require_once('require/class.Spotter.php'); |
||
9 | require_once('require/class.Language.php'); |
||
10 | |||
11 | $Spotter = new Spotter(); |
||
12 | $sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING); |
||
13 | View Code Duplication | if (isset($_GET['departure_airport']) && isset($_GET['arrival_airport'])) { |
|
1 ignored issue
–
show
|
|||
14 | $spotter_array = $Spotter->getSpotterDataByRoute($_GET['departure_airport'], $_GET['arrival_airport'], "0,1", $sort); |
||
15 | } else $spotter_array = array(); |
||
16 | |||
17 | if (!empty($spotter_array)) |
||
18 | { |
||
19 | $title = sprintf(_("Most Common Time of Day between %s (%s), %s - %s (%s), %s"),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']); |
||
20 | require_once('header.php'); |
||
21 | print '<div class="info column">'; |
||
22 | print '<h1>'._("Flights between").' '.$spotter_array[0]['departure_airport_name'].' ('.$spotter_array[0]['departure_airport_icao'].'), '.$spotter_array[0]['departure_airport_country'].' - '.$spotter_array[0]['arrival_airport_name'].' ('.$spotter_array[0]['arrival_airport_icao'].'), '.$spotter_array[0]['arrival_airport_country'].'</h1>'; |
||
23 | print '<div><span class="label">'._("Coming From").'</span><a href="'.$globalURL.'/airport/'.$spotter_array[0]['departure_airport_icao'].'">'.$spotter_array[0]['departure_airport_name'].' ('.$spotter_array[0]['departure_airport_icao'].'), '.$spotter_array[0]['departure_airport_country'].'</a></div>'; |
||
24 | print '<div><span class="label">'._("Flying To").'</span><a href="'.$globalURL.'/airport/'.$spotter_array[0]['arrival_airport_icao'].'">'.$spotter_array[0]['arrival_airport_name'].' ('.$spotter_array[0]['arrival_airport_icao'].'), '.$spotter_array[0]['arrival_airport_country'].'</a></div>'; |
||
25 | print '</div>'; |
||
26 | |||
27 | include('route-sub-menu.php'); |
||
28 | print '<div class="column">'; |
||
29 | print '<h2>'._("Most Common Time of Day").'</h2>'; |
||
30 | print '<p>'.sprintf(_("The statistic below shows the most common time of day of flights between <strong>%s (%s), %s</strong> and <strong>%s (%s), %s</strong>."),$spotter_array[0]['departure_airport_name'],$spotter_array[0]['departure_airport_icao'],$spotter_array[0]['departure_airport_country'],$spotter_array[0]['arrival_airport_name'],$spotter_array[0]['arrival_airport_icao'],$spotter_array[0]['arrival_airport_country']).'</p>'; |
||
31 | |||
32 | $hour_array = $Spotter->countAllHoursByRoute($_GET['departure_airport'], $_GET['arrival_airport']); |
||
33 | print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>'; |
||
34 | print '<div id="chartHour" class="chart" width="100%"></div> |
||
35 | <script> |
||
36 | google.load("visualization", "1", {packages:["corechart"]}); |
||
37 | google.setOnLoadCallback(drawChart); |
||
38 | function drawChart() { |
||
39 | var data = google.visualization.arrayToDataTable([ |
||
40 | ["'._("Hour").'", "'._("# of Flights").'"], '; |
||
41 | $hour_data = ''; |
||
42 | 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. ![]() |
|||
43 | { |
||
44 | $hour_data .= '[ "'.date("ga", strtotime($hour_item['hour_name'].":00")).'",'.$hour_item['hour_count'].'],'; |
||
45 | } |
||
46 | $hour_data = substr($hour_data, 0, -1); |
||
47 | print $hour_data; |
||
48 | print ']); |
||
49 | |||
50 | var options = { |
||
51 | legend: {position: "none"}, |
||
52 | chartArea: {"width": "80%", "height": "60%"}, |
||
53 | vAxis: {title: "'._("# of Flights").'"}, |
||
54 | hAxis: {showTextEvery: 2}, |
||
55 | height:300, |
||
56 | colors: ["#1a3151"] |
||
57 | }; |
||
58 | |||
59 | var chart = new google.visualization.AreaChart(document.getElementById("chartHour")); |
||
60 | chart.draw(data, options); |
||
61 | } |
||
62 | $(window).resize(function(){ |
||
63 | drawChart(); |
||
64 | }); |
||
65 | </script>'; |
||
66 | print '</div>'; |
||
67 | } else { |
||
68 | $title = _("Unknown Route"); |
||
69 | require_once('header.php'); |
||
70 | print '<h1>'._("Error").'</h1>'; |
||
71 | print '<p>'._("Sorry, this route does not exist in this database. :(").'</p>'; |
||
72 | } |
||
73 | |||
74 | require_once('footer.php'); |
||
75 | ?> |
||
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.