-
Notifications
You must be signed in to change notification settings - Fork 159
/
airport-detailed.php
207 lines (196 loc) · 9.15 KB
/
airport-detailed.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<?php
require_once('require/class.Connection.php');
require_once('require/class.Spotter.php');
require_once('require/class.Language.php');
require_once('require/class.Stats.php');
require_once('require/class.METAR.php');
if (!isset($_GET['airport'])){
header('Location: '.$globalURL.'/airport');
} else {
$Spotter = new Spotter();
//calculation for the pagination
if(!isset($_GET['limit']))
{
$limit_start = 0;
$limit_end = 25;
$absolute_difference = 25;
} else {
$limit_explode = explode(",", $_GET['limit']);
$limit_start = $limit_explode[0];
$limit_end = $limit_explode[1];
if (!ctype_digit(strval($limit_start)) || !ctype_digit(strval($limit_end))) {
$limit_start = 0;
$limit_end = 25;
}
}
$absolute_difference = abs($limit_start - $limit_end);
$limit_next = $limit_end + $absolute_difference;
$limit_previous_1 = $limit_start - $absolute_difference;
$limit_previous_2 = $limit_end - $absolute_difference;
$airport_icao = filter_input(INPUT_GET,'airport',FILTER_SANITIZE_STRING);
$airport = $airport_icao;
$page_url = $globalURL.'/airport/'.$airport_icao;
if (isset($_GET['sort'])) {
$sort = filter_input(INPUT_GET,'sort',FILTER_SANITIZE_STRING);
$spotter_array = $Spotter->getSpotterDataByAirport($airport_icao,$limit_start.",".$absolute_difference, $sort);
} else {
$spotter_array = $Spotter->getSpotterDataByAirport($airport_icao,$limit_start.",".$absolute_difference, '');
}
$airport_array = $Spotter->getAllAirportInfo($airport_icao);
if (!empty($airport_array))
{
if (isset($globalMETAR) && $globalMETAR) {
$METAR = new METAR();
$metar_info = $METAR->getMETAR($airport_icao);
//print_r($metar_info);
if (isset($metar_info[0]['metar'])) $metar_parse = $METAR->parse($metar_info[0]['metar']);
//print_r($metar_parse);
}
$title = sprintf(_("Detailed View for %s, %s (%s)"),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']);
require_once('header.php');
print '<div class="select-item">';
print '<form action="'.$globalURL.'/airport" method="post">';
print '<select name="airport" class="selectpicker" data-live-search="true">';
print '<option></option>';
$Stats = new Stats();
$airport_names = $Stats->getAllAirportNames();
if (empty($airport_names)) $airport_names = $Spotter->getAllAirportNames();
ksort($airport_names);
foreach($airport_names as $airport_name)
{
if($airport_icao == $airport_name['airport_icao'])
{
print '<option value="'.$airport_name['airport_icao'].'" selected="selected">'.$airport_name['airport_city'].', '.$airport_name['airport_name'].', '.$airport_name['airport_country'].' ('.$airport_name['airport_icao'].')</option>';
} else {
print '<option value="'.$airport_name['airport_icao'].'">'.$airport_name['airport_city'].', '.$airport_name['airport_name'].', '.$airport_name['airport_country'].' ('.$airport_name['airport_icao'].')</option>';
}
}
print '</select>';
print '<button type="submit"><i class="fa fa-angle-double-right"></i></button>';
print '</form>';
print '</div>';
if ($airport_icao != "NA")
{
print '<div class="info column">';
print '<h1>'.$airport_array[0]['city'].', '.$airport_array[0]['name'].' ('.$airport_array[0]['icao'].')</h1>';
print '<div><span class="label">'._("Name").'</span>'.$airport_array[0]['name'].'</div>';
print '<div><span class="label">'._("City").'</span>'.$airport_array[0]['city'].'</div>';
print '<div><span class="label">'._("Country").'</span>'.$airport_array[0]['country'].'</div>';
print '<div><span class="label">'._("ICAO").'</span>'.$airport_array[0]['icao'].'</div>';
print '<div><span class="label">'._("IATA").'</span>'.$airport_array[0]['iata'].'</div>';
print '<div><span class="label">'._("Altitude").'</span>';
if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
print $airport_array[0]['altitude'].' feet';
} else {
print round($airport_array[0]['altitude']*0.3048).' m';
}
print '</div>';
print '<div><span class="label">'._("Coordinates").'</span><a href="http://maps.google.ca/maps?z=10&t=k&q='.$airport_array[0]['latitude'].','.$airport_array[0]['longitude'].'" target="_blank">Google Map<i class="fa fa-angle-double-right"></i></a></div>';
print '<div><span class="label">'._("Live Air Traffic").'</span><a href="http://www.liveatc.net/search/?icao='.$airport_array[0]['icao'].'" target="_blank">LiveATC.net<i class="fa fa-angle-double-right"></i></a></div>';
print '</div>';
print '<script type="text/javascript" src="https://www.google.com/jsapi"></script>';
$Stats = new Stats();
$all_data = $Stats->getLast7DaysAirports($airport_icao);
// Use spotter also
if (isset($globalTimezone)) {
date_default_timezone_set($globalTimezone);
} else date_default_timezone_set('UTC');
if (count($all_data) > 0) {
print '<div id="chart6" class="chart" width="100%"></div>
<script>
google.load("visualization", "1.1", {packages:["line","corechart"]});
google.setOnLoadCallback(drawChart6);
function drawChart6() {
var data = google.visualization.arrayToDataTable([
["'._("Date").'","'._("Departure").'","'._("Arrival").'"], ';
$airport_data = '';
foreach($all_data as $data)
{
$airport_data .= '[ "'.$data['date'].'",'.$data['departure'].','.$data['arrival'].'],';
}
$airport_data = substr($airport_data, 0, -1);
print $airport_data.']);
var options = {
legend: {position: "none"},
chart: {
title: "'._("Last week flights departure/arrival").'"
},
height:210
};
var chart = new google.charts.Line(document.getElementById("chart6"));
chart.draw(data, options);
}
$(window).resize(function(){
drawChart6();
});
</script>';
}
print '<div class="info column">';
if (isset($metar_parse)) {
print '<div><span class="label">METAR</span>';
print $metar_info[0]['metar'].'<br />';
print '<b>'.$metar_info[0]['metar_date'].'</b> ';
if (isset($metar_parse['wind'])) {
print _("Wind:").' ';
if (isset($metar_parse['wind']['direction'])) {
$direction = $Spotter->parseDirection($metar_parse['wind']['direction']);
print $direction[0]['direction_fullname'];
print ' ('.$metar_parse['wind']['direction'].'°) ';
}
if (isset($metar_parse['wind']['speed'])) {
print $metar_parse['wind']['speed'].' m/s';
}
print ' - ';
}
if (isset($metar_parse['visibility'])) {
print _("Visibility:").' '.$metar_parse['visibility'].' m'." - ";
}
if (isset($metar_parse['weather'])) {
print _("Weather:").' '.$metar_parse['weather']." - ";
}
if (isset($metar_parse['temperature'])) {
print _("Temperature:").' '.$metar_parse['temperature'].' °C'." - ";
}
if (isset($metar_parse['dew'])) {
print _("Dew point:").' '.$metar_parse['dew'].' °C'." - ";
}
if (isset($metar_parse['temperature']) && isset($metar_parse['dew'])) {
$humidity = round(100 * pow((112 - (0.1 * $metar_parse['temperature']) + $metar_parse['dew']) / (112 + (0.9 * $metar_parse['temperature'])), 8),1);
print _("Humidity:").' '.$humidity.'%'." - ";
}
if (isset($metar_parse['QNH'])) {
print _("Pressure:").' '.$metar_parse['QNH'].' hPa';
}
print '</div>';
}
print '</div>';
} else {
print '<div class="alert alert-warning">'._("This special airport profile shows all flights that do <u>not</u> have a departure and/or arrival airport associated with them.").'</div>';
}
include('airport-sub-menu.php');
print '<div class="table column">';
if ($airport_array[0]['iata'] != "NA")
{
print '<p>'.sprintf(_("The table below shows the detailed information of all flights to/from <strong>%s, %s (%s)</strong>."),$airport_array[0]['city'],$airport_array[0]['name'],$airport_array[0]['icao']).'</p>';
}
include('table-output.php');
print '<div class="pagination">';
if ($limit_previous_1 >= 0)
{
print '<a href="'.$page_url.'/'.$limit_previous_1.','.$limit_previous_2.'/'.$_GET['sort'].'">«'._("Previous Page").'</a>';
}
if (isset($spotter_array[0]['query_number_rows']) && $spotter_array[0]['query_number_rows'] == $absolute_difference)
{
print '<a href="'.$page_url.'/'.$limit_end.','.$limit_next.'/'.$_GET['sort'].'">'._("Next Page").'»</a>';
}
print '</div>';
print '</div>';
} else {
$title = "Airport";
require_once('header.php');
print '<h1>'._("Error").'</h1>';
print '<p>'._("Sorry, the airport does not exist in this database. :(").'</p>';
}
}
require_once('footer.php');
?>