Ysurac /
FlightAirMap
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['airline'])) { |
||
| 6 | header('Location: '.$globalURL.'/airline'); |
||
| 7 | die(); |
||
| 8 | } |
||
| 9 | $airline = filter_input(INPUT_GET,'airline',FILTER_SANITIZE_STRING); |
||
| 10 | $Spotter = new Spotter(); |
||
| 11 | $spotter_array = $Spotter->getSpotterDataByAirline($airline,"0,1",""); |
||
| 12 | |||
| 13 | |||
| 14 | if (!empty($spotter_array)) |
||
| 15 | { |
||
| 16 | $title = sprintf(_("Most Common Time of Day from %s (%s)"),$spotter_array[0]['airline_name'],$spotter_array[0]['airline_icao']); |
||
| 17 | require_once('header.php'); |
||
| 18 | print '<div class="select-item">'; |
||
| 19 | print '<form action="'.$globalURL.'/airline" method="post">'; |
||
| 20 | print '<select name="airline" class="selectpicker" data-live-search="true">'; |
||
| 21 | print '<option></option>'; |
||
| 22 | $airline_names = $Spotter->getAllAirlineNames(); |
||
| 23 | foreach($airline_names as $airline_name) |
||
| 24 | { |
||
| 25 | if($airline == $airline_name['airline_icao']) |
||
| 26 | { |
||
| 27 | print '<option value="'.$airline_name['airline_icao'].'" selected="selected">'.$airline_name['airline_name'].' ('.$airline_name['airline_icao'].')</option>'; |
||
| 28 | } else { |
||
| 29 | print '<option value="'.$airline_name['airline_icao'].'">'.$airline_name['airline_name'].' ('.$airline_name['airline_icao'].')</option>'; |
||
| 30 | } |
||
| 31 | } |
||
| 32 | print '</select>'; |
||
| 33 | print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>'; |
||
| 34 | print '</form>'; |
||
| 35 | print '</div>'; |
||
| 36 | |||
| 37 | if ($airline != "NA") |
||
| 38 | { |
||
| 39 | print '<div class="info column">'; |
||
| 40 | print '<h1>'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')</h1>'; |
||
| 41 | if ($globalIVAO && @getimagesize($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.gif')) |
||
| 42 | { |
||
| 43 | print '<img src="'.$globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.gif" alt="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" title="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" class="logo" />'; |
||
| 44 | } |
||
| 45 | elseif (@getimagesize($globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.png')) |
||
| 46 | { |
||
| 47 | print '<img src="'.$globalURL.'/images/airlines/'.$spotter_array[0]['airline_icao'].'.png" alt="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" title="'.$spotter_array[0]['airline_name'].' ('.$spotter_array[0]['airline_icao'].')" class="logo" />'; |
||
| 48 | } |
||
| 49 | print '<div><span class="label">'._("Name").'</span>'.$spotter_array[0]['airline_name'].'</div>'; |
||
| 50 | print '<div><span class="label">'._("Country").'</span>'.$spotter_array[0]['airline_country'].'</div>'; |
||
| 51 | print '<div><span class="label">'._("ICAO").'</span>'.$spotter_array[0]['airline_icao'].'</div>'; |
||
| 52 | print '<div><span class="label">'._("IATA").'</span>'.$spotter_array[0]['airline_iata'].'</div>'; |
||
| 53 | print '<div><span class="label">'._("Callsign").'</span>'.$spotter_array[0]['airline_callsign'].'</div>'; |
||
| 54 | print '<div><span class="label">'._("Type").'</span>'.ucwords($spotter_array[0]['airline_type']).'</div>'; |
||
| 55 | print '</div>'; |
||
| 56 | } else { |
||
| 57 | print '<div class="alert alert-warning">'._("This special airline profile shows all flights that do <u>not</u> have a airline associated with them.").'</div>'; |
||
| 58 | } |
||
| 59 | |||
| 60 | include('airline-sub-menu.php'); |
||
| 61 | print '<div class="column">'; |
||
| 62 | print '<h2>'._("Most Common Time of Day").'</h2>'; |
||
| 63 | print '<p>'.sprintf(_("The statistic below shows the most common time of day from <strong>%s</strong>."),$spotter_array[0]['airline_name']).'</p>'; |
||
| 64 | $hour_array = $Spotter->countAllHoursByAirline($airline); |
||
| 65 | print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>'; |
||
| 66 | print '<div id="chartHour" class="chart" width="100%"></div> |
||
| 67 | <script> |
||
| 68 | google.load("visualization", "1", {packages:["corechart"]}); |
||
| 69 | google.setOnLoadCallback(drawChart); |
||
| 70 | function drawChart() { |
||
| 71 | var data = google.visualization.arrayToDataTable([ |
||
| 72 | ["'._("Hour").'", "'._("# of Flights").'"], '; |
||
| 73 | $hour_data = ''; |
||
| 74 | View Code Duplication | foreach($hour_array as $hour_item) |
|
|
1 ignored issue
–
show
|
|||
| 75 | { |
||
| 76 | $hour_data .= '[ "'.date("ga", strtotime($hour_item['hour_name'].":00")).'",'.$hour_item['hour_count'].'],'; |
||
| 77 | } |
||
| 78 | $hour_data = substr($hour_data, 0, -1); |
||
| 79 | print $hour_data; |
||
| 80 | print ']); |
||
| 81 | |||
| 82 | var options = { |
||
| 83 | legend: {position: "none"}, |
||
| 84 | chartArea: {"width": "80%", "height": "60%"}, |
||
| 85 | vAxis: {title: "# of Flights"}, |
||
| 86 | hAxis: {showTextEvery: 2}, |
||
| 87 | height:300, |
||
| 88 | colors: ["#1a3151"] |
||
| 89 | }; |
||
| 90 | |||
| 91 | var chart = new google.visualization.AreaChart(document.getElementById("chartHour")); |
||
| 92 | chart.draw(data, options); |
||
| 93 | } |
||
| 94 | $(window).resize(function(){ |
||
| 95 | drawChart(); |
||
| 96 | }); |
||
| 97 | </script>'; |
||
| 98 | print '</div>'; |
||
| 99 | |||
| 100 | } else { |
||
| 101 | $title = _("Airline Statistic"); |
||
| 102 | require_once('header.php'); |
||
| 103 | print '<h1>'._("Error").'</h1>'; |
||
| 104 | print '<p>'._("Sorry, the airline does not exist in this database. :(").'</p>'; |
||
| 105 | } |
||
| 106 | require_once('footer.php'); |
||
| 107 | ?> |
||
|
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...
|
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.