Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / aircraft-data.php
blob233e1ec1309c04df60771c46c3b299d29f879987
1 <?php
2 require_once('require/class.Connection.php');
3 require_once('require/class.Spotter.php');
4 require_once('require/class.Common.php');
5 require_once('require/class.Language.php');
6 require_once('require/class.SpotterLive.php');
7 require_once('require/class.SpotterArchive.php');
8 require_once('require/class.Elevation.php');
9 $SpotterLive = new SpotterLive();
10 $SpotterArchive = new SpotterArchive();
11 $Elevation = new Elevation();
12 $Common = new Common();
14 $from_archive = false;
15 if (isset($_GET['ident'])) {
16 $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING);
17 if (isset($_GET['currenttime'])) {
18 $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
19 $currenttime = round($currenttime/1000);
20 $spotter_array = $SpotterLive->getDateLiveSpotterDataByIdent($ident,$currenttime);
21 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
22 $from_archive = true;
23 $spotter_array = $SpotterArchive->getDateArchiveSpotterDataByIdent($ident,$currenttime);
25 } else {
26 $spotter_array = $SpotterLive->getLastLiveSpotterDataByIdent($ident);
27 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
28 $from_archive = true;
29 $spotter_array = $SpotterArchive->getLastArchiveSpotterDataByIdent($ident);
33 if (isset($_GET['flightaware_id'])) {
34 $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING);
35 if (isset($_GET['currenttime'])) {
36 $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
37 $currenttime = round($currenttime/1000);
38 $spotter_array = $SpotterLive->getDateLiveSpotterDataById($flightaware_id,$currenttime);
39 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
40 $from_archive = true;
41 // $spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
42 $spotter_array = $SpotterArchive->getDateArchiveSpotterDataById($flightaware_id,$currenttime);
44 } else {
45 $spotter_array = $SpotterLive->getLastLiveSpotterDataById($flightaware_id);
46 if (empty($spotter_array) && isset($globalArchiveResults) && $globalArchiveResults) {
47 $from_archive = true;
48 $spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
53 <div class="alldetails">
54 <button type="button" class="close">&times;</button>
55 <?php
56 if (!empty($spotter_array)) {
57 $spotter_item = $spotter_array[0];
58 date_default_timezone_set('UTC');
59 if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
61 if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
62 $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
63 } else $image = $spotter_item['image_thumbnail'];
65 /* else {
66 $image = "images/placeholder_thumb.png";
67 } */
69 print '<div class="top">';
70 if (isset($globalCam) && $globalCam === TRUE) {
71 print '<div class="left"><img src="http://192.168.1.47:81/videostream.cgi?user=admin&pwd=888888&resolution=8&rate=0" alt="cam"/></div>';
73 if (isset($image)) {
74 print '<div class="left"><img src="'.$image.'" alt="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].'" title="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].' Image &copy; '.$spotter_item['image_copyright'].'"/><br />Image &copy; '.$spotter_item['image_copyright'].'</div>';
76 print '<div class="right">';
77 print '<div class="callsign-details">';
78 if ($spotter_item['ident'] != 'Not Available') {
79 print '<div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a>';
80 if (isset($spotter_item['blocked']) && $spotter_item['blocked'] === true) print '<img src="'.$globalURL.'/images/forbidden.png" title="'._("Callsign is in blocked FAA list").'" class="blocked" />';
81 print '</div>';
83 if (isset($spotter_item['airline_name']) && $spotter_item['airline_name'] != 'Not Available') print '<div class="airline">'.$spotter_item['airline_name'].'</div>';
84 print '</div>';
85 if ($spotter_item['departure_airport'] != 'NA' && $spotter_item['arrival_airport'] != 'NA') {
86 print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
87 if (isset($spotter_item['departure_airport_time']) && $spotter_item['departure_airport_time'] != 'NULL') {
88 if ($spotter_item['departure_airport_time'] > 2460) {
89 print '<br /><span class="time">'.date('H:m',$spotter_item['departure_airport_time']).'</span>';
90 } else {
91 print '<br /><span class="time">'.$spotter_item['departure_airport_time'].'</span>';
94 print '</div><i class="fa fa-long-arrow-right"></i><div class="airport">';
95 print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country'];
96 if (isset($spotter_item['arrival_airport_time']) && $spotter_item['arrival_airport_time'] != 'NULL') {
97 if ($spotter_item['arrival_airport_time'] > 2460) {
98 print '<br /><span class="time">'.date('H:m',$spotter_item['arrival_airport_time']).'</span>';
99 } else {
100 print '<br /><span class="time">'.$spotter_item['arrival_airport_time'].'</span>';
103 print '</div></div>';
104 //if (isset($spotter_item['route_stop'])) print 'Route stop : '.$spotter_item['route_stop'];
105 print '</div></div>';
107 print '<div class="details"><div class="mobile airports"><div class="airport">';
108 print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country'];
109 print '</div><i class="fa fa-long-arrow-right"></i><div class="airport">';
110 print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country'];
111 print '</div>';
112 print '</div>';
113 print '<div id="aircraft">';
114 print '<span>'._("Aircraft").'</span>';
115 if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>';
116 if (isset($spotter_item['aircraft_type']) && isset($spotter_item['aircraft_manufacturer']) && $spotter_item['aircraft_manufacturer'] != 'N/A' && isset($spotter_item['aircraft_name']) && $spotter_item['aircraft_name'] != 'N/A') {
117 $aircraft_names = explode('/',$spotter_item['aircraft_name']);
118 if (count($aircraft_names) == 1) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>';
119 else print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'" title="'.$spotter_item['aircraft_name'].'">'.$spotter_item['aircraft_manufacturer'].' '.$aircraft_names[0].' ('.$spotter_item['aircraft_type'].')</a>';
120 } elseif (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_type'].'</a>';
121 else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'];
122 print '</div>';
123 if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>';
125 print '<div id="altitude"><span>'._("Altitude").'</span>';
126 if (isset($globalGroundAltitude) && $globalGroundAltitude) {
127 try {
128 $groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']);
129 } catch(Exception $e) {
130 // If catched not exist
134 print '<span class="altitude">';
135 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
136 if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print $spotter_item['real_altitude'].' feet (FL'.$spotter_item['altitude'].')';
137 else print $spotter_item['altitude'].'00 feet (FL'.$spotter_item['altitude'].')';
138 } else {
139 if (isset($spotter_item['real_altitude']) && $spotter_item['real_altitude'] != '') print round($spotter_item['real_altitude']*0.3048).' m (FL'.$spotter_item['altitude'].')';
140 else print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')';
142 print '</span>';
144 if (isset($groundAltitude) && $groundAltitude < $spotter_item['altitude']*30.48) {
145 print '<br>';
146 print '<span>'._("Ground Altitude").'</span>';
147 print '<i>';
148 print '<span class="groundaltitude">';
149 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
150 print round($groundAltitude*3.28084).' feet';
151 } else {
152 print round($groundAltitude).' m';
154 print '</span>';
155 print '</i>';
157 print '</div>';
158 print '<div id="coordinates"><span>'._("Coordinates").'</span>';
159 if ((!isset($_COOKIE['unitcoordinate']) && isset($globalUnitCoordinate) && $globalUnitCoordinate == 'dms') || (isset($_COOKIE['unitcoordinate']) && $_COOKIE['unitcoordinate'] == 'dms')) {
160 $latitude = $Common->convertDMS($spotter_item['latitude'],'latitude');
161 print '<span class="latitude">'.$latitude['deg'].'° '.$latitude['min']."′ ".$latitude['sec'].'" '.$latitude['NSEW'].'</span>, ';
162 $longitude = $Common->convertDMS($spotter_item['longitude'],'longitude');
163 print '<span class="longitude">'.$longitude['deg'].'° '.$longitude['min']."′ ".$longitude['sec'].'" '.$longitude['NSEW'].'</span>';
164 } elseif ((!isset($_COOKIE['unitcoordinate']) && isset($globalUnitCoordinate) && $globalUnitCoordinate == 'dm') || (isset($_COOKIE['unitcoordinate']) && $_COOKIE['unitcoordinate'] == 'dm')) {
165 $latitude = $Common->convertDM($spotter_item['latitude'],'latitude');
166 print '<span class="latitude">'.$latitude['deg'].'° '.round($latitude['min'],3)."′".$latitude['NSEW'].'</span>, ';
167 $longitude = $Common->convertDM($spotter_item['longitude'],'longitude');
168 print '<span class="longitude">'.$longitude['deg'].'° '.round($longitude['min'],3)."′".$longitude['NSEW'].'</span>';
169 } else {
170 print '<span class="latitude">'.$spotter_item['latitude'].'</span>, ';
171 print '<span class="longitude">'.$spotter_item['longitude'].'</span>';
173 print '</div>';
175 print '<div id="speed"><span>'._("Speed").'</span>';
176 if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
177 print round($spotter_item['ground_speed']*1.15078).' mph';
178 } elseif ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
179 print $spotter_item['ground_speed'].' knots';
180 } else {
181 print round($spotter_item['ground_speed']*1.852).' km/h';
183 print '</div>';
184 if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
185 print '<div id="realspeed"><span>'._("Calculated Speed").'</span>';
186 print '<span class="realspeed"></span>';
187 print '</div>';
190 if (isset($globalCam) && $globalCam) {
191 require_once(dirname(__FILE__).'/require/class.Common.php');
192 $Common = new Common();
193 $azimuth = round($Common->azimuth($globalCenterLatitude,$globalCenterLongitude,$spotter_item['latitude'],$spotter_item['longitude']));
194 $distance = $Common->distance($globalCenterLatitude,$globalCenterLongitude,$spotter_item['latitude'],$spotter_item['longitude'],'m');
195 $plunge = round($Common->plunge($globalCenterAltitude,$spotter_item['real_altitude'],$distance));
196 print '<div id="camcoordinates"><span>'._("Cam Coordinates").'</span>';
197 print 'azimuth: '.$azimuth;
198 print ' / ';
199 print 'plunge: '.$plunge;
200 print ' / ';
201 print 'distance: '.$distance;
202 print '</div>';
203 //echo $Common->getData('http://127.0.0.1/camera.php?azimuth='.$azimuth.'&plunge='.$plunge,'get','','','','','','',false,true);
204 //echo $Common->getData('file://'.dirname(__FILE__).'/camera.php?azimuth='.$azimuth.'&plunge='.$plunge,'get','','','','','','',false,true);
205 echo $Common->getData('http://'.$_SERVER['SERVER_NAME'].'/camera.php?azimuth='.$azimuth.'&plunge='.$plunge,'get','','','','','','',false,true);
208 print '<div id="heading"><span>'._("Heading").'</span><span class="heading">'.$spotter_item['heading'].'</span>°</div>';
209 if (isset($spotter_item['verticalrate']) && $spotter_item['verticalrate'] != '') {
210 print '<div id="verticalrate"><span>'._("Vertical rate").'</span>';
211 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
212 print $spotter_item['verticalrate']. ' ft/min';
213 } else {
214 print round($spotter_item['verticalrate']*0.3048). ' m/min';
216 print '</div>';
218 if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') {
219 print '<div id="pilot"><span>'._("Pilot").'</span>';
220 if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')';
221 else print $spotter_item['pilot_name'];
222 print '</div>';
224 if (isset($spotter_item['aircraft_owner']) && $spotter_item['aircraft_owner'] != '') {
225 print '<div id="owner"><span>'._("Owner").'</span>';
226 print $spotter_item['aircraft_owner'];
227 print '</div>';
229 if (isset($spotter_item['over_country']) && $spotter_item['over_country'] != '') {
230 print '<div id="overcountry"><span>'._("Over country").'</span>';
231 print $spotter_item['over_country'];
232 print '</div>';
234 if (isset($spotter_item['source_name']) && $spotter_item['source_name'] != '') {
235 print '<div id="source"><span>'._("Source").'</span>';
236 print $spotter_item['source_name'];
237 print '</div>';
239 print '<div id="trackit">';
240 if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
241 print '<a href="?3d&trackid='.$spotter_item['flightaware_id'].'">'._("Track it link !").'</a>';
242 } else {
243 print '<a href="?2d&trackid='.$spotter_item['flightaware_id'].'">'._("Track it link !").'</a>';
245 print '</div>';
246 print '</div>';
247 if (isset($globalVA) && $globalVA && isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>';
248 if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>';
249 if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>';
250 if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>';
251 print '</div>';
254 </div>