@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | require_once('../require/settings.php'); |
3 | 3 | require_once('../require/class.Language.php'); |
4 | 4 | |
5 | -setcookie("MapFormat",'2d'); |
|
5 | +setcookie("MapFormat", '2d'); |
|
6 | 6 | |
7 | 7 | if (!isset($globalOpenWeatherMapKey)) $globalOpenWeatherMapKey = ''; |
8 | 8 | // Compressed GeoJson is used if true |
@@ -20,10 +20,10 @@ discard block |
||
20 | 20 | $lastupd = $_GET['archivespeed']*$archiveupdatetime; |
21 | 21 | if (isset($_GET['enddate']) && $_GET['enddate'] != '') $enddate = $_GET['enddate']; |
22 | 22 | else $enddate = time(); |
23 | - setcookie("archive_begin",$begindate); |
|
24 | - setcookie("archive_end",$enddate); |
|
25 | - setcookie("archive_update",$lastupd); |
|
26 | - setcookie("archive_speed",$archivespeed); |
|
23 | + setcookie("archive_begin", $begindate); |
|
24 | + setcookie("archive_end", $enddate); |
|
25 | + setcookie("archive_update", $lastupd); |
|
26 | + setcookie("archive_speed", $archivespeed); |
|
27 | 27 | ?> |
28 | 28 | document.cookie = 'archive_begin=<?php print $begindate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'; |
29 | 29 | document.cookie = 'archive_end=<?php print $enddate; ?>; expires=Thu, 2 Aug 2100 20:47:11 UTC; path=/'; |
@@ -75,16 +75,16 @@ discard block |
||
75 | 75 | <?php |
76 | 76 | } |
77 | 77 | if (isset($_GET['ident'])) { |
78 | - $ident = filter_input(INPUT_GET,'ident',FILTER_SANITIZE_STRING); |
|
78 | + $ident = filter_input(INPUT_GET, 'ident', FILTER_SANITIZE_STRING); |
|
79 | 79 | } |
80 | 80 | if (isset($_GET['flightaware_id'])) { |
81 | - $flightaware_id = filter_input(INPUT_GET,'flightaware_id',FILTER_SANITIZE_STRING); |
|
81 | + $flightaware_id = filter_input(INPUT_GET, 'flightaware_id', FILTER_SANITIZE_STRING); |
|
82 | 82 | } |
83 | 83 | if (isset($_GET['latitude'])) { |
84 | - $latitude = filter_input(INPUT_GET,'latitude',FILTER_SANITIZE_STRING); |
|
84 | + $latitude = filter_input(INPUT_GET, 'latitude', FILTER_SANITIZE_STRING); |
|
85 | 85 | } |
86 | 86 | if (isset($_GET['longitude'])) { |
87 | - $longitude = filter_input(INPUT_GET,'longitude',FILTER_SANITIZE_STRING); |
|
87 | + $longitude = filter_input(INPUT_GET, 'longitude', FILTER_SANITIZE_STRING); |
|
88 | 88 | } |
89 | 89 | ?> |
90 | 90 | |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | } else { |
113 | 113 | if ((isset($globalCenterLatitude) && $globalCenterLatitude != '' && isset($globalCenterLongitude) && $globalCenterLongitude != '') || isset($_COOKIE['lastcentercoord'])) { |
114 | 114 | if (isset($_COOKIE['lastcentercoord'])) { |
115 | - $lastcentercoord = explode(',',$_COOKIE['lastcentercoord']); |
|
115 | + $lastcentercoord = explode(',', $_COOKIE['lastcentercoord']); |
|
116 | 116 | $viewcenterlatitude = $lastcentercoord[0]; |
117 | 117 | $viewcenterlongitude = $lastcentercoord[1]; |
118 | 118 | $viewzoom = $lastcentercoord[2]; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | || navigator.userAgent.match(/BlackBerry/i) |
134 | 134 | || navigator.userAgent.match(/Windows Phone/i)) |
135 | 135 | { |
136 | - var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) print $viewzoom-1; elseif (isset($viewzoom)) print $viewzoom; else print '8'; ?>; |
|
136 | + var zoom = <?php if (isset($viewzoom) && $viewzoom == $globalLiveZoom) print $viewzoom - 1; elseif (isset($viewzoom)) print $viewzoom; else print '8'; ?>; |
|
137 | 137 | } else { |
138 | 138 | var zoom = <?php if (isset($viewzoom)) print $viewzoom; else print '9'; ?>; |
139 | 139 | } |
@@ -227,19 +227,19 @@ discard block |
||
227 | 227 | map.addLayer(yandexLayer); |
228 | 228 | <?php |
229 | 229 | } elseif ($MapType == 'Bing-Aerial') { |
230 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
230 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap'); |
|
231 | 231 | ?> |
232 | 232 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Aerial'}); |
233 | 233 | map.addLayer(bingLayer); |
234 | 234 | <?php |
235 | 235 | } elseif ($MapType == 'Bing-Hybrid') { |
236 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
236 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap'); |
|
237 | 237 | ?> |
238 | 238 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'AerialWithLabels'}); |
239 | 239 | map.addLayer(bingLayer); |
240 | 240 | <?php |
241 | 241 | } elseif ($MapType == 'Bing-Road') { |
242 | - if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType','OpenStreetMap'); |
|
242 | + if (!isset($globalBingMapKey) || $globalBingMapKey == '') setcookie('MapType', 'OpenStreetMap'); |
|
243 | 243 | ?> |
244 | 244 | var bingLayer = new L.tileLayer.bing({bingMapsKey: '<?php print $globalBingMapKey; ?>',imagerySet: 'Road'}); |
245 | 245 | map.addLayer(bingLayer); |
@@ -357,7 +357,7 @@ discard block |
||
357 | 357 | |
358 | 358 | function update_tsk() { |
359 | 359 | var bbox = map.getBounds().toBBoxString(); |
360 | - var tskLayerQuery = $.getJSON("<?php print $globalURL; ?>/tsk-geojson.php?tsk=<?php echo filter_input(INPUT_GET,'tsk',FILTER_SANITIZE_URL); ?>",function (data) { |
|
360 | + var tskLayerQuery = $.getJSON("<?php print $globalURL; ?>/tsk-geojson.php?tsk=<?php echo filter_input(INPUT_GET, 'tsk', FILTER_SANITIZE_URL); ?>",function (data) { |
|
361 | 361 | tskLayer = L.geoJson(data,{ |
362 | 362 | onEachFeature: function (feature, layer) { |
363 | 363 | tskPopup(feature, layer); |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | } |
370 | 370 | } |
371 | 371 | |
372 | - var tsk_geojson = Cesium.loadJson("<?php print $globalURL; ?>/tsk-geojson.php?tsk=<?php print filter_input(INPUT_GET,'tsk',FILTER_SANITIZE_URL); ?>"); |
|
372 | + var tsk_geojson = Cesium.loadJson("<?php print $globalURL; ?>/tsk-geojson.php?tsk=<?php print filter_input(INPUT_GET, 'tsk', FILTER_SANITIZE_URL); ?>"); |
|
373 | 373 | tsk_geojson.then(function(geojsondata) { |
374 | 374 | tsk = new Cesium.CustomDataSource('tsk'); |
375 | 375 | for (var i =0;i < geojsondata.features.length; i++) { |
@@ -456,7 +456,7 @@ discard block |
||
456 | 456 | <?php |
457 | 457 | if (isset($_COOKIE['lastcentercoord']) || (isset($globalCenterLatitude) && isset($globalCenterLongitude) && $globalCenterLatitude != '' && $globalCenterLongitude != '')) { |
458 | 458 | if (isset($_COOKIE['lastcentercoord'])) { |
459 | - $lastcentercoord = explode(',',$_COOKIE['lastcentercoord']); |
|
459 | + $lastcentercoord = explode(',', $_COOKIE['lastcentercoord']); |
|
460 | 460 | if (!isset($lastcentercoord[3])) $zoom = $lastcentercoord[2]*1000000.0; |
461 | 461 | else $zoom = $lastcentercoord[3]; |
462 | 462 | $viewcenterlatitude = $lastcentercoord[0]; |
@@ -18,22 +18,22 @@ discard block |
||
18 | 18 | * @return Array the images list |
19 | 19 | * |
20 | 20 | */ |
21 | - public function getSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
21 | + public function getSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
22 | 22 | { |
23 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
24 | - $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
|
25 | - $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
|
23 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
24 | + $aircraft_icao = filter_var($aircraft_icao, FILTER_SANITIZE_STRING); |
|
25 | + $airline_icao = filter_var($airline_icao, FILTER_SANITIZE_STRING); |
|
26 | 26 | $reg = $registration; |
27 | 27 | if (($reg == '' || $reg == 'NA') && $aircraft_icao != '') $reg = $aircraft_icao.$airline_icao; |
28 | 28 | $reg = trim($reg); |
29 | - $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
29 | + $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright, spotter_image.registration |
|
30 | 30 | FROM spotter_image |
31 | 31 | WHERE spotter_image.registration = :registration LIMIT 1"; |
32 | 32 | $sth = $this->db->prepare($query); |
33 | 33 | $sth->execute(array(':registration' => $reg)); |
34 | 34 | $result = $sth->fetchAll(PDO::FETCH_ASSOC); |
35 | 35 | if (!empty($result)) return $result; |
36 | - elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('',$aircraft_icao,$airline_icao); |
|
36 | + elseif ($registration != '' && ($aircraft_icao != '' || $airline_icao != '')) return $this->getSpotterImage('', $aircraft_icao, $airline_icao); |
|
37 | 37 | else return array(); |
38 | 38 | } |
39 | 39 | |
@@ -43,23 +43,23 @@ discard block |
||
43 | 43 | * @return Array the images list |
44 | 44 | * |
45 | 45 | */ |
46 | - public function getMarineImage($mmsi,$imo = '',$name = '') |
|
46 | + public function getMarineImage($mmsi, $imo = '', $name = '') |
|
47 | 47 | { |
48 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
49 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
50 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
48 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
49 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
50 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
51 | 51 | $name = trim($name); |
52 | - $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
52 | + $query = "SELECT marine_image.image, marine_image.image_thumbnail, marine_image.image_source, marine_image.image_source_website,marine_image.image_copyright, marine_image.mmsi, marine_image.imo, marine_image.name |
|
53 | 53 | FROM marine_image |
54 | 54 | WHERE marine_image.mmsi = :mmsi"; |
55 | 55 | $query_data = array(':mmsi' => $mmsi); |
56 | 56 | if ($imo != '') { |
57 | 57 | $query .= " AND marine_image.imo = :imo"; |
58 | - $query_data = array_merge($query_data,array(':imo' => $imo)); |
|
58 | + $query_data = array_merge($query_data, array(':imo' => $imo)); |
|
59 | 59 | } |
60 | 60 | if ($name != '') { |
61 | 61 | $query .= " AND marine_image.name = :name"; |
62 | - $query_data = array_merge($query_data,array(':name' => $name)); |
|
62 | + $query_data = array_merge($query_data, array(':name' => $name)); |
|
63 | 63 | } |
64 | 64 | $query .= " LIMIT 1"; |
65 | 65 | $sth = $this->db->prepare($query); |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
81 | 81 | elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
82 | 82 | if ($copyright != '') { |
83 | - $copyright = str_replace('Copyright ','',$copyright); |
|
84 | - $copyright = str_replace('© ','',$copyright); |
|
85 | - $copyright = str_replace('(c) ','',$copyright); |
|
83 | + $copyright = str_replace('Copyright ', '', $copyright); |
|
84 | + $copyright = str_replace('© ', '', $copyright); |
|
85 | + $copyright = str_replace('(c) ', '', $copyright); |
|
86 | 86 | } |
87 | 87 | return $copyright; |
88 | 88 | } |
@@ -93,25 +93,25 @@ discard block |
||
93 | 93 | * @return String either success or error |
94 | 94 | * |
95 | 95 | */ |
96 | - public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
|
96 | + public function addSpotterImage($registration, $aircraft_icao = '', $airline_icao = '') |
|
97 | 97 | { |
98 | - global $globalDebug,$globalAircraftImageFetch, $globalOffline; |
|
98 | + global $globalDebug, $globalAircraftImageFetch, $globalOffline; |
|
99 | 99 | if ((isset($globalAircraftImageFetch) && $globalAircraftImageFetch === FALSE) || (isset($globalOffline) && $globalOffline === TRUE)) return ''; |
100 | - $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
|
100 | + $registration = filter_var($registration, FILTER_SANITIZE_STRING); |
|
101 | 101 | $registration = trim($registration); |
102 | 102 | //getting the aircraft image |
103 | 103 | if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
104 | 104 | elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
105 | 105 | elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
106 | - $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
|
106 | + $image_url = $this->findAircraftImage($registration, $aircraft_icao, $airline_icao); |
|
107 | 107 | if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
108 | 108 | if ($image_url['original'] != '') { |
109 | 109 | if ($globalDebug) echo 'Found !'."\n"; |
110 | - $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
110 | + $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
111 | 111 | try { |
112 | 112 | $sth = $this->db->prepare($query); |
113 | - $sth->execute(array(':registration' => $registration,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
114 | - } catch(PDOException $e) { |
|
113 | + $sth->execute(array(':registration' => $registration, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
114 | + } catch (PDOException $e) { |
|
115 | 115 | echo $e->getMessage()."\n"; |
116 | 116 | return "error"; |
117 | 117 | } |
@@ -125,13 +125,13 @@ discard block |
||
125 | 125 | * @return String either success or error |
126 | 126 | * |
127 | 127 | */ |
128 | - public function addMarineImage($mmsi,$imo = '',$name = '') |
|
128 | + public function addMarineImage($mmsi, $imo = '', $name = '') |
|
129 | 129 | { |
130 | - global $globalDebug,$globalMarineImageFetch, $globalOffline; |
|
130 | + global $globalDebug, $globalMarineImageFetch, $globalOffline; |
|
131 | 131 | if ((isset($globalMarineImageFetch) && !$globalMarineImageFetch) || (isset($globalOffline) && $globalOffline === TRUE)) return ''; |
132 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
133 | - $imo = filter_var($imo,FILTER_SANITIZE_STRING); |
|
134 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
132 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
133 | + $imo = filter_var($imo, FILTER_SANITIZE_STRING); |
|
134 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
135 | 135 | $name = trim($name); |
136 | 136 | $Marine = new Marine($this->db); |
137 | 137 | if ($imo == '' || $name == '') { |
@@ -145,14 +145,14 @@ discard block |
||
145 | 145 | |
146 | 146 | //getting the aircraft image |
147 | 147 | if ($globalDebug && $name != '') echo 'Try to find an vessel image for '.$name.'...'; |
148 | - $image_url = $this->findMarineImage($mmsi,$imo,$name); |
|
148 | + $image_url = $this->findMarineImage($mmsi, $imo, $name); |
|
149 | 149 | if ($image_url['original'] != '') { |
150 | 150 | if ($globalDebug) echo 'Found !'."\n"; |
151 | - $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
151 | + $query = "INSERT INTO marine_image (mmsi,imo,name, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:mmsi,:imo,:name,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
|
152 | 152 | try { |
153 | 153 | $sth = $this->db->prepare($query); |
154 | - $sth->execute(array(':mmsi' => $mmsi,':imo' => $imo,':name' => $name,':image' => $image_url['original'],':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'],':source' => $image_url['source'],':source_website' => $image_url['source_website'])); |
|
155 | - } catch(PDOException $e) { |
|
154 | + $sth->execute(array(':mmsi' => $mmsi, ':imo' => $imo, ':name' => $name, ':image' => $image_url['original'], ':image_thumbnail' => $image_url['thumbnail'], ':copyright' => $image_url['copyright'], ':source' => $image_url['source'], ':source_website' => $image_url['source_website'])); |
|
155 | + } catch (PDOException $e) { |
|
156 | 156 | echo $e->getMessage()."\n"; |
157 | 157 | return "error"; |
158 | 158 | } |
@@ -172,9 +172,9 @@ discard block |
||
172 | 172 | global $globalAircraftImageSources, $globalIVAO, $globalAircraftImageCheckICAO, $globalVA; |
173 | 173 | $Spotter = new Spotter($this->db); |
174 | 174 | if (!isset($globalIVAO)) $globalIVAO = FALSE; |
175 | - $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
|
175 | + $aircraft_registration = filter_var($aircraft_registration, FILTER_SANITIZE_STRING); |
|
176 | 176 | if ($aircraft_registration != '' && $aircraft_registration != 'NA' && (!isset($globalVA) || $globalVA !== TRUE)) { |
177 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
177 | + if (strpos($aircraft_registration, '/') !== false) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
178 | 178 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
179 | 179 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
180 | 180 | if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
@@ -188,25 +188,25 @@ discard block |
||
188 | 188 | if (isset($aircraft_info[0]['type'])) $aircraft_name = $aircraft_info[0]['type']; |
189 | 189 | else $aircraft_name = ''; |
190 | 190 | $aircraft_registration = $aircraft_icao; |
191 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
191 | + } else return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
192 | 192 | unset($Spotter); |
193 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
193 | + if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl', 'wikimedia', 'airportdata', 'deviantart', 'flickr', 'bing', 'jetphotos', 'planepictures', 'planespotters'); |
|
194 | 194 | foreach ($globalAircraftImageSources as $source) { |
195 | 195 | $source = strtolower($source); |
196 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft',$aircraft_icao,$airline_icao); |
|
197 | - if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft',$aircraft_registration,$aircraft_name); |
|
198 | - if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft',$aircraft_registration,$aircraft_name); |
|
199 | - if ($source == 'bing') $images_array = $this->fromBing('aircraft',$aircraft_registration,$aircraft_name); |
|
200 | - if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft',$aircraft_registration,$aircraft_name); |
|
201 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft',$aircraft_registration,$aircraft_name); |
|
202 | - if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft',$aircraft_registration,$aircraft_name); |
|
203 | - if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft',$aircraft_registration,$aircraft_name); |
|
204 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft',$aircraft_registration,$aircraft_name); |
|
205 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft',$aircraft_registration,$aircraft_name); |
|
196 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl('aircraft', $aircraft_icao, $airline_icao); |
|
197 | + if ($source == 'planespotters' && !$globalIVAO && extension_loaded('simplexml')) $images_array = $this->fromPlanespotters('aircraft', $aircraft_registration, $aircraft_name); |
|
198 | + if ($source == 'flickr' && extension_loaded('simplexml')) $images_array = $this->fromFlickr('aircraft', $aircraft_registration, $aircraft_name); |
|
199 | + if ($source == 'bing') $images_array = $this->fromBing('aircraft', $aircraft_registration, $aircraft_name); |
|
200 | + if ($source == 'deviantart' && extension_loaded('simplexml')) $images_array = $this->fromDeviantart('aircraft', $aircraft_registration, $aircraft_name); |
|
201 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('aircraft', $aircraft_registration, $aircraft_name); |
|
202 | + if ($source == 'jetphotos' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromJetPhotos('aircraft', $aircraft_registration, $aircraft_name); |
|
203 | + if ($source == 'planepictures' && !$globalIVAO && class_exists("DomDocument")) $images_array = $this->fromPlanePictures('aircraft', $aircraft_registration, $aircraft_name); |
|
204 | + if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData('aircraft', $aircraft_registration, $aircraft_name); |
|
205 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('aircraft', $aircraft_registration, $aircraft_name); |
|
206 | 206 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
207 | 207 | } |
208 | 208 | if ((!isset($globalAircraftImageCheckICAO) || $globalAircraftImageCheckICAO === TRUE) && isset($aircraft_icao)) return $this->findAircraftImage($aircraft_icao); |
209 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
209 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -218,14 +218,14 @@ discard block |
||
218 | 218 | * @return Array the aircraft thumbnail, orignal url and copyright |
219 | 219 | * |
220 | 220 | */ |
221 | - public function findMarineImage($mmsi,$imo = '',$name = '') |
|
221 | + public function findMarineImage($mmsi, $imo = '', $name = '') |
|
222 | 222 | { |
223 | 223 | global $globalMarineImageSources; |
224 | - $mmsi = filter_var($mmsi,FILTER_SANITIZE_STRING); |
|
224 | + $mmsi = filter_var($mmsi, FILTER_SANITIZE_STRING); |
|
225 | 225 | //$imo = filter_var($imo,FILTER_SANITIZE_STRING); |
226 | - $name = filter_var($name,FILTER_SANITIZE_STRING); |
|
226 | + $name = filter_var($name, FILTER_SANITIZE_STRING); |
|
227 | 227 | $name = trim($name); |
228 | - if (strlen($name) < 4) return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
228 | + if (strlen($name) < 4) return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
229 | 229 | /* |
230 | 230 | $Marine = new Marine($this->db); |
231 | 231 | if ($imo == '' || $name == '') { |
@@ -237,17 +237,17 @@ discard block |
||
237 | 237 | } |
238 | 238 | unset($Marine); |
239 | 239 | */ |
240 | - if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia','deviantart','flickr','bing'); |
|
240 | + if (!isset($globalMarineImageSources)) $globalMarineImageSources = array('wikimedia', 'deviantart', 'flickr', 'bing'); |
|
241 | 241 | foreach ($globalMarineImageSources as $source) { |
242 | 242 | $source = strtolower($source); |
243 | - if ($source == 'flickr') $images_array = $this->fromFlickr('marine',$mmsi,$name); |
|
244 | - if ($source == 'bing') $images_array = $this->fromBing('marine',$mmsi,$name); |
|
245 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine',$mmsi,$name); |
|
246 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine',$mmsi,$name); |
|
247 | - if ($source == 'customsources') $images_array = $this->fromCustomSource('marine',$mmsi,$name); |
|
243 | + if ($source == 'flickr') $images_array = $this->fromFlickr('marine', $mmsi, $name); |
|
244 | + if ($source == 'bing') $images_array = $this->fromBing('marine', $mmsi, $name); |
|
245 | + if ($source == 'deviantart') $images_array = $this->fromDeviantart('marine', $mmsi, $name); |
|
246 | + if ($source == 'wikimedia') $images_array = $this->fromWikimedia('marine', $mmsi, $name); |
|
247 | + if ($source == 'customsources') $images_array = $this->fromCustomSource('marine', $mmsi, $name); |
|
248 | 248 | if (isset($images_array) && $images_array['original'] != '') return $images_array; |
249 | 249 | } |
250 | - return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
250 | + return array('thumbnail' => '', 'original' => '', 'copyright' => '', 'source' => '', 'source_website' => ''); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
@@ -258,25 +258,25 @@ discard block |
||
258 | 258 | * @return Array the aircraft thumbnail, orignal url and copyright |
259 | 259 | * |
260 | 260 | */ |
261 | - public function fromPlanespotters($type,$aircraft_registration, $aircraft_name='') { |
|
261 | + public function fromPlanespotters($type, $aircraft_registration, $aircraft_name = '') { |
|
262 | 262 | $Common = new Common(); |
263 | 263 | // If aircraft registration is only number, also check with aircraft model |
264 | - if (preg_match('/^[[:digit]]+$/',$aircraft_registration) && $aircraft_name != '') { |
|
265 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
264 | + if (preg_match('/^[[:digit]]+$/', $aircraft_registration) && $aircraft_name != '') { |
|
265 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$aircraft_registration.'&actype=s_'.urlencode($aircraft_name).'&output=rss'; |
|
266 | 266 | } else { |
267 | 267 | //$url= 'http://www.planespotters.net/Aviation_Photos/search.php?tag='.$airline_aircraft_type.'&output=rss'; |
268 | - $url= 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
268 | + $url = 'http://www.planespotters.net/Aviation_Photos/search.php?reg='.$aircraft_registration.'&output=rss'; |
|
269 | 269 | } |
270 | 270 | $data = $Common->getData($url); |
271 | 271 | if (substr($data, 0, 5) != "<?xml") return false; |
272 | 272 | if ($xml = simplexml_load_string($data)) { |
273 | 273 | if (isset($xml->channel->item)) { |
274 | 274 | $image_url = array(); |
275 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
275 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
276 | 276 | $image_url['thumbnail'] = $thumbnail_url; |
277 | - $image_url['original'] = str_replace('thumbnail','original',$thumbnail_url); |
|
278 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
279 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
277 | + $image_url['original'] = str_replace('thumbnail', 'original', $thumbnail_url); |
|
278 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright); |
|
279 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
280 | 280 | $image_url['source'] = 'planespotters'; |
281 | 281 | return $image_url; |
282 | 282 | } |
@@ -292,31 +292,31 @@ discard block |
||
292 | 292 | * @return Array the aircraft thumbnail, orignal url and copyright |
293 | 293 | * |
294 | 294 | */ |
295 | - public function fromDeviantart($type,$registration, $name='') { |
|
295 | + public function fromDeviantart($type, $registration, $name = '') { |
|
296 | 296 | $Common = new Common(); |
297 | 297 | if ($type == 'aircraft') { |
298 | 298 | // If aircraft registration is only number, also check with aircraft model |
299 | - if (preg_match('/^[[:digit]]+$/',$registration) && $name != '') { |
|
300 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
299 | + if (preg_match('/^[[:digit]]+$/', $registration) && $name != '') { |
|
300 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q='.$registration.'%20'.urlencode($name); |
|
301 | 301 | } else { |
302 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
302 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=aircraft%20'.$registration; |
|
303 | 303 | } |
304 | 304 | } elseif ($type == 'marine') { |
305 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
305 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q=ship%20"'.urlencode($name).'"'; |
|
306 | 306 | } else { |
307 | - $url= 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
307 | + $url = 'http://backend.deviantart.com/rss.xml?type=deviation&q="'.urlencode($name).'"'; |
|
308 | 308 | } |
309 | 309 | $data = $Common->getData($url); |
310 | 310 | if (substr($data, 0, 5) != "<?xml") return false; |
311 | 311 | if ($xml = simplexml_load_string($data)) { |
312 | 312 | if (isset($xml->channel->item->link)) { |
313 | 313 | $image_url = array(); |
314 | - $thumbnail_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
314 | + $thumbnail_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->thumbnail->attributes()->url); |
|
315 | 315 | $image_url['thumbnail'] = $thumbnail_url; |
316 | - $original_url = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
316 | + $original_url = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->content->attributes()->url); |
|
317 | 317 | $image_url['original'] = $original_url; |
318 | - $image_url['copyright'] = str_replace('Copyright ','',trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
319 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
318 | + $image_url['copyright'] = str_replace('Copyright ', '', trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->copyright)); |
|
319 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
320 | 320 | $image_url['source'] = 'deviantart'; |
321 | 321 | return $image_url; |
322 | 322 | } |
@@ -332,32 +332,32 @@ discard block |
||
332 | 332 | * @return Array the aircraft thumbnail, orignal url and copyright |
333 | 333 | * |
334 | 334 | */ |
335 | - public function fromJetPhotos($type,$aircraft_registration, $aircraft_name='') { |
|
335 | + public function fromJetPhotos($type, $aircraft_registration, $aircraft_name = '') { |
|
336 | 336 | $Common = new Common(); |
337 | - $url= 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
337 | + $url = 'http://jetphotos.net/showphotos.php?displaymode=2®search='.$aircraft_registration; |
|
338 | 338 | $data = $Common->getData($url); |
339 | 339 | $dom = new DOMDocument(); |
340 | 340 | @$dom->loadHTML($data); |
341 | 341 | $all_pics = array(); |
342 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
342 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
343 | 343 | if ($image->getAttribute('itemprop') == "http://schema.org/image") { |
344 | 344 | $all_pics[] = $image->getAttribute('src'); |
345 | 345 | } |
346 | 346 | } |
347 | 347 | $all_authors = array(); |
348 | - foreach($dom->getElementsByTagName('meta') as $author) { |
|
348 | + foreach ($dom->getElementsByTagName('meta') as $author) { |
|
349 | 349 | if ($author->getAttribute('itemprop') == "http://schema.org/author") { |
350 | 350 | $all_authors[] = $author->getAttribute('content'); |
351 | 351 | } |
352 | 352 | } |
353 | 353 | $all_ref = array(); |
354 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
354 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
355 | 355 | $all_ref[] = $link->getAttribute('href'); |
356 | 356 | } |
357 | 357 | if (isset($all_pics[0])) { |
358 | 358 | $image_url = array(); |
359 | 359 | $image_url['thumbnail'] = $all_pics[0]; |
360 | - $image_url['original'] = str_replace('_tb','',$all_pics[0]); |
|
360 | + $image_url['original'] = str_replace('_tb', '', $all_pics[0]); |
|
361 | 361 | $image_url['copyright'] = $all_authors[0]; |
362 | 362 | $image_url['source_website'] = 'http://jetphotos.net'.$all_ref[8]; |
363 | 363 | $image_url['source'] = 'JetPhotos'; |
@@ -374,24 +374,24 @@ discard block |
||
374 | 374 | * @return Array the aircraft thumbnail, orignal url and copyright |
375 | 375 | * |
376 | 376 | */ |
377 | - public function fromPlanePictures($type,$aircraft_registration, $aircraft_name='') { |
|
377 | + public function fromPlanePictures($type, $aircraft_registration, $aircraft_name = '') { |
|
378 | 378 | $Common = new Common(); |
379 | - $url= 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
379 | + $url = 'http://www.planepictures.net/netsearch4.cgi?srch='.$aircraft_registration.'&stype=reg&srng=2'; |
|
380 | 380 | $data = $Common->getData($url); |
381 | 381 | $dom = new DOMDocument(); |
382 | 382 | @$dom->loadHTML($data); |
383 | 383 | $all_pics = array(); |
384 | - foreach($dom->getElementsByTagName('img') as $image) { |
|
384 | + foreach ($dom->getElementsByTagName('img') as $image) { |
|
385 | 385 | $all_pics[] = $image->getAttribute('src'); |
386 | 386 | } |
387 | 387 | $all_links = array(); |
388 | - foreach($dom->getElementsByTagName('a') as $link) { |
|
389 | - $all_links[] = array('text' => $link->textContent,'href' => $link->getAttribute('href')); |
|
388 | + foreach ($dom->getElementsByTagName('a') as $link) { |
|
389 | + $all_links[] = array('text' => $link->textContent, 'href' => $link->getAttribute('href')); |
|
390 | 390 | } |
391 | - if (isset($all_pics[1]) && !preg_match('/bit.ly/',$all_pics[1]) && !preg_match('/flagge/',$all_pics[1])) { |
|
391 | + if (isset($all_pics[1]) && !preg_match('/bit.ly/', $all_pics[1]) && !preg_match('/flagge/', $all_pics[1])) { |
|
392 | 392 | $image_url = array(); |
393 | 393 | $image_url['thumbnail'] = 'http://www.planepictures.net/'.$all_pics[1]; |
394 | - $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN','',$all_pics[1]); |
|
394 | + $image_url['original'] = 'http://www.planepictures.net/'.str_replace('_TN', '', $all_pics[1]); |
|
395 | 395 | $image_url['copyright'] = $all_links[6]['text']; |
396 | 396 | $image_url['source_website'] = 'http://www.planepictures.net/'.$all_links[2]['href']; |
397 | 397 | $image_url['source'] = 'PlanePictures'; |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @return Array the aircraft thumbnail, orignal url and copyright |
409 | 409 | * |
410 | 410 | */ |
411 | - public function fromFlickr($type,$registration,$name='') { |
|
411 | + public function fromFlickr($type, $registration, $name = '') { |
|
412 | 412 | $Common = new Common(); |
413 | 413 | if ($type == 'aircraft') { |
414 | 414 | if ($name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$registration.','.urlencode($name); |
@@ -421,12 +421,12 @@ discard block |
||
421 | 421 | if (substr($data, 0, 5) != "<?xml") return false; |
422 | 422 | if ($xml = simplexml_load_string($data)) { |
423 | 423 | if (isset($xml->channel->item)) { |
424 | - $original_url = trim((string)$xml->channel->item->enclosure->attributes()->url); |
|
424 | + $original_url = trim((string) $xml->channel->item->enclosure->attributes()->url); |
|
425 | 425 | $image_url = array(); |
426 | 426 | $image_url['thumbnail'] = $original_url; |
427 | 427 | $image_url['original'] = $original_url; |
428 | - $image_url['copyright'] = trim((string)$xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
429 | - $image_url['source_website'] = trim((string)$xml->channel->item->link); |
|
428 | + $image_url['copyright'] = trim((string) $xml->channel->item->children('http://search.yahoo.com/mrss/')->credit); |
|
429 | + $image_url['source_website'] = trim((string) $xml->channel->item->link); |
|
430 | 430 | $image_url['source'] = 'flickr'; |
431 | 431 | return $image_url; |
432 | 432 | } |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | return false; |
435 | 435 | } |
436 | 436 | |
437 | - public function fromIvaoMtl($type,$aircraft_icao,$airline_icao) { |
|
437 | + public function fromIvaoMtl($type, $aircraft_icao, $airline_icao) { |
|
438 | 438 | $Common = new Common(); |
439 | 439 | //echo "\n".'SEARCH IMAGE : http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg'; |
440 | 440 | if ($Common->urlexist('http://mtlcatalog.ivao.aero/images/aircraft/'.$aircraft_icao.$airline_icao.'.jpg')) { |
@@ -458,7 +458,7 @@ discard block |
||
458 | 458 | * @return Array the aircraft thumbnail, orignal url and copyright |
459 | 459 | * |
460 | 460 | */ |
461 | - public function fromBing($type,$aircraft_registration,$aircraft_name='') { |
|
461 | + public function fromBing($type, $aircraft_registration, $aircraft_name = '') { |
|
462 | 462 | global $globalImageBingKey; |
463 | 463 | $Common = new Common(); |
464 | 464 | if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
@@ -469,8 +469,8 @@ discard block |
||
469 | 469 | if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.urlencode($aircraft_name).'%20%2Bship%20-site:flickr.com%27'; |
470 | 470 | else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Bship%20-site:flickr.com%27'; |
471 | 471 | } |
472 | - $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
|
473 | - $data = $Common->getData($url,'get','',$headers); |
|
472 | + $headers = array("Authorization: Basic ".base64_encode("ignored:".$globalImageBingKey)); |
|
473 | + $data = $Common->getData($url, 'get', '', $headers); |
|
474 | 474 | $result = json_decode($data); |
475 | 475 | if (isset($result->d->results[0]->MediaUrl)) { |
476 | 476 | $image_url = array(); |
@@ -495,14 +495,14 @@ discard block |
||
495 | 495 | * @return Array the aircraft thumbnail, orignal url and copyright |
496 | 496 | * |
497 | 497 | */ |
498 | - public function fromAirportData($type,$aircraft_registration,$aircraft_name='') { |
|
498 | + public function fromAirportData($type, $aircraft_registration, $aircraft_name = '') { |
|
499 | 499 | $Common = new Common(); |
500 | 500 | $url = 'http://www.airport-data.com/api/ac_thumb.json?&n=1&r='.$aircraft_registration; |
501 | 501 | $data = $Common->getData($url); |
502 | 502 | $result = json_decode($data); |
503 | 503 | if (isset($result->count) && $result->count > 0) { |
504 | 504 | $image_url = array(); |
505 | - $image_url['original'] = str_replace('thumbnails','large',$result->data[0]->image); |
|
505 | + $image_url['original'] = str_replace('thumbnails', 'large', $result->data[0]->image); |
|
506 | 506 | $image_url['source_website'] = $result->data[0]->link; |
507 | 507 | $image_url['thumbnail'] = $result->data[0]->image; |
508 | 508 | $image_url['copyright'] = $result->data[0]->photographer; |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @return Array the aircraft thumbnail, orignal url and copyright |
521 | 521 | * |
522 | 522 | */ |
523 | - public function fromWikimedia($type,$registration,$name='') { |
|
523 | + public function fromWikimedia($type, $registration, $name = '') { |
|
524 | 524 | $Common = new Common(); |
525 | 525 | if ($type == 'aircraft') { |
526 | 526 | if ($name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$registration.'"%20'.urlencode($name); |
@@ -533,7 +533,7 @@ discard block |
||
533 | 533 | $result = json_decode($data); |
534 | 534 | if (isset($result->query->search[0]->title)) { |
535 | 535 | $fileo = $result->query->search[0]->title; |
536 | - if (substr($fileo,-3) == 'pdf') return false; |
|
536 | + if (substr($fileo, -3) == 'pdf') return false; |
|
537 | 537 | $file = urlencode($fileo); |
538 | 538 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
539 | 539 | $data2 = $Common->getData($url2); |
@@ -558,11 +558,11 @@ discard block |
||
558 | 558 | if (isset($result2->query->pages)) { |
559 | 559 | foreach ($result2->query->pages as $page) { |
560 | 560 | if (isset($page->imageinfo[0]->extmetadata->Artist)) { |
561 | - $image_url['copyright'] = preg_replace('/ from(.*)/','',strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
561 | + $image_url['copyright'] = preg_replace('/ from(.*)/', '', strip_tags($page->imageinfo[0]->extmetadata->Artist->value)); |
|
562 | 562 | if (isset($page->imageinfo[0]->extmetadata->License->value)) { |
563 | 563 | $image_url['copyright'] = $image_url['copyright'].' (under '.$page->imageinfo[0]->extmetadata->License->value.')'; |
564 | 564 | } |
565 | - $image_url['copyright'] = trim(str_replace('\n','',$image_url['copyright'])); |
|
565 | + $image_url['copyright'] = trim(str_replace('\n', '', $image_url['copyright'])); |
|
566 | 566 | return $image_url; |
567 | 567 | } |
568 | 568 | } |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | * @return Array the aircraft thumbnail, orignal url and copyright |
582 | 582 | * |
583 | 583 | */ |
584 | - public function fromCustomSource($type,$registration,$name='') { |
|
584 | + public function fromCustomSource($type, $registration, $name = '') { |
|
585 | 585 | global $globalAircraftImageCustomSources, $globalMarineImageCustomSources, $globalDebug; |
586 | 586 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
587 | 587 | if (!empty($globalAircraftImageCustomSources) && $type == 'aircraft') { |
@@ -598,15 +598,15 @@ discard block |
||
598 | 598 | print_r($source); |
599 | 599 | print_r($customsources); |
600 | 600 | } |
601 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
602 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
601 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
602 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
603 | 603 | if ($Common->urlexist($url)) { |
604 | 604 | $image_url = array(); |
605 | 605 | $image_url['thumbnail'] = $url_thumbnail; |
606 | 606 | $image_url['original'] = $url; |
607 | 607 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
608 | 608 | else $exifCopyright = ''; |
609 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
609 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
610 | 610 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
611 | 611 | else $image_url['copyright'] = $source['source_website']; |
612 | 612 | $image_url['source_website'] = $source['source_website']; |
@@ -630,19 +630,19 @@ discard block |
||
630 | 630 | print_r($source); |
631 | 631 | print_r($customsources); |
632 | 632 | } |
633 | - $url = str_replace('{registration}',$registration,$source['original']); |
|
634 | - $url = str_replace('{mmsi}',$registration,$url); |
|
635 | - $url = str_replace('{name}',$name,$url); |
|
636 | - $url_thumbnail = str_replace('{registration}',$registration,$source['thumbnail']); |
|
637 | - $url_thumbnail = str_replace('{mmsi}',$registration,$url_thumbnail); |
|
638 | - $url_thumbnail = str_replace('{name}',$name,$url_thumbnail); |
|
633 | + $url = str_replace('{registration}', $registration, $source['original']); |
|
634 | + $url = str_replace('{mmsi}', $registration, $url); |
|
635 | + $url = str_replace('{name}', $name, $url); |
|
636 | + $url_thumbnail = str_replace('{registration}', $registration, $source['thumbnail']); |
|
637 | + $url_thumbnail = str_replace('{mmsi}', $registration, $url_thumbnail); |
|
638 | + $url_thumbnail = str_replace('{name}', $name, $url_thumbnail); |
|
639 | 639 | if ($Common->urlexist($url)) { |
640 | 640 | $image_url = array(); |
641 | 641 | $image_url['thumbnail'] = $url_thumbnail; |
642 | 642 | $image_url['original'] = $url; |
643 | 643 | if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
644 | 644 | else $exifCopyright = ''; |
645 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
645 | + if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
646 | 646 | elseif (isset($source['copyright'])) $image_url['copyright'] = $source['copyright']; |
647 | 647 | else $image_url['copyright'] = $source['source_website']; |
648 | 648 | $image_url['source_website'] = $source['source_website']; |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | $Connection = new Connection(); |
69 | 69 | $sth = $Connection->db->prepare($query); |
70 | 70 | $sth->execute(); |
71 | - } catch(PDOException $e) { |
|
71 | + } catch (PDOException $e) { |
|
72 | 72 | return "error : ".$e->getMessage(); |
73 | 73 | } |
74 | 74 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $Connection = new Connection(); |
88 | 88 | $sth = $Connection->db->prepare($query); |
89 | 89 | $sth->execute(); |
90 | - } catch(PDOException $e) { |
|
90 | + } catch (PDOException $e) { |
|
91 | 91 | return "error : ".$e->getMessage(); |
92 | 92 | } |
93 | 93 | } |
@@ -100,9 +100,9 @@ discard block |
||
100 | 100 | public function parse($data) { |
101 | 101 | //$data = str_replace(array('\n','\r','\r','\n'),'',$data); |
102 | 102 | $codes = implode('|', array_keys($this->texts)); |
103 | - $regWeather = '#^(\+|\-|VC)?(' . $codes . ')(' . $codes . ')?$#'; |
|
103 | + $regWeather = '#^(\+|\-|VC)?('.$codes.')('.$codes.')?$#'; |
|
104 | 104 | //$pieces = explode(' ',$data); |
105 | - $pieces = preg_split('/\s/',$data); |
|
105 | + $pieces = preg_split('/\s/', $data); |
|
106 | 106 | $pos = 0; |
107 | 107 | if ($pieces[0] == 'METAR') $pos++; |
108 | 108 | elseif ($pieces[0] == 'SPECI') $pos++; |
@@ -112,25 +112,25 @@ discard block |
||
112 | 112 | $result['location'] = $pieces[$pos]; |
113 | 113 | $pos++; |
114 | 114 | if (!isset($pieces[$pos])) return $result; |
115 | - $result['dayofmonth'] = substr($pieces[$pos],0,2); |
|
116 | - $result['time'] = substr($pieces[$pos],2,4); |
|
115 | + $result['dayofmonth'] = substr($pieces[$pos], 0, 2); |
|
116 | + $result['time'] = substr($pieces[$pos], 2, 4); |
|
117 | 117 | $c = count($pieces); |
118 | - for($pos++; $pos < $c; $pos++) { |
|
118 | + for ($pos++; $pos < $c; $pos++) { |
|
119 | 119 | $piece = $pieces[$pos]; |
120 | 120 | if ($piece == 'RMK') break; |
121 | 121 | if ($piece == 'AUTO') $result['auto'] = true; |
122 | 122 | if ($piece == 'COR') $result['correction'] = true; |
123 | 123 | // Wind Speed |
124 | 124 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
125 | - $result['wind']['direction'] = (float)$matches[1]; |
|
125 | + $result['wind']['direction'] = (float) $matches[1]; |
|
126 | 126 | $result['wind']['unit'] = $matches[4]; |
127 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
128 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
129 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
130 | - $result['wind']['gust'] = (float)$matches[3]; |
|
127 | + if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float) $matches[2])*0.51444444444, 2); |
|
128 | + elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float) $matches[2])*1000, 2); |
|
129 | + elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float) $matches[2]), 2); |
|
130 | + $result['wind']['gust'] = (float) $matches[3]; |
|
131 | 131 | $result['wind']['unit'] = $matches[4]; |
132 | - $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
|
133 | - $result['wind']['max_variation'] = array_key_exists(6,$matches) ? $matches[6] : 0; |
|
132 | + $result['wind']['min_variation'] = array_key_exists(5, $matches) ? $matches[5] : 0; |
|
133 | + $result['wind']['max_variation'] = array_key_exists(6, $matches) ? $matches[6] : 0; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /* if (preg_match('#^([0-9]{3})([0-9]{2})(G([0-9]{2}))?(KT|MPS)$#', $piece, $matches)) { |
@@ -151,14 +151,14 @@ discard block |
||
151 | 151 | |
152 | 152 | // Temperature |
153 | 153 | if (preg_match('#^(M?[0-9]{2,})/(M?[0-9]{2,})$#', $piece, $matches)) { |
154 | - $temp = (float)$matches[1]; |
|
154 | + $temp = (float) $matches[1]; |
|
155 | 155 | if ($matches[1]{0} == 'M') { |
156 | - $temp = ((float)substr($matches[1], 1)) * -1; |
|
156 | + $temp = ((float) substr($matches[1], 1))*-1; |
|
157 | 157 | } |
158 | 158 | $result['temperature'] = $temp; |
159 | - $dew = (float)$matches[2]; |
|
159 | + $dew = (float) $matches[2]; |
|
160 | 160 | if ($matches[2]{0} == 'M') { |
161 | - $dew = ((float)substr($matches[2], 1)) * -1; |
|
161 | + $dew = ((float) substr($matches[2], 1))*-1; |
|
162 | 162 | } |
163 | 163 | $result['dew'] = $dew; |
164 | 164 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $result['QNH'] = $matches[2]; |
171 | 171 | } else { |
172 | 172 | // inHg |
173 | - $result['QNH'] = round(($matches[2] / 100)*33.86389,2); |
|
173 | + $result['QNH'] = round(($matches[2]/100)*33.86389, 2); |
|
174 | 174 | } |
175 | 175 | /* |
176 | 176 | $result['QNH'] = $matches[1] == 'Q' ? $matches[2] : ($matches[2] / 100); |
@@ -191,12 +191,12 @@ discard block |
||
191 | 191 | // Visibility |
192 | 192 | if (preg_match('#^([0-9]{4})|(([0-9]{1,4})SM)$#', $piece, $matches)) { |
193 | 193 | if (isset($matches[3]) && strlen($matches[3]) > 0) { |
194 | - $result['visibility'] = (float)$matches[3] * 1609.34; |
|
194 | + $result['visibility'] = (float) $matches[3]*1609.34; |
|
195 | 195 | } else { |
196 | 196 | if ($matches[1] == '9999') { |
197 | 197 | $result['visibility'] = '> 10000'; |
198 | 198 | } else { |
199 | - $result['visibility'] = (float)$matches[1]; |
|
199 | + $result['visibility'] = (float) $matches[1]; |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | if (preg_match('#^CAVOK$#', $piece, $matches)) { |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
219 | 219 | elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
220 | 220 | $cloud['type_code'] = $type; |
221 | - $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
|
221 | + $cloud['level'] = round(((float) $matches[2])*100*0.3048); |
|
222 | 222 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
223 | 223 | $result['cloud'][] = $cloud; |
224 | 224 | } |
@@ -228,8 +228,8 @@ discard block |
||
228 | 228 | $rvr['runway'] = $matches[1]; |
229 | 229 | $rvr['assessment'] = $matches[2]; |
230 | 230 | $rvr['rvr'] = $matches[3]; |
231 | - $rvr['rvr_max'] = array_key_exists(4,$matches) ? $matches[4] : 0; |
|
232 | - $rvr['unit'] = array_key_exists(5,$matches) ? $matches[5] : ''; |
|
231 | + $rvr['rvr_max'] = array_key_exists(4, $matches) ? $matches[4] : 0; |
|
232 | + $rvr['unit'] = array_key_exists(5, $matches) ? $matches[5] : ''; |
|
233 | 233 | $result['RVR'] = $rvr; |
234 | 234 | } |
235 | 235 | //if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | $result['RVR']['friction'] = $matches[5]; |
243 | 243 | } |
244 | 244 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
245 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
246 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
245 | + if (isset($matches[5])) $range = array('exact' => (float) $matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
246 | + else $range = array('exact' => (float) $matches[2], 'unit' => 'M'); |
|
247 | 247 | if (isset($matches[3])) { |
248 | 248 | $range = Array( |
249 | - 'from' => (float)$matches[2], |
|
250 | - 'to' => (float)$matches[4], |
|
249 | + 'from' => (float) $matches[2], |
|
250 | + 'to' => (float) $matches[4], |
|
251 | 251 | 'unit' => $matches[5] ? 'FT' : 'M' |
252 | 252 | ); |
253 | 253 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | try { |
301 | 301 | $sth = $this->db->prepare($query); |
302 | 302 | $sth->execute($query_values); |
303 | - } catch(PDOException $e) { |
|
303 | + } catch (PDOException $e) { |
|
304 | 304 | return "error : ".$e->getMessage(); |
305 | 305 | } |
306 | 306 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -316,19 +316,19 @@ discard block |
||
316 | 316 | * @param String $metar METAR text |
317 | 317 | * @param String $date date of the METAR |
318 | 318 | */ |
319 | - public function addMETAR($location,$metar,$date) { |
|
319 | + public function addMETAR($location, $metar, $date) { |
|
320 | 320 | global $globalDBdriver; |
321 | - $date = date('Y-m-d H:i:s',strtotime($date)); |
|
321 | + $date = date('Y-m-d H:i:s', strtotime($date)); |
|
322 | 322 | if ($globalDBdriver == 'mysql') { |
323 | 323 | $query = "INSERT INTO metar (metar_location,metar_date,metar) VALUES (:location,:date,:metar) ON DUPLICATE KEY UPDATE metar_date = :date, metar = :metar"; |
324 | 324 | } else { |
325 | 325 | $query = "UPDATE metar SET metar_date = :date, metar = metar WHERE metar_location = :location;INSERT INTO metar (metar_location,metar_date,metar) SELECT :location,:date,:metar WHERE NOT EXISTS (SELECT 1 FROM metar WHERE metar_location = :location);"; |
326 | 326 | } |
327 | - $query_values = array(':location' => $location,':date' => $date,':metar' => utf8_encode($metar)); |
|
327 | + $query_values = array(':location' => $location, ':date' => $date, ':metar' => utf8_encode($metar)); |
|
328 | 328 | try { |
329 | 329 | $sth = $this->db->prepare($query); |
330 | 330 | $sth->execute($query_values); |
331 | - } catch(PDOException $e) { |
|
331 | + } catch (PDOException $e) { |
|
332 | 332 | return "error : ".$e->getMessage(); |
333 | 333 | } |
334 | 334 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | try { |
344 | 344 | $sth = $this->db->prepare($query); |
345 | 345 | $sth->execute($query_values); |
346 | - } catch(PDOException $e) { |
|
346 | + } catch (PDOException $e) { |
|
347 | 347 | return "error : ".$e->getMessage(); |
348 | 348 | } |
349 | 349 | } |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | try { |
357 | 357 | $sth = $this->db->prepare($query); |
358 | 358 | $sth->execute(); |
359 | - } catch(PDOException $e) { |
|
359 | + } catch (PDOException $e) { |
|
360 | 360 | return "error : ".$e->getMessage(); |
361 | 361 | } |
362 | 362 | } |
@@ -370,27 +370,27 @@ discard block |
||
370 | 370 | date_default_timezone_set("UTC"); |
371 | 371 | $Common = new Common(); |
372 | 372 | if (isset($globalIVAO) && $globalIVAO) { |
373 | - $Common->download('http://wx.ivao.aero/metar.php',dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
374 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt',"r"); |
|
373 | + $Common->download('http://wx.ivao.aero/metar.php', dirname(__FILE__).'/../install/tmp/ivaometar.txt'); |
|
374 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/ivaometar.txt', "r"); |
|
375 | 375 | } else { |
376 | - $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT',dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
377 | - $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT',"r"); |
|
376 | + $Common->download('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT', dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT'); |
|
377 | + $handle = fopen(dirname(__FILE__).'/../install/tmp/'.date('H').'Z.TXT', "r"); |
|
378 | 378 | } |
379 | 379 | if ($handle) { |
380 | 380 | if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
381 | 381 | $date = ''; |
382 | 382 | if ($globalTransaction) $this->db->beginTransaction(); |
383 | - while(($line = fgets($handle,4096)) !== false) { |
|
384 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
383 | + while (($line = fgets($handle, 4096)) !== false) { |
|
384 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
385 | 385 | $date = $line; |
386 | 386 | } elseif ($line != '') { |
387 | 387 | if ($date == '') $date = date('Y/m/d H:m'); |
388 | 388 | $pos = 0; |
389 | - $pieces = preg_split('/\s/',$line); |
|
389 | + $pieces = preg_split('/\s/', $line); |
|
390 | 390 | if ($pieces[0] == 'METAR') $pos++; |
391 | 391 | if (strlen($pieces[$pos]) != 4) $pos++; |
392 | 392 | $location = $pieces[$pos]; |
393 | - echo $this->addMETAR($location,$line,$date); |
|
393 | + echo $this->addMETAR($location, $line, $date); |
|
394 | 394 | } |
395 | 395 | } |
396 | 396 | fclose($handle); |
@@ -409,22 +409,22 @@ discard block |
||
409 | 409 | if ($globalMETARurl == '') return array(); |
410 | 410 | date_default_timezone_set("UTC"); |
411 | 411 | $Common = new Common(); |
412 | - $url = str_replace('{icao}',$icao,$globalMETARurl); |
|
412 | + $url = str_replace('{icao}', $icao, $globalMETARurl); |
|
413 | 413 | $cycle = $Common->getData($url); |
414 | 414 | $date = ''; |
415 | - foreach(explode("\n",$cycle) as $line) { |
|
416 | - if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
|
415 | + foreach (explode("\n", $cycle) as $line) { |
|
416 | + if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#', $line)) { |
|
417 | 417 | $date = $line; |
418 | 418 | } |
419 | 419 | if ($line != '') { |
420 | 420 | if ($date == '') $date = date('Y/m/d H:m'); |
421 | 421 | $pos = 0; |
422 | - $pieces = preg_split('/\s/',$line); |
|
422 | + $pieces = preg_split('/\s/', $line); |
|
423 | 423 | if ($pieces[0] == 'METAR') $pos++; |
424 | 424 | if (strlen($pieces[$pos]) != 4) $pos++; |
425 | 425 | $location = $pieces[$pos]; |
426 | 426 | if (strlen($location == 4)) { |
427 | - $this->addMETAR($location,$line,$date); |
|
427 | + $this->addMETAR($location, $line, $date); |
|
428 | 428 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
429 | 429 | } else return array(); |
430 | 430 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | */ |
16 | 16 | public function parse_xml($url) { |
17 | 17 | $Common = new Common(); |
18 | - $filedata = $Common->getData($url,'get','','','','','','',true); |
|
18 | + $filedata = $Common->getData($url, 'get', '', '', '', '', '', '', true); |
|
19 | 19 | if ($filedata != '' && $filedata !== false) { |
20 | 20 | $xml = simplexml_load_string($filedata); |
21 | 21 | if ($xml !== false) { |
@@ -26,22 +26,22 @@ discard block |
||
26 | 26 | * @param Array $filter the filter |
27 | 27 | * @return Array the SQL part |
28 | 28 | */ |
29 | - public function getFilter($filter = array(),$where = false,$and = false) { |
|
29 | + public function getFilter($filter = array(), $where = false, $and = false) { |
|
30 | 30 | global $globalFilter, $globalStatsFilters, $globalFilterName; |
31 | 31 | if (is_array($globalStatsFilters) && isset($globalStatsFilters[$globalFilterName])) { |
32 | 32 | if (isset($globalStatsFilters[$globalFilterName][0]['source'])) { |
33 | - foreach($globalStatsFilters[$globalFilterName] as $source) { |
|
33 | + foreach ($globalStatsFilters[$globalFilterName] as $source) { |
|
34 | 34 | if (isset($source['source'])) $filter['source'][] = $source['source']; |
35 | 35 | } |
36 | 36 | } else { |
37 | 37 | $filter = $globalStatsFilters[$globalFilterName]; |
38 | 38 | } |
39 | 39 | } |
40 | - if (is_array($globalFilter)) $filter = array_merge($filter,$globalFilter); |
|
40 | + if (is_array($globalFilter)) $filter = array_merge($filter, $globalFilter); |
|
41 | 41 | $filter_query_join = ''; |
42 | 42 | $filter_query_where = ''; |
43 | 43 | if (isset($filter['source']) && !empty($filter['source'])) { |
44 | - $filter_query_where = " WHERE format_source IN ('".implode("','",$filter['source'])."')"; |
|
44 | + $filter_query_where = " WHERE format_source IN ('".implode("','", $filter['source'])."')"; |
|
45 | 45 | } |
46 | 46 | if ($filter_query_where == '' && $where) $filter_query_where = ' WHERE'; |
47 | 47 | elseif ($filter_query_where != '' && $and) $filter_query_where .= ' AND'; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | try { |
61 | 61 | $sth = $this->db->prepare($query); |
62 | 62 | $sth->execute($query_values); |
63 | - } catch(PDOException $e) { |
|
63 | + } catch (PDOException $e) { |
|
64 | 64 | return "error : ".$e->getMessage(); |
65 | 65 | } |
66 | 66 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -73,13 +73,13 @@ discard block |
||
73 | 73 | * @return Array Return ATC |
74 | 74 | */ |
75 | 75 | public function getById($id) { |
76 | - $filter_query = $this->getFilter(array(),true,true); |
|
76 | + $filter_query = $this->getFilter(array(), true, true); |
|
77 | 77 | $query = "SELECT * FROM atc".$filter_query." atc_id = :id"; |
78 | 78 | $query_values = array(':id' => $id); |
79 | 79 | try { |
80 | 80 | $sth = $this->db->prepare($query); |
81 | 81 | $sth->execute($query_values); |
82 | - } catch(PDOException $e) { |
|
82 | + } catch (PDOException $e) { |
|
83 | 83 | return "error : ".$e->getMessage(); |
84 | 84 | } |
85 | 85 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -92,19 +92,19 @@ discard block |
||
92 | 92 | * @param String $format_source Format source |
93 | 93 | * @return Array Return ATC |
94 | 94 | */ |
95 | - public function getByIdent($ident,$format_source = '') { |
|
96 | - $filter_query = $this->getFilter(array(),true,true); |
|
95 | + public function getByIdent($ident, $format_source = '') { |
|
96 | + $filter_query = $this->getFilter(array(), true, true); |
|
97 | 97 | if ($format_source == '') { |
98 | 98 | $query = "SELECT * FROM atc".$filter_query." ident = :ident"; |
99 | 99 | $query_values = array(':ident' => $ident); |
100 | 100 | } else { |
101 | 101 | $query = "SELECT * FROM atc".$filter_query." ident = :ident AND format_source = :format_source"; |
102 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
102 | + $query_values = array(':ident' => $ident, ':format_source' => $format_source); |
|
103 | 103 | } |
104 | 104 | try { |
105 | 105 | $sth = $this->db->prepare($query); |
106 | 106 | $sth->execute($query_values); |
107 | - } catch(PDOException $e) { |
|
107 | + } catch (PDOException $e) { |
|
108 | 108 | return "error : ".$e->getMessage(); |
109 | 109 | } |
110 | 110 | $all = $sth->fetchAll(PDO::FETCH_ASSOC); |
@@ -126,18 +126,18 @@ discard block |
||
126 | 126 | * @param String $format_source Format source |
127 | 127 | * @param String $source_name Source name |
128 | 128 | */ |
129 | - public function add($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
130 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
131 | - $info = str_replace('^','<br />',$info); |
|
132 | - $info = str_replace('&sect;','',$info); |
|
133 | - $info = str_replace('"','',$info); |
|
129 | + public function add($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
130 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
131 | + $info = str_replace('^', '<br />', $info); |
|
132 | + $info = str_replace('&sect;', '', $info); |
|
133 | + $info = str_replace('"', '', $info); |
|
134 | 134 | if ($type == '') $type = NULL; |
135 | 135 | $query = "INSERT INTO atc (ident,frequency,latitude,longitude,atc_range,info,atc_lastseen,type,ivao_id,ivao_name,format_source,source_name) VALUES (:ident,:frequency,:latitude,:longitude,:range,:info,:date,:type,:ivao_id,:ivao_name,:format_source,:source_name)"; |
136 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
136 | + $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name); |
|
137 | 137 | try { |
138 | 138 | $sth = $this->db->prepare($query); |
139 | 139 | $sth->execute($query_values); |
140 | - } catch(PDOException $e) { |
|
140 | + } catch (PDOException $e) { |
|
141 | 141 | return "error : ".$e->getMessage(); |
142 | 142 | } |
143 | 143 | } |
@@ -157,18 +157,18 @@ discard block |
||
157 | 157 | * @param String $format_source Format source |
158 | 158 | * @param String $source_name Source name |
159 | 159 | */ |
160 | - public function update($ident,$frequency,$latitude,$longitude,$range,$info,$date,$type = '',$ivao_id = '',$ivao_name = '',$format_source = '',$source_name = '') { |
|
161 | - $info = preg_replace('/[^(\x20-\x7F)]*/','',$info); |
|
162 | - $info = str_replace('^','<br />',$info); |
|
163 | - $info = str_replace('&sect;','',$info); |
|
164 | - $info = str_replace('"','',$info); |
|
160 | + public function update($ident, $frequency, $latitude, $longitude, $range, $info, $date, $type = '', $ivao_id = '', $ivao_name = '', $format_source = '', $source_name = '') { |
|
161 | + $info = preg_replace('/[^(\x20-\x7F)]*/', '', $info); |
|
162 | + $info = str_replace('^', '<br />', $info); |
|
163 | + $info = str_replace('&sect;', '', $info); |
|
164 | + $info = str_replace('"', '', $info); |
|
165 | 165 | if ($type == '') $type = NULL; |
166 | 166 | $query = "UPDATE atc SET frequency = :frequency,latitude = :latitude,longitude = :longitude,atc_range = :range,info = :info,atc_lastseen = :date,type = :type,ivao_id = :ivao_id,ivao_name = :ivao_name WHERE ident = :ident AND format_source = :format_source AND source_name = :source_name"; |
167 | - $query_values = array(':ident' => $ident,':frequency' => $frequency,':latitude' => $latitude,':longitude' => $longitude,':range' => $range,':info' => $info,':date' => $date,':ivao_id' => $ivao_id,':ivao_name' => $ivao_name, ':type' => $type,':format_source' => $format_source,':source_name' => $source_name); |
|
167 | + $query_values = array(':ident' => $ident, ':frequency' => $frequency, ':latitude' => $latitude, ':longitude' => $longitude, ':range' => $range, ':info' => $info, ':date' => $date, ':ivao_id' => $ivao_id, ':ivao_name' => $ivao_name, ':type' => $type, ':format_source' => $format_source, ':source_name' => $source_name); |
|
168 | 168 | try { |
169 | 169 | $sth = $this->db->prepare($query); |
170 | 170 | $sth->execute($query_values); |
171 | - } catch(PDOException $e) { |
|
171 | + } catch (PDOException $e) { |
|
172 | 172 | return "error : ".$e->getMessage(); |
173 | 173 | } |
174 | 174 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | try { |
184 | 184 | $sth = $this->db->prepare($query); |
185 | 185 | $sth->execute($query_values); |
186 | - } catch(PDOException $e) { |
|
186 | + } catch (PDOException $e) { |
|
187 | 187 | return "error : ".$e->getMessage(); |
188 | 188 | } |
189 | 189 | } |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | * @param String $ident Flight ident |
194 | 194 | * @param String $format_source Format source |
195 | 195 | */ |
196 | - public function deleteByIdent($ident,$format_source) { |
|
196 | + public function deleteByIdent($ident, $format_source) { |
|
197 | 197 | $query = "DELETE FROM atc WHERE ident = :ident AND format_source = :format_source"; |
198 | - $query_values = array(':ident' => $ident,':format_source' => $format_source); |
|
198 | + $query_values = array(':ident' => $ident, ':format_source' => $format_source); |
|
199 | 199 | try { |
200 | 200 | $sth = $this->db->prepare($query); |
201 | 201 | $sth->execute($query_values); |
202 | - } catch(PDOException $e) { |
|
202 | + } catch (PDOException $e) { |
|
203 | 203 | return "error : ".$e->getMessage(); |
204 | 204 | } |
205 | 205 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | try { |
214 | 214 | $sth = $this->db->prepare($query); |
215 | 215 | $sth->execute($query_values); |
216 | - } catch(PDOException $e) { |
|
216 | + } catch (PDOException $e) { |
|
217 | 217 | return "error : ".$e->getMessage(); |
218 | 218 | } |
219 | 219 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | try { |
232 | 232 | $sth = $this->db->prepare($query); |
233 | 233 | $sth->execute(); |
234 | - } catch(PDOException $e) { |
|
234 | + } catch (PDOException $e) { |
|
235 | 235 | return "error"; |
236 | 236 | } |
237 | 237 | return "success"; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | /* |
22 | 22 | * Initialize DB connection |
23 | 23 | */ |
24 | - public function __construct($dbc = null,$fromACARSscript = false) { |
|
24 | + public function __construct($dbc = null, $fromACARSscript = false) { |
|
25 | 25 | $Connection = new Connection($dbc); |
26 | 26 | $this->db = $Connection->db(); |
27 | 27 | if ($this->db === null) die('Error: No DB connection. (ACARS)'); |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | * @return String the icao |
39 | 39 | */ |
40 | 40 | public function ident2icao($ident) { |
41 | - if (substr($ident,0,2) == 'AF') { |
|
42 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
43 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
41 | + if (substr($ident, 0, 2) == 'AF') { |
|
42 | + if (filter_var(substr($ident, 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
43 | + else $icao = 'AFR'.ltrim(substr($ident, 2), '0'); |
|
44 | 44 | } else { |
45 | 45 | $Spotter = new Spotter($this->db); |
46 | - $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
|
46 | + $identicao = $Spotter->getAllAirlineInfo(substr($ident, 0, 2)); |
|
47 | 47 | if (isset($identicao[0])) { |
48 | - $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
|
48 | + $icao = $identicao[0]['icao'].ltrim(substr($ident, 2), '0'); |
|
49 | 49 | } else $icao = $ident; |
50 | 50 | } |
51 | 51 | return $icao; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | |
70 | 70 | $sth = $this->db->prepare($query); |
71 | 71 | $sth->execute(); |
72 | - } catch(PDOException $e) { |
|
72 | + } catch (PDOException $e) { |
|
73 | 73 | return "error"; |
74 | 74 | } |
75 | 75 | return "success"; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | |
94 | 94 | $sth = $this->db->prepare($query); |
95 | 95 | $sth->execute(); |
96 | - } catch(PDOException $e) { |
|
96 | + } catch (PDOException $e) { |
|
97 | 97 | return "error"; |
98 | 98 | } |
99 | 99 | return "success"; |
@@ -118,13 +118,13 @@ discard block |
||
118 | 118 | $ident = ''; |
119 | 119 | $message = ''; |
120 | 120 | $result = array(); |
121 | - $n = sscanf($data,'(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
122 | - if ($n == 0) $n = sscanf($data,'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
123 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
124 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
121 | + $n = sscanf($data, '(null) %*d %*02d/%*02d/%*04d %*02d:%*02d:%*02d %*d %*[0-9-] %*[A-Z0-9] %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
122 | + if ($n == 0) $n = sscanf($data, 'AC%*c %7s %*c %2[0-9a-zA-Z_] %d %4[0-9A-Z] %6[0-9A-Z] %[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
123 | + if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
124 | + if ($n == 0) $n = sscanf($data, '%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]', $registration, $label, $block_id, $msg_no, $ident, $message); |
|
125 | 125 | if ($n != 0) { |
126 | - $registration = str_replace('.','',$registration); |
|
127 | - $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
|
126 | + $registration = str_replace('.', '', $registration); |
|
127 | + $result = array('registration' => $registration, 'ident' => $ident, 'label' => $label, 'block_id' => $block_id, 'msg_no' => $msg_no, 'message' => $message); |
|
128 | 128 | if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
129 | 129 | } else $message = $data; |
130 | 130 | $decode = array(); |
@@ -144,14 +144,14 @@ discard block |
||
144 | 144 | $temp = ''; |
145 | 145 | $n = sscanf($message, "FST01%4c%4c%c%06d%c%07d%03d%*8[0-9a-zA-Z ]-%02dC", $dair, $darr, $lac, $la, $lnc, $ln, $alt, $temp); |
146 | 146 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
147 | - $latitude = $la / 10000.0; |
|
148 | - $longitude = $ln / 10000.0; |
|
147 | + $latitude = $la/10000.0; |
|
148 | + $longitude = $ln/10000.0; |
|
149 | 149 | if ($lac == 'S') $latitude = '-'.$latitude; |
150 | 150 | if ($lnc == 'W') $longitude = '-'.$longitude; |
151 | 151 | // Temp not always available |
152 | 152 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
153 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
154 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
153 | + if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => $alt); |
|
154 | + else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt, 'Temperature' => $temp.'°C'); |
|
155 | 155 | |
156 | 156 | //$icao = $Translation->checkTranslation($ident); |
157 | 157 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -163,19 +163,19 @@ discard block |
||
163 | 163 | $dhour = ''; |
164 | 164 | $darr = ''; |
165 | 165 | $ahour = ''; |
166 | - $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
|
166 | + $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr, $ahour); |
|
167 | 167 | if ($n == 4 && strlen($darr) == 4) { |
168 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
169 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
170 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
168 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
169 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
170 | + if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '.$darr.' - departure hour : '.$dhour.' - arrival hour : '.$ahour."\n"; |
|
171 | 171 | //$icao = ACARS->ident2icao($ident); |
172 | 172 | //$icao = $Translation->checkTranslation($ident); |
173 | 173 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
174 | 174 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
175 | 175 | $found = true; |
176 | 176 | } |
177 | - elseif ($n == 2 || $n == 4) { |
|
178 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
177 | + elseif ($n == 2 || $n == 4) { |
|
178 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
179 | 179 | if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
180 | 180 | //$icao = ACARS->ident2icao($ident); |
181 | 181 | //$icao = $Translation->checkTranslation($ident); |
@@ -233,11 +233,11 @@ discard block |
||
233 | 233 | $ahour = ''; |
234 | 234 | $aair = ''; |
235 | 235 | $apiste = ''; |
236 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
|
236 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z]/%*3d/%4s/%*cSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao, $aident, $dair, $darr, $ddate, $dhour, $ahour, $aair, $apiste); |
|
237 | 237 | if ($n > 8) { |
238 | - if ($globalDebug) echo 'airicao : '. $airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '. $darr.' - date depart : '.$ddate.' - departure hour : '. $dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
239 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
240 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
238 | + if ($globalDebug) echo 'airicao : '.$airicao.' - ident : '.$aident.' - departure airport : '.$dair.' - arrival airport : '.$darr.' - date depart : '.$ddate.' - departure hour : '.$dhour.' - arrival hour : '.$ahour.' - arrival airport : '.$aair.' - arrival piste : '.$apiste."\n"; |
|
239 | + if ($dhour != '') $dhour = substr(sprintf('%04d', $dhour), 0, 2).':'.substr(sprintf('%04d', $dhour), 2); |
|
240 | + if ($ahour != '') $ahour = substr(sprintf('%04d', $ahour), 0, 2).':'.substr(sprintf('%04d', $ahour), 2); |
|
241 | 241 | $icao = trim($aident); |
242 | 242 | |
243 | 243 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
@@ -262,8 +262,8 @@ discard block |
||
262 | 262 | if ($n == 10 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
263 | 263 | $las = $las.'.'.$lass; |
264 | 264 | $lns = $lns.'.'.$lns; |
265 | - $latitude = $las / 1000.0; |
|
266 | - $longitude = $lns / 1000.0; |
|
265 | + $latitude = $las/1000.0; |
|
266 | + $longitude = $lns/1000.0; |
|
267 | 267 | if ($lac == 'S') $latitude = '-'.$latitude; |
268 | 268 | if ($lnc == 'W') $longitude = '-'.$longitude; |
269 | 269 | if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
@@ -358,17 +358,17 @@ discard block |
||
358 | 358 | $alt = ''; |
359 | 359 | $fuel = ''; |
360 | 360 | $speed = ''; |
361 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
361 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "#DFB(POS-%s -%4d%c%5d%c/%*d F%dRMK/FUEL %f M%f", $aident, $las, $lac, $lns, $lnc, $alt, $fuel, $speed); |
|
362 | 362 | if ($n == 9) { |
363 | 363 | //if (self->$debug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
364 | 364 | $icao = trim($aident); |
365 | 365 | $decode['icao'] = $icao; |
366 | - $latitude = $las / 100.0; |
|
367 | - $longitude = $lns / 100.0; |
|
366 | + $latitude = $las/100.0; |
|
367 | + $longitude = $lns/100.0; |
|
368 | 368 | if ($lac == 'S') $latitude = '-'.$latitude; |
369 | 369 | if ($lnc == 'W') $longitude = '-'.$longitude; |
370 | 370 | |
371 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
|
371 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Altitude' => 'FL'.$alt, 'Fuel' => $fuel, 'speed' => $speed); |
|
372 | 372 | $found = true; |
373 | 373 | } |
374 | 374 | } |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | if ($lac == 'S') $latitude = '-'.$latitude; |
388 | 388 | if ($lnc == 'W') $longitude = '-'.$longitude; |
389 | 389 | |
390 | - $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
|
390 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
|
391 | 391 | $found = true; |
392 | 392 | } |
393 | 393 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | $dair = ''; |
421 | 421 | $darr = ''; |
422 | 422 | $aident = ''; |
423 | - $n = sscanf(str_replace(array("\r\n", "\n", "\r"),'',$message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
423 | + $n = sscanf(str_replace(array("\r\n", "\n", "\r"), '', $message), "%*[0-9A-Z],,%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,%*4[A-Z],%[0-9A-Z],", $dair, $darr, $aident); |
|
424 | 424 | if ($n == 8) { |
425 | 425 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
426 | 426 | $icao = trim($aident); |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | */ |
453 | 453 | $dair = ''; |
454 | 454 | $darr = ''; |
455 | - $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
|
455 | + $n = sscanf($message, '%4[A-Z]%4[A-Z]%*4d', $dair, $darr); |
|
456 | 456 | if ($n == 3) { |
457 | 457 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
458 | 458 | //$icao = $Translation->checkTranslation($ident); |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | */ |
468 | 468 | $dair = ''; |
469 | 469 | $darr = ''; |
470 | - $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
|
470 | + $n = sscanf($message, '3J01 DSPTCH %*d/%*d %4s/%4s .%*6s', $dair, $darr); |
|
471 | 471 | if ($n == 3) { |
472 | 472 | if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
473 | 473 | //$icao = $Translation->checkTranslation($ident); |
@@ -477,7 +477,7 @@ discard block |
||
477 | 477 | } |
478 | 478 | } |
479 | 479 | if (!$found) { |
480 | - $n = sscanf($message,'MET01%4c',$airport); |
|
480 | + $n = sscanf($message, 'MET01%4c', $airport); |
|
481 | 481 | if ($n == 1) { |
482 | 482 | if ($globalDebug) echo 'airport name : '.$airport; |
483 | 483 | $decode = array('Airport/Waypoint name' => $airport); |
@@ -485,241 +485,241 @@ discard block |
||
485 | 485 | } |
486 | 486 | } |
487 | 487 | if ($label == 'H1') { |
488 | - if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
|
489 | - $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
|
488 | + if (preg_match('/^#CFBFLR/', $message) || preg_match('/^#CFBWRN/', $message)) { |
|
489 | + $decode = array_merge(array('Message nature' => 'Equipment failure'), $decode); |
|
490 | 490 | } |
491 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
492 | - $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
|
491 | + elseif (preg_match('/^#DFB\*TKO/', $message) || preg_match('/^#DFBTKO/', $message)) { |
|
492 | + $decode = array_merge(array('Message nature' => 'Take off performance data'), $decode); |
|
493 | 493 | } |
494 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
495 | - $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
|
494 | + elseif (preg_match('/^#DFB\*CRZ/', $message) || preg_match('/^#DFBCRZ/', $message)) { |
|
495 | + $decode = array_merge(array('Message nature' => 'Cruise performance data'), $decode); |
|
496 | 496 | } |
497 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
498 | - $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
|
497 | + elseif (preg_match('/^#DFB\*WOB/', $message) || preg_match('/^#DFBWOB/', $message)) { |
|
498 | + $decode = array_merge(array('Message nature' => 'Weather observation'), $decode); |
|
499 | 499 | } |
500 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
501 | - $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
|
500 | + elseif (preg_match(':^#DFB/PIREP:', $message)) { |
|
501 | + $decode = array_merge(array('Message nature' => 'Pilot Report'), $decode); |
|
502 | 502 | } |
503 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
504 | - $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
|
503 | + elseif (preg_match('/^#DFBEDA/', $message) || preg_match('/^#DFBENG/', $message)) { |
|
504 | + $decode = array_merge(array('Message nature' => 'Engine Data'), $decode); |
|
505 | 505 | } |
506 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
507 | - $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
|
506 | + elseif (preg_match(':^#M1AAEP:', $message)) { |
|
507 | + $decode = array_merge(array('Message nature' => 'Position/Weather Report'), $decode); |
|
508 | 508 | } |
509 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
510 | - $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
|
509 | + elseif (preg_match(':^#M2APWD:', $message)) { |
|
510 | + $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'), $decode); |
|
511 | 511 | } |
512 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
513 | - $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
|
512 | + elseif (preg_match(':^#M1BREQPWI:', $message)) { |
|
513 | + $decode = array_merge(array('Message nature' => 'Predicted wind info request'), $decode); |
|
514 | 514 | } |
515 | - elseif (preg_match(':^#CF:',$message)) { |
|
516 | - $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
|
515 | + elseif (preg_match(':^#CF:', $message)) { |
|
516 | + $decode = array_merge(array('Message nature' => 'Central Fault Display'), $decode); |
|
517 | 517 | } |
518 | - elseif (preg_match(':^#DF:',$message)) { |
|
519 | - $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
|
518 | + elseif (preg_match(':^#DF:', $message)) { |
|
519 | + $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'), $decode); |
|
520 | 520 | } |
521 | - elseif (preg_match(':^#EC:',$message)) { |
|
522 | - $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
|
521 | + elseif (preg_match(':^#EC:', $message)) { |
|
522 | + $decode = array_merge(array('Message nature' => 'Engine Display System'), $decode); |
|
523 | 523 | } |
524 | - elseif (preg_match(':^#EI:',$message)) { |
|
525 | - $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
|
524 | + elseif (preg_match(':^#EI:', $message)) { |
|
525 | + $decode = array_merge(array('Message nature' => 'Engine Report'), $decode); |
|
526 | 526 | } |
527 | - elseif (preg_match(':^#H1:',$message)) { |
|
528 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
|
527 | + elseif (preg_match(':^#H1:', $message)) { |
|
528 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'), $decode); |
|
529 | 529 | } |
530 | - elseif (preg_match(':^#H2:',$message)) { |
|
531 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
|
530 | + elseif (preg_match(':^#H2:', $message)) { |
|
531 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'), $decode); |
|
532 | 532 | } |
533 | - elseif (preg_match(':^#HD:',$message)) { |
|
534 | - $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
|
533 | + elseif (preg_match(':^#HD:', $message)) { |
|
534 | + $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'), $decode); |
|
535 | 535 | } |
536 | - elseif (preg_match(':^#M1:',$message)) { |
|
537 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
|
536 | + elseif (preg_match(':^#M1:', $message)) { |
|
537 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'), $decode); |
|
538 | 538 | } |
539 | - elseif (preg_match(':^#M2:',$message)) { |
|
540 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
|
539 | + elseif (preg_match(':^#M2:', $message)) { |
|
540 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'), $decode); |
|
541 | 541 | } |
542 | - elseif (preg_match(':^#M3:',$message)) { |
|
543 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
|
542 | + elseif (preg_match(':^#M3:', $message)) { |
|
543 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'), $decode); |
|
544 | 544 | } |
545 | - elseif (preg_match(':^#MD:',$message)) { |
|
546 | - $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
|
545 | + elseif (preg_match(':^#MD:', $message)) { |
|
546 | + $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'), $decode); |
|
547 | 547 | } |
548 | - elseif (preg_match(':^#PS:',$message)) { |
|
549 | - $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
|
548 | + elseif (preg_match(':^#PS:', $message)) { |
|
549 | + $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'), $decode); |
|
550 | 550 | } |
551 | - elseif (preg_match(':^#S1:',$message)) { |
|
552 | - $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
|
551 | + elseif (preg_match(':^#S1:', $message)) { |
|
552 | + $decode = array_merge(array('Message nature' => 'SDU - Left'), $decode); |
|
553 | 553 | } |
554 | - elseif (preg_match(':^#S2:',$message)) { |
|
555 | - $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
|
554 | + elseif (preg_match(':^#S2:', $message)) { |
|
555 | + $decode = array_merge(array('Message nature' => 'SDU - Right'), $decode); |
|
556 | 556 | } |
557 | - elseif (preg_match(':^#SD:',$message)) { |
|
558 | - $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
|
557 | + elseif (preg_match(':^#SD:', $message)) { |
|
558 | + $decode = array_merge(array('Message nature' => 'SDU - Selected'), $decode); |
|
559 | 559 | } |
560 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
561 | - $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
|
560 | + elseif (preg_match(':^#T[0-8]:', $message)) { |
|
561 | + $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'), $decode); |
|
562 | 562 | } |
563 | - elseif (preg_match(':^#WO:',$message)) { |
|
564 | - $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
|
563 | + elseif (preg_match(':^#WO:', $message)) { |
|
564 | + $decode = array_merge(array('Message nature' => 'Weather Observation Report'), $decode); |
|
565 | 565 | } |
566 | - elseif (preg_match(':^#A1:',$message)) { |
|
567 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
|
566 | + elseif (preg_match(':^#A1:', $message)) { |
|
567 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance'), $decode); |
|
568 | 568 | } |
569 | - elseif (preg_match(':^#A3:',$message)) { |
|
570 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
|
569 | + elseif (preg_match(':^#A3:', $message)) { |
|
570 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Response'), $decode); |
|
571 | 571 | } |
572 | - elseif (preg_match(':^#A4:',$message)) { |
|
573 | - $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
|
572 | + elseif (preg_match(':^#A4:', $message)) { |
|
573 | + $decode = array_merge(array('Message nature' => 'Flight Systems Message'), $decode); |
|
574 | 574 | } |
575 | - elseif (preg_match(':^#A6:',$message)) { |
|
576 | - $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
|
575 | + elseif (preg_match(':^#A6:', $message)) { |
|
576 | + $decode = array_merge(array('Message nature' => 'Request ADS Reports'), $decode); |
|
577 | 577 | } |
578 | - elseif (preg_match(':^#A8:',$message)) { |
|
579 | - $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
|
578 | + elseif (preg_match(':^#A8:', $message)) { |
|
579 | + $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'), $decode); |
|
580 | 580 | } |
581 | - elseif (preg_match(':^#A9:',$message)) { |
|
582 | - $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
|
581 | + elseif (preg_match(':^#A9:', $message)) { |
|
582 | + $decode = array_merge(array('Message nature' => 'ATIS report'), $decode); |
|
583 | 583 | } |
584 | - elseif (preg_match(':^#A0:',$message)) { |
|
585 | - $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
|
584 | + elseif (preg_match(':^#A0:', $message)) { |
|
585 | + $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'), $decode); |
|
586 | 586 | } |
587 | - elseif (preg_match(':^#AA:',$message)) { |
|
588 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
587 | + elseif (preg_match(':^#AA:', $message)) { |
|
588 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
589 | 589 | } |
590 | - elseif (preg_match(':^#AB:',$message)) { |
|
591 | - $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
|
590 | + elseif (preg_match(':^#AB:', $message)) { |
|
591 | + $decode = array_merge(array('Message nature' => 'TWIP Report'), $decode); |
|
592 | 592 | } |
593 | - elseif (preg_match(':^#AC:',$message)) { |
|
594 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
|
593 | + elseif (preg_match(':^#AC:', $message)) { |
|
594 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance'), $decode); |
|
595 | 595 | } |
596 | - elseif (preg_match(':^#AD:',$message)) { |
|
597 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
|
596 | + elseif (preg_match(':^#AD:', $message)) { |
|
597 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'), $decode); |
|
598 | 598 | } |
599 | - elseif (preg_match(':^#AF:',$message)) { |
|
600 | - $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
|
599 | + elseif (preg_match(':^#AF:', $message)) { |
|
600 | + $decode = array_merge(array('Message nature' => 'CPC Command/Response'), $decode); |
|
601 | 601 | } |
602 | - elseif (preg_match(':^#B1:',$message)) { |
|
603 | - $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
|
602 | + elseif (preg_match(':^#B1:', $message)) { |
|
603 | + $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'), $decode); |
|
604 | 604 | } |
605 | - elseif (preg_match(':^#B2:',$message)) { |
|
606 | - $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
|
605 | + elseif (preg_match(':^#B2:', $message)) { |
|
606 | + $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'), $decode); |
|
607 | 607 | } |
608 | - elseif (preg_match(':^#B3:',$message)) { |
|
609 | - $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
|
608 | + elseif (preg_match(':^#B3:', $message)) { |
|
609 | + $decode = array_merge(array('Message nature' => 'Request Departure Clearance'), $decode); |
|
610 | 610 | } |
611 | - elseif (preg_match(':^#B4:',$message)) { |
|
612 | - $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
|
611 | + elseif (preg_match(':^#B4:', $message)) { |
|
612 | + $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'), $decode); |
|
613 | 613 | } |
614 | - elseif (preg_match(':^#B6:',$message)) { |
|
615 | - $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
|
614 | + elseif (preg_match(':^#B6:', $message)) { |
|
615 | + $decode = array_merge(array('Message nature' => 'Provide ADS Report'), $decode); |
|
616 | 616 | } |
617 | - elseif (preg_match(':^#B8:',$message)) { |
|
618 | - $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
|
617 | + elseif (preg_match(':^#B8:', $message)) { |
|
618 | + $decode = array_merge(array('Message nature' => 'Request Departure Slot'), $decode); |
|
619 | 619 | } |
620 | - elseif (preg_match(':^#B9:',$message)) { |
|
621 | - $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
|
620 | + elseif (preg_match(':^#B9:', $message)) { |
|
621 | + $decode = array_merge(array('Message nature' => 'Request ATIS Report'), $decode); |
|
622 | 622 | } |
623 | - elseif (preg_match(':^#B0:',$message)) { |
|
624 | - $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
|
623 | + elseif (preg_match(':^#B0:', $message)) { |
|
624 | + $decode = array_merge(array('Message nature' => 'ATS Facility Notification'), $decode); |
|
625 | 625 | } |
626 | - elseif (preg_match(':^#BA:',$message)) { |
|
627 | - $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
|
626 | + elseif (preg_match(':^#BA:', $message)) { |
|
627 | + $decode = array_merge(array('Message nature' => 'ATCComm'), $decode); |
|
628 | 628 | } |
629 | - elseif (preg_match(':^#BB:',$message)) { |
|
630 | - $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
|
629 | + elseif (preg_match(':^#BB:', $message)) { |
|
630 | + $decode = array_merge(array('Message nature' => 'Request TWIP Report'), $decode); |
|
631 | 631 | } |
632 | - elseif (preg_match(':^#BC:',$message)) { |
|
633 | - $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
|
632 | + elseif (preg_match(':^#BC:', $message)) { |
|
633 | + $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'), $decode); |
|
634 | 634 | } |
635 | - elseif (preg_match(':^#BD:',$message)) { |
|
636 | - $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
|
635 | + elseif (preg_match(':^#BD:', $message)) { |
|
636 | + $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'), $decode); |
|
637 | 637 | } |
638 | - elseif (preg_match(':^#BE:',$message)) { |
|
639 | - $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
|
638 | + elseif (preg_match(':^#BE:', $message)) { |
|
639 | + $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'), $decode); |
|
640 | 640 | } |
641 | - elseif (preg_match(':^#BF:',$message)) { |
|
642 | - $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
|
641 | + elseif (preg_match(':^#BF:', $message)) { |
|
642 | + $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'), $decode); |
|
643 | 643 | } |
644 | - elseif (preg_match(':^#H3:',$message)) { |
|
645 | - $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
|
644 | + elseif (preg_match(':^#H3:', $message)) { |
|
645 | + $decode = array_merge(array('Message nature' => 'Icing Report'), $decode); |
|
646 | 646 | } |
647 | 647 | } |
648 | 648 | if ($label == '10') { |
649 | - if (preg_match(':^DTO01:',$message)) { |
|
650 | - $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
|
649 | + if (preg_match(':^DTO01:', $message)) { |
|
650 | + $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'), $decode); |
|
651 | 651 | } |
652 | - elseif (preg_match(':^AIS01:',$message)) { |
|
653 | - $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
|
652 | + elseif (preg_match(':^AIS01:', $message)) { |
|
653 | + $decode = array_merge(array('Message nature' => 'AIS Request'), $decode); |
|
654 | 654 | } |
655 | - elseif (preg_match(':^FTX01:',$message)) { |
|
656 | - $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
|
655 | + elseif (preg_match(':^FTX01:', $message)) { |
|
656 | + $decode = array_merge(array('Message nature' => 'Free Text Downlink'), $decode); |
|
657 | 657 | } |
658 | - elseif (preg_match(':^FPL01:',$message)) { |
|
659 | - $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
|
658 | + elseif (preg_match(':^FPL01:', $message)) { |
|
659 | + $decode = array_merge(array('Message nature' => 'Flight Plan Request'), $decode); |
|
660 | 660 | } |
661 | - elseif (preg_match(':^WAB01:',$message)) { |
|
662 | - $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
|
661 | + elseif (preg_match(':^WAB01:', $message)) { |
|
662 | + $decode = array_merge(array('Message nature' => 'Weight & Balance Request'), $decode); |
|
663 | 663 | } |
664 | - elseif (preg_match(':^MET01:',$message)) { |
|
665 | - $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
|
664 | + elseif (preg_match(':^MET01:', $message)) { |
|
665 | + $decode = array_merge(array('Message nature' => 'Weather Data Request'), $decode); |
|
666 | 666 | } |
667 | - elseif (preg_match(':^WAB02:',$message)) { |
|
668 | - $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
|
667 | + elseif (preg_match(':^WAB02:', $message)) { |
|
668 | + $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'), $decode); |
|
669 | 669 | } |
670 | 670 | } |
671 | 671 | if ($label == '15') { |
672 | - if (preg_match(':^FST01:',$message)) { |
|
673 | - $decode = array_merge(array('Message nature' => 'Flight Status Report'),$decode); |
|
672 | + if (preg_match(':^FST01:', $message)) { |
|
673 | + $decode = array_merge(array('Message nature' => 'Flight Status Report'), $decode); |
|
674 | 674 | } |
675 | 675 | } |
676 | 676 | if (!$found && $label == 'SA') { |
677 | - $n = sscanf($message, "%d%c%c%6[0-9]", $version,$state,$type,$at); |
|
677 | + $n = sscanf($message, "%d%c%c%6[0-9]", $version, $state, $type, $at); |
|
678 | 678 | if ($n == 4) { |
679 | 679 | $vsta = array('Version' => $version); |
680 | 680 | if ($state == 'E') { |
681 | - $vsta = array_merge($vsta,array('Link state' => 'Established')); |
|
681 | + $vsta = array_merge($vsta, array('Link state' => 'Established')); |
|
682 | 682 | } |
683 | 683 | elseif ($state == 'L') { |
684 | - $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
|
684 | + $vsta = array_merge($vsta, array('Link state' => 'Lost')); |
|
685 | 685 | } |
686 | 686 | else { |
687 | - $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
|
687 | + $vsta = array_merge($vsta, array('Link state' => 'Unknown')); |
|
688 | 688 | } |
689 | 689 | if ($type == 'V') { |
690 | - $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
|
690 | + $vsta = array_merge($vsta, array('Link type' => 'VHF ACARS')); |
|
691 | 691 | } |
692 | 692 | elseif ($type == 'S') { |
693 | - $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
|
693 | + $vsta = array_merge($vsta, array('Link type' => 'Generic SATCOM')); |
|
694 | 694 | } |
695 | 695 | elseif ($type == 'H') { |
696 | - $vsta = array_merge($vsta,array('Link type' => 'HF')); |
|
696 | + $vsta = array_merge($vsta, array('Link type' => 'HF')); |
|
697 | 697 | } |
698 | 698 | elseif ($type == 'G') { |
699 | - $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
|
699 | + $vsta = array_merge($vsta, array('Link type' => 'GlobalStar SATCOM')); |
|
700 | 700 | } |
701 | 701 | elseif ($type == 'C') { |
702 | - $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
|
702 | + $vsta = array_merge($vsta, array('Link type' => 'ICO SATCOM')); |
|
703 | 703 | } |
704 | 704 | elseif ($type == '2') { |
705 | - $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
|
705 | + $vsta = array_merge($vsta, array('Link type' => 'VDL Mode 2')); |
|
706 | 706 | } |
707 | 707 | elseif ($type == 'X') { |
708 | - $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
|
708 | + $vsta = array_merge($vsta, array('Link type' => 'Inmarsat Aero')); |
|
709 | 709 | } |
710 | 710 | elseif ($type == 'I') { |
711 | - $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
|
711 | + $vsta = array_merge($vsta, array('Link type' => 'Irridium SATCOM')); |
|
712 | 712 | } |
713 | 713 | else { |
714 | - $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
|
714 | + $vsta = array_merge($vsta, array('Link type' => 'Unknown')); |
|
715 | 715 | } |
716 | - $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
|
717 | - $decode = array_merge($vsta,$decode); |
|
716 | + $vsta = array_merge($vsta, array('Event occured at' => implode(':', str_split($at, 2)))); |
|
717 | + $decode = array_merge($vsta, $decode); |
|
718 | 718 | } |
719 | 719 | } |
720 | 720 | |
721 | 721 | $title = $this->getTitlefromLabel($label); |
722 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
722 | + if ($title != '') $decode = array_merge(array('Message title' => $title), $decode); |
|
723 | 723 | /* |
724 | 724 | // Business jets always use GS0001 |
725 | 725 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -747,13 +747,13 @@ discard block |
||
747 | 747 | $Translation = new Translation($this->db); |
748 | 748 | $message = $this->parse($data); |
749 | 749 | if (isset($message['registration']) && $message['registration'] != '' && $message['ident'] != '' && $message['registration'] != '!') { |
750 | - $ident = (string)$message['ident']; |
|
750 | + $ident = (string) $message['ident']; |
|
751 | 751 | $label = $message['label']; |
752 | 752 | $block_id = $message['block_id']; |
753 | 753 | $msg_no = $message['msg_no']; |
754 | 754 | $msg = $message['message']; |
755 | 755 | $decode = $message['decode']; |
756 | - $registration = (string)$message['registration']; |
|
756 | + $registration = (string) $message['registration']; |
|
757 | 757 | if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
758 | 758 | else $latitude = ''; |
759 | 759 | if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
@@ -767,20 +767,20 @@ discard block |
||
767 | 767 | $Image->addSpotterImage($registration); |
768 | 768 | } |
769 | 769 | // Business jets always use GS0001 |
770 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
770 | + if ($ident != 'GS0001') $info = $this->addModeSData($ident, $registration, $icao, $airicao, $latitude, $longitude); |
|
771 | 771 | if ($globalDebug && isset($info) && $info != '') echo $info; |
772 | 772 | if (count($decode) > 0) $decode_json = json_encode($decode); |
773 | 773 | else $decode_json = ''; |
774 | 774 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
775 | - $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
|
775 | + $Schedule->addSchedule($icao, $decode['Departure airport'], $decode['Departure hour'], $decode['Arrival airport'], $decode['Arrival hour'], 'ACARS'); |
|
776 | 776 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
777 | - $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
|
777 | + $Schedule->addSchedule($icao, $decode['Departure airport'], '', $decode['Arrival airport'], '', 'ACARS'); |
|
778 | 778 | } |
779 | - $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
780 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
781 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
779 | + $result = $this->addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
780 | + if (!isset($globalACARSArchive)) $globalACARSArchive = array('10', '80', '81', '82', '3F'); |
|
781 | + if ($result && in_array($label, $globalACARSArchive)) $this->addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $msg, $decode_json); |
|
782 | 782 | if ($globalDebug && count($decode) > 0) { |
783 | - echo "Human readable data : ".implode(' - ',$decode)."\n"; |
|
783 | + echo "Human readable data : ".implode(' - ', $decode)."\n"; |
|
784 | 784 | } |
785 | 785 | } |
786 | 786 | } |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | * @param String $msg_no Number of the ACARS message |
796 | 796 | * @param String $message ACARS message |
797 | 797 | */ |
798 | - public function addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
798 | + public function addLiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
799 | 799 | global $globalDebug; |
800 | 800 | date_default_timezone_set('UTC'); |
801 | 801 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
@@ -803,21 +803,21 @@ discard block |
||
803 | 803 | $this->db = $Connection->db; |
804 | 804 | if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
805 | 805 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
806 | - $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
|
806 | + $query_test_values = array(':ident' => $ident, ':registration' => $registration, ':message' => $message); |
|
807 | 807 | try { |
808 | 808 | $stht = $this->db->prepare($query_test); |
809 | 809 | $stht->execute($query_test_values); |
810 | - } catch(PDOException $e) { |
|
810 | + } catch (PDOException $e) { |
|
811 | 811 | return "error : ".$e->getMessage(); |
812 | 812 | } |
813 | 813 | if ($stht->fetchColumn() == 0) { |
814 | 814 | if ($globalDebug) echo "Add Live ACARS data..."; |
815 | 815 | $query = "INSERT INTO acars_live (ident,registration,label,block_id,msg_no,message,decode,date) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode,:date)"; |
816 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode,':date' => date("Y-m-d H:i:s")); |
|
816 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode, ':date' => date("Y-m-d H:i:s")); |
|
817 | 817 | try { |
818 | 818 | $sth = $this->db->prepare($query); |
819 | 819 | $sth->execute($query_values); |
820 | - } catch(PDOException $e) { |
|
820 | + } catch (PDOException $e) { |
|
821 | 821 | return "error : ".$e->getMessage(); |
822 | 822 | } |
823 | 823 | } else { |
@@ -839,10 +839,10 @@ discard block |
||
839 | 839 | * @param String $msg_no Number of the ACARS message |
840 | 840 | * @param String $message ACARS message |
841 | 841 | */ |
842 | - public function addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$message,$decode = '') { |
|
842 | + public function addArchiveAcarsData($ident, $registration, $label, $block_id, $msg_no, $message, $decode = '') { |
|
843 | 843 | global $globalDebug; |
844 | 844 | date_default_timezone_set('UTC'); |
845 | - if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/',$message) === 0 && preg_match('/^ARR0/',$message) === 0 && preg_match('/^ETA/',$message) === 0 && preg_match('/^WXR/',$message) === 0 && preg_match('/^FTX01.FIC/',$message) === 0) { |
|
845 | + if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '' && preg_match('/^MET0/', $message) === 0 && preg_match('/^ARR0/', $message) === 0 && preg_match('/^ETA/', $message) === 0 && preg_match('/^WXR/', $message) === 0 && preg_match('/^FTX01.FIC/', $message) === 0) { |
|
846 | 846 | /* |
847 | 847 | if ($globalDebug) echo "Test if not already in Archive ACARS table..."; |
848 | 848 | $query_test = "SELECT COUNT(*) as nb FROM acars_archive WHERE ident = :ident AND registration = :registration AND message = :message"; |
@@ -857,11 +857,11 @@ discard block |
||
857 | 857 | */ |
858 | 858 | if ($globalDebug) echo "Add Live ACARS data..."; |
859 | 859 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
860 | - $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
860 | + $query_values = array(':ident' => $ident, ':registration' => $registration, ':label' => $label, ':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
|
861 | 861 | try { |
862 | 862 | $sth = $this->db->prepare($query); |
863 | 863 | $sth->execute($query_values); |
864 | - } catch(PDOException $e) { |
|
864 | + } catch (PDOException $e) { |
|
865 | 865 | return "error : ".$e->getMessage(); |
866 | 866 | } |
867 | 867 | if ($globalDebug) echo "Done\n"; |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | try { |
883 | 883 | $sth = $this->db->prepare($query); |
884 | 884 | $sth->execute($query_values); |
885 | - } catch(PDOException $e) { |
|
885 | + } catch (PDOException $e) { |
|
886 | 886 | echo "error : ".$e->getMessage(); |
887 | 887 | return ''; |
888 | 888 | } |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | try { |
903 | 903 | $sth = $this->db->prepare($query); |
904 | 904 | $sth->execute($query_values); |
905 | - } catch(PDOException $e) { |
|
905 | + } catch (PDOException $e) { |
|
906 | 906 | echo "error : ".$e->getMessage(); |
907 | 907 | return array(); |
908 | 908 | } |
@@ -923,7 +923,7 @@ discard block |
||
923 | 923 | try { |
924 | 924 | $sth = $this->db->prepare($query); |
925 | 925 | $sth->execute($query_values); |
926 | - } catch(PDOException $e) { |
|
926 | + } catch (PDOException $e) { |
|
927 | 927 | echo "error : ".$e->getMessage(); |
928 | 928 | return array(); |
929 | 929 | } |
@@ -937,7 +937,7 @@ discard block |
||
937 | 937 | * |
938 | 938 | * @return Array Return ACARS data in array |
939 | 939 | */ |
940 | - public function getLatestAcarsData($limit = '',$label = '') { |
|
940 | + public function getLatestAcarsData($limit = '', $label = '') { |
|
941 | 941 | global $globalURL, $globalDBdriver; |
942 | 942 | $Image = new Image($this->db); |
943 | 943 | $Spotter = new Spotter($this->db); |
@@ -948,8 +948,8 @@ discard block |
||
948 | 948 | if ($limit != "") |
949 | 949 | { |
950 | 950 | $limit_array = explode(",", $limit); |
951 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
952 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
951 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
952 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
953 | 953 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
954 | 954 | { |
955 | 955 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -965,46 +965,46 @@ discard block |
||
965 | 965 | try { |
966 | 966 | $sth = $this->db->prepare($query); |
967 | 967 | $sth->execute($query_values); |
968 | - } catch(PDOException $e) { |
|
968 | + } catch (PDOException $e) { |
|
969 | 969 | return "error : ".$e->getMessage(); |
970 | 970 | } |
971 | 971 | $i = 0; |
972 | 972 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
973 | 973 | $data = array(); |
974 | 974 | if ($row['registration'] != '') { |
975 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
975 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
976 | 976 | $image_array = $Image->getSpotterImage($row['registration']); |
977 | - if (count($image_array) > 0) $data = array_merge($data,array('image' => $image_array[0]['image'],'image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
978 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
979 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
977 | + if (count($image_array) > 0) $data = array_merge($data, array('image' => $image_array[0]['image'], 'image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
978 | + else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
979 | + } else $data = array_merge($data, array('image' => '', 'image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
980 | 980 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
981 | 981 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
982 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
982 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
983 | 983 | if (isset($identicao[0])) { |
984 | - if (substr($row['ident'],0,2) == 'AF') { |
|
985 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
986 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
987 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
988 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
984 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
985 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
986 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
987 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
988 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
989 | 989 | } else $icao = $row['ident']; |
990 | - $icao = $Translation->checkTranslation($icao,false); |
|
991 | - $decode = json_decode($row['decode'],true); |
|
990 | + $icao = $Translation->checkTranslation($icao, false); |
|
991 | + $decode = json_decode($row['decode'], true); |
|
992 | 992 | $found = false; |
993 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
993 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
994 | 994 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
995 | 995 | if (isset($airport_info[0]['icao'])) { |
996 | 996 | $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
997 | 997 | $found = true; |
998 | 998 | } |
999 | 999 | } |
1000 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
1000 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
1001 | 1001 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1002 | 1002 | if (isset($airport_info[0]['icao'])) { |
1003 | 1003 | $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1004 | 1004 | $found = true; |
1005 | 1005 | } |
1006 | 1006 | } |
1007 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
1007 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
1008 | 1008 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
1009 | 1009 | if (isset($airport_info[0]['icao'])) { |
1010 | 1010 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1012,7 +1012,7 @@ discard block |
||
1012 | 1012 | } |
1013 | 1013 | } |
1014 | 1014 | if ($found) $row['decode'] = json_encode($decode); |
1015 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1015 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1016 | 1016 | $result[] = $data; |
1017 | 1017 | $i++; |
1018 | 1018 | } |
@@ -1028,7 +1028,7 @@ discard block |
||
1028 | 1028 | * |
1029 | 1029 | * @return Array Return ACARS data in array |
1030 | 1030 | */ |
1031 | - public function getArchiveAcarsData($limit = '',$label = '') { |
|
1031 | + public function getArchiveAcarsData($limit = '', $label = '') { |
|
1032 | 1032 | global $globalURL, $globalDBdriver; |
1033 | 1033 | $Image = new Image($this->db); |
1034 | 1034 | $Spotter = new Spotter($this->db); |
@@ -1038,8 +1038,8 @@ discard block |
||
1038 | 1038 | if ($limit != "") |
1039 | 1039 | { |
1040 | 1040 | $limit_array = explode(",", $limit); |
1041 | - $limit_array[0] = filter_var($limit_array[0],FILTER_SANITIZE_NUMBER_INT); |
|
1042 | - $limit_array[1] = filter_var($limit_array[1],FILTER_SANITIZE_NUMBER_INT); |
|
1041 | + $limit_array[0] = filter_var($limit_array[0], FILTER_SANITIZE_NUMBER_INT); |
|
1042 | + $limit_array[1] = filter_var($limit_array[1], FILTER_SANITIZE_NUMBER_INT); |
|
1043 | 1043 | if ($limit_array[0] >= 0 && $limit_array[1] >= 0) |
1044 | 1044 | { |
1045 | 1045 | $limit_query = " LIMIT ".$limit_array[1]." OFFSET ".$limit_array[0]; |
@@ -1060,43 +1060,43 @@ discard block |
||
1060 | 1060 | try { |
1061 | 1061 | $sth = $this->db->prepare($query); |
1062 | 1062 | $sth->execute($query_values); |
1063 | - } catch(PDOException $e) { |
|
1063 | + } catch (PDOException $e) { |
|
1064 | 1064 | return "error : ".$e->getMessage(); |
1065 | 1065 | } |
1066 | - $i=0; |
|
1066 | + $i = 0; |
|
1067 | 1067 | while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { |
1068 | 1068 | $data = array(); |
1069 | 1069 | if ($row['registration'] != '') { |
1070 | - $row['registration'] = str_replace('.','',$row['registration']); |
|
1070 | + $row['registration'] = str_replace('.', '', $row['registration']); |
|
1071 | 1071 | $image_array = $Image->getSpotterImage($row['registration']); |
1072 | - if (count($image_array) > 0) $data = array_merge($data,array('image_thumbnail' => $image_array[0]['image_thumbnail'],'image_copyright' => $image_array[0]['image_copyright'],'image_source' => $image_array[0]['image_source'],'image_source_website' => $image_array[0]['image_source_website'])); |
|
1073 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1074 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1072 | + if (count($image_array) > 0) $data = array_merge($data, array('image_thumbnail' => $image_array[0]['image_thumbnail'], 'image_copyright' => $image_array[0]['image_copyright'], 'image_source' => $image_array[0]['image_source'], 'image_source_website' => $image_array[0]['image_source_website'])); |
|
1073 | + else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1074 | + } else $data = array_merge($data, array('image_thumbnail' => '', 'image_copyright' => '', 'image_source' => '', 'image_source_website' => '')); |
|
1075 | 1075 | $icao = ''; |
1076 | 1076 | if ($row['registration'] == '') $row['registration'] = 'NA'; |
1077 | 1077 | if ($row['ident'] == '') $row['ident'] = 'NA'; |
1078 | - $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
|
1078 | + $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'], 0, 2)); |
|
1079 | 1079 | if (isset($identicao[0])) { |
1080 | - if (substr($row['ident'],0,2) == 'AF') { |
|
1081 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1082 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1083 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1084 | - $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
|
1080 | + if (substr($row['ident'], 0, 2) == 'AF') { |
|
1081 | + if (filter_var(substr($row['ident'], 2), FILTER_VALIDATE_INT, array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1082 | + else $icao = 'AFR'.ltrim(substr($row['ident'], 2), '0'); |
|
1083 | + } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'], 2), '0'); |
|
1084 | + $data = array_merge($data, array('airline_icao' => $identicao[0]['icao'], 'airline_name' => $identicao[0]['name'])); |
|
1085 | 1085 | } else $icao = $row['ident']; |
1086 | 1086 | $icao = $Translation->checkTranslation($icao); |
1087 | - $decode = json_decode($row['decode'],true); |
|
1087 | + $decode = json_decode($row['decode'], true); |
|
1088 | 1088 | $found = false; |
1089 | - if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
|
1089 | + if ($decode != '' && array_key_exists('Departure airport', $decode)) { |
|
1090 | 1090 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1091 | 1091 | if (isset($airport_info[0]['icao'])) $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1092 | 1092 | $found = true; |
1093 | 1093 | } |
1094 | - if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
|
1094 | + if ($decode != '' && array_key_exists('Arrival airport', $decode)) { |
|
1095 | 1095 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1096 | 1096 | if (isset($airport_info[0]['icao'])) $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
1097 | 1097 | $found = true; |
1098 | 1098 | } |
1099 | - if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
|
1099 | + if ($decode != '' && array_key_exists('Airport/Waypoint name', $decode)) { |
|
1100 | 1100 | $airport_info = $Spotter->getAllAirportInfo($decode['Airport/Waypoint name']); |
1101 | 1101 | if (isset($airport_info[0]['icao'])) { |
1102 | 1102 | $decode['Airport/Waypoint name'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
@@ -1104,7 +1104,7 @@ discard block |
||
1104 | 1104 | } |
1105 | 1105 | } |
1106 | 1106 | if ($found) $row['decode'] = json_encode($decode); |
1107 | - $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1107 | + $data = array_merge($data, array('registration' => $row['registration'], 'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
|
1108 | 1108 | $result[] = $data; |
1109 | 1109 | $i++; |
1110 | 1110 | } |
@@ -1122,7 +1122,7 @@ discard block |
||
1122 | 1122 | * @param String $icao |
1123 | 1123 | * @param String $ICAOTypeCode |
1124 | 1124 | */ |
1125 | - public function addModeSData($ident,$registration,$icao = '',$ICAOTypeCode = '',$latitude = '', $longitude = '') { |
|
1125 | + public function addModeSData($ident, $registration, $icao = '', $ICAOTypeCode = '', $latitude = '', $longitude = '') { |
|
1126 | 1126 | global $globalDebug, $globalDBdriver; |
1127 | 1127 | $ident = trim($ident); |
1128 | 1128 | $Translation = new Translation($this->db); |
@@ -1135,7 +1135,7 @@ discard block |
||
1135 | 1135 | if ($globalDebug) echo "Ident or registration null, exit\n"; |
1136 | 1136 | return ''; |
1137 | 1137 | } |
1138 | - $registration = str_replace('.','',$registration); |
|
1138 | + $registration = str_replace('.', '', $registration); |
|
1139 | 1139 | $ident = $Translation->ident2icao($ident); |
1140 | 1140 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1141 | 1141 | if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
@@ -1144,7 +1144,7 @@ discard block |
||
1144 | 1144 | try { |
1145 | 1145 | $sthsi = $this->db->prepare($querysi); |
1146 | 1146 | $sthsi->execute($querysi_values); |
1147 | - } catch(PDOException $e) { |
|
1147 | + } catch (PDOException $e) { |
|
1148 | 1148 | if ($globalDebug) echo $e->getMessage(); |
1149 | 1149 | return "error : ".$e->getMessage(); |
1150 | 1150 | } |
@@ -1154,8 +1154,8 @@ discard block |
||
1154 | 1154 | $Translation = new Translation($this->db); |
1155 | 1155 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1156 | 1156 | if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
1157 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1158 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1157 | + if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1158 | + elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'], $ident, 'ACARS'); |
|
1159 | 1159 | } else { |
1160 | 1160 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1161 | 1161 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | try { |
1164 | 1164 | $sth = $this->db->prepare($query); |
1165 | 1165 | $sth->execute($query_values); |
1166 | - } catch(PDOException $e) { |
|
1166 | + } catch (PDOException $e) { |
|
1167 | 1167 | if ($globalDebug) echo $e->getMessage(); |
1168 | 1168 | return "error : ".$e->getMessage(); |
1169 | 1169 | } |
@@ -1171,7 +1171,7 @@ discard block |
||
1171 | 1171 | $sth->closeCursor(); |
1172 | 1172 | if (isset($result['modes'])) $hex = $result['modes']; |
1173 | 1173 | else $hex = ''; |
1174 | - $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
|
1174 | + $SI_data = array('hex' => $hex, 'ident' => $ident, 'aircraft_icao' => $ICAOTypeCode, 'registration' => $registration, 'latitude' => $latitude, '$longitude' => $longitude, 'format_source' => 'ACARS'); |
|
1175 | 1175 | if ($this->fromACARSscript) $this->SI->add($SI_data); |
1176 | 1176 | } |
1177 | 1177 | } |
@@ -1181,7 +1181,7 @@ discard block |
||
1181 | 1181 | try { |
1182 | 1182 | $sth = $this->db->prepare($query); |
1183 | 1183 | $sth->execute($query_values); |
1184 | - } catch(PDOException $e) { |
|
1184 | + } catch (PDOException $e) { |
|
1185 | 1185 | if ($globalDebug) echo $e->getMessage(); |
1186 | 1186 | return "error : ".$e->getMessage(); |
1187 | 1187 | } |
@@ -1191,7 +1191,7 @@ discard block |
||
1191 | 1191 | if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
1192 | 1192 | else $ModeS = ''; |
1193 | 1193 | if ($ModeS == '') { |
1194 | - $id = explode('-',$result['flightaware_id']); |
|
1194 | + $id = explode('-', $result['flightaware_id']); |
|
1195 | 1195 | $ModeS = $id[0]; |
1196 | 1196 | } |
1197 | 1197 | if ($ModeS != '') { |
@@ -1201,20 +1201,20 @@ discard block |
||
1201 | 1201 | try { |
1202 | 1202 | $sthc = $this->db->prepare($queryc); |
1203 | 1203 | $sthc->execute($queryc_values); |
1204 | - } catch(PDOException $e) { |
|
1204 | + } catch (PDOException $e) { |
|
1205 | 1205 | if ($globalDebug) echo $e->getMessage(); |
1206 | 1206 | return "error : ".$e->getMessage(); |
1207 | 1207 | } |
1208 | 1208 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1209 | 1209 | $sthc->closeCursor(); |
1210 | - if (count($row) == 0) { |
|
1210 | + if (count($row) == 0) { |
|
1211 | 1211 | if ($globalDebug) echo " Add to ModeS table - "; |
1212 | 1212 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
1213 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1213 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1214 | 1214 | try { |
1215 | 1215 | $sthi = $this->db->prepare($queryi); |
1216 | 1216 | $sthi->execute($queryi_values); |
1217 | - } catch(PDOException $e) { |
|
1217 | + } catch (PDOException $e) { |
|
1218 | 1218 | if ($globalDebug) echo $e->getMessage(); |
1219 | 1219 | return "error : ".$e->getMessage(); |
1220 | 1220 | } |
@@ -1222,15 +1222,15 @@ discard block |
||
1222 | 1222 | if ($globalDebug) echo " Update ModeS table - "; |
1223 | 1223 | if ($ICAOTypeCode != '') { |
1224 | 1224 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1225 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1225 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
|
1226 | 1226 | } else { |
1227 | 1227 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1228 | - $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration); |
|
1228 | + $queryi_values = array(':ModeS' => $ModeS, ':ModeSCountry' => $country, ':Registration' => $registration); |
|
1229 | 1229 | } |
1230 | 1230 | try { |
1231 | 1231 | $sthi = $this->db->prepare($queryi); |
1232 | 1232 | $sthi->execute($queryi_values); |
1233 | - } catch(PDOException $e) { |
|
1233 | + } catch (PDOException $e) { |
|
1234 | 1234 | if ($globalDebug) echo $e->getMessage(); |
1235 | 1235 | return "error : ".$e->getMessage(); |
1236 | 1236 | } |
@@ -1267,12 +1267,12 @@ discard block |
||
1267 | 1267 | elseif ($globalDBdriver == 'pgsql') { |
1268 | 1268 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1269 | 1269 | } |
1270 | - $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
|
1270 | + $queryi_values = array(':Registration' => $registration, ':ident' => $icao); |
|
1271 | 1271 | } |
1272 | 1272 | try { |
1273 | 1273 | $sthi = $this->db->prepare($queryi); |
1274 | 1274 | $sthi->execute($queryi_values); |
1275 | - } catch(PDOException $e) { |
|
1275 | + } catch (PDOException $e) { |
|
1276 | 1276 | if ($globalDebug) echo $e->getMessage(); |
1277 | 1277 | return "error : ".$e->getMessage(); |
1278 | 1278 | } |
@@ -1,12 +1,12 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | require_once(dirname(__FILE__).'/settings.php'); |
3 | 3 | |
4 | -class Connection{ |
|
4 | +class Connection { |
|
5 | 5 | public $db = null; |
6 | 6 | public $dbs = array(); |
7 | 7 | public $latest_schema = 50; |
8 | 8 | |
9 | - public function __construct($dbc = null,$dbname = null,$user = null,$pass = null) { |
|
9 | + public function __construct($dbc = null, $dbname = null, $user = null, $pass = null) { |
|
10 | 10 | global $globalNoDB; |
11 | 11 | if (isset($globalNoDB) && $globalNoDB === TRUE) { |
12 | 12 | $this->db = null; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | if ($user === null && $pass === null) { |
17 | 17 | $this->createDBConnection(); |
18 | 18 | } else { |
19 | - $this->createDBConnection(null,$user,$pass); |
|
19 | + $this->createDBConnection(null, $user, $pass); |
|
20 | 20 | } |
21 | 21 | } else { |
22 | 22 | $this->createDBConnection($dbname); |
@@ -100,14 +100,14 @@ discard block |
||
100 | 100 | while (true) { |
101 | 101 | try { |
102 | 102 | if ($globalDBSdriver == 'mysql') { |
103 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
103 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;charset=utf8", $globalDBSuser, $globalDBSpass); |
|
104 | 104 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
105 | 105 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
106 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
107 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,500); |
|
108 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
109 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
110 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
106 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
107 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 500); |
|
108 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
109 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
110 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
111 | 111 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
112 | 112 | $this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); |
113 | 113 | // Workaround against "ONLY_FULL_GROUP_BY" mode |
@@ -117,19 +117,19 @@ discard block |
||
117 | 117 | $this->dbs[$DBname]->exec('SET SESSION time_zone = "+00:00"'); |
118 | 118 | //$this->dbs[$DBname]->exec('SET @@session.time_zone = "+00:00"'); |
119 | 119 | } else { |
120 | - $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
120 | + $this->dbs[$DBname] = new PDO("$globalDBSdriver:host=$globalDBShost;port=$globalDBSport;dbname=$globalDBSname;options='--client_encoding=utf8'", $globalDBSuser, $globalDBSpass); |
|
121 | 121 | //$this->dbs[$DBname]->setAttribute(PDO::MYSQL_ATTR_INIT_COMMAND, "SET NAMES 'utf8'"); |
122 | 122 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); |
123 | - $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE,PDO::CASE_LOWER); |
|
124 | - if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,200); |
|
125 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT,$globalDBTimeOut); |
|
126 | - if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,true); |
|
127 | - else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT,$globalDBPersistent); |
|
123 | + $this->dbs[$DBname]->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|
124 | + if (!isset($globalDBTimeOut)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, 200); |
|
125 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_TIMEOUT, $globalDBTimeOut); |
|
126 | + if (!isset($globalDBPersistent)) $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, true); |
|
127 | + else $this->dbs[$DBname]->setAttribute(PDO::ATTR_PERSISTENT, $globalDBPersistent); |
|
128 | 128 | $this->dbs[$DBname]->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); |
129 | 129 | $this->dbs[$DBname]->exec('SET timezone="UTC"'); |
130 | 130 | } |
131 | 131 | break; |
132 | - } catch(PDOException $e) { |
|
132 | + } catch (PDOException $e) { |
|
133 | 133 | $i++; |
134 | 134 | if (isset($globalDebug) && $globalDebug) echo 'Error connecting to DB: '.$globalDBSname.' - Error: '.$e->getMessage()."\n"; |
135 | 135 | //exit; |
@@ -154,10 +154,10 @@ discard block |
||
154 | 154 | try { |
155 | 155 | //$Connection = new Connection(); |
156 | 156 | $results = $this->db->query($query); |
157 | - } catch(PDOException $e) { |
|
157 | + } catch (PDOException $e) { |
|
158 | 158 | return false; |
159 | 159 | } |
160 | - if($results->rowCount()>0) { |
|
160 | + if ($results->rowCount() > 0) { |
|
161 | 161 | return true; |
162 | 162 | } |
163 | 163 | else return false; |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | return false; |
180 | 180 | } |
181 | 181 | |
182 | - } catch(PDOException $e) { |
|
183 | - if($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
182 | + } catch (PDOException $e) { |
|
183 | + if ($e->getCode() != 'HY000' || !stristr($e->getMessage(), 'server has gone away')) { |
|
184 | 184 | throw $e; |
185 | 185 | } |
186 | 186 | //echo 'error ! '.$e->getMessage(); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | /* |
193 | 193 | * Check if index exist |
194 | 194 | */ |
195 | - public function indexExists($table,$index) |
|
195 | + public function indexExists($table, $index) |
|
196 | 196 | { |
197 | 197 | global $globalDBdriver, $globalDBname; |
198 | 198 | if ($globalDBdriver == 'mysql') { |
@@ -203,11 +203,11 @@ discard block |
||
203 | 203 | try { |
204 | 204 | //$Connection = new Connection(); |
205 | 205 | $results = $this->db->query($query); |
206 | - } catch(PDOException $e) { |
|
206 | + } catch (PDOException $e) { |
|
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | $nb = $results->fetchAll(PDO::FETCH_ASSOC); |
210 | - if($nb[0]['nb'] > 0) { |
|
210 | + if ($nb[0]['nb'] > 0) { |
|
211 | 211 | return true; |
212 | 212 | } |
213 | 213 | else return false; |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | $query = "SELECT * FROM ".$table." LIMIT 0"; |
223 | 223 | try { |
224 | 224 | $results = $this->db->query($query); |
225 | - } catch(PDOException $e) { |
|
225 | + } catch (PDOException $e) { |
|
226 | 226 | return "error : ".$e->getMessage()."\n"; |
227 | 227 | } |
228 | 228 | $columns = array(); |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | return $columns; |
235 | 235 | } |
236 | 236 | |
237 | - public function getColumnType($table,$column) { |
|
237 | + public function getColumnType($table, $column) { |
|
238 | 238 | $select = $this->db->query('SELECT '.$column.' FROM '.$table); |
239 | 239 | $tomet = $select->getColumnMeta(0); |
240 | 240 | return $tomet['native_type']; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * Check if a column name exist in a table |
245 | 245 | * @return Boolean column exist or not |
246 | 246 | */ |
247 | - public function checkColumnName($table,$name) |
|
247 | + public function checkColumnName($table, $name) |
|
248 | 248 | { |
249 | 249 | global $globalDBdriver, $globalDBname; |
250 | 250 | if ($globalDBdriver == 'mysql') { |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | } |
255 | 255 | try { |
256 | 256 | $sth = $this->db()->prepare($query); |
257 | - $sth->execute(array(':database' => $globalDBname,':table' => $table,':name' => $name)); |
|
258 | - } catch(PDOException $e) { |
|
257 | + $sth->execute(array(':database' => $globalDBname, ':table' => $table, ':name' => $name)); |
|
258 | + } catch (PDOException $e) { |
|
259 | 259 | echo "error : ".$e->getMessage()."\n"; |
260 | 260 | } |
261 | 261 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -294,7 +294,7 @@ discard block |
||
294 | 294 | try { |
295 | 295 | $sth = $this->db->prepare($query); |
296 | 296 | $sth->execute(); |
297 | - } catch(PDOException $e) { |
|
297 | + } catch (PDOException $e) { |
|
298 | 298 | return "error : ".$e->getMessage()."\n"; |
299 | 299 | } |
300 | 300 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
@@ -18,82 +18,82 @@ discard block |
||
18 | 18 | public function parse($buffer) { |
19 | 19 | // Not yet finished, no CRC checks |
20 | 20 | $data = array(); |
21 | - $typehex = substr($buffer,0,1); |
|
22 | - if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1); |
|
23 | - elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13); |
|
24 | - else $hex = substr($buffer,1,-1); |
|
25 | - $bin = gmp_strval( gmp_init($hex,16), 2); |
|
21 | + $typehex = substr($buffer, 0, 1); |
|
22 | + if ($typehex == '*' || $typehex == ':') $hex = substr($buffer, 1, -1); |
|
23 | + elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer, 13, -13); |
|
24 | + else $hex = substr($buffer, 1, -1); |
|
25 | + $bin = gmp_strval(gmp_init($hex, 16), 2); |
|
26 | 26 | //if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) { |
27 | 27 | if (strlen($hex) == 28) { |
28 | - $df = intval(substr($bin,0,5),2); |
|
28 | + $df = intval(substr($bin, 0, 5), 2); |
|
29 | 29 | //$ca = intval(substr($bin,5,3),2); |
30 | 30 | // Only support DF17 for now |
31 | 31 | //if ($df == 17 || ($df == 18 && ($ca == 0 || $ca == 1 || $ca == 6))) { |
32 | - if (($df == 17 || $df == 18) && ($this->parityCheck($hex,$bin) || $typehex == '@')) { |
|
33 | - $icao = substr($hex,2,6); |
|
32 | + if (($df == 17 || $df == 18) && ($this->parityCheck($hex, $bin) || $typehex == '@')) { |
|
33 | + $icao = substr($hex, 2, 6); |
|
34 | 34 | $data['hex'] = $icao; |
35 | - $tc = intval(substr($bin,32,5),2); |
|
35 | + $tc = intval(substr($bin, 32, 5), 2); |
|
36 | 36 | if ($tc >= 1 && $tc <= 4) { |
37 | 37 | //callsign |
38 | - $csbin = substr($bin,40,56); |
|
38 | + $csbin = substr($bin, 40, 56); |
|
39 | 39 | $charset = str_split('#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######'); |
40 | 40 | $cs = ''; |
41 | - $cs .= $charset[intval(substr($csbin,0,6),2)]; |
|
42 | - $cs .= $charset[intval(substr($csbin,6,6),2)]; |
|
43 | - $cs .= $charset[intval(substr($csbin,12,6),2)]; |
|
44 | - $cs .= $charset[intval(substr($csbin,18,6),2)]; |
|
45 | - $cs .= $charset[intval(substr($csbin,24,6),2)]; |
|
46 | - $cs .= $charset[intval(substr($csbin,30,6),2)]; |
|
47 | - $cs .= $charset[intval(substr($csbin,36,6),2)]; |
|
48 | - $cs .= $charset[intval(substr($csbin,42,6),2)]; |
|
49 | - $cs = str_replace('_','',$cs); |
|
50 | - $cs = str_replace('#','',$cs); |
|
41 | + $cs .= $charset[intval(substr($csbin, 0, 6), 2)]; |
|
42 | + $cs .= $charset[intval(substr($csbin, 6, 6), 2)]; |
|
43 | + $cs .= $charset[intval(substr($csbin, 12, 6), 2)]; |
|
44 | + $cs .= $charset[intval(substr($csbin, 18, 6), 2)]; |
|
45 | + $cs .= $charset[intval(substr($csbin, 24, 6), 2)]; |
|
46 | + $cs .= $charset[intval(substr($csbin, 30, 6), 2)]; |
|
47 | + $cs .= $charset[intval(substr($csbin, 36, 6), 2)]; |
|
48 | + $cs .= $charset[intval(substr($csbin, 42, 6), 2)]; |
|
49 | + $cs = str_replace('_', '', $cs); |
|
50 | + $cs = str_replace('#', '', $cs); |
|
51 | 51 | $callsign = $cs; |
52 | 52 | $data['ident'] = $callsign; |
53 | 53 | } elseif ($tc >= 9 && $tc <= 18) { |
54 | 54 | // Check Q-bit |
55 | - $q = substr($bin,47,1); |
|
55 | + $q = substr($bin, 47, 1); |
|
56 | 56 | if ($q) { |
57 | - $n = intval(substr($bin,40,7).substr($bin,48,4),2); |
|
58 | - $alt = $n*25-1000; |
|
57 | + $n = intval(substr($bin, 40, 7).substr($bin, 48, 4), 2); |
|
58 | + $alt = $n*25 - 1000; |
|
59 | 59 | $data['altitude'] = $alt; |
60 | 60 | } |
61 | 61 | // Check odd/even flag |
62 | - $oe = substr($bin,53,1); |
|
62 | + $oe = substr($bin, 53, 1); |
|
63 | 63 | //if ($oe) => odd else even |
64 | 64 | // 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. |
65 | - $cprlat = intval(substr($bin,54,17),2)/131072.0; |
|
66 | - $cprlon = intval(substr($bin,71,17),2)/131072.0; |
|
67 | - if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
65 | + $cprlat = intval(substr($bin, 54, 17), 2)/131072.0; |
|
66 | + $cprlon = intval(substr($bin, 71, 17), 2)/131072.0; |
|
67 | + if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat, 'longitude' => $cprlon, 'created' => time()); |
|
68 | 68 | elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
69 | 69 | $cprlat_odd = $cprlat; |
70 | 70 | $cprlon_odd = $cprlon; |
71 | 71 | $cprlat_even = $this::$latlon[$icao]['latitude']; |
72 | 72 | $cprlon_even = $this::$latlon[$icao]['longitude']; |
73 | - $j = 59*$cprlat_even-60*$cprlat_odd+0.5; |
|
74 | - $lat_even = (360.0/60)*($j%60+$cprlat_even); |
|
75 | - $lat_odd = (360.0/59)*($j%59+$cprlat_odd); |
|
73 | + $j = 59*$cprlat_even - 60*$cprlat_odd + 0.5; |
|
74 | + $lat_even = (360.0/60)*($j%60 + $cprlat_even); |
|
75 | + $lat_odd = (360.0/59)*($j%59 + $cprlat_odd); |
|
76 | 76 | if ($lat_even >= 270) $lat_even = $lat_even - 360; |
77 | 77 | if ($lat_odd >= 270) $lat_odd = $lat_odd - 360; |
78 | 78 | // check latitude zone |
79 | 79 | if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) { |
80 | 80 | if ($this::$latlon[$icao]['created'] > time()) { |
81 | - $ni = $this->cprN($lat_even,0); |
|
82 | - $m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5); |
|
83 | - $lon = (360.0/$ni)*($m%$ni+$cprlon_even); |
|
81 | + $ni = $this->cprN($lat_even, 0); |
|
82 | + $m = floor($cprlon_even*($this->cprNL($lat_even) - 1) - $cprlon_odd*$this->cprNL($lat_even) + 0.5); |
|
83 | + $lon = (360.0/$ni)*($m%$ni + $cprlon_even); |
|
84 | 84 | $lat = $lat_even; |
85 | - if ($lon > 180) $lon = $lon -360; |
|
85 | + if ($lon > 180) $lon = $lon - 360; |
|
86 | 86 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
87 | 87 | //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; |
88 | 88 | $data['latitude'] = $lat; |
89 | 89 | $data['longitude'] = $lon; |
90 | 90 | } |
91 | 91 | } else { |
92 | - $ni = $this->cprN($lat_odd,1); |
|
93 | - $m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5); |
|
94 | - $lon = (360.0/$ni)*($m%$ni+$cprlon_odd); |
|
92 | + $ni = $this->cprN($lat_odd, 1); |
|
93 | + $m = floor($cprlon_even*($this->cprNL($lat_odd) - 1) - $cprlon_odd*$this->cprNL($lat_odd) + 0.5); |
|
94 | + $lon = (360.0/$ni)*($m%$ni + $cprlon_odd); |
|
95 | 95 | $lat = $lat_odd; |
96 | - if ($lon > 180) $lon = $lon -360; |
|
96 | + if ($lon > 180) $lon = $lon - 360; |
|
97 | 97 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
98 | 98 | //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; |
99 | 99 | $data['latitude'] = $lat; |
@@ -105,15 +105,15 @@ discard block |
||
105 | 105 | } |
106 | 106 | } elseif ($tc == 19) { |
107 | 107 | // speed & heading |
108 | - $v_ew_dir = intval(substr($bin,45,1)); |
|
109 | - $v_ew = intval(substr($bin,46,10),2); |
|
110 | - $v_ns_dir = intval(substr($bin,56,1)); |
|
111 | - $v_ns = intval(substr($bin,57,10),2); |
|
108 | + $v_ew_dir = intval(substr($bin, 45, 1)); |
|
109 | + $v_ew = intval(substr($bin, 46, 10), 2); |
|
110 | + $v_ns_dir = intval(substr($bin, 56, 1)); |
|
111 | + $v_ns = intval(substr($bin, 57, 10), 2); |
|
112 | 112 | if ($v_ew_dir) $v_ew = -1*$v_ew; |
113 | 113 | if ($v_ns_dir) $v_ns = -1*$v_ns; |
114 | - $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew); |
|
115 | - $heading = atan2($v_ew,$v_ns)*360.0/(2*pi()); |
|
116 | - if ($heading <0) $heading = $heading+360; |
|
114 | + $speed = sqrt($v_ns*$v_ns + $v_ew*$v_ew); |
|
115 | + $heading = atan2($v_ew, $v_ns)*360.0/(2*pi()); |
|
116 | + if ($heading < 0) $heading = $heading + 360; |
|
117 | 117 | $data['speed'] = $speed; |
118 | 118 | $data['heading'] = $heading; |
119 | 119 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * Lookup table to convert the latitude to index. |
129 | 129 | */ |
130 | 130 | private function cprNL($lat) { |
131 | - if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
131 | + if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
132 | 132 | if ($lat < 10.47047130) return 59; |
133 | 133 | if ($lat < 14.82817437) return 58; |
134 | 134 | if ($lat < 18.18626357) return 57; |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | return 1; |
191 | 191 | } |
192 | 192 | |
193 | - private function cprN($lat,$isodd) { |
|
193 | + private function cprN($lat, $isodd) { |
|
194 | 194 | $nl = $this->cprNL($lat) - $isodd; |
195 | 195 | if ($nl > 1) return $nl; |
196 | 196 | else return 1; |
@@ -214,9 +214,9 @@ discard block |
||
214 | 214 | 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000, 0x000000 |
215 | 215 | ); |
216 | 216 | $crc = 0; |
217 | - $checksum = intval(substr($msg,22,6),16); |
|
217 | + $checksum = intval(substr($msg, 22, 6), 16); |
|
218 | 218 | for ($j = 0; $j < strlen($bin); $j++) { |
219 | - if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0); |
|
219 | + if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j], 0); |
|
220 | 220 | } |
221 | 221 | if ($crc == $checksum) return true; |
222 | 222 | else { |
@@ -238,10 +238,10 @@ discard block |
||
238 | 238 | $msg['aircraftid'] = hexdec($data['address']); |
239 | 239 | $msg['hex'] = $data['address']; |
240 | 240 | $msg['flightid'] = hexdec($data['address']); |
241 | - $msg['date_gen'] = date('Y/m/d',$data['timestamp']); |
|
242 | - $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180'; |
|
243 | - $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
|
244 | - $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
|
241 | + $msg['date_gen'] = date('Y/m/d', $data['timestamp']); |
|
242 | + $msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180'; |
|
243 | + $msg['date_log'] = date('Y/m/d', $data['timestamp']); |
|
244 | + $msg['time_log'] = date('H:i:s', $data['timestamp']).'.180'; |
|
245 | 245 | $msg['callsign'] = $data['ident']; |
246 | 246 | $msg['altitude'] = ''; |
247 | 247 | $msg['speed'] = ''; |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $msg['emergency'] = ''; |
255 | 255 | $msg['SPI'] = ''; |
256 | 256 | $msg['ground'] = ''; |
257 | - $result[] = implode(',',$msg); |
|
257 | + $result[] = implode(',', $msg); |
|
258 | 258 | } |
259 | 259 | if (isset($data['latitude']) && $data['latitude'] != 0) { |
260 | 260 | $msg = array(); |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | $msg['aircraftid'] = hexdec($data['address']); |
265 | 265 | $msg['hex'] = $data['address']; |
266 | 266 | $msg['flightid'] = hexdec($data['address']); |
267 | - $msg['date_gen'] = date('Y/m/d',$data['timestamp']); |
|
268 | - $msg['time_gen'] = date('H:i:s',$data['timestamp']).'.180'; |
|
269 | - $msg['date_log'] = date('Y/m/d',$data['timestamp']); |
|
270 | - $msg['time_log'] = date('H:i:s',$data['timestamp']).'.180'; |
|
267 | + $msg['date_gen'] = date('Y/m/d', $data['timestamp']); |
|
268 | + $msg['time_gen'] = date('H:i:s', $data['timestamp']).'.180'; |
|
269 | + $msg['date_log'] = date('Y/m/d', $data['timestamp']); |
|
270 | + $msg['time_log'] = date('H:i:s', $data['timestamp']).'.180'; |
|
271 | 271 | $msg['callsign'] = ''; |
272 | 272 | if (isset($data['altitude'])) $msg['altitude'] = $data['altitude']; |
273 | 273 | else $msg['altitude'] = ''; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | $msg['SPI'] = 0; |
286 | 286 | if (isset($data['ground'])) $msg['ground'] = 1; |
287 | 287 | else $msg['ground'] = 0; |
288 | - $result[] = implode(',',$msg); |
|
288 | + $result[] = implode(',', $msg); |
|
289 | 289 | } |
290 | 290 | return $result; |
291 | 291 | } |