Merge pull request #456 from Struart88/patch-2
[FlightAirMap.git] / tracker-data.php
blobe4f4b6c5c72b70b831de40cd248de114bf696b16
1 <?php
2 require_once('require/class.Connection.php');
3 require_once('require/class.Tracker.php');
4 require_once('require/class.Language.php');
5 require_once('require/class.Common.php');
6 require_once('require/class.TrackerLive.php');
7 require_once('require/class.TrackerArchive.php');
8 require_once('require/class.Elevation.php');
9 $TrackerLive = new TrackerLive();
10 $TrackerArchive = new TrackerArchive();
11 $Elevation = new Elevation();
12 $Common = new Common();
14 $from_archive = false;
15 if (isset($_GET['ident'])) {
16 $ident = urldecode(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 = $TrackerLive->getDateLiveTrackerDataByIdent($ident,$currenttime);
21 if (empty($spotter_array)) {
22 $from_archive = true;
23 $spotter_array = $TrackerArchive->getDateArchiveTrackerDataByIdent($ident,$currenttime);
26 } else {
27 $spotter_array = $TrackerLive->getLastLiveTrackerDataByIdent($ident);
28 if (empty($spotter_array)) {
29 $from_archive = true;
30 $spotter_array = $TrackerArchive->getLastArchiveTrackerDataByIdent($ident);
34 if (isset($_GET['famtrackid'])) {
35 $famtrackid = urldecode(filter_input(INPUT_GET,'famtrackid',FILTER_SANITIZE_STRING));
36 if (isset($_GET['currenttime'])) {
37 $currenttime = filter_input(INPUT_GET,'currenttime',FILTER_SANITIZE_NUMBER_INT);
38 $currenttime = round($currenttime/1000);
39 $spotter_array = $TrackerLive->getDateLiveTrackerDataById($famtrackid,$currenttime);
41 if (empty($spotter_array)) {
42 $from_archive = true;
43 // $spotter_array = $SpotterArchive->getLastArchiveSpotterDataById($flightaware_id);
44 $spotter_array = $TrackerArchive->getDateArchiveTrackerDataById($famtrackid,$currenttime);
47 } else {
48 $spotter_array = $TrackerLive->getLastLiveTrackerDataById($famtrackid);
49 if (empty($spotter_array)) {
50 $from_archive = true;
51 $spotter_array = $TrackerArchive->getLastArchiveTrackerDataById($famtrackid);
56 <div class="alldetails">
57 <button type="button" class="close">&times;</button>
58 <?php
59 $spotter_item = $spotter_array[0];
60 date_default_timezone_set('UTC');
61 if (isset($spotter_item['image_thumbnail']) && $spotter_item['image_thumbnail'] != "")
63 if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') {
64 $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']);
65 } else $image = $spotter_item['image_thumbnail'];
68 /* else {
69 $image = "images/placeholder_thumb.png";
70 } */
72 print '<div class="top">';
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"><div class="callsign-details"><div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['famtrackid'].'" target="_blank">'.$spotter_item['ident'].'</a></div>';
77 print '<div class="right"><div class="callsign-details"><div class="callsign">'.$spotter_item['ident'].'</div>';
78 print '</div>';
79 print '</div></div>';
80 print '<div class="details">';
81 print '<div><span>'._("Altitude").'</span>';
82 if (isset($globalGroundAltitude) && $globalGroundAltitude) {
83 try {
84 $groundAltitude = $Elevation->getElevation($spotter_item['latitude'],$spotter_item['longitude']);
85 } catch(Exception $e) {
88 print '<span class="altitude">';
89 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
90 print $spotter_item['altitude'].' feet (FL'.$spotter_item['altitude'].')';
91 } else {
92 print round($spotter_item['altitude']*0.3048).' m (FL'.round($spotter_item['altitude']/100).')';
94 print '</span>';
95 if (isset($groundAltitude) && $groundAltitude < $spotter_item['altitude']*0.3048) {
96 print '<br>';
97 print '<span>'._("Ground Altitude").'</span>';
98 print '<i>';
99 print '<span class="groundaltitude">';
100 if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) {
101 print round($groundAltitude*3.28084).' feet';
102 } else {
103 print round($groundAltitude).' m';
105 print '</span>';
106 print '</i>';
108 print '</div>';
109 print '<div><span>'._("Speed").'</span>';
110 if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) {
111 print round($spotter_item['ground_speed']*0.621371).' mph';
112 } elseif ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'knots') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'knots')) {
113 print round($spotter_item['ground_speed']*0.539957).' knots';
114 } else {
115 print $spotter_item['ground_speed'].' km/h';
117 print '</div>';
118 print '<div><span>'._("Coordinates").'</span>';
119 if ((!isset($_COOKIE['unitcoordinate']) && isset($globalUnitCoordinate) && $globalUnitCoordinate == 'dms') || (isset($_COOKIE['unitcoordinate']) && $_COOKIE['unitcoordinate'] == 'dms')) {
120 $latitude = $Common->convertDMS($spotter_item['latitude'],'latitude');
121 print '<span class="latitude">'.$latitude['deg'].'° '.$latitude['min']."′ ".$latitude['sec'].'" '.$latitude['NSEW'].'</span>, ';
122 $longitude = $Common->convertDMS($spotter_item['longitude'],'longitude');
123 print '<span class="longitude">'.$longitude['deg'].'° '.$longitude['min']."′ ".$longitude['sec'].'" '.$longitude['NSEW'].'</span>';
124 } elseif ((!isset($_COOKIE['unitcoordinate']) && isset($globalUnitCoordinate) && $globalUnitCoordinate == 'dm') || (isset($_COOKIE['unitcoordinate']) && $_COOKIE['unitcoordinate'] == 'dm')) {
125 $latitude = $Common->convertDM($spotter_item['latitude'],'latitude');
126 print '<span class="latitude">'.$latitude['deg'].'° '.round($latitude['min'],3)."′ ".$latitude['NSEW'].'</span>, ';
127 $longitude = $Common->convertDM($spotter_item['longitude'],'longitude');
128 print '<span class="longitude">'.$longitude['deg'].'° '.round($longitude['min'],3)."′ ".$longitude['NSEW'].'</span>';
129 } else {
130 print '<span class="latitude">'.$spotter_item['latitude'].'</span>, ';
131 print '<span class="longitude">'.$spotter_item['longitude'].'</span>';
133 print '</div>';
134 print '<div><span>'._("Type").'</span>'.$spotter_item['type'].'</div>';
135 print '<div><span>'._("Heading").'</span><span class="heading">'.$spotter_item['heading'].'</span>°</div>';
136 if (isset($spotter_item['over_country']) && $spotter_item['over_country'] != '') {
137 print '<div><span>'._("Over country").'</span>';
138 print $spotter_item['over_country'];
139 print '</div>';
141 if (isset($spotter_item['source_name']) && $spotter_item['source_name'] != '') {
142 print '<div><span>'._("Source").'</span>';
143 print $spotter_item['source_name'];
144 print '</div>';
146 if (isset($spotter_item['comment']) && $spotter_item['comment'] != '') {
147 print '<div><span>'._("Comment").'</span>';
148 print $spotter_item['comment'];
149 print '</div>';
151 if (isset($_COOKIE['MapFormat']) && $_COOKIE['MapFormat'] == '3d') {
152 print '<a href="?3d&trackerid='.$spotter_item['famtrackid'].'">Track it link !</a>';
153 } else {
154 print '<a href="?2d&trackerid='.$spotter_item['famtrackid'].'">Track it link !</a>';
156 print '</div>';
157 print '</div>';
159 </div>