@@ -28,16 +28,25 @@ discard block |
||
28 | 28 | } elseif (is_numeric(substr(substr($ident, 0, 4), -1, 1))) { |
29 | 29 | //$airline_icao = substr($ident, 0, 3); |
30 | 30 | return $ident; |
31 | - } else return $ident; |
|
32 | - } else return $ident; |
|
31 | + } else { |
|
32 | + return $ident; |
|
33 | + } |
|
34 | + } else { |
|
35 | + return $ident; |
|
36 | + } |
|
33 | 37 | if ($airline_icao == 'AF') { |
34 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
35 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
38 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
39 | + $icao = $ident; |
|
40 | + } else { |
|
41 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
42 | + } |
|
36 | 43 | } else { |
37 | 44 | $identicao = $Spotter->getAllAirlineInfo($airline_icao); |
38 | 45 | if (isset($identicao[0])) { |
39 | 46 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
40 | - } else $icao = $ident; |
|
47 | + } else { |
|
48 | + $icao = $ident; |
|
49 | + } |
|
41 | 50 | } |
42 | 51 | return $icao; |
43 | 52 | } |
@@ -55,7 +64,9 @@ discard block |
||
55 | 64 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
56 | 65 | if (count($row) > 0) { |
57 | 66 | return $row['operator_correct']; |
58 | - } else return $ident; |
|
67 | + } else { |
|
68 | + return $ident; |
|
69 | + } |
|
59 | 70 | } |
60 | 71 | |
61 | 72 | public function addOperator($ident,$correct_ident,$source) { |
@@ -84,7 +95,9 @@ discard block |
||
84 | 95 | global $globalTranslationSources, $globalTranslationFetch; |
85 | 96 | //if (!isset($globalTranslationSources)) $globalTranslationSources = array('planefinder'); |
86 | 97 | $globalTranslationSources = array(); |
87 | - if (!isset($globalTranslationFetch)) $globalTranslationFetch = TRUE; |
|
98 | + if (!isset($globalTranslationFetch)) { |
|
99 | + $globalTranslationFetch = TRUE; |
|
100 | + } |
|
88 | 101 | //echo "Check Translation for ".$ident."..."; |
89 | 102 | $correct = $this->getOperator($ident); |
90 | 103 | if ($correct != '' && $correct != $ident) { |
@@ -54,7 +54,9 @@ discard block |
||
54 | 54 | $orderby_query = ' '.$search_orderby_array[$sort]['sql']; |
55 | 55 | } |
56 | 56 | |
57 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
57 | + if (!isset($globalLiveInterval)) { |
|
58 | + $globalLiveInterval = '200'; |
|
59 | + } |
|
58 | 60 | if ($globalDBdriver == 'mysql') { |
59 | 61 | //$query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL 30 SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate"; |
60 | 62 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query.$orderby_query; |
@@ -91,7 +93,9 @@ discard block |
||
91 | 93 | $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
92 | 94 | } |
93 | 95 | |
94 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
96 | + if (!isset($globalLiveInterval)) { |
|
97 | + $globalLiveInterval = '200'; |
|
98 | + } |
|
95 | 99 | if ($globalDBdriver == 'mysql') { |
96 | 100 | // $query = "SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate$orderby_query"; |
97 | 101 | // $query = 'SELECT spotter_live.ident, spotter_live.flightaware_id, spotter_live.aircraft_icao, spotter_live.departure_airport_icao as departure_airport, spotter_live.arrival_airport_icao as arrival_airport, spotter_live.latitude, spotter_live.longitude, spotter_live.altitude, spotter_live.heading, spotter_live.ground_speed, spotter_live.squawk, a.aircraft_shadow FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate INNER JOIN (SELECT * FROM aircraft) a on spotter_live.aircraft_icao = a.icao'; |
@@ -149,7 +153,9 @@ discard block |
||
149 | 153 | $filter_query = " AND format_source = 'aprs' AND source_name IN ('".implode("','",$filter['source_aprs'])."')"; |
150 | 154 | } |
151 | 155 | |
152 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
156 | + if (!isset($globalLiveInterval)) { |
|
157 | + $globalLiveInterval = '200'; |
|
158 | + } |
|
153 | 159 | if ($globalDBdriver == 'mysql') { |
154 | 160 | //$query = 'SELECT COUNT(*) as nb FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate'.$filter_query; |
155 | 161 | $query = 'SELECT COUNT(DISTINCT flightaware_id) as nb FROM spotter_live WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= date'.$filter_query; |
@@ -177,7 +183,9 @@ discard block |
||
177 | 183 | { |
178 | 184 | global $globalDBdriver, $globalLiveInterval; |
179 | 185 | $Spotter = new Spotter($this->db); |
180 | - if (!isset($globalLiveInterval)) $globalLiveInterval = '200'; |
|
186 | + if (!isset($globalLiveInterval)) { |
|
187 | + $globalLiveInterval = '200'; |
|
188 | + } |
|
181 | 189 | $filter_query = ''; |
182 | 190 | if (isset($filter['source'])) { |
183 | 191 | $filter_query = " AND format_source IN ('".implode(',',$filter['source'])."')"; |
@@ -197,7 +205,9 @@ discard block |
||
197 | 205 | $minlat = filter_var($coord[1],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
198 | 206 | $maxlong = filter_var($coord[2],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
199 | 207 | $maxlat = filter_var($coord[3],FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION); |
200 | - } else return array(); |
|
208 | + } else { |
|
209 | + return array(); |
|
210 | + } |
|
201 | 211 | if ($globalDBdriver == 'mysql') { |
202 | 212 | //$query = "SELECT spotter_output.* FROM spotter_output WHERE spotter_output.flightaware_id IN (SELECT spotter_live.flightaware_id FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL ".$globalLiveInterval." SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN ".$minlat." AND ".$maxlat." AND spotter_live.longitude BETWEEN ".$minlong." AND ".$maxlong.")"; |
203 | 213 | $query = 'SELECT spotter_live.* FROM spotter_live INNER JOIN (SELECT l.flightaware_id, max(l.date) as maxdate FROM spotter_live l WHERE DATE_SUB(UTC_TIMESTAMP(),INTERVAL '.$globalLiveInterval.' SECOND) <= l.date GROUP BY l.flightaware_id) s on spotter_live.flightaware_id = s.flightaware_id AND spotter_live.date = s.maxdate AND spotter_live.latitude BETWEEN '.$minlat.' AND '.$maxlat.' AND spotter_live.longitude BETWEEN '.$minlong.' AND '.$maxlong.' GROUP BY spotter_live.flightaware_id'.$filter_query; |
@@ -443,7 +453,9 @@ discard block |
||
443 | 453 | $i++; |
444 | 454 | $j++; |
445 | 455 | if ($j == 30) { |
446 | - if ($globalDebug) echo "."; |
|
456 | + if ($globalDebug) { |
|
457 | + echo "."; |
|
458 | + } |
|
447 | 459 | try { |
448 | 460 | |
449 | 461 | $sth = $this->db->prepare(substr($query_delete,0,-1).")"); |
@@ -795,7 +807,9 @@ discard block |
||
795 | 807 | { |
796 | 808 | return false; |
797 | 809 | } |
798 | - } else $altitude = 0; |
|
810 | + } else { |
|
811 | + $altitude = 0; |
|
812 | + } |
|
799 | 813 | |
800 | 814 | if ($heading != '') |
801 | 815 | { |
@@ -813,7 +827,9 @@ discard block |
||
813 | 827 | } |
814 | 828 | } |
815 | 829 | date_default_timezone_set('UTC'); |
816 | - if ($date == '') $date = date("Y-m-d H:i:s", time()); |
|
830 | + if ($date == '') { |
|
831 | + $date = date("Y-m-d H:i:s", time()); |
|
832 | + } |
|
817 | 833 | |
818 | 834 | /* |
819 | 835 | //getting the aircraft image |
@@ -894,10 +910,18 @@ discard block |
||
894 | 910 | $arrival_airport_country = ''; |
895 | 911 | } |
896 | 912 | |
897 | - if ($squawk == '' || $Common->isInteger($squawk) == false ) $squawk = NULL; |
|
898 | - if ($verticalrate == '' || $Common->isInteger($verticalrate) == false ) $verticalrate = NULL; |
|
899 | - if ($groundspeed == '' || $Common->isInteger($groundspeed) == false ) $groundspeed = 0; |
|
900 | - if ($heading == '' || $Common->isInteger($heading) == false ) $heading = 0; |
|
913 | + if ($squawk == '' || $Common->isInteger($squawk) == false ) { |
|
914 | + $squawk = NULL; |
|
915 | + } |
|
916 | + if ($verticalrate == '' || $Common->isInteger($verticalrate) == false ) { |
|
917 | + $verticalrate = NULL; |
|
918 | + } |
|
919 | + if ($groundspeed == '' || $Common->isInteger($groundspeed) == false ) { |
|
920 | + $groundspeed = 0; |
|
921 | + } |
|
922 | + if ($heading == '' || $Common->isInteger($heading) == false ) { |
|
923 | + $heading = 0; |
|
924 | + } |
|
901 | 925 | |
902 | 926 | $query = 'INSERT INTO spotter_live (flightaware_id, ident, registration, airline_name, airline_icao, airline_country, airline_type, aircraft_icao, aircraft_shadow, aircraft_name, aircraft_manufacturer, departure_airport_icao, departure_airport_name, departure_airport_city, departure_airport_country, arrival_airport_icao, arrival_airport_name, arrival_airport_city, arrival_airport_country, latitude, longitude, waypoints, altitude, heading, ground_speed, date, departure_airport_time, arrival_airport_time, squawk, route_stop, ModeS, pilot_id, pilot_name, verticalrate, ground, format_source, source_name, over_country) |
903 | 927 | VALUES (:flightaware_id,:ident,:registration,:airline_name,:airline_icao,:airline_country,:airline_type,:aircraft_icao,:aircraft_shadow,:aircraft_type,:aircraft_manufacturer,:departure_airport_icao,:departure_airport_name, :departure_airport_city, :departure_airport_country, :arrival_airport_icao, :arrival_airport_name, :arrival_airport_city, :arrival_airport_country, :latitude,:longitude,:waypoints,:altitude,:heading,:groundspeed,:date,:departure_airport_time,:arrival_airport_time,:squawk,:route_stop,:ModeS, :pilot_id, :pilot_name, :verticalrate, :ground, :format_source, :source_name, :over_country)'; |
@@ -912,9 +936,13 @@ discard block |
||
912 | 936 | return "error : ".$e->getMessage(); |
913 | 937 | } |
914 | 938 | if (isset($globalArchive) && $globalArchive && $putinarchive && !$noarchive) { |
915 | - if ($globalDebug) echo '(Add to SBS archive : '; |
|
939 | + if ($globalDebug) { |
|
940 | + echo '(Add to SBS archive : '; |
|
941 | + } |
|
916 | 942 | $result = $SpotterArchive->addSpotterArchiveData($flightaware_id, $ident, $registration, $airline_name, $airline_icao, $airline_country, $airline_type, $aircraft_icao, $aircraft_shadow, $aircraft_name, $aircraft_manufacturer, $departure_airport_icao, $departure_airport_name, $departure_airport_city, $departure_airport_country, $departure_airport_time,$arrival_airport_icao, $arrival_airport_name, $arrival_airport_city, $arrival_airport_country, $arrival_airport_time, $route_stop, $date,$latitude, $longitude, $waypoints, $altitude, $heading, $groundspeed, $squawk, $ModeS, $pilot_id, $pilot_name,$verticalrate,$format_source,$source_name, $over_country); |
917 | - if ($globalDebug) echo $result.')'; |
|
943 | + if ($globalDebug) { |
|
944 | + echo $result.')'; |
|
945 | + } |
|
918 | 946 | } |
919 | 947 | return "success"; |
920 | 948 |
@@ -27,8 +27,11 @@ discard block |
||
27 | 27 | } else { |
28 | 28 | curl_setopt($ch, CURLOPT_USERAGENT, $useragent); |
29 | 29 | } |
30 | - if ($timeout == '') curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
31 | - else curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
30 | + if ($timeout == '') { |
|
31 | + curl_setopt($ch, CURLOPT_TIMEOUT, 10); |
|
32 | + } else { |
|
33 | + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
|
34 | + } |
|
32 | 35 | curl_setopt($ch, CURLOPT_HEADERFUNCTION, array('Common',"curlResponseHeaderCallback")); |
33 | 36 | if ($type == 'post') { |
34 | 37 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); |
@@ -73,8 +76,9 @@ discard block |
||
73 | 76 | |
74 | 77 | private function curlResponseHeaderCallback($ch, $headerLine) { |
75 | 78 | global $cookies; |
76 | - if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) |
|
77 | - $cookies[] = $cookie; |
|
79 | + if (preg_match('/^Set-Cookie:\s*([^;]*)/mi', $headerLine, $cookie) == 1) { |
|
80 | + $cookies[] = $cookie; |
|
81 | + } |
|
78 | 82 | return strlen($headerLine); // Needed by curl |
79 | 83 | } |
80 | 84 | |
@@ -84,8 +88,12 @@ discard block |
||
84 | 88 | * @return Array array of the tables in HTML page |
85 | 89 | */ |
86 | 90 | public function table2array($data) { |
87 | - if (!is_string($data)) return array(); |
|
88 | - if ($data == '') return array(); |
|
91 | + if (!is_string($data)) { |
|
92 | + return array(); |
|
93 | + } |
|
94 | + if ($data == '') { |
|
95 | + return array(); |
|
96 | + } |
|
89 | 97 | $html = str_get_html($data); |
90 | 98 | $tabledata=array(); |
91 | 99 | foreach($html->find('tr') as $element) |
@@ -141,7 +149,9 @@ discard block |
||
141 | 149 | * @return Float Distance in $unit |
142 | 150 | */ |
143 | 151 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
144 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
152 | + if ($lat == $latc && $lon == $lonc) { |
|
153 | + return 0; |
|
154 | + } |
|
145 | 155 | $dist = rad2deg(acos(sin(deg2rad(floatval($lat)))*sin(deg2rad(floatval($latc)))+ cos(deg2rad(floatval($lat)))*cos(deg2rad(floatval($latc)))*cos(deg2rad(floatval($lon)-floatval($lonc)))))*60*1.1515; |
146 | 156 | if ($unit == "km") { |
147 | 157 | return round($dist * 1.609344); |
@@ -165,10 +175,16 @@ discard block |
||
165 | 175 | public function withinThreshold ($timeDifference, $distance) { |
166 | 176 | $x = abs($timeDifference); |
167 | 177 | $d = abs($distance); |
168 | - if ($x == 0 || $d == 0) return true; |
|
178 | + if ($x == 0 || $d == 0) { |
|
179 | + return true; |
|
180 | + } |
|
169 | 181 | // may be due to Internet jitter; distance is realistic |
170 | - if ($x < 0.7 && $d < 2000) return true; |
|
171 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
182 | + if ($x < 0.7 && $d < 2000) { |
|
183 | + return true; |
|
184 | + } else { |
|
185 | + return $d/$x < 1500*0.27778; |
|
186 | + } |
|
187 | + // 1500 km/h max |
|
172 | 188 | } |
173 | 189 | |
174 | 190 | |
@@ -228,7 +244,9 @@ discard block |
||
228 | 244 | public function hex2str($hex) { |
229 | 245 | $str = ''; |
230 | 246 | $hexln = strlen($hex); |
231 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
247 | + for($i=0;$i<$hexln;$i+=2) { |
|
248 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
249 | + } |
|
232 | 250 | return $str; |
233 | 251 | } |
234 | 252 | |
@@ -256,8 +274,11 @@ discard block |
||
256 | 274 | $b = $lat2 - $lat1; |
257 | 275 | $c = -($a*$lat1+$b*$lon1); |
258 | 276 | $d = $a*$lat3+$b*$lon3+$c; |
259 | - if ($d > -$approx && $d < $approx) return true; |
|
260 | - else return false; |
|
277 | + if ($d > -$approx && $d < $approx) { |
|
278 | + return true; |
|
279 | + } else { |
|
280 | + return false; |
|
281 | + } |
|
261 | 282 | } |
262 | 283 | |
263 | 284 | public function array_merge_noappend() { |
@@ -283,7 +304,9 @@ discard block |
||
283 | 304 | return $result; |
284 | 305 | } |
285 | 306 | $handle = @opendir('./locale'); |
286 | - if ($handle === false) return $result; |
|
307 | + if ($handle === false) { |
|
308 | + return $result; |
|
309 | + } |
|
287 | 310 | while (false !== ($file = readdir($handle))) { |
288 | 311 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
289 | 312 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -23,14 +23,19 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function ident2icao($ident) { |
25 | 25 | if (substr($ident,0,2) == 'AF') { |
26 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
27 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
26 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
27 | + $icao = $ident; |
|
28 | + } else { |
|
29 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
30 | + } |
|
28 | 31 | } else { |
29 | 32 | $Spotter = new Spotter($this->db); |
30 | 33 | $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
31 | 34 | if (isset($identicao[0])) { |
32 | 35 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
33 | - } else $icao = $ident; |
|
36 | + } else { |
|
37 | + $icao = $ident; |
|
38 | + } |
|
34 | 39 | } |
35 | 40 | return $icao; |
36 | 41 | } |
@@ -97,12 +102,18 @@ discard block |
||
97 | 102 | $Translation = new Translation($this->db); |
98 | 103 | |
99 | 104 | $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); |
100 | - 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); |
|
105 | + if ($n == 0) { |
|
106 | + $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); |
|
107 | + } |
|
101 | 108 | if ($n != 0) { |
102 | 109 | $registration = str_replace('.','',$registration); |
103 | 110 | $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
104 | - if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
105 | - } else $message = $data; |
|
111 | + if ($globalDebug) { |
|
112 | + echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
113 | + } |
|
114 | + } else { |
|
115 | + $message = $data; |
|
116 | + } |
|
106 | 117 | $icao = ''; |
107 | 118 | $airicao = ''; |
108 | 119 | $decode = array(); |
@@ -116,12 +127,21 @@ discard block |
||
116 | 127 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
117 | 128 | $latitude = $la / 10000.0; |
118 | 129 | $longitude = $ln / 10000.0; |
119 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
120 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
130 | + if ($lac == 'S') { |
|
131 | + $latitude = '-'.$latitude; |
|
132 | + } |
|
133 | + if ($lnc == 'W') { |
|
134 | + $longitude = '-'.$longitude; |
|
135 | + } |
|
121 | 136 | // Temp not always available |
122 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
123 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
124 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
137 | + if ($globalDebug) { |
|
138 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
139 | + } |
|
140 | + if ($temp == '') { |
|
141 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
142 | + } else { |
|
143 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
144 | + } |
|
125 | 145 | |
126 | 146 | //$icao = $Translation->checkTranslation($ident); |
127 | 147 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -131,25 +151,35 @@ discard block |
||
131 | 151 | if (!$found && ($label == '10')) { |
132 | 152 | $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
133 | 153 | if ($n == 4 && strlen($darr) == 4) { |
134 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
135 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
136 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
154 | + if ($dhour != '') { |
|
155 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
156 | + } |
|
157 | + if ($ahour != '') { |
|
158 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
159 | + } |
|
160 | + if ($globalDebug) { |
|
161 | + echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
162 | + } |
|
137 | 163 | //$icao = ACARS->ident2icao($ident); |
138 | 164 | //$icao = $Translation->checkTranslation($ident); |
139 | 165 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
140 | 166 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
141 | 167 | $found = true; |
142 | - } |
|
143 | - elseif ($n == 2 || $n == 4) { |
|
144 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
145 | - if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
168 | + } elseif ($n == 2 || $n == 4) { |
|
169 | + if ($dhour != '') { |
|
170 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
171 | + } |
|
172 | + if ($globalDebug) { |
|
173 | + echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
174 | + } |
|
146 | 175 | //$icao = ACARS->ident2icao($ident); |
147 | 176 | //$icao = $Translation->checkTranslation($ident); |
148 | 177 | $decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour); |
149 | 178 | $found = true; |
150 | - } |
|
151 | - elseif ($n == 1) { |
|
152 | - if ($globalDebug) echo 'airport arrival : '.$darr."\n"; |
|
179 | + } elseif ($n == 1) { |
|
180 | + if ($globalDebug) { |
|
181 | + echo 'airport arrival : '.$darr."\n"; |
|
182 | + } |
|
153 | 183 | //$icao = ACARS->ident2icao($ident); |
154 | 184 | //$icao = $Translation->checkTranslation($ident); |
155 | 185 | $decode = array('Arrival airport' => $darr); |
@@ -166,7 +196,9 @@ discard block |
||
166 | 196 | |
167 | 197 | $n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr); |
168 | 198 | if ($n == 4) { |
169 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
199 | + if ($globalDebug) { |
|
200 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
201 | + } |
|
170 | 202 | //$icao = ACARS->ident2icao($ident); |
171 | 203 | //$icao = $Translation->checkTranslation($ident); |
172 | 204 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -191,14 +223,23 @@ discard block |
||
191 | 223 | //$n = sscanf($message, "%*[0-9A-Z]/%*3d/%4s/%*c\nSCH/%6[0-9A-Z ]/%4c/%4c/%5s/%4d\n%*3c/%4d/%4c/%[0-9A-Z ]/", $airicao,$aident,$dair, $darr, $ddate, $dhour,$ahour, $aair, $apiste); |
192 | 224 | $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); |
193 | 225 | if ($n > 8) { |
194 | - 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"; |
|
195 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
196 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
226 | + if ($globalDebug) { |
|
227 | + 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"; |
|
228 | + } |
|
229 | + if ($dhour != '') { |
|
230 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
231 | + } |
|
232 | + if ($ahour != '') { |
|
233 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
234 | + } |
|
197 | 235 | $icao = trim($aident); |
198 | 236 | |
199 | 237 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
200 | - if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
201 | - else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
238 | + if ($ahour == '') { |
|
239 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
240 | + } else { |
|
241 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
242 | + } |
|
202 | 243 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
203 | 244 | $decode['icao'] = $icao; |
204 | 245 | $found = true; |
@@ -215,9 +256,15 @@ discard block |
||
215 | 256 | $lns = $lns.'.'.$lns; |
216 | 257 | $latitude = $las / 1000.0; |
217 | 258 | $longitude = $lns / 1000.0; |
218 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
219 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
220 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
259 | + if ($lac == 'S') { |
|
260 | + $latitude = '-'.$latitude; |
|
261 | + } |
|
262 | + if ($lnc == 'W') { |
|
263 | + $longitude = '-'.$longitude; |
|
264 | + } |
|
265 | + if ($globalDebug) { |
|
266 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
267 | + } |
|
221 | 268 | $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
222 | 269 | $found = true; |
223 | 270 | } |
@@ -233,7 +280,9 @@ discard block |
||
233 | 280 | */ |
234 | 281 | $n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr); |
235 | 282 | if ($n == 4) { |
236 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
283 | + if ($globalDebug) { |
|
284 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
285 | + } |
|
237 | 286 | //$icao = $Translation->checkTranslation($ident); |
238 | 287 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
239 | 288 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -244,7 +293,9 @@ discard block |
||
244 | 293 | // example message : "Reg. : TS-ION - Ident : TU0634 - Label : 1L - Message : 000442152001337,DTTJ,LFPO,1609" |
245 | 294 | $n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr); |
246 | 295 | if ($n == 4) { |
247 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
296 | + if ($globalDebug) { |
|
297 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
298 | + } |
|
248 | 299 | //$icao = $Translation->checkTranslation($ident); |
249 | 300 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
250 | 301 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -255,7 +306,9 @@ discard block |
||
255 | 306 | // example message : "Reg. : OO-TAH - Ident : 3V042J - Label : 5U - Message : 002AF EBLG EBBR N4621.5E 524.2195" |
256 | 307 | $n = sscanf($message, "002AF %4c %4c ", $dair, $darr); |
257 | 308 | if ($n == 2) { |
258 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
309 | + if ($globalDebug) { |
|
310 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
311 | + } |
|
259 | 312 | //$icao = $Translation->checkTranslation($ident); |
260 | 313 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
261 | 314 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -267,7 +320,9 @@ discard block |
||
267 | 320 | // example message : 'Reg. : F-GHQJ - Ident : AF6241 - Label : H1 - Message : #DFBA01/CCF-GHQJ,FEB27,205556,LFMN,LFPO,0241/C106,17404,5000,42,0010,0,0100,42,X/CEN270,36012,257,778,6106,299,B5B7G8/EC731134,42387,01439,41194,12/EE731212,44932,11870,43555,12/N10875,0875,0910,6330,1205,-----' |
268 | 321 | $n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
269 | 322 | if ($n == 6) { |
270 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
323 | + if ($globalDebug) { |
|
324 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
325 | + } |
|
271 | 326 | //$icao = $Translation->checkTranslation($ident); |
272 | 327 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
273 | 328 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -278,7 +333,9 @@ discard block |
||
278 | 333 | // example message : 'Reg. : F-GUGP - Ident : AF1842 - Label : H1 - Message : #DFBA01/A31801,1,1/CCF-GUGP,MAR11,093856,LFPG,LSGG,1842/C106,55832,5000,37,0010,0,0100,37,X/CEN282,31018,277,750,5515,255,C11036/EC577870,02282,07070,01987,73,14/EE577871,02282,06947,01987,73/N10790,0790,0903,5' |
279 | 334 | $n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
280 | 335 | if ($n == 7) { |
281 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
336 | + if ($globalDebug) { |
|
337 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
338 | + } |
|
282 | 339 | //$icao = $Translation->checkTranslation($ident); |
283 | 340 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
284 | 341 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -298,8 +355,12 @@ discard block |
||
298 | 355 | $decode['icao'] = $icao; |
299 | 356 | $latitude = $las / 100.0; |
300 | 357 | $longitude = $lns / 100.0; |
301 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
302 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
358 | + if ($lac == 'S') { |
|
359 | + $latitude = '-'.$latitude; |
|
360 | + } |
|
361 | + if ($lnc == 'W') { |
|
362 | + $longitude = '-'.$longitude; |
|
363 | + } |
|
303 | 364 | |
304 | 365 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
305 | 366 | $found = true; |
@@ -313,8 +374,12 @@ discard block |
||
313 | 374 | if ($n == 4) { |
314 | 375 | $latitude = $las; |
315 | 376 | $longitude = $lns; |
316 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
317 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
377 | + if ($lac == 'S') { |
|
378 | + $latitude = '-'.$latitude; |
|
379 | + } |
|
380 | + if ($lnc == 'W') { |
|
381 | + $longitude = '-'.$longitude; |
|
382 | + } |
|
318 | 383 | |
319 | 384 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
320 | 385 | $found = true; |
@@ -328,7 +393,9 @@ discard block |
||
328 | 393 | */ |
329 | 394 | $n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr); |
330 | 395 | if ($n == 5) { |
331 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
396 | + if ($globalDebug) { |
|
397 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
398 | + } |
|
332 | 399 | //$icao = $Translation->checkTranslation($ident); |
333 | 400 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
334 | 401 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -346,7 +413,9 @@ discard block |
||
346 | 413 | // $n = sscanf($message, "%*[0-9A-Z],,\n%*[0-9A-Z],%*[0-9A-Z],%4s,%4s,.%*6s,\n%*4[A-Z],\n%[0-9A-Z],", $dair, $darr, $aident); |
347 | 414 | $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); |
348 | 415 | if ($n == 8) { |
349 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
416 | + if ($globalDebug) { |
|
417 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
418 | + } |
|
350 | 419 | $icao = trim($aident); |
351 | 420 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
352 | 421 | $decode['icao'] = $icao; |
@@ -361,7 +430,9 @@ discard block |
||
361 | 430 | */ |
362 | 431 | $n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr); |
363 | 432 | if ($n == 5) { |
364 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
433 | + if ($globalDebug) { |
|
434 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
435 | + } |
|
365 | 436 | //$icao = $Translation->checkTranslation($ident); |
366 | 437 | |
367 | 438 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -375,7 +446,9 @@ discard block |
||
375 | 446 | */ |
376 | 447 | $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
377 | 448 | if ($n == 3) { |
378 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
449 | + if ($globalDebug) { |
|
450 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
451 | + } |
|
379 | 452 | //$icao = $Translation->checkTranslation($ident); |
380 | 453 | |
381 | 454 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -389,7 +462,9 @@ discard block |
||
389 | 462 | */ |
390 | 463 | $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
391 | 464 | if ($n == 3) { |
392 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
465 | + if ($globalDebug) { |
|
466 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
467 | + } |
|
393 | 468 | //$icao = $Translation->checkTranslation($ident); |
394 | 469 | |
395 | 470 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -400,7 +475,9 @@ discard block |
||
400 | 475 | if (!$found) { |
401 | 476 | $n = sscanf($message,'MET01%4c',$airport); |
402 | 477 | if ($n == 1) { |
403 | - if ($globalDebug) echo 'airport name : '.$airport; |
|
478 | + if ($globalDebug) { |
|
479 | + echo 'airport name : '.$airport; |
|
480 | + } |
|
404 | 481 | $decode = array('Airport/Waypoint name' => $airport); |
405 | 482 | $found = true; |
406 | 483 | } |
@@ -409,184 +486,126 @@ discard block |
||
409 | 486 | if ($label == 'H1') { |
410 | 487 | if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
411 | 488 | $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
412 | - } |
|
413 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
489 | + } elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
414 | 490 | $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
415 | - } |
|
416 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
491 | + } elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
417 | 492 | $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
418 | - } |
|
419 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
493 | + } elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
420 | 494 | $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
421 | - } |
|
422 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
495 | + } elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
423 | 496 | $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
424 | - } |
|
425 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
497 | + } elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
426 | 498 | $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
427 | - } |
|
428 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
499 | + } elseif (preg_match(':^#M1AAEP:',$message)) { |
|
429 | 500 | $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
430 | - } |
|
431 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
501 | + } elseif (preg_match(':^#M2APWD:',$message)) { |
|
432 | 502 | $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
433 | - } |
|
434 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
503 | + } elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
435 | 504 | $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
436 | - } |
|
437 | - elseif (preg_match(':^#CF:',$message)) { |
|
505 | + } elseif (preg_match(':^#CF:',$message)) { |
|
438 | 506 | $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
439 | - } |
|
440 | - elseif (preg_match(':^#DF:',$message)) { |
|
507 | + } elseif (preg_match(':^#DF:',$message)) { |
|
441 | 508 | $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
442 | - } |
|
443 | - elseif (preg_match(':^#EC:',$message)) { |
|
509 | + } elseif (preg_match(':^#EC:',$message)) { |
|
444 | 510 | $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
445 | - } |
|
446 | - elseif (preg_match(':^#EI:',$message)) { |
|
511 | + } elseif (preg_match(':^#EI:',$message)) { |
|
447 | 512 | $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
448 | - } |
|
449 | - elseif (preg_match(':^#H1:',$message)) { |
|
513 | + } elseif (preg_match(':^#H1:',$message)) { |
|
450 | 514 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
451 | - } |
|
452 | - elseif (preg_match(':^#H2:',$message)) { |
|
515 | + } elseif (preg_match(':^#H2:',$message)) { |
|
453 | 516 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
454 | - } |
|
455 | - elseif (preg_match(':^#HD:',$message)) { |
|
517 | + } elseif (preg_match(':^#HD:',$message)) { |
|
456 | 518 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
457 | - } |
|
458 | - elseif (preg_match(':^#M1:',$message)) { |
|
519 | + } elseif (preg_match(':^#M1:',$message)) { |
|
459 | 520 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
460 | - } |
|
461 | - elseif (preg_match(':^#M2:',$message)) { |
|
521 | + } elseif (preg_match(':^#M2:',$message)) { |
|
462 | 522 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
463 | - } |
|
464 | - elseif (preg_match(':^#M3:',$message)) { |
|
523 | + } elseif (preg_match(':^#M3:',$message)) { |
|
465 | 524 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
466 | - } |
|
467 | - elseif (preg_match(':^#MD:',$message)) { |
|
525 | + } elseif (preg_match(':^#MD:',$message)) { |
|
468 | 526 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
469 | - } |
|
470 | - elseif (preg_match(':^#PS:',$message)) { |
|
527 | + } elseif (preg_match(':^#PS:',$message)) { |
|
471 | 528 | $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
472 | - } |
|
473 | - elseif (preg_match(':^#S1:',$message)) { |
|
529 | + } elseif (preg_match(':^#S1:',$message)) { |
|
474 | 530 | $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
475 | - } |
|
476 | - elseif (preg_match(':^#S2:',$message)) { |
|
531 | + } elseif (preg_match(':^#S2:',$message)) { |
|
477 | 532 | $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
478 | - } |
|
479 | - elseif (preg_match(':^#SD:',$message)) { |
|
533 | + } elseif (preg_match(':^#SD:',$message)) { |
|
480 | 534 | $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
481 | - } |
|
482 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
535 | + } elseif (preg_match(':^#T[0-8]:',$message)) { |
|
483 | 536 | $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
484 | - } |
|
485 | - elseif (preg_match(':^#WO:',$message)) { |
|
537 | + } elseif (preg_match(':^#WO:',$message)) { |
|
486 | 538 | $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
487 | - } |
|
488 | - elseif (preg_match(':^#A1:',$message)) { |
|
539 | + } elseif (preg_match(':^#A1:',$message)) { |
|
489 | 540 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
490 | - } |
|
491 | - elseif (preg_match(':^#A3:',$message)) { |
|
541 | + } elseif (preg_match(':^#A3:',$message)) { |
|
492 | 542 | $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
493 | - } |
|
494 | - elseif (preg_match(':^#A4:',$message)) { |
|
543 | + } elseif (preg_match(':^#A4:',$message)) { |
|
495 | 544 | $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
496 | - } |
|
497 | - elseif (preg_match(':^#A6:',$message)) { |
|
545 | + } elseif (preg_match(':^#A6:',$message)) { |
|
498 | 546 | $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
499 | - } |
|
500 | - elseif (preg_match(':^#A8:',$message)) { |
|
547 | + } elseif (preg_match(':^#A8:',$message)) { |
|
501 | 548 | $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
502 | - } |
|
503 | - elseif (preg_match(':^#A9:',$message)) { |
|
549 | + } elseif (preg_match(':^#A9:',$message)) { |
|
504 | 550 | $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
505 | - } |
|
506 | - elseif (preg_match(':^#A0:',$message)) { |
|
551 | + } elseif (preg_match(':^#A0:',$message)) { |
|
507 | 552 | $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
508 | - } |
|
509 | - elseif (preg_match(':^#AA:',$message)) { |
|
553 | + } elseif (preg_match(':^#AA:',$message)) { |
|
510 | 554 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
511 | - } |
|
512 | - elseif (preg_match(':^#AB:',$message)) { |
|
555 | + } elseif (preg_match(':^#AB:',$message)) { |
|
513 | 556 | $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
514 | - } |
|
515 | - elseif (preg_match(':^#AC:',$message)) { |
|
557 | + } elseif (preg_match(':^#AC:',$message)) { |
|
516 | 558 | $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
517 | - } |
|
518 | - elseif (preg_match(':^#AD:',$message)) { |
|
559 | + } elseif (preg_match(':^#AD:',$message)) { |
|
519 | 560 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
520 | - } |
|
521 | - elseif (preg_match(':^#AF:',$message)) { |
|
561 | + } elseif (preg_match(':^#AF:',$message)) { |
|
522 | 562 | $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
523 | - } |
|
524 | - elseif (preg_match(':^#B1:',$message)) { |
|
563 | + } elseif (preg_match(':^#B1:',$message)) { |
|
525 | 564 | $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
526 | - } |
|
527 | - elseif (preg_match(':^#B2:',$message)) { |
|
565 | + } elseif (preg_match(':^#B2:',$message)) { |
|
528 | 566 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
529 | - } |
|
530 | - elseif (preg_match(':^#B3:',$message)) { |
|
567 | + } elseif (preg_match(':^#B3:',$message)) { |
|
531 | 568 | $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
532 | - } |
|
533 | - elseif (preg_match(':^#B4:',$message)) { |
|
569 | + } elseif (preg_match(':^#B4:',$message)) { |
|
534 | 570 | $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
535 | - } |
|
536 | - elseif (preg_match(':^#B6:',$message)) { |
|
571 | + } elseif (preg_match(':^#B6:',$message)) { |
|
537 | 572 | $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
538 | - } |
|
539 | - elseif (preg_match(':^#B8:',$message)) { |
|
573 | + } elseif (preg_match(':^#B8:',$message)) { |
|
540 | 574 | $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
541 | - } |
|
542 | - elseif (preg_match(':^#B9:',$message)) { |
|
575 | + } elseif (preg_match(':^#B9:',$message)) { |
|
543 | 576 | $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
544 | - } |
|
545 | - elseif (preg_match(':^#B0:',$message)) { |
|
577 | + } elseif (preg_match(':^#B0:',$message)) { |
|
546 | 578 | $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
547 | - } |
|
548 | - elseif (preg_match(':^#BA:',$message)) { |
|
579 | + } elseif (preg_match(':^#BA:',$message)) { |
|
549 | 580 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
550 | - } |
|
551 | - elseif (preg_match(':^#BB:',$message)) { |
|
581 | + } elseif (preg_match(':^#BB:',$message)) { |
|
552 | 582 | $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
553 | - } |
|
554 | - elseif (preg_match(':^#BC:',$message)) { |
|
583 | + } elseif (preg_match(':^#BC:',$message)) { |
|
555 | 584 | $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
556 | - } |
|
557 | - elseif (preg_match(':^#BD:',$message)) { |
|
585 | + } elseif (preg_match(':^#BD:',$message)) { |
|
558 | 586 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
559 | - } |
|
560 | - elseif (preg_match(':^#BE:',$message)) { |
|
587 | + } elseif (preg_match(':^#BE:',$message)) { |
|
561 | 588 | $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
562 | - } |
|
563 | - elseif (preg_match(':^#BF:',$message)) { |
|
589 | + } elseif (preg_match(':^#BF:',$message)) { |
|
564 | 590 | $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
565 | - } |
|
566 | - elseif (preg_match(':^#H3:',$message)) { |
|
591 | + } elseif (preg_match(':^#H3:',$message)) { |
|
567 | 592 | $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
568 | 593 | } |
569 | 594 | } |
570 | 595 | if ($label == '10') { |
571 | 596 | if (preg_match(':^DTO01:',$message)) { |
572 | 597 | $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
573 | - } |
|
574 | - elseif (preg_match(':^AIS01:',$message)) { |
|
598 | + } elseif (preg_match(':^AIS01:',$message)) { |
|
575 | 599 | $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
576 | - } |
|
577 | - elseif (preg_match(':^FTX01:',$message)) { |
|
600 | + } elseif (preg_match(':^FTX01:',$message)) { |
|
578 | 601 | $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
579 | - } |
|
580 | - elseif (preg_match(':^FPL01:',$message)) { |
|
602 | + } elseif (preg_match(':^FPL01:',$message)) { |
|
581 | 603 | $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
582 | - } |
|
583 | - elseif (preg_match(':^WAB01:',$message)) { |
|
604 | + } elseif (preg_match(':^WAB01:',$message)) { |
|
584 | 605 | $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
585 | - } |
|
586 | - elseif (preg_match(':^MET01:',$message)) { |
|
606 | + } elseif (preg_match(':^MET01:',$message)) { |
|
587 | 607 | $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
588 | - } |
|
589 | - elseif (preg_match(':^WAB02:',$message)) { |
|
608 | + } elseif (preg_match(':^WAB02:',$message)) { |
|
590 | 609 | $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
591 | 610 | } |
592 | 611 | } |
@@ -601,38 +620,28 @@ discard block |
||
601 | 620 | $vsta = array('Version' => $version); |
602 | 621 | if ($state == 'E') { |
603 | 622 | $vsta = array_merge($vsta,array('Link state' => 'Established')); |
604 | - } |
|
605 | - elseif ($state == 'L') { |
|
623 | + } elseif ($state == 'L') { |
|
606 | 624 | $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
607 | - } |
|
608 | - else { |
|
625 | + } else { |
|
609 | 626 | $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
610 | 627 | } |
611 | 628 | if ($type == 'V') { |
612 | 629 | $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
613 | - } |
|
614 | - elseif ($type == 'S') { |
|
630 | + } elseif ($type == 'S') { |
|
615 | 631 | $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
616 | - } |
|
617 | - elseif ($type == 'H') { |
|
632 | + } elseif ($type == 'H') { |
|
618 | 633 | $vsta = array_merge($vsta,array('Link type' => 'HF')); |
619 | - } |
|
620 | - elseif ($type == 'G') { |
|
634 | + } elseif ($type == 'G') { |
|
621 | 635 | $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
622 | - } |
|
623 | - elseif ($type == 'C') { |
|
636 | + } elseif ($type == 'C') { |
|
624 | 637 | $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
625 | - } |
|
626 | - elseif ($type == '2') { |
|
638 | + } elseif ($type == '2') { |
|
627 | 639 | $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
628 | - } |
|
629 | - elseif ($type == 'X') { |
|
640 | + } elseif ($type == 'X') { |
|
630 | 641 | $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
631 | - } |
|
632 | - elseif ($type == 'I') { |
|
642 | + } elseif ($type == 'I') { |
|
633 | 643 | $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
634 | - } |
|
635 | - else { |
|
644 | + } else { |
|
636 | 645 | $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
637 | 646 | } |
638 | 647 | $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
@@ -641,7 +650,9 @@ discard block |
||
641 | 650 | } |
642 | 651 | |
643 | 652 | $title = $this->getTitlefromLabel($label); |
644 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
653 | + if ($title != '') { |
|
654 | + $decode = array_merge(array('Message title' => $title),$decode); |
|
655 | + } |
|
645 | 656 | |
646 | 657 | /* |
647 | 658 | // Business jets always use GS0001 |
@@ -682,14 +693,26 @@ discard block |
||
682 | 693 | $decode = $message['decode']; |
683 | 694 | $registration = $message['registration']; |
684 | 695 | |
685 | - if (isset($decode['latitude'])) $latitude = $latitude; |
|
686 | - else $latitude = ''; |
|
687 | - if (isset($decode['longitude'])) $longitude = $longitude; |
|
688 | - else $longitude = ''; |
|
689 | - if (isset($decode['airicao'])) $airicao = $decode['airicao']; |
|
690 | - else $airicao = ''; |
|
691 | - if (isset($decode['icao'])) $icao = $decode['icao']; |
|
692 | - else $icao = $Translation->checkTranslation($ident); |
|
696 | + if (isset($decode['latitude'])) { |
|
697 | + $latitude = $latitude; |
|
698 | + } else { |
|
699 | + $latitude = ''; |
|
700 | + } |
|
701 | + if (isset($decode['longitude'])) { |
|
702 | + $longitude = $longitude; |
|
703 | + } else { |
|
704 | + $longitude = ''; |
|
705 | + } |
|
706 | + if (isset($decode['airicao'])) { |
|
707 | + $airicao = $decode['airicao']; |
|
708 | + } else { |
|
709 | + $airicao = ''; |
|
710 | + } |
|
711 | + if (isset($decode['icao'])) { |
|
712 | + $icao = $decode['icao']; |
|
713 | + } else { |
|
714 | + $icao = $Translation->checkTranslation($ident); |
|
715 | + } |
|
693 | 716 | |
694 | 717 | $image_array = $Image->getSpotterImage($registration); |
695 | 718 | if (!isset($image_array[0]['registration'])) { |
@@ -697,11 +720,18 @@ discard block |
||
697 | 720 | } |
698 | 721 | |
699 | 722 | // Business jets always use GS0001 |
700 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
701 | - if ($globalDebug && isset($info) && $info != '') echo $info; |
|
723 | + if ($ident != 'GS0001') { |
|
724 | + $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
725 | + } |
|
726 | + if ($globalDebug && isset($info) && $info != '') { |
|
727 | + echo $info; |
|
728 | + } |
|
702 | 729 | |
703 | - if (count($decode) > 0) $decode_json = json_encode($decode); |
|
704 | - else $decode_json = ''; |
|
730 | + if (count($decode) > 0) { |
|
731 | + $decode_json = json_encode($decode); |
|
732 | + } else { |
|
733 | + $decode_json = ''; |
|
734 | + } |
|
705 | 735 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
706 | 736 | $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
707 | 737 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
@@ -709,8 +739,12 @@ discard block |
||
709 | 739 | } |
710 | 740 | |
711 | 741 | $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
712 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
713 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
742 | + if (!isset($globalACARSArchive)) { |
|
743 | + $globalACARSArchive = array('10','80','81','82','3F'); |
|
744 | + } |
|
745 | + if ($result && in_array($label,$globalACARSArchive)) { |
|
746 | + $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
747 | + } |
|
714 | 748 | |
715 | 749 | if ($globalDebug && count($decode) > 0) { |
716 | 750 | echo "Human readable data : ".implode(' - ',$decode)."\n"; |
@@ -735,7 +769,9 @@ discard block |
||
735 | 769 | $Connection = new Connection($this->db); |
736 | 770 | $this->db = $Connection->db; |
737 | 771 | |
738 | - if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
|
772 | + if ($globalDebug) { |
|
773 | + echo "Test if not already in Live ACARS table..."; |
|
774 | + } |
|
739 | 775 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
740 | 776 | $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
741 | 777 | try { |
@@ -745,7 +781,9 @@ discard block |
||
745 | 781 | return "error : ".$e->getMessage(); |
746 | 782 | } |
747 | 783 | if ($stht->fetchColumn() == 0) { |
748 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
784 | + if ($globalDebug) { |
|
785 | + echo "Add Live ACARS data..."; |
|
786 | + } |
|
749 | 787 | $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)"; |
750 | 788 | $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")); |
751 | 789 | try { |
@@ -756,10 +794,14 @@ discard block |
||
756 | 794 | return "error : ".$e->getMessage(); |
757 | 795 | } |
758 | 796 | } else { |
759 | - if ($globalDebug) echo "Data already in DB...\n"; |
|
797 | + if ($globalDebug) { |
|
798 | + echo "Data already in DB...\n"; |
|
799 | + } |
|
760 | 800 | return false; |
761 | 801 | } |
762 | - if ($globalDebug) echo "Done\n"; |
|
802 | + if ($globalDebug) { |
|
803 | + echo "Done\n"; |
|
804 | + } |
|
763 | 805 | return true; |
764 | 806 | } |
765 | 807 | } |
@@ -791,7 +833,9 @@ discard block |
||
791 | 833 | } |
792 | 834 | if ($stht->fetchColumn() == 0) { |
793 | 835 | */ |
794 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
836 | + if ($globalDebug) { |
|
837 | + echo "Add Live ACARS data..."; |
|
838 | + } |
|
795 | 839 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
796 | 840 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
797 | 841 | try { |
@@ -802,7 +846,9 @@ discard block |
||
802 | 846 | return "error : ".$e->getMessage(); |
803 | 847 | } |
804 | 848 | // } |
805 | - if ($globalDebug) echo "Done\n"; |
|
849 | + if ($globalDebug) { |
|
850 | + echo "Done\n"; |
|
851 | + } |
|
806 | 852 | } |
807 | 853 | } |
808 | 854 | |
@@ -825,8 +871,11 @@ discard block |
||
825 | 871 | return "error : ".$e->getMessage(); |
826 | 872 | } |
827 | 873 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
828 | - if (count($row) > 0) return $row[0]['title']; |
|
829 | - else return ''; |
|
874 | + if (count($row) > 0) { |
|
875 | + return $row[0]['title']; |
|
876 | + } else { |
|
877 | + return ''; |
|
878 | + } |
|
830 | 879 | } |
831 | 880 | |
832 | 881 | /** |
@@ -845,8 +894,11 @@ discard block |
||
845 | 894 | return "error : ".$e->getMessage(); |
846 | 895 | } |
847 | 896 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
848 | - if (count($row) > 0) return $row; |
|
849 | - else return ''; |
|
897 | + if (count($row) > 0) { |
|
898 | + return $row; |
|
899 | + } else { |
|
900 | + return ''; |
|
901 | + } |
|
850 | 902 | } |
851 | 903 | |
852 | 904 | /** |
@@ -866,8 +918,11 @@ discard block |
||
866 | 918 | return "error : ".$e->getMessage(); |
867 | 919 | } |
868 | 920 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
869 | - if (count($row) > 0) return $row[0]; |
|
870 | - else return array(); |
|
921 | + if (count($row) > 0) { |
|
922 | + return $row[0]; |
|
923 | + } else { |
|
924 | + return array(); |
|
925 | + } |
|
871 | 926 | } |
872 | 927 | |
873 | 928 | /** |
@@ -919,21 +974,37 @@ discard block |
||
919 | 974 | if ($row['registration'] != '') { |
920 | 975 | $row['registration'] = str_replace('.','',$row['registration']); |
921 | 976 | $image_array = $Image->getSpotterImage($row['registration']); |
922 | - 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'])); |
|
923 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
924 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
977 | + if (count($image_array) > 0) { |
|
978 | + $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'])); |
|
979 | + } else { |
|
980 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
981 | + } |
|
982 | + } else { |
|
983 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
984 | + } |
|
925 | 985 | $icao = ''; |
926 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
927 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
986 | + if ($row['registration'] == '') { |
|
987 | + $row['registration'] = 'NA'; |
|
988 | + } |
|
989 | + if ($row['ident'] == '') { |
|
990 | + $row['ident'] = 'NA'; |
|
991 | + } |
|
928 | 992 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
929 | 993 | if (isset($identicao[0])) { |
930 | 994 | if (substr($row['ident'],0,2) == 'AF') { |
931 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
932 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
933 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
995 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
996 | + $icao = $row['ident']; |
|
997 | + } else { |
|
998 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
999 | + } |
|
1000 | + } else { |
|
1001 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1002 | + } |
|
934 | 1003 | |
935 | 1004 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
936 | - } else $icao = $row['ident']; |
|
1005 | + } else { |
|
1006 | + $icao = $row['ident']; |
|
1007 | + } |
|
937 | 1008 | $icao = $Translation->checkTranslation($icao,false); |
938 | 1009 | |
939 | 1010 | $decode = json_decode($row['decode'],true); |
@@ -959,7 +1030,9 @@ discard block |
||
959 | 1030 | $found = true; |
960 | 1031 | } |
961 | 1032 | } |
962 | - if ($found) $row['decode'] = json_encode($decode); |
|
1033 | + if ($found) { |
|
1034 | + $row['decode'] = json_encode($decode); |
|
1035 | + } |
|
963 | 1036 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
964 | 1037 | $result[] = $data; |
965 | 1038 | $i++; |
@@ -967,8 +1040,9 @@ discard block |
||
967 | 1040 | if (isset($result)) { |
968 | 1041 | $result[0]['query_number_rows'] = $i; |
969 | 1042 | return $result; |
1043 | + } else { |
|
1044 | + return array(); |
|
970 | 1045 | } |
971 | - else return array(); |
|
972 | 1046 | } |
973 | 1047 | |
974 | 1048 | /** |
@@ -1028,20 +1102,36 @@ discard block |
||
1028 | 1102 | if ($row['registration'] != '') { |
1029 | 1103 | $row['registration'] = str_replace('.','',$row['registration']); |
1030 | 1104 | $image_array = $Image->getSpotterImage($row['registration']); |
1031 | - 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'])); |
|
1032 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1033 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1105 | + if (count($image_array) > 0) { |
|
1106 | + $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'])); |
|
1107 | + } else { |
|
1108 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1109 | + } |
|
1110 | + } else { |
|
1111 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
1112 | + } |
|
1034 | 1113 | $icao = ''; |
1035 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
1036 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
1114 | + if ($row['registration'] == '') { |
|
1115 | + $row['registration'] = 'NA'; |
|
1116 | + } |
|
1117 | + if ($row['ident'] == '') { |
|
1118 | + $row['ident'] = 'NA'; |
|
1119 | + } |
|
1037 | 1120 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
1038 | 1121 | if (isset($identicao[0])) { |
1039 | 1122 | if (substr($row['ident'],0,2) == 'AF') { |
1040 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
1041 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1042 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1123 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
1124 | + $icao = $row['ident']; |
|
1125 | + } else { |
|
1126 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
1127 | + } |
|
1128 | + } else { |
|
1129 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
1130 | + } |
|
1043 | 1131 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
1044 | - } else $icao = $row['ident']; |
|
1132 | + } else { |
|
1133 | + $icao = $row['ident']; |
|
1134 | + } |
|
1045 | 1135 | $icao = $Translation->checkTranslation($icao); |
1046 | 1136 | |
1047 | 1137 | |
@@ -1049,12 +1139,16 @@ discard block |
||
1049 | 1139 | $found = false; |
1050 | 1140 | if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
1051 | 1141 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
1052 | - 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>'; |
|
1142 | + if (isset($airport_info[0]['icao'])) { |
|
1143 | + $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1144 | + } |
|
1053 | 1145 | $found = true; |
1054 | 1146 | } |
1055 | 1147 | if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
1056 | 1148 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
1057 | - 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>'; |
|
1149 | + if (isset($airport_info[0]['icao'])) { |
|
1150 | + $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
1151 | + } |
|
1058 | 1152 | $found = true; |
1059 | 1153 | } |
1060 | 1154 | if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
@@ -1064,7 +1158,9 @@ discard block |
||
1064 | 1158 | $found = true; |
1065 | 1159 | } |
1066 | 1160 | } |
1067 | - if ($found) $row['decode'] = json_encode($decode); |
|
1161 | + if ($found) { |
|
1162 | + $row['decode'] = json_encode($decode); |
|
1163 | + } |
|
1068 | 1164 | |
1069 | 1165 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
1070 | 1166 | $result[] = $data; |
@@ -1073,7 +1169,9 @@ discard block |
||
1073 | 1169 | if (isset($result)) { |
1074 | 1170 | $result[0]['query_number_rows'] = $i; |
1075 | 1171 | return $result; |
1076 | - } else return array(); |
|
1172 | + } else { |
|
1173 | + return array(); |
|
1174 | + } |
|
1077 | 1175 | } |
1078 | 1176 | |
1079 | 1177 | /** |
@@ -1089,19 +1187,29 @@ discard block |
||
1089 | 1187 | $ident = trim($ident); |
1090 | 1188 | $Translation = new Translation($this->db); |
1091 | 1189 | $Spotter = new Spotter($this->db); |
1092 | - if ($globalDebug) echo "Test if we add ModeS data..."; |
|
1190 | + if ($globalDebug) { |
|
1191 | + echo "Test if we add ModeS data..."; |
|
1192 | + } |
|
1093 | 1193 | //if ($icao == '') $icao = ACARS->ident2icao($ident); |
1094 | - if ($icao == '') $icao = $Translation->checkTranslation($ident); |
|
1095 | - if ($globalDebug) echo '- Ident : '.$icao.' - '; |
|
1194 | + if ($icao == '') { |
|
1195 | + $icao = $Translation->checkTranslation($ident); |
|
1196 | + } |
|
1197 | + if ($globalDebug) { |
|
1198 | + echo '- Ident : '.$icao.' - '; |
|
1199 | + } |
|
1096 | 1200 | if ($ident == '' || $registration == '') { |
1097 | - if ($globalDebug) echo "Ident or registration null, exit\n"; |
|
1201 | + if ($globalDebug) { |
|
1202 | + echo "Ident or registration null, exit\n"; |
|
1203 | + } |
|
1098 | 1204 | return ''; |
1099 | 1205 | } |
1100 | 1206 | |
1101 | 1207 | $registration = str_replace('.','',$registration); |
1102 | 1208 | $ident = $Translation->ident2icao($ident); |
1103 | 1209 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
1104 | - if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
|
1210 | + if ($globalDebug) { |
|
1211 | + echo "Check if needed to add translation ".$ident.'... '; |
|
1212 | + } |
|
1105 | 1213 | $querysi = "SELECT ident FROM spotter_live s,aircraft_modes a WHERE a.ModeS = s.ModeS AND a.Registration = :registration AND s.format_source <> 'ACARS' LIMIT 1"; |
1106 | 1214 | $querysi_values = array(':registration' => $registration); |
1107 | 1215 | try { |
@@ -1109,7 +1217,9 @@ discard block |
||
1109 | 1217 | $sthsi = $this->db->prepare($querysi); |
1110 | 1218 | $sthsi->execute($querysi_values); |
1111 | 1219 | } catch(PDOException $e) { |
1112 | - if ($globalDebug) echo $e->getMessage(); |
|
1220 | + if ($globalDebug) { |
|
1221 | + echo $e->getMessage(); |
|
1222 | + } |
|
1113 | 1223 | return "error : ".$e->getMessage(); |
1114 | 1224 | } |
1115 | 1225 | $resultsi = $sthsi->fetch(PDO::FETCH_ASSOC); |
@@ -1117,9 +1227,14 @@ discard block |
||
1117 | 1227 | if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') { |
1118 | 1228 | $Translation = new Translation($this->db); |
1119 | 1229 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
1120 | - if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
1121 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1122 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1230 | + if ($globalDebug) { |
|
1231 | + echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
1232 | + } |
|
1233 | + if ($ident != $trans_ident) { |
|
1234 | + $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
1235 | + } elseif ($trans_ident == $ident) { |
|
1236 | + $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
1237 | + } |
|
1123 | 1238 | } else { |
1124 | 1239 | if ($registration != '' && $latitude != '' && $longitude != '') { |
1125 | 1240 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1128,17 +1243,24 @@ discard block |
||
1128 | 1243 | $sth = $this->db->prepare($query); |
1129 | 1244 | $sth->execute($query_values); |
1130 | 1245 | } catch(PDOException $e) { |
1131 | - if ($globalDebug) echo $e->getMessage(); |
|
1246 | + if ($globalDebug) { |
|
1247 | + echo $e->getMessage(); |
|
1248 | + } |
|
1132 | 1249 | return "error : ".$e->getMessage(); |
1133 | 1250 | } |
1134 | 1251 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
1135 | - if (isset($result['modes'])) $hex = $result['modes']; |
|
1136 | - else $hex = ''; |
|
1252 | + if (isset($result['modes'])) { |
|
1253 | + $hex = $result['modes']; |
|
1254 | + } else { |
|
1255 | + $hex = ''; |
|
1256 | + } |
|
1137 | 1257 | $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
1138 | 1258 | $this->SI->add($SI_data); |
1139 | 1259 | } |
1140 | 1260 | } |
1141 | - if ($globalDebug) echo 'Done'."\n"; |
|
1261 | + if ($globalDebug) { |
|
1262 | + echo 'Done'."\n"; |
|
1263 | + } |
|
1142 | 1264 | |
1143 | 1265 | $query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1"; |
1144 | 1266 | $query_values = array(':ident' => $icao); |
@@ -1147,14 +1269,19 @@ discard block |
||
1147 | 1269 | $sth = $this->db->prepare($query); |
1148 | 1270 | $sth->execute($query_values); |
1149 | 1271 | } catch(PDOException $e) { |
1150 | - if ($globalDebug) echo $e->getMessage(); |
|
1272 | + if ($globalDebug) { |
|
1273 | + echo $e->getMessage(); |
|
1274 | + } |
|
1151 | 1275 | return "error : ".$e->getMessage(); |
1152 | 1276 | } |
1153 | 1277 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
1154 | 1278 | //print_r($result); |
1155 | 1279 | if (isset($result['flightaware_id'])) { |
1156 | - if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
|
1157 | - else $ModeS = ''; |
|
1280 | + if (isset($result['ModeS'])) { |
|
1281 | + $ModeS = $result['ModeS']; |
|
1282 | + } else { |
|
1283 | + $ModeS = ''; |
|
1284 | + } |
|
1158 | 1285 | if ($ModeS == '') { |
1159 | 1286 | $id = explode('-',$result['flightaware_id']); |
1160 | 1287 | $ModeS = $id[0]; |
@@ -1168,13 +1295,17 @@ discard block |
||
1168 | 1295 | $sthc = $this->db->prepare($queryc); |
1169 | 1296 | $sthc->execute($queryc_values); |
1170 | 1297 | } catch(PDOException $e) { |
1171 | - if ($globalDebug) echo $e->getMessage(); |
|
1298 | + if ($globalDebug) { |
|
1299 | + echo $e->getMessage(); |
|
1300 | + } |
|
1172 | 1301 | return "error : ".$e->getMessage(); |
1173 | 1302 | } |
1174 | 1303 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
1175 | 1304 | |
1176 | 1305 | if (count($row) == 0) { |
1177 | - if ($globalDebug) echo " Add to ModeS table - "; |
|
1306 | + if ($globalDebug) { |
|
1307 | + echo " Add to ModeS table - "; |
|
1308 | + } |
|
1178 | 1309 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
1179 | 1310 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
1180 | 1311 | try { |
@@ -1182,11 +1313,15 @@ discard block |
||
1182 | 1313 | $sthi = $this->db->prepare($queryi); |
1183 | 1314 | $sthi->execute($queryi_values); |
1184 | 1315 | } catch(PDOException $e) { |
1185 | - if ($globalDebug) echo $e->getMessage(); |
|
1316 | + if ($globalDebug) { |
|
1317 | + echo $e->getMessage(); |
|
1318 | + } |
|
1186 | 1319 | return "error : ".$e->getMessage(); |
1187 | 1320 | } |
1188 | 1321 | } else { |
1189 | - if ($globalDebug) echo " Update ModeS table - "; |
|
1322 | + if ($globalDebug) { |
|
1323 | + echo " Update ModeS table - "; |
|
1324 | + } |
|
1190 | 1325 | if ($ICAOTypeCode != '') { |
1191 | 1326 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
1192 | 1327 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
@@ -1199,7 +1334,9 @@ discard block |
||
1199 | 1334 | $sthi = $this->db->prepare($queryi); |
1200 | 1335 | $sthi->execute($queryi_values); |
1201 | 1336 | } catch(PDOException $e) { |
1202 | - if ($globalDebug) echo $e->getMessage(); |
|
1337 | + if ($globalDebug) { |
|
1338 | + echo $e->getMessage(); |
|
1339 | + } |
|
1203 | 1340 | return "error : ".$e->getMessage(); |
1204 | 1341 | } |
1205 | 1342 | } |
@@ -1221,7 +1358,9 @@ discard block |
||
1221 | 1358 | return "error : ".$e->getMessage(); |
1222 | 1359 | } |
1223 | 1360 | */ |
1224 | - if ($globalDebug) echo " Update Spotter_output table - "; |
|
1361 | + if ($globalDebug) { |
|
1362 | + echo " Update Spotter_output table - "; |
|
1363 | + } |
|
1225 | 1364 | if ($ICAOTypeCode != '') { |
1226 | 1365 | if ($globalDBdriver == 'mysql') { |
1227 | 1366 | $queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
@@ -1232,8 +1371,7 @@ discard block |
||
1232 | 1371 | } else { |
1233 | 1372 | if ($globalDBdriver == 'mysql') { |
1234 | 1373 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
1235 | - } |
|
1236 | - elseif ($globalDBdriver == 'pgsql') { |
|
1374 | + } elseif ($globalDBdriver == 'pgsql') { |
|
1237 | 1375 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
1238 | 1376 | } |
1239 | 1377 | $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
@@ -1243,15 +1381,21 @@ discard block |
||
1243 | 1381 | $sthi = $this->db->prepare($queryi); |
1244 | 1382 | $sthi->execute($queryi_values); |
1245 | 1383 | } catch(PDOException $e) { |
1246 | - if ($globalDebug) echo $e->getMessage(); |
|
1384 | + if ($globalDebug) { |
|
1385 | + echo $e->getMessage(); |
|
1386 | + } |
|
1247 | 1387 | return "error : ".$e->getMessage(); |
1248 | 1388 | } |
1249 | 1389 | |
1250 | 1390 | } |
1251 | 1391 | } else { |
1252 | - if ($globalDebug) echo " Can't find ModeS in spotter_output - "; |
|
1392 | + if ($globalDebug) { |
|
1393 | + echo " Can't find ModeS in spotter_output - "; |
|
1394 | + } |
|
1395 | + } |
|
1396 | + if ($globalDebug) { |
|
1397 | + echo "Done\n"; |
|
1253 | 1398 | } |
1254 | - if ($globalDebug) echo "Done\n"; |
|
1255 | 1399 | } |
1256 | 1400 | } |
1257 | 1401 | ?> |
@@ -6,9 +6,13 @@ discard block |
||
6 | 6 | // Not yet finished, no CRC checks |
7 | 7 | //echo $buffer."\n"; |
8 | 8 | $typehex = substr($buffer,0,1); |
9 | - if ($typehex == '*' || $typehex == ':') $hex = substr($buffer,1,-1); |
|
10 | - elseif ($typehex == '@' || $typehex == '%') $hex = substr($buffer,13,-13); |
|
11 | - else $hex = substr($buffer,1,-1); |
|
9 | + if ($typehex == '*' || $typehex == ':') { |
|
10 | + $hex = substr($buffer,1,-1); |
|
11 | + } elseif ($typehex == '@' || $typehex == '%') { |
|
12 | + $hex = substr($buffer,13,-13); |
|
13 | + } else { |
|
14 | + $hex = substr($buffer,1,-1); |
|
15 | + } |
|
12 | 16 | $bin = gmp_strval( gmp_init($hex,16), 2); |
13 | 17 | //if (strlen($hex) == 28 && $this->parityCheck($hex,$bin)) { |
14 | 18 | if (strlen($hex) == 28) { |
@@ -51,8 +55,9 @@ discard block |
||
51 | 55 | // 131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. |
52 | 56 | $cprlat = intval(substr($bin,54,17),2)/131072.0; |
53 | 57 | $cprlon = intval(substr($bin,71,17),2)/131072.0; |
54 | - if ($oe == 0) $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
55 | - elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
58 | + if ($oe == 0) { |
|
59 | + $this::$latlon[$icao] = array('latitude' => $cprlat,'longitude' => $cprlon,'created' => time()); |
|
60 | + } elseif (isset($this::$latlon[$icao]) && (time() - $this::$latlon[$icao]['created']) < 10) { |
|
56 | 61 | $cprlat_odd = $cprlat; |
57 | 62 | $cprlon_odd = $cprlon; |
58 | 63 | $cprlat_even = $this::$latlon[$icao]['latitude']; |
@@ -61,8 +66,12 @@ discard block |
||
61 | 66 | $j = 59*$cprlat_even-60*$cprlat_odd+0.5; |
62 | 67 | $lat_even = (360.0/60)*($j%60+$cprlat_even); |
63 | 68 | $lat_odd = (360.0/59)*($j%59+$cprlat_odd); |
64 | - if ($lat_even >= 270) $lat_even = $lat_even - 360; |
|
65 | - if ($lat_odd >= 270) $lat_odd = $lat_odd - 360; |
|
69 | + if ($lat_even >= 270) { |
|
70 | + $lat_even = $lat_even - 360; |
|
71 | + } |
|
72 | + if ($lat_odd >= 270) { |
|
73 | + $lat_odd = $lat_odd - 360; |
|
74 | + } |
|
66 | 75 | // check latitude zone |
67 | 76 | if ($this->cprNL($lat_even) == $this->cprNL($lat_odd)) { |
68 | 77 | if ($this::$latlon[$icao]['created'] > time()) { |
@@ -70,7 +79,9 @@ discard block |
||
70 | 79 | $m = floor($cprlon_even*($this->cprNL($lat_even)-1) - $cprlon_odd * $this->cprNL($lat_even)+0.5); |
71 | 80 | $lon = (360.0/$ni)*($m%$ni+$cprlon_even); |
72 | 81 | $lat = $lat_even; |
73 | - if ($lon > 180) $lon = $lon -360; |
|
82 | + if ($lon > 180) { |
|
83 | + $lon = $lon -360; |
|
84 | + } |
|
74 | 85 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
75 | 86 | //if ($globalDebug) echo 'cs : '.$cs.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon; |
76 | 87 | $data['latitude'] = $lat; |
@@ -81,14 +92,18 @@ discard block |
||
81 | 92 | $m = floor($cprlon_even*($this->cprNL($lat_odd)-1) - $cprlon_odd * $this->cprNL($lat_odd)+0.5); |
82 | 93 | $lon = (360.0/$ni)*($m%$ni+$cprlon_odd); |
83 | 94 | $lat = $lat_odd; |
84 | - if ($lon > 180) $lon = $lon -360; |
|
95 | + if ($lon > 180) { |
|
96 | + $lon = $lon -360; |
|
97 | + } |
|
85 | 98 | if ($lat > -91 && $lat < 91 && $lon > -181 && $lon < 181) { |
86 | 99 | //if ($globalDebug) echo 'icao : '.$icao.' - hex : '.$hex.' - lat : '.$lat.' - lon : '.$lon.' second'."\n"; |
87 | 100 | $data['latitude'] = $lat; |
88 | 101 | $data['longitude'] = $lon; |
89 | 102 | } |
90 | 103 | } |
91 | - } else echo "Not cprNL"; |
|
104 | + } else { |
|
105 | + echo "Not cprNL"; |
|
106 | + } |
|
92 | 107 | unset($this::$latlon[$icao]); |
93 | 108 | } |
94 | 109 | } elseif ($tc == 19) { |
@@ -97,11 +112,17 @@ discard block |
||
97 | 112 | $v_ew = intval(substr($bin,46,10),2); |
98 | 113 | $v_ns_dir = intval(substr($bin,56,1)); |
99 | 114 | $v_ns = intval(substr($bin,57,10),2); |
100 | - if ($v_ew_dir) $v_ew = -1*$v_ew; |
|
101 | - if ($v_ns_dir) $v_ns = -1*$v_ns; |
|
115 | + if ($v_ew_dir) { |
|
116 | + $v_ew = -1*$v_ew; |
|
117 | + } |
|
118 | + if ($v_ns_dir) { |
|
119 | + $v_ns = -1*$v_ns; |
|
120 | + } |
|
102 | 121 | $speed = sqrt($v_ns*$v_ns+$v_ew*$v_ew); |
103 | 122 | $heading = atan2($v_ew,$v_ns)*360.0/(2*pi()); |
104 | - if ($heading <0) $heading = $heading+360; |
|
123 | + if ($heading <0) { |
|
124 | + $heading = $heading+360; |
|
125 | + } |
|
105 | 126 | $data['speed'] = $speed; |
106 | 127 | $data['heading'] = $heading; |
107 | 128 | } |
@@ -116,72 +137,194 @@ discard block |
||
116 | 137 | |
117 | 138 | function cprNL($lat) { |
118 | 139 | //Lookup table to convert the latitude to index. |
119 | - if ($lat < 0) $lat = -$lat; // Table is simmetric about the equator. |
|
120 | - if ($lat < 10.47047130) return 59; |
|
121 | - if ($lat < 14.82817437) return 58; |
|
122 | - if ($lat < 18.18626357) return 57; |
|
123 | - if ($lat < 21.02939493) return 56; |
|
124 | - if ($lat < 23.54504487) return 55; |
|
125 | - if ($lat < 25.82924707) return 54; |
|
126 | - if ($lat < 27.93898710) return 53; |
|
127 | - if ($lat < 29.91135686) return 52; |
|
128 | - if ($lat < 31.77209708) return 51; |
|
129 | - if ($lat < 33.53993436) return 50; |
|
130 | - if ($lat < 35.22899598) return 49; |
|
131 | - if ($lat < 36.85025108) return 48; |
|
132 | - if ($lat < 38.41241892) return 47; |
|
133 | - if ($lat < 39.92256684) return 46; |
|
134 | - if ($lat < 41.38651832) return 45; |
|
135 | - if ($lat < 42.80914012) return 44; |
|
136 | - if ($lat < 44.19454951) return 43; |
|
137 | - if ($lat < 45.54626723) return 42; |
|
138 | - if ($lat < 46.86733252) return 41; |
|
139 | - if ($lat < 48.16039128) return 40; |
|
140 | - if ($lat < 49.42776439) return 39; |
|
141 | - if ($lat < 50.67150166) return 38; |
|
142 | - if ($lat < 51.89342469) return 37; |
|
143 | - if ($lat < 53.09516153) return 36; |
|
144 | - if ($lat < 54.27817472) return 35; |
|
145 | - if ($lat < 55.44378444) return 34; |
|
146 | - if ($lat < 56.59318756) return 33; |
|
147 | - if ($lat < 57.72747354) return 32; |
|
148 | - if ($lat < 58.84763776) return 31; |
|
149 | - if ($lat < 59.95459277) return 30; |
|
150 | - if ($lat < 61.04917774) return 29; |
|
151 | - if ($lat < 62.13216659) return 28; |
|
152 | - if ($lat < 63.20427479) return 27; |
|
153 | - if ($lat < 64.26616523) return 26; |
|
154 | - if ($lat < 65.31845310) return 25; |
|
155 | - if ($lat < 66.36171008) return 24; |
|
156 | - if ($lat < 67.39646774) return 23; |
|
157 | - if ($lat < 68.42322022) return 22; |
|
158 | - if ($lat < 69.44242631) return 21; |
|
159 | - if ($lat < 70.45451075) return 20; |
|
160 | - if ($lat < 71.45986473) return 19; |
|
161 | - if ($lat < 72.45884545) return 18; |
|
162 | - if ($lat < 73.45177442) return 17; |
|
163 | - if ($lat < 74.43893416) return 16; |
|
164 | - if ($lat < 75.42056257) return 15; |
|
165 | - if ($lat < 76.39684391) return 14; |
|
166 | - if ($lat < 77.36789461) return 13; |
|
167 | - if ($lat < 78.33374083) return 12; |
|
168 | - if ($lat < 79.29428225) return 11; |
|
169 | - if ($lat < 80.24923213) return 10; |
|
170 | - if ($lat < 81.19801349) return 9; |
|
171 | - if ($lat < 82.13956981) return 8; |
|
172 | - if ($lat < 83.07199445) return 7; |
|
173 | - if ($lat < 83.99173563) return 6; |
|
174 | - if ($lat < 84.89166191) return 5; |
|
175 | - if ($lat < 85.75541621) return 4; |
|
176 | - if ($lat < 86.53536998) return 3; |
|
177 | - if ($lat < 87.00000000) return 2; |
|
140 | + if ($lat < 0) { |
|
141 | + $lat = -$lat; |
|
142 | + } |
|
143 | + // Table is simmetric about the equator. |
|
144 | + if ($lat < 10.47047130) { |
|
145 | + return 59; |
|
146 | + } |
|
147 | + if ($lat < 14.82817437) { |
|
148 | + return 58; |
|
149 | + } |
|
150 | + if ($lat < 18.18626357) { |
|
151 | + return 57; |
|
152 | + } |
|
153 | + if ($lat < 21.02939493) { |
|
154 | + return 56; |
|
155 | + } |
|
156 | + if ($lat < 23.54504487) { |
|
157 | + return 55; |
|
158 | + } |
|
159 | + if ($lat < 25.82924707) { |
|
160 | + return 54; |
|
161 | + } |
|
162 | + if ($lat < 27.93898710) { |
|
163 | + return 53; |
|
164 | + } |
|
165 | + if ($lat < 29.91135686) { |
|
166 | + return 52; |
|
167 | + } |
|
168 | + if ($lat < 31.77209708) { |
|
169 | + return 51; |
|
170 | + } |
|
171 | + if ($lat < 33.53993436) { |
|
172 | + return 50; |
|
173 | + } |
|
174 | + if ($lat < 35.22899598) { |
|
175 | + return 49; |
|
176 | + } |
|
177 | + if ($lat < 36.85025108) { |
|
178 | + return 48; |
|
179 | + } |
|
180 | + if ($lat < 38.41241892) { |
|
181 | + return 47; |
|
182 | + } |
|
183 | + if ($lat < 39.92256684) { |
|
184 | + return 46; |
|
185 | + } |
|
186 | + if ($lat < 41.38651832) { |
|
187 | + return 45; |
|
188 | + } |
|
189 | + if ($lat < 42.80914012) { |
|
190 | + return 44; |
|
191 | + } |
|
192 | + if ($lat < 44.19454951) { |
|
193 | + return 43; |
|
194 | + } |
|
195 | + if ($lat < 45.54626723) { |
|
196 | + return 42; |
|
197 | + } |
|
198 | + if ($lat < 46.86733252) { |
|
199 | + return 41; |
|
200 | + } |
|
201 | + if ($lat < 48.16039128) { |
|
202 | + return 40; |
|
203 | + } |
|
204 | + if ($lat < 49.42776439) { |
|
205 | + return 39; |
|
206 | + } |
|
207 | + if ($lat < 50.67150166) { |
|
208 | + return 38; |
|
209 | + } |
|
210 | + if ($lat < 51.89342469) { |
|
211 | + return 37; |
|
212 | + } |
|
213 | + if ($lat < 53.09516153) { |
|
214 | + return 36; |
|
215 | + } |
|
216 | + if ($lat < 54.27817472) { |
|
217 | + return 35; |
|
218 | + } |
|
219 | + if ($lat < 55.44378444) { |
|
220 | + return 34; |
|
221 | + } |
|
222 | + if ($lat < 56.59318756) { |
|
223 | + return 33; |
|
224 | + } |
|
225 | + if ($lat < 57.72747354) { |
|
226 | + return 32; |
|
227 | + } |
|
228 | + if ($lat < 58.84763776) { |
|
229 | + return 31; |
|
230 | + } |
|
231 | + if ($lat < 59.95459277) { |
|
232 | + return 30; |
|
233 | + } |
|
234 | + if ($lat < 61.04917774) { |
|
235 | + return 29; |
|
236 | + } |
|
237 | + if ($lat < 62.13216659) { |
|
238 | + return 28; |
|
239 | + } |
|
240 | + if ($lat < 63.20427479) { |
|
241 | + return 27; |
|
242 | + } |
|
243 | + if ($lat < 64.26616523) { |
|
244 | + return 26; |
|
245 | + } |
|
246 | + if ($lat < 65.31845310) { |
|
247 | + return 25; |
|
248 | + } |
|
249 | + if ($lat < 66.36171008) { |
|
250 | + return 24; |
|
251 | + } |
|
252 | + if ($lat < 67.39646774) { |
|
253 | + return 23; |
|
254 | + } |
|
255 | + if ($lat < 68.42322022) { |
|
256 | + return 22; |
|
257 | + } |
|
258 | + if ($lat < 69.44242631) { |
|
259 | + return 21; |
|
260 | + } |
|
261 | + if ($lat < 70.45451075) { |
|
262 | + return 20; |
|
263 | + } |
|
264 | + if ($lat < 71.45986473) { |
|
265 | + return 19; |
|
266 | + } |
|
267 | + if ($lat < 72.45884545) { |
|
268 | + return 18; |
|
269 | + } |
|
270 | + if ($lat < 73.45177442) { |
|
271 | + return 17; |
|
272 | + } |
|
273 | + if ($lat < 74.43893416) { |
|
274 | + return 16; |
|
275 | + } |
|
276 | + if ($lat < 75.42056257) { |
|
277 | + return 15; |
|
278 | + } |
|
279 | + if ($lat < 76.39684391) { |
|
280 | + return 14; |
|
281 | + } |
|
282 | + if ($lat < 77.36789461) { |
|
283 | + return 13; |
|
284 | + } |
|
285 | + if ($lat < 78.33374083) { |
|
286 | + return 12; |
|
287 | + } |
|
288 | + if ($lat < 79.29428225) { |
|
289 | + return 11; |
|
290 | + } |
|
291 | + if ($lat < 80.24923213) { |
|
292 | + return 10; |
|
293 | + } |
|
294 | + if ($lat < 81.19801349) { |
|
295 | + return 9; |
|
296 | + } |
|
297 | + if ($lat < 82.13956981) { |
|
298 | + return 8; |
|
299 | + } |
|
300 | + if ($lat < 83.07199445) { |
|
301 | + return 7; |
|
302 | + } |
|
303 | + if ($lat < 83.99173563) { |
|
304 | + return 6; |
|
305 | + } |
|
306 | + if ($lat < 84.89166191) { |
|
307 | + return 5; |
|
308 | + } |
|
309 | + if ($lat < 85.75541621) { |
|
310 | + return 4; |
|
311 | + } |
|
312 | + if ($lat < 86.53536998) { |
|
313 | + return 3; |
|
314 | + } |
|
315 | + if ($lat < 87.00000000) { |
|
316 | + return 2; |
|
317 | + } |
|
178 | 318 | return 1; |
179 | 319 | } |
180 | 320 | |
181 | 321 | function cprN($lat,$isodd) { |
182 | 322 | $nl = $this->cprNL($lat) - $isodd; |
183 | - if ($nl > 1) return $nl; |
|
184 | - else return 1; |
|
323 | + if ($nl > 1) { |
|
324 | + return $nl; |
|
325 | + } else { |
|
326 | + return 1; |
|
327 | + } |
|
185 | 328 | } |
186 | 329 | |
187 | 330 | |
@@ -207,10 +350,13 @@ discard block |
||
207 | 350 | $checksum = intval(substr($msg,22,6),16); |
208 | 351 | |
209 | 352 | for ($j = 0; $j < strlen($bin); $j++) { |
210 | - if ($bin[$j]) $crc = $crc^intval($modes_checksum_table[$j],0); |
|
353 | + if ($bin[$j]) { |
|
354 | + $crc = $crc^intval($modes_checksum_table[$j],0); |
|
355 | + } |
|
211 | 356 | } |
212 | - if ($crc == $checksum) return true; |
|
213 | - else { |
|
357 | + if ($crc == $checksum) { |
|
358 | + return true; |
|
359 | + } else { |
|
214 | 360 | //echo "**** CRC ERROR ****\n"; |
215 | 361 | return false; |
216 | 362 | } |
@@ -72,8 +72,11 @@ discard block |
||
72 | 72 | |
73 | 73 | |
74 | 74 | public function countAllAircraftTypes($limit = true) { |
75 | - if ($limit) $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
76 | - else $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' ORDER BY aircraft_icao_count DESC"; |
|
75 | + if ($limit) { |
|
76 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' ORDER BY aircraft_icao_count DESC LIMIT 10 OFFSET 0"; |
|
77 | + } else { |
|
78 | + $query = "SELECT aircraft_icao, cnt AS aircraft_icao_count, aircraft_name FROM stats_aircraft WHERE aircraft_name <> '' AND aircraft_icao <> '' ORDER BY aircraft_icao_count DESC"; |
|
79 | + } |
|
77 | 80 | try { |
78 | 81 | $sth = $this->db->prepare($query); |
79 | 82 | $sth->execute(); |
@@ -88,8 +91,11 @@ discard block |
||
88 | 91 | return $all; |
89 | 92 | } |
90 | 93 | public function countAllAirlineCountries($limit = true) { |
91 | - if ($limit) $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
92 | - else $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
94 | + if ($limit) { |
|
95 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao GROUP BY airline_country ORDER BY airline_country_count DESC LIMIT 10 OFFSET 0"; |
|
96 | + } else { |
|
97 | + $query = "SELECT airlines.country AS airline_country, SUM(stats_airline.cnt) as airline_country_count FROM stats_airline,airlines WHERE stats_airline.airline_icao=airlines.icao GROUP BY airline_country ORDER BY airline_country_count DESC"; |
|
98 | + } |
|
93 | 99 | try { |
94 | 100 | $sth = $this->db->prepare($query); |
95 | 101 | $sth->execute(); |
@@ -105,8 +111,11 @@ discard block |
||
105 | 111 | return $all; |
106 | 112 | } |
107 | 113 | public function countAllAircraftManufacturers($limit = true) { |
108 | - if ($limit) $query = "SELECT aircraft.manufacturer AS aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft,aircraft WHERE stats_aircraft.aircraft_icao=aircraft.icao GROUP BY aircraft.manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
109 | - else $query = "SELECT aircraft.manufacturer AS aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft,aircraft WHERE stats_aircraft.aircraft_icao=aircraft.icao GROUP BY aircraft.manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
114 | + if ($limit) { |
|
115 | + $query = "SELECT aircraft.manufacturer AS aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft,aircraft WHERE stats_aircraft.aircraft_icao=aircraft.icao GROUP BY aircraft.manufacturer ORDER BY aircraft_manufacturer_count DESC LIMIT 10 OFFSET 0"; |
|
116 | + } else { |
|
117 | + $query = "SELECT aircraft.manufacturer AS aircraft_manufacturer, SUM(stats_aircraft.cnt) as aircraft_manufacturer_count FROM stats_aircraft,aircraft WHERE stats_aircraft.aircraft_icao=aircraft.icao GROUP BY aircraft.manufacturer ORDER BY aircraft_manufacturer_count DESC"; |
|
118 | + } |
|
110 | 119 | try { |
111 | 120 | $sth = $this->db->prepare($query); |
112 | 121 | $sth->execute(); |
@@ -122,8 +131,11 @@ discard block |
||
122 | 131 | } |
123 | 132 | |
124 | 133 | public function countAllArrivalCountries($limit = true) { |
125 | - if ($limit) $query = "SELECT airport_country AS arrival_airport_country, arrival as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0"; |
|
126 | - else $query = "SELECT airport_country AS arrival_airport_country, arrival as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly'"; |
|
134 | + if ($limit) { |
|
135 | + $query = "SELECT airport_country AS arrival_airport_country, arrival as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0"; |
|
136 | + } else { |
|
137 | + $query = "SELECT airport_country AS arrival_airport_country, arrival as airport_arrival_country_count FROM stats_airport WHERE stats_type = 'yearly'"; |
|
138 | + } |
|
127 | 139 | try { |
128 | 140 | $sth = $this->db->prepare($query); |
129 | 141 | $sth->execute(); |
@@ -138,8 +150,11 @@ discard block |
||
138 | 150 | return $all; |
139 | 151 | } |
140 | 152 | public function countAllDepartureCountries($limit = true) { |
141 | - if ($limit) $query = "SELECT airport_country AS departure_airport_country, departure as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0"; |
|
142 | - else $query = "SELECT airport_country AS departure_airport_country, departure as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly'"; |
|
153 | + if ($limit) { |
|
154 | + $query = "SELECT airport_country AS departure_airport_country, departure as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0"; |
|
155 | + } else { |
|
156 | + $query = "SELECT airport_country AS departure_airport_country, departure as airport_departure_country_count FROM stats_airport WHERE stats_type = 'yearly'"; |
|
157 | + } |
|
143 | 158 | try { |
144 | 159 | $sth = $this->db->prepare($query); |
145 | 160 | $sth->execute(); |
@@ -155,8 +170,11 @@ discard block |
||
155 | 170 | } |
156 | 171 | |
157 | 172 | public function countAllAirlines($limit = true) { |
158 | - if ($limit) $query = "SELECT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = airline_icao ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
159 | - else $query = "SELECT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = airline_icao ORDER BY airline_count DESC"; |
|
173 | + if ($limit) { |
|
174 | + $query = "SELECT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = airline_icao ORDER BY airline_count DESC LIMIT 10 OFFSET 0"; |
|
175 | + } else { |
|
176 | + $query = "SELECT stats_airline.airline_icao, stats_airline.cnt AS airline_count, stats_airline.airline_name, airlines.country as airline_country FROM stats_airline, airlines WHERE stats_airline.airline_name <> '' AND stats_airline.airline_icao <> '' AND airlines.icao = airline_icao ORDER BY airline_count DESC"; |
|
177 | + } |
|
160 | 178 | try { |
161 | 179 | $sth = $this->db->prepare($query); |
162 | 180 | $sth->execute(); |
@@ -171,8 +189,11 @@ discard block |
||
171 | 189 | return $all; |
172 | 190 | } |
173 | 191 | public function countAllAircraftRegistrations($limit = true) { |
174 | - if ($limit) $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
175 | - else $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao ORDER BY aircraft_registration_count DESC"; |
|
192 | + if ($limit) { |
|
193 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name, s.registration FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao ORDER BY aircraft_registration_count DESC LIMIT 10 OFFSET 0"; |
|
194 | + } else { |
|
195 | + $query = "SELECT s.aircraft_icao, s.cnt AS aircraft_registration_count, a.type AS aircraft_name FROM stats_registration s, aircraft a WHERE s.registration <> '' AND a.icao = s.aircraft_icao ORDER BY aircraft_registration_count DESC"; |
|
196 | + } |
|
176 | 197 | try { |
177 | 198 | $sth = $this->db->prepare($query); |
178 | 199 | $sth->execute(); |
@@ -187,8 +208,11 @@ discard block |
||
187 | 208 | return $all; |
188 | 209 | } |
189 | 210 | public function countAllCallsigns($limit = true) { |
190 | - if ($limit) $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
191 | - else $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao ORDER BY callsign_icao_count DESC"; |
|
211 | + if ($limit) { |
|
212 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao ORDER BY callsign_icao_count DESC LIMIT 10 OFFSET 0"; |
|
213 | + } else { |
|
214 | + $query = "SELECT s.callsign_icao, s.cnt AS callsign_icao_count, a.name AS airline_name, a.icao as airline_icao FROM stats_callsign s, airlines a WHERE s.callsign_icao <> '' AND a.icao = s.airline_icao ORDER BY callsign_icao_count DESC"; |
|
215 | + } |
|
192 | 216 | try { |
193 | 217 | $sth = $this->db->prepare($query); |
194 | 218 | $sth->execute(); |
@@ -205,8 +229,11 @@ discard block |
||
205 | 229 | public function countAllFlightOverCountries($limit = true) { |
206 | 230 | $Connection = new Connection(); |
207 | 231 | if ($Connection->tableExists('countries')) { |
208 | - if ($limit) $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
209 | - else $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 ORDER BY flight_count DESC"; |
|
232 | + if ($limit) { |
|
233 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 ORDER BY flight_count DESC LIMIT 20 OFFSET 0"; |
|
234 | + } else { |
|
235 | + $query = "SELECT countries.iso3 as flight_country_iso3, countries.iso2 as flight_country_iso2, countries.name as flight_country, cnt as flight_count, lat as flight_country_latitude, lon as flight_country_longitude FROM stats_country, countries WHERE stats_country.iso2 = countries.iso2 ORDER BY flight_count DESC"; |
|
236 | + } |
|
210 | 237 | try { |
211 | 238 | $sth = $this->db->prepare($query); |
212 | 239 | $sth->execute(); |
@@ -226,8 +253,11 @@ discard block |
||
226 | 253 | } |
227 | 254 | } |
228 | 255 | public function countAllPilots($limit = true) { |
229 | - if ($limit) $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
230 | - else $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot ORDER BY pilot_count DESC"; |
|
256 | + if ($limit) { |
|
257 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot ORDER BY pilot_count DESC LIMIT 10 OFFSET 0"; |
|
258 | + } else { |
|
259 | + $query = "SELECT pilot_id, cnt AS pilot_count, pilot_name FROM stats_pilot ORDER BY pilot_count DESC"; |
|
260 | + } |
|
231 | 261 | try { |
232 | 262 | $sth = $this->db->prepare($query); |
233 | 263 | $sth->execute(); |
@@ -242,8 +272,11 @@ discard block |
||
242 | 272 | return $all; |
243 | 273 | } |
244 | 274 | public function countAllOwners($limit = true) { |
245 | - if ($limit) $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
246 | - else $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner ORDER BY owner_count DESC"; |
|
275 | + if ($limit) { |
|
276 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner ORDER BY owner_count DESC LIMIT 10 OFFSET 0"; |
|
277 | + } else { |
|
278 | + $query = "SELECT owner_name, cnt AS owner_count FROM stats_owner ORDER BY owner_count DESC"; |
|
279 | + } |
|
247 | 280 | try { |
248 | 281 | $sth = $this->db->prepare($query); |
249 | 282 | $sth->execute(); |
@@ -258,8 +291,11 @@ discard block |
||
258 | 291 | return $all; |
259 | 292 | } |
260 | 293 | public function countAllDepartureAirports($limit = true) { |
261 | - if ($limit) $query = "SELECT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0"; |
|
262 | - else $query = "SELECT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE stats_type = 'yearly'"; |
|
294 | + if ($limit) { |
|
295 | + $query = "SELECT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0"; |
|
296 | + } else { |
|
297 | + $query = "SELECT airport_icao AS airport_departure_icao,airport_city AS airport_departure_city,airport_country AS airport_departure_country,departure AS airport_departure_icao_count FROM stats_airport WHERE stats_type = 'yearly'"; |
|
298 | + } |
|
263 | 299 | try { |
264 | 300 | $sth = $this->db->prepare($query); |
265 | 301 | $sth->execute(); |
@@ -281,7 +317,9 @@ discard block |
||
281 | 317 | $icao = $value['airport_departure_icao']; |
282 | 318 | if (isset($all[$icao])) { |
283 | 319 | $all[$icao]['airport_departure_icao_count'] = $all[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
284 | - } else $all[$icao] = $value; |
|
320 | + } else { |
|
321 | + $all[$icao] = $value; |
|
322 | + } |
|
285 | 323 | } |
286 | 324 | $count = array(); |
287 | 325 | foreach ($all as $key => $row) { |
@@ -292,8 +330,11 @@ discard block |
||
292 | 330 | return $all; |
293 | 331 | } |
294 | 332 | public function countAllArrivalAirports($limit = true) { |
295 | - if ($limit) $query = "SELECT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0"; |
|
296 | - else $query = "SELECT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE stats_type = 'yearly'"; |
|
333 | + if ($limit) { |
|
334 | + $query = "SELECT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE stats_type = 'yearly' LIMIT 10 OFFSET 0"; |
|
335 | + } else { |
|
336 | + $query = "SELECT airport_icao AS airport_arrival_icao,airport_city AS airport_arrival_city,airport_country AS airport_arrival_country,arrival AS airport_arrival_icao_count FROM stats_airport WHERE stats_type = 'yearly'"; |
|
337 | + } |
|
297 | 338 | try { |
298 | 339 | $sth = $this->db->prepare($query); |
299 | 340 | $sth->execute(); |
@@ -315,7 +356,9 @@ discard block |
||
315 | 356 | $icao = $value['airport_arrival_icao']; |
316 | 357 | if (isset($all[$icao])) { |
317 | 358 | $all[$icao]['airport_arrival_icao_count'] = $all[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
318 | - } else $all[$icao] = $value; |
|
359 | + } else { |
|
360 | + $all[$icao] = $value; |
|
361 | + } |
|
319 | 362 | } |
320 | 363 | $count = array(); |
321 | 364 | foreach ($all as $key => $row) { |
@@ -328,11 +371,17 @@ discard block |
||
328 | 371 | public function countAllMonthsLastYear($limit = true) { |
329 | 372 | global $globalDBdriver; |
330 | 373 | if ($globalDBdriver == 'mysql') { |
331 | - if ($limit) $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH)"; |
|
332 | - else $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth'"; |
|
374 | + if ($limit) { |
|
375 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= DATE_SUB(UTC_TIMESTAMP(),INTERVAL 12 MONTH)"; |
|
376 | + } else { |
|
377 | + $query = "SELECT MONTH(stats_date) as month_name, YEAR(stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth'"; |
|
378 | + } |
|
333 | 379 | } else { |
334 | - if ($limit) $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS'"; |
|
335 | - else $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth'"; |
|
380 | + if ($limit) { |
|
381 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth' AND stats_date >= CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '12 MONTHS'"; |
|
382 | + } else { |
|
383 | + $query = "SELECT EXTRACT(MONTH FROM stats_date) as month_name, EXTRACT(YEAR FROM stats_date) as year_name, cnt as date_count FROM stats WHERE stats_type = 'flights_bymonth'"; |
|
384 | + } |
|
336 | 385 | } |
337 | 386 | $query_data = array(); |
338 | 387 | try { |
@@ -434,10 +483,17 @@ discard block |
||
434 | 483 | } |
435 | 484 | public function countAllHours($orderby = 'hour',$limit = true) { |
436 | 485 | global $globalTimezone; |
437 | - if ($limit) $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour'"; |
|
438 | - else $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour'"; |
|
439 | - if ($orderby == 'hour') $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
|
440 | - if ($orderby == 'count') $query .= " ORDER BY hour_count DESC"; |
|
486 | + if ($limit) { |
|
487 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour'"; |
|
488 | + } else { |
|
489 | + $query = "SELECT flight_date as hour_name, cnt as hour_count FROM stats_flight WHERE stats_type = 'hour'"; |
|
490 | + } |
|
491 | + if ($orderby == 'hour') { |
|
492 | + $query .= " ORDER BY CAST(flight_date AS integer) ASC"; |
|
493 | + } |
|
494 | + if ($orderby == 'count') { |
|
495 | + $query .= " ORDER BY hour_count DESC"; |
|
496 | + } |
|
441 | 497 | try { |
442 | 498 | $sth = $this->db->prepare($query); |
443 | 499 | $sth->execute(); |
@@ -917,13 +973,17 @@ discard block |
||
917 | 973 | $alldata = $Spotter->countAllMonths(); |
918 | 974 | $lastyear = false; |
919 | 975 | foreach ($alldata as $number) { |
920 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
976 | + if ($number['year_name'] != date('Y')) { |
|
977 | + $lastyear = true; |
|
978 | + } |
|
921 | 979 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
922 | 980 | } |
923 | 981 | $alldata = $Spotter->countAllMilitaryMonths(); |
924 | 982 | $lastyear = false; |
925 | 983 | foreach ($alldata as $number) { |
926 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
984 | + if ($number['year_name'] != date('Y')) { |
|
985 | + $lastyear = true; |
|
986 | + } |
|
927 | 987 | $this->addStat('military_flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
928 | 988 | } |
929 | 989 | $alldata = $Spotter->countAllMonthsOwners(); |
@@ -1019,7 +1079,9 @@ discard block |
||
1019 | 1079 | } |
1020 | 1080 | } |
1021 | 1081 | } |
1022 | - if (!isset($globalArchiveMonths) || $globalArchiveMonths == '') $globalArchiveMonths = 2; |
|
1082 | + if (!isset($globalArchiveMonths) || $globalArchiveMonths == '') { |
|
1083 | + $globalArchiveMonths = 2; |
|
1084 | + } |
|
1023 | 1085 | if ($globalArchiveMonths > 0) { |
1024 | 1086 | $alldata = $Spotter->countAllAircraftTypes(false,$globalArchiveMonths); |
1025 | 1087 | foreach ($alldata as $number) { |
@@ -1062,7 +1124,9 @@ discard block |
||
1062 | 1124 | $icao = $value['airport_departure_icao']; |
1063 | 1125 | if (isset($alldata[$icao])) { |
1064 | 1126 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1065 | - } else $alldata[$icao] = $value; |
|
1127 | + } else { |
|
1128 | + $alldata[$icao] = $value; |
|
1129 | + } |
|
1066 | 1130 | } |
1067 | 1131 | $count = array(); |
1068 | 1132 | foreach ($alldata as $key => $row) { |
@@ -1085,7 +1149,9 @@ discard block |
||
1085 | 1149 | $icao = $value['airport_arrival_icao']; |
1086 | 1150 | if (isset($alldata[$icao])) { |
1087 | 1151 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1088 | - } else $alldata[$icao] = $value; |
|
1152 | + } else { |
|
1153 | + $alldata[$icao] = $value; |
|
1154 | + } |
|
1089 | 1155 | } |
1090 | 1156 | $count = array(); |
1091 | 1157 | foreach ($alldata as $key => $row) { |
@@ -1132,7 +1198,9 @@ discard block |
||
1132 | 1198 | echo 'Update stats !'."\n"; |
1133 | 1199 | if (isset($last_update[0]['value'])) { |
1134 | 1200 | $last_update_day = $last_update[0]['value']; |
1135 | - } else $last_update_day = '2012-12-12 12:12:12'; |
|
1201 | + } else { |
|
1202 | + $last_update_day = '2012-12-12 12:12:12'; |
|
1203 | + } |
|
1136 | 1204 | $Spotter = new Spotter($this->db); |
1137 | 1205 | $alldata = $Spotter->countAllAircraftTypes(false,0,$last_update_day); |
1138 | 1206 | foreach ($alldata as $number) { |
@@ -1169,7 +1237,9 @@ discard block |
||
1169 | 1237 | $icao = $value['airport_departure_icao']; |
1170 | 1238 | if (isset($alldata[$icao])) { |
1171 | 1239 | $alldata[$icao]['airport_departure_icao_count'] = $alldata[$icao]['airport_departure_icao_count'] + $value['airport_departure_icao_count']; |
1172 | - } else $alldata[$icao] = $value; |
|
1240 | + } else { |
|
1241 | + $alldata[$icao] = $value; |
|
1242 | + } |
|
1173 | 1243 | } |
1174 | 1244 | $count = array(); |
1175 | 1245 | foreach ($alldata as $key => $row) { |
@@ -1191,7 +1261,9 @@ discard block |
||
1191 | 1261 | $icao = $value['airport_arrival_icao']; |
1192 | 1262 | if (isset($alldata[$icao])) { |
1193 | 1263 | $alldata[$icao]['airport_arrival_icao_count'] = $alldata[$icao]['airport_arrival_icao_count'] + $value['airport_arrival_icao_count']; |
1194 | - } else $alldata[$icao] = $value; |
|
1264 | + } else { |
|
1265 | + $alldata[$icao] = $value; |
|
1266 | + } |
|
1195 | 1267 | } |
1196 | 1268 | $count = array(); |
1197 | 1269 | foreach ($alldata as $key => $row) { |
@@ -1217,7 +1289,9 @@ discard block |
||
1217 | 1289 | $alldata = $Spotter->countAllMonths(); |
1218 | 1290 | $lastyear = false; |
1219 | 1291 | foreach ($alldata as $number) { |
1220 | - if ($number['year_name'] != date('Y')) $lastyear = true; |
|
1292 | + if ($number['year_name'] != date('Y')) { |
|
1293 | + $lastyear = true; |
|
1294 | + } |
|
1221 | 1295 | $this->addStat('flights_bymonth',$number['date_count'],date('Y-m-d H:i:s',mktime(0,0,0,$number['month_name'],1,$number['year_name']))); |
1222 | 1296 | } |
1223 | 1297 | $alldata = $Spotter->countAllMilitaryMonths(); |
@@ -1258,7 +1332,9 @@ discard block |
||
1258 | 1332 | $icao = $value['departure_airport_icao']; |
1259 | 1333 | if (isset($alldata[$icao])) { |
1260 | 1334 | $alldata[$icao]['departure_airport_count'] = $alldata[$icao]['departure_airport_count'] + $value['departure_airport_count']; |
1261 | - } else $alldata[$icao] = $value; |
|
1335 | + } else { |
|
1336 | + $alldata[$icao] = $value; |
|
1337 | + } |
|
1262 | 1338 | } |
1263 | 1339 | $count = array(); |
1264 | 1340 | foreach ($alldata as $key => $row) { |
@@ -1280,7 +1356,9 @@ discard block |
||
1280 | 1356 | $icao = $value['arrival_airport_icao']; |
1281 | 1357 | if (isset($alldata[$icao])) { |
1282 | 1358 | $alldata[$icao]['arrival_airport_icao_count'] = $alldata[$icao]['arrival_airport_count'] + $value['arrival_airport_count']; |
1283 | - } else $alldata[$icao] = $value; |
|
1359 | + } else { |
|
1360 | + $alldata[$icao] = $value; |
|
1361 | + } |
|
1284 | 1362 | } |
1285 | 1363 | $count = array(); |
1286 | 1364 | foreach ($alldata as $key => $row) { |
@@ -58,8 +58,11 @@ discard block |
||
58 | 58 | return "error : ".$e->getMessage(); |
59 | 59 | } |
60 | 60 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
61 | - if ($row['nb'] > 0) return false; |
|
62 | - else return true; |
|
61 | + if ($row['nb'] > 0) { |
|
62 | + return false; |
|
63 | + } else { |
|
64 | + return true; |
|
65 | + } |
|
63 | 66 | } |
64 | 67 | |
65 | 68 | public static function insert_last_update() { |
@@ -83,9 +86,14 @@ discard block |
||
83 | 86 | //$pieces = explode(' ',$data); |
84 | 87 | $pieces = preg_split('/\s/',$data); |
85 | 88 | $pos = 0; |
86 | - if ($pieces[0] == 'METAR') $pos++; |
|
87 | - elseif ($pieces[0] == 'SPECI') $pos++; |
|
88 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
89 | + if ($pieces[0] == 'METAR') { |
|
90 | + $pos++; |
|
91 | + } elseif ($pieces[0] == 'SPECI') { |
|
92 | + $pos++; |
|
93 | + } |
|
94 | + if (strlen($pieces[$pos]) != 4) { |
|
95 | + $pos++; |
|
96 | + } |
|
89 | 97 | $result['location'] = $pieces[$pos]; |
90 | 98 | $pos++; |
91 | 99 | $result['dayofmonth'] = substr($pieces[$pos],0,2); |
@@ -93,16 +101,26 @@ discard block |
||
93 | 101 | $c = count($pieces); |
94 | 102 | for($pos++; $pos < $c; $pos++) { |
95 | 103 | $piece = $pieces[$pos]; |
96 | - if ($piece == 'RMK') break; |
|
97 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
98 | - if ($piece == 'COR') $result['correction'] = true; |
|
104 | + if ($piece == 'RMK') { |
|
105 | + break; |
|
106 | + } |
|
107 | + if ($piece == 'AUTO') { |
|
108 | + $result['auto'] = true; |
|
109 | + } |
|
110 | + if ($piece == 'COR') { |
|
111 | + $result['correction'] = true; |
|
112 | + } |
|
99 | 113 | // Wind Speed |
100 | 114 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
101 | 115 | $result['wind']['direction'] = (float)$matches[1]; |
102 | 116 | $result['wind']['unit'] = $matches[4]; |
103 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
104 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
105 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
117 | + if ($result['wind']['unit'] == 'KT') { |
|
118 | + $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
119 | + } elseif ($result['wind']['unit'] == 'KPH') { |
|
120 | + $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
121 | + } elseif ($result['wind']['unit'] == 'MPS') { |
|
122 | + $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
123 | + } |
|
106 | 124 | $result['wind']['gust'] = (float)$matches[3]; |
107 | 125 | $result['wind']['unit'] = $matches[4]; |
108 | 126 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
@@ -183,14 +201,23 @@ discard block |
||
183 | 201 | if (preg_match('#^(SKC|CLR|FEW|SCT|BKN|OVC|VV)([0-9]{3})(CB|TCU|CU|CI)?$#', $piece, $matches)) { |
184 | 202 | //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
185 | 203 | $type = $matches[1]; |
186 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
187 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
188 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
189 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
190 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
191 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
192 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
193 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
204 | + if ($type == 'SKC') { |
|
205 | + $cloud['type'] = 'No cloud/Sky clear'; |
|
206 | + } elseif ($type == 'CLR') { |
|
207 | + $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
208 | + } elseif ($type == 'NSC') { |
|
209 | + $cloud['type'] = 'No significant cloud'; |
|
210 | + } elseif ($type == 'FEW') { |
|
211 | + $cloud['type'] = 'Few'; |
|
212 | + } elseif ($type == 'SCT') { |
|
213 | + $cloud['type'] = 'Scattered'; |
|
214 | + } elseif ($type == 'BKN') { |
|
215 | + $cloud['type'] = 'Broken'; |
|
216 | + } elseif ($type == 'OVC') { |
|
217 | + $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
218 | + } elseif ($type == 'VV') { |
|
219 | + $cloud['type'] = 'Vertical visibility'; |
|
220 | + } |
|
194 | 221 | $cloud['type_code'] = $type; |
195 | 222 | $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
196 | 223 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
@@ -219,8 +246,11 @@ discard block |
||
219 | 246 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
220 | 247 | //echo $piece; |
221 | 248 | //print_r($matches); |
222 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
223 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
249 | + if (isset($matches[5])) { |
|
250 | + $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
251 | + } else { |
|
252 | + $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
253 | + } |
|
224 | 254 | if (isset($matches[3])) { |
225 | 255 | $range = Array( |
226 | 256 | 'from' => (float)$matches[2], |
@@ -253,8 +283,11 @@ discard block |
||
253 | 283 | if (isset($matches[3])) { |
254 | 284 | $text[] = $this->texts[$matches[3]]; |
255 | 285 | } |
256 | - if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
|
257 | - else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
286 | + if (!isset($result['weather'])) { |
|
287 | + $result['weather'] = implode(' ', $text); |
|
288 | + } else { |
|
289 | + $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
290 | + } |
|
258 | 291 | } |
259 | 292 | } |
260 | 293 | return $result; |
@@ -266,8 +299,11 @@ discard block |
||
266 | 299 | if (isset($globalMETARcycle) && $globalMETARcycle) { |
267 | 300 | $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
268 | 301 | } else { |
269 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
270 | - elseif ($globalDBdriver == 'pgsql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
302 | + if ($globalDBdriver == 'mysql') { |
|
303 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
304 | + } elseif ($globalDBdriver == 'pgsql') { |
|
305 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
306 | + } |
|
271 | 307 | } |
272 | 308 | $query_values = array(':icao' => $icao); |
273 | 309 | try { |
@@ -322,7 +358,9 @@ discard block |
||
322 | 358 | |
323 | 359 | public function addMETARCycle() { |
324 | 360 | global $globalDebug, $globalIVAO; |
325 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
361 | + if (isset($globalDebug) && $globalDebug) { |
|
362 | + echo "Downloading METAR cycle..."; |
|
363 | + } |
|
326 | 364 | date_default_timezone_set("UTC"); |
327 | 365 | $Common = new Common(); |
328 | 366 | if (isset($globalIVAO) && $globalIVAO) { |
@@ -330,7 +368,9 @@ discard block |
||
330 | 368 | } else { |
331 | 369 | $cycle = $Common->getData('http://weather.noaa.gov/pub/data/observations/metar/cycles/'.date('H').'Z.TXT'); |
332 | 370 | } |
333 | - if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
|
371 | + if (isset($globalDebug) && $globalDebug) { |
|
372 | + echo "Done - Updating DB..."; |
|
373 | + } |
|
334 | 374 | $date = ''; |
335 | 375 | foreach(explode("\n",$cycle) as $line) { |
336 | 376 | if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
@@ -339,22 +379,32 @@ discard block |
||
339 | 379 | } elseif ($line != '') { |
340 | 380 | //$this->parse($line); |
341 | 381 | //echo $line; |
342 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
382 | + if ($date == '') { |
|
383 | + $date = date('Y/m/d H:m'); |
|
384 | + } |
|
343 | 385 | $pos = 0; |
344 | 386 | $pieces = preg_split('/\s/',$line); |
345 | - if ($pieces[0] == 'METAR') $pos++; |
|
346 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
387 | + if ($pieces[0] == 'METAR') { |
|
388 | + $pos++; |
|
389 | + } |
|
390 | + if (strlen($pieces[$pos]) != 4) { |
|
391 | + $pos++; |
|
392 | + } |
|
347 | 393 | $location = $pieces[$pos]; |
348 | 394 | echo $this->addMETAR($location,$line,$date); |
349 | 395 | } |
350 | 396 | //echo $line."\n"; |
351 | 397 | } |
352 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
398 | + if (isset($globalDebug) && $globalDebug) { |
|
399 | + echo "Done\n"; |
|
400 | + } |
|
353 | 401 | |
354 | 402 | } |
355 | 403 | public function downloadMETAR($icao) { |
356 | 404 | global $globalMETARurl; |
357 | - if ($globalMETARurl == '') return array(); |
|
405 | + if ($globalMETARurl == '') { |
|
406 | + return array(); |
|
407 | + } |
|
358 | 408 | date_default_timezone_set("UTC"); |
359 | 409 | $Common = new Common(); |
360 | 410 | $url = str_replace('{icao}',$icao,$globalMETARurl); |
@@ -367,16 +417,24 @@ discard block |
||
367 | 417 | } elseif ($line != '') { |
368 | 418 | //$this->parse($line); |
369 | 419 | //echo $line; |
370 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
420 | + if ($date == '') { |
|
421 | + $date = date('Y/m/d H:m'); |
|
422 | + } |
|
371 | 423 | $pos = 0; |
372 | 424 | $pieces = preg_split('/\s/',$line); |
373 | - if ($pieces[0] == 'METAR') $pos++; |
|
374 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
425 | + if ($pieces[0] == 'METAR') { |
|
426 | + $pos++; |
|
427 | + } |
|
428 | + if (strlen($pieces[$pos]) != 4) { |
|
429 | + $pos++; |
|
430 | + } |
|
375 | 431 | $location = $pieces[$pos]; |
376 | 432 | if (strlen($location == 4)) { |
377 | 433 | $this->addMETAR($location,$line,$date); |
378 | 434 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
379 | - } else return array(); |
|
435 | + } else { |
|
436 | + return array(); |
|
437 | + } |
|
380 | 438 | } |
381 | 439 | //echo $line."\n"; |
382 | 440 | } |
@@ -26,23 +26,31 @@ discard block |
||
26 | 26 | $body_len = strlen($body); |
27 | 27 | $header = substr($input,0,$splitpos); |
28 | 28 | $header_len = strlen($header); |
29 | - if ($debug) echo 'header : '.$header."\n"; |
|
29 | + if ($debug) { |
|
30 | + echo 'header : '.$header."\n"; |
|
31 | + } |
|
30 | 32 | |
31 | 33 | /* Parse source, target and path. */ |
32 | 34 | //FLRDF0A52>APRS,qAS,LSTB |
33 | 35 | if (preg_match('/^([A-Z0-9\\-]{1,9})>(.*)$/',$header,$matches)) { |
34 | 36 | $ident = $matches[1]; |
35 | 37 | $all_elements = $matches[2]; |
36 | - if ($debug) echo 'ident : '.$ident."\n"; |
|
38 | + if ($debug) { |
|
39 | + echo 'ident : '.$ident."\n"; |
|
40 | + } |
|
37 | 41 | $result['ident'] = $ident; |
38 | - } else return false; |
|
42 | + } else { |
|
43 | + return false; |
|
44 | + } |
|
39 | 45 | $elements = explode(',',$all_elements); |
40 | 46 | $source = end($elements); |
41 | 47 | $result['source'] = $source; |
42 | 48 | foreach ($elements as $element) { |
43 | 49 | if (preg_match('/^([a-zA-Z0-9-]{1,9})([*]?)$/',$element)) { |
44 | 50 | //echo "ok"; |
45 | - if ($element == 'TCPIP*') return false; |
|
51 | + if ($element == 'TCPIP*') { |
|
52 | + return false; |
|
53 | + } |
|
46 | 54 | } elseif (preg_match('/^([0-9A-F]{32})$/',$element)) { |
47 | 55 | //echo "ok"; |
48 | 56 | } else { |
@@ -82,7 +90,9 @@ discard block |
||
82 | 90 | $symbol_table = $matches[4]; |
83 | 91 | $lat = intval($lat_deg); |
84 | 92 | $lon = intval($lon_deg); |
85 | - if ($lat > 89 || $lon > 179) return false; |
|
93 | + if ($lat > 89 || $lon > 179) { |
|
94 | + return false; |
|
95 | + } |
|
86 | 96 | |
87 | 97 | /* |
88 | 98 | $tmp_5b = str_replace('.','',$lat_min); |
@@ -92,8 +102,12 @@ discard block |
||
92 | 102 | */ |
93 | 103 | $latitude = $lat + floatval($lat_min)/60; |
94 | 104 | $longitude = $lon + floatval($lon_min)/60; |
95 | - if ($sind == 'S') $latitude = 0-$latitude; |
|
96 | - if ($wind == 'W') $longitude = 0-$longitude; |
|
105 | + if ($sind == 'S') { |
|
106 | + $latitude = 0-$latitude; |
|
107 | + } |
|
108 | + if ($wind == 'W') { |
|
109 | + $longitude = 0-$longitude; |
|
110 | + } |
|
97 | 111 | $result['latitude'] = $latitude; |
98 | 112 | $result['longitude'] = $longitude; |
99 | 113 | } |
@@ -108,7 +122,9 @@ discard block |
||
108 | 122 | if (preg_match('/^([0-9\\. ]{3})\\/([0-9\\. ]{3})/',$body_parse)) { |
109 | 123 | $course = substr($body_parse,0,3); |
110 | 124 | $tmp_s = intval($course); |
111 | - if ($tmp_s >= 1 && $tmp_s <= 360) $result['course'] = intval($course); |
|
125 | + if ($tmp_s >= 1 && $tmp_s <= 360) { |
|
126 | + $result['course'] = intval($course); |
|
127 | + } |
|
112 | 128 | $speed = substr($body_parse,4,3); |
113 | 129 | $result['speed'] = round($speed*1.852); |
114 | 130 | $body_parse = substr($body_parse,7); |
@@ -138,10 +154,16 @@ discard block |
||
138 | 154 | $lon_off = (($dao[2])-48.0)*0.001/60.0; |
139 | 155 | |
140 | 156 | } |
141 | - if ($result['latitude'] < 0) $result['latitude'] -= $lat_off; |
|
142 | - else $result['latitude'] += $lat_off; |
|
143 | - if ($result['longitude'] < 0) $result['longitude'] -= $lon_off; |
|
144 | - else $result['longitude'] += $lon_off; |
|
157 | + if ($result['latitude'] < 0) { |
|
158 | + $result['latitude'] -= $lat_off; |
|
159 | + } else { |
|
160 | + $result['latitude'] += $lat_off; |
|
161 | + } |
|
162 | + if ($result['longitude'] < 0) { |
|
163 | + $result['longitude'] -= $lon_off; |
|
164 | + } else { |
|
165 | + $result['longitude'] += $lon_off; |
|
166 | + } |
|
145 | 167 | $body_parse = substr($body_parse,6); |
146 | 168 | } |
147 | 169 | |
@@ -153,27 +175,48 @@ discard block |
||
153 | 175 | $address = substr($id,2); |
154 | 176 | //print_r($matches); |
155 | 177 | $addressType = (intval(substr($id,0,2),16))&3; |
156 | - if ($addressType == 0) $result['addresstype'] = "RANDOM"; |
|
157 | - elseif ($addressType == 1) $result['addresstype'] = "ICAO"; |
|
158 | - elseif ($addressType == 2) $result['addresstype'] = "FLARM"; |
|
159 | - elseif ($addressType == 3) $result['addresstype'] = "OGN"; |
|
178 | + if ($addressType == 0) { |
|
179 | + $result['addresstype'] = "RANDOM"; |
|
180 | + } elseif ($addressType == 1) { |
|
181 | + $result['addresstype'] = "ICAO"; |
|
182 | + } elseif ($addressType == 2) { |
|
183 | + $result['addresstype'] = "FLARM"; |
|
184 | + } elseif ($addressType == 3) { |
|
185 | + $result['addresstype'] = "OGN"; |
|
186 | + } |
|
160 | 187 | $aircraftType = $this->urshift(((intval(substr($id,0,2),16)) & 0b1111100),2); |
161 | 188 | $result['aircrafttype_code'] = $aircraftType; |
162 | - if ($aircraftType == 0) $result['aircrafttype'] = "UNKNOWN"; |
|
163 | - elseif ($aircraftType == 1) $result['aircrafttype'] = "GLIDER"; |
|
164 | - elseif ($aircraftType == 2) $result['aircrafttype'] = "TOW_PLANE"; |
|
165 | - elseif ($aircraftType == 3) $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
166 | - elseif ($aircraftType == 4) $result['aircrafttype'] = "PARACHUTE"; |
|
167 | - elseif ($aircraftType == 5) $result['aircrafttype'] = "DROP_PLANE"; |
|
168 | - elseif ($aircraftType == 6) $result['aircrafttype'] = "HANG_GLIDER"; |
|
169 | - elseif ($aircraftType == 7) $result['aircrafttype'] = "PARA_GLIDER"; |
|
170 | - elseif ($aircraftType == 8) $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
171 | - elseif ($aircraftType == 9) $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
172 | - elseif ($aircraftType == 10) $result['aircrafttype'] = "UFO"; |
|
173 | - elseif ($aircraftType == 11) $result['aircrafttype'] = "BALLOON"; |
|
174 | - elseif ($aircraftType == 12) $result['aircrafttype'] = "AIRSHIP"; |
|
175 | - elseif ($aircraftType == 13) $result['aircrafttype'] = "UAV"; |
|
176 | - elseif ($aircraftType == 15) $result['aircrafttype'] = "STATIC_OBJECT"; |
|
189 | + if ($aircraftType == 0) { |
|
190 | + $result['aircrafttype'] = "UNKNOWN"; |
|
191 | + } elseif ($aircraftType == 1) { |
|
192 | + $result['aircrafttype'] = "GLIDER"; |
|
193 | + } elseif ($aircraftType == 2) { |
|
194 | + $result['aircrafttype'] = "TOW_PLANE"; |
|
195 | + } elseif ($aircraftType == 3) { |
|
196 | + $result['aircrafttype'] = "HELICOPTER_ROTORCRAFT"; |
|
197 | + } elseif ($aircraftType == 4) { |
|
198 | + $result['aircrafttype'] = "PARACHUTE"; |
|
199 | + } elseif ($aircraftType == 5) { |
|
200 | + $result['aircrafttype'] = "DROP_PLANE"; |
|
201 | + } elseif ($aircraftType == 6) { |
|
202 | + $result['aircrafttype'] = "HANG_GLIDER"; |
|
203 | + } elseif ($aircraftType == 7) { |
|
204 | + $result['aircrafttype'] = "PARA_GLIDER"; |
|
205 | + } elseif ($aircraftType == 8) { |
|
206 | + $result['aircrafttype'] = "POWERED_AIRCRAFT"; |
|
207 | + } elseif ($aircraftType == 9) { |
|
208 | + $result['aircrafttype'] = "JET_AIRCRAFT"; |
|
209 | + } elseif ($aircraftType == 10) { |
|
210 | + $result['aircrafttype'] = "UFO"; |
|
211 | + } elseif ($aircraftType == 11) { |
|
212 | + $result['aircrafttype'] = "BALLOON"; |
|
213 | + } elseif ($aircraftType == 12) { |
|
214 | + $result['aircrafttype'] = "AIRSHIP"; |
|
215 | + } elseif ($aircraftType == 13) { |
|
216 | + $result['aircrafttype'] = "UAV"; |
|
217 | + } elseif ($aircraftType == 15) { |
|
218 | + $result['aircrafttype'] = "STATIC_OBJECT"; |
|
219 | + } |
|
177 | 220 | $stealth = (intval(substr($id,0,2), 16) & 0b10000000) != 0; |
178 | 221 | $result['stealth'] = $stealth; |
179 | 222 | $result['address'] = $address; |
@@ -215,8 +258,12 @@ discard block |
||
215 | 258 | } |
216 | 259 | } |
217 | 260 | } |
218 | - if (isset($result['latitude'])) $result['latitude'] = round($result['latitude'],4); |
|
219 | - if (isset($result['longitude'])) $result['longitude'] = round($result['longitude'],4); |
|
261 | + if (isset($result['latitude'])) { |
|
262 | + $result['latitude'] = round($result['latitude'],4); |
|
263 | + } |
|
264 | + if (isset($result['longitude'])) { |
|
265 | + $result['longitude'] = round($result['longitude'],4); |
|
266 | + } |
|
220 | 267 | //print_r($result); |
221 | 268 | return $result; |
222 | 269 | } |
@@ -126,7 +126,9 @@ discard block |
||
126 | 126 | $row = $sth->fetch(PDO::FETCH_ASSOC); |
127 | 127 | if (count($row) > 0) { |
128 | 128 | return $row; |
129 | - } else return array(); |
|
129 | + } else { |
|
130 | + return array(); |
|
131 | + } |
|
130 | 132 | } |
131 | 133 | |
132 | 134 | public function checkSchedule($ident) { |
@@ -161,7 +163,9 @@ discard block |
||
161 | 163 | $Common = new Common(); |
162 | 164 | $check_date = new Datetime($date); |
163 | 165 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
164 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
166 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
167 | + return array(); |
|
168 | + } |
|
165 | 169 | $url = "http://www.airfrance.fr/cgi-bin/AF/FR/fr/local/resainfovol/infovols/detailsVolJson.do?codeCompagnie[0]=".$carrier."&numeroVol[0]=".$numvol."&dayFlightDate=".$check_date->format('d')."&yearMonthFlightDate=".$check_date->format('Ym'); |
166 | 170 | $json = $Common->getData($url); |
167 | 171 | |
@@ -188,7 +192,9 @@ discard block |
||
188 | 192 | */ |
189 | 193 | |
190 | 194 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airfrance'); |
191 | - } else return array(); |
|
195 | + } else { |
|
196 | + return array(); |
|
197 | + } |
|
192 | 198 | } |
193 | 199 | |
194 | 200 | /** |
@@ -203,7 +209,9 @@ discard block |
||
203 | 209 | date_default_timezone_set($globalTimezone); |
204 | 210 | $check_date = new Datetime($date); |
205 | 211 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
206 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
212 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
213 | + return array(); |
|
214 | + } |
|
207 | 215 | $url = "http://www.easyjet.com/ft/api/flights?date=".$check_date->format('Y-m-d')."&fn=".$callsign; |
208 | 216 | $json = $Common->getData($url); |
209 | 217 | $parsed_json = json_decode($json); |
@@ -216,7 +224,9 @@ discard block |
||
216 | 224 | $arrivalTime = $parsed_json->{'flights'}[0]->{'dates'}->{'fsta'}; |
217 | 225 | |
218 | 226 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_easyjet'); |
219 | - } else return array(); |
|
227 | + } else { |
|
228 | + return array(); |
|
229 | + } |
|
220 | 230 | } |
221 | 231 | |
222 | 232 | /** |
@@ -227,7 +237,9 @@ discard block |
||
227 | 237 | private function getRyanair($callsign) { |
228 | 238 | $Common = new Common(); |
229 | 239 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
230 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
240 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
241 | + return array(); |
|
242 | + } |
|
231 | 243 | $url = "http://www.ryanair.com/fr/api/2/flight-info/0/50/"; |
232 | 244 | $post = '{"flight":"'.$numvol.'","minDepartureTime":"00:00","maxDepartureTime":"23:59"}'; |
233 | 245 | $headers = array('Content-Type: application/json','Content-Length: ' . strlen($post)); |
@@ -241,8 +253,12 @@ discard block |
||
241 | 253 | $departureTime = $parsed_json->{'flightInfo'}[0]->{'departureTime'}; |
242 | 254 | $arrivalTime = $parsed_json->{'flightInfo'}[0]->{'arrivalTime'}; |
243 | 255 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime, 'Source' => 'website_ryanair'); |
244 | - } else return array(); |
|
245 | - } else return array(); |
|
256 | + } else { |
|
257 | + return array(); |
|
258 | + } |
|
259 | + } else { |
|
260 | + return array(); |
|
261 | + } |
|
246 | 262 | } |
247 | 263 | |
248 | 264 | /** |
@@ -253,7 +269,9 @@ discard block |
||
253 | 269 | private function getSwiss($callsign) { |
254 | 270 | $Common = new Common(); |
255 | 271 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
256 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
272 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
273 | + return array(); |
|
274 | + } |
|
257 | 275 | $url = "http://www.world-of-swiss.com/fr/routenetwork.json"; |
258 | 276 | $json = $Common->getData($url); |
259 | 277 | $parsed_json = json_decode($json); |
@@ -271,8 +289,12 @@ discard block |
||
271 | 289 | } |
272 | 290 | if (isset($DepartureAirportIata)) { |
273 | 291 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_swiss'); |
274 | - } else return array(); |
|
275 | - } else return array(); |
|
292 | + } else { |
|
293 | + return array(); |
|
294 | + } |
|
295 | + } else { |
|
296 | + return array(); |
|
297 | + } |
|
276 | 298 | } |
277 | 299 | |
278 | 300 | /** |
@@ -286,12 +308,18 @@ discard block |
||
286 | 308 | $Common = new Common(); |
287 | 309 | $check_date = new Datetime($date); |
288 | 310 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
289 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
290 | - if ($globalBritishAirwaysKey == '') return array(); |
|
311 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
312 | + return array(); |
|
313 | + } |
|
314 | + if ($globalBritishAirwaysKey == '') { |
|
315 | + return array(); |
|
316 | + } |
|
291 | 317 | $url = "https://api.ba.com/rest-v1/v1/flights;flightNumber=".$numvol.";scheduledDepartureDate=".$check_date->format('Y-m-d').".json"; |
292 | 318 | $headers = array('Client-Key: '.$globalBritishAirwaysKey); |
293 | 319 | $json = $Common->getData($url,'get','',$headers); |
294 | - if ($json == '') return array(); |
|
320 | + if ($json == '') { |
|
321 | + return array(); |
|
322 | + } |
|
295 | 323 | $parsed_json = json_decode($json); |
296 | 324 | $flights = $parsed_json->{'FlightsResponse'}; |
297 | 325 | if (count($flights) > 0) { |
@@ -300,7 +328,9 @@ discard block |
||
300 | 328 | $departureTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledDepartureDateTime'})); |
301 | 329 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightsResponse'}->{'Flight'}->{'Sector'}->{'ScheduledArrivalDateTime'})); |
302 | 330 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_britishairways'); |
303 | - } else return array(); |
|
331 | + } else { |
|
332 | + return array(); |
|
333 | + } |
|
304 | 334 | } |
305 | 335 | |
306 | 336 | /** |
@@ -314,19 +344,27 @@ discard block |
||
314 | 344 | $Common = new Common(); |
315 | 345 | $check_date = new Datetime($date); |
316 | 346 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
317 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
318 | - if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') return array(); |
|
347 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
348 | + return array(); |
|
349 | + } |
|
350 | + if (!isset($globalLufthansaKey) || $globalLufthansaKey == '' || !isset($globalLufthansaKey['key']) || $globalLufthansaKey['key'] == '') { |
|
351 | + return array(); |
|
352 | + } |
|
319 | 353 | $url = "https://api.lufthansa.com/v1/oauth/token"; |
320 | 354 | $post = array('client_id' => $globalLufthansaKey['key'],'client_secret' => $globalLufthansaKey['secret'],'grant_type' => 'client_credentials'); |
321 | 355 | $data = $Common->getData($url,'post',$post); |
322 | 356 | $parsed_data = json_decode($data); |
323 | - if (!isset($parsed_data->{'access_token'})) return array(); |
|
357 | + if (!isset($parsed_data->{'access_token'})) { |
|
358 | + return array(); |
|
359 | + } |
|
324 | 360 | $token = $parsed_data->{'access_token'}; |
325 | 361 | |
326 | 362 | $url = "https://api.lufthansa.com/v1/operations/flightstatus/LH".$numvol."/".$check_date->format('Y-m-d'); |
327 | 363 | $headers = array('Authorization: Bearer '.$token,'Accept: application/json'); |
328 | 364 | $json = $Common->getData($url,'get','',$headers); |
329 | - if ($json == '') return array(); |
|
365 | + if ($json == '') { |
|
366 | + return array(); |
|
367 | + } |
|
330 | 368 | $parsed_json = json_decode($json); |
331 | 369 | if (isset($parsed_json->{'FlightStatusResource'}) && count($parsed_json->{'FlightStatusResource'}) > 0) { |
332 | 370 | $DepartureAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Departure'}->{'AirportCode'}; |
@@ -334,7 +372,9 @@ discard block |
||
334 | 372 | $ArrivalAirportIata = $parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'AirportCode'}; |
335 | 373 | $arrivalTime = date('H:i',strtotime($parsed_json->{'FlightStatusResource'}->{'Flights'}->{'Flight'}->{'Arrival'}->{'ScheduledTimeLocal'}->{'DateTime'})); |
336 | 374 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_lufthansa'); |
337 | - } else return array(); |
|
375 | + } else { |
|
376 | + return array(); |
|
377 | + } |
|
338 | 378 | } |
339 | 379 | |
340 | 380 | /** |
@@ -348,12 +388,18 @@ discard block |
||
348 | 388 | $Common = new Common(); |
349 | 389 | $check_date = new Datetime($date); |
350 | 390 | $numvol = sprintf('%04d',preg_replace('/^[A-Z]*/','',$callsign)); |
351 | - if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) return array(); |
|
352 | - if ($globalTransaviaKey == '') return array(); |
|
391 | + if (!filter_var(preg_replace('/^[A-Z]*/','',$callsign),FILTER_VALIDATE_INT)) { |
|
392 | + return array(); |
|
393 | + } |
|
394 | + if ($globalTransaviaKey == '') { |
|
395 | + return array(); |
|
396 | + } |
|
353 | 397 | $url = "https://tst.api.transavia.com/v1/flightstatus/departuredate/".$check_date->format('Ymd').'/flightnumber/HV'.$numvol; |
354 | 398 | $headers = array('apikey: '.$globalTransaviaKey); |
355 | 399 | $json = $Common->getData($url,'get','',$headers); |
356 | - if ($json == '') return array(); |
|
400 | + if ($json == '') { |
|
401 | + return array(); |
|
402 | + } |
|
357 | 403 | $parsed_json = json_decode($json); |
358 | 404 | |
359 | 405 | if (isset($parsed_json->{'data'}[0])) { |
@@ -362,7 +408,9 @@ discard block |
||
362 | 408 | $ArrivalAirportIata = $parsed_json->{'data'}[0]->{'flight'}->{'arrivalAirport'}->{'locationCode'}; |
363 | 409 | $arrivalTime = date('H:i',strtotime($parsed_json->{'data'}[0]->{'flight'}->{'arrivalDateTime'})); |
364 | 410 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_transavia'); |
365 | - } else return array(); |
|
411 | + } else { |
|
412 | + return array(); |
|
413 | + } |
|
366 | 414 | } |
367 | 415 | |
368 | 416 | /** |
@@ -373,7 +421,9 @@ discard block |
||
373 | 421 | private function getTunisair($callsign) { |
374 | 422 | $Common = new Common(); |
375 | 423 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
376 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
424 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
425 | + return array(); |
|
426 | + } |
|
377 | 427 | $url = "http://www.tunisair.com/site/publish/module/Volj/fr/Flight_List.asp"; |
378 | 428 | $data = $Common->getData($url); |
379 | 429 | $table = $Common->table2array($data); |
@@ -393,7 +443,9 @@ discard block |
||
393 | 443 | private function getVueling($callsign) { |
394 | 444 | $Common = new Common(); |
395 | 445 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
396 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
446 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
447 | + return array(); |
|
448 | + } |
|
397 | 449 | $url = "https://www.vueling.com/Base/BaseProxy/RenderMacro/?macroalias=DailyFlights&OriginSelected=&DestinationSelected=&idioma=en-GB&pageid=30694&ItemsByPage=50&FlightNumberFilter=".$numvol; |
398 | 450 | $data = $Common->getData($url); |
399 | 451 | if ($data != '') { |
@@ -421,7 +473,9 @@ discard block |
||
421 | 473 | $Common = new Common(); |
422 | 474 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
423 | 475 | $check_date = new Datetime($date); |
424 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
476 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
477 | + return array(); |
|
478 | + } |
|
425 | 479 | $url = "https://www.iberia.com/web/flightDetail.do"; |
426 | 480 | $post = array('numvuelo' => $numvol,'fecha' => $check_date->format('Ymd'),'airlineID' => 'IB'); |
427 | 481 | $data = $Common->getData($url,'post',$post); |
@@ -438,7 +492,9 @@ discard block |
||
438 | 492 | $arrivalTime = trim(str_replace(' lunes','',str_replace(' ','',$flight[5][1]))); |
439 | 493 | if ($arrivalTime == 'Hora estimada de llegada') { |
440 | 494 | $arrivalTime = substr(trim(str_replace(' lunes','',str_replace(' ','',$flight[5][2]))),0,5); |
441 | - } else $arrivalTime = substr($arrivalTime,0,5); |
|
495 | + } else { |
|
496 | + $arrivalTime = substr($arrivalTime,0,5); |
|
497 | + } |
|
442 | 498 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_iberia'); |
443 | 499 | } |
444 | 500 | } |
@@ -455,7 +511,9 @@ discard block |
||
455 | 511 | $Common = new Common(); |
456 | 512 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
457 | 513 | $check_date = new Datetime($date); |
458 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
514 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
515 | + return array(); |
|
516 | + } |
|
459 | 517 | $url = "http://www.staralliance.com/flifoQueryAction.do?myAirline=&airlineCode=".$carrier."&flightNo=".$numvol."&day=".$check_date->format('d')."&month=".$check_date->format('m')."&year=".$check_date->format('Y')."&departuredate=".$check_date->format('d-M-Y'); |
460 | 518 | $data = $Common->getData($url); |
461 | 519 | if ($data != '') { |
@@ -471,7 +529,9 @@ discard block |
||
471 | 529 | $departureTime = substr(trim(str_replace('Scheduled: ','',$flight[29][0])),0,5); |
472 | 530 | $arrivalTime = substr(trim(str_replace('Scheduled: ','',$flight[29][1])),0,5); |
473 | 531 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_staralliance'); |
474 | - } else return array(); |
|
532 | + } else { |
|
533 | + return array(); |
|
534 | + } |
|
475 | 535 | } |
476 | 536 | |
477 | 537 | |
@@ -490,7 +550,9 @@ discard block |
||
490 | 550 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
491 | 551 | $check_date = new Datetime($date); |
492 | 552 | $url= "http://booking.alitalia.com/FlightStatus/fr_fr/FlightInfo?Brand=az&NumeroVolo=".$numvol."&DataCompleta=".$check_date->format('d/m/Y'); |
493 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
553 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
554 | + return array(); |
|
555 | + } |
|
494 | 556 | $data = $Common->getData($url); |
495 | 557 | if ($data != '') { |
496 | 558 | $table = $Common->text2array($data); |
@@ -514,7 +576,9 @@ discard block |
||
514 | 576 | $check_date = new Datetime($date); |
515 | 577 | $url= "http://www.brusselsairlines.com/api/flightstatus/getresults?from=NA&to=NA&date=".$check_date->format('d/m/Y')."&hour=NA&lookup=flightnumber&flightnumber=".$numvol."&publicationID=302"; |
516 | 578 | //http://www.brusselsairlines.com/fr-fr/informations-pratiques/statut-de-votre-vol/resultat.aspx?flightnumber=".$numvol."&date=".$check_date->format('d/m/Y')."&lookup=flightnumber"; |
517 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
579 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
580 | + return array(); |
|
581 | + } |
|
518 | 582 | $data = $Common->getData($url); |
519 | 583 | if ($data != '') { |
520 | 584 | //echo $data; |
@@ -605,7 +669,9 @@ discard block |
||
605 | 669 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
606 | 670 | $url= "http://www.flytap.com/France/fr/PlanifierEtReserver/Outils/DepartsEtArrivees"; |
607 | 671 | $check_date = new Datetime($date); |
608 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
672 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
673 | + return array(); |
|
674 | + } |
|
609 | 675 | $post = array('arrivalsdepartures_content' => 'number','arrivalsdepartures_tp' => $numvol,'arrivalsdepartures_trk' => 'ARR','arrivalsdepartures_date_trk' => '1','aptCode' => '','arrivalsdepartures' => 'DEP','arrivalsdepartures_date' => '1','aptCodeFrom' => '','aptCodeTo' => '','arrivalsdepartures2' => 'DEP','arrivalsdepartures_date2' => '1'); |
610 | 676 | $data = $Common->getData($url,'post',$post); |
611 | 677 | if ($data != '') { |
@@ -640,7 +706,9 @@ discard block |
||
640 | 706 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
641 | 707 | $url= "http://info.flightmapper.net/flight/".$airline_icao.'_'.$numvol; |
642 | 708 | $check_date = new Datetime($date); |
643 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
709 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
710 | + return array(); |
|
711 | + } |
|
644 | 712 | $data = $Common->getData($url); |
645 | 713 | if ($data != '') { |
646 | 714 | $table = $Common->table2array($data); |
@@ -678,7 +746,9 @@ discard block |
||
678 | 746 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
679 | 747 | $url= "http://fr.flightaware.com/live/flight/".$callsign; |
680 | 748 | $check_date = new Datetime($date); |
681 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
749 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
750 | + return array(); |
|
751 | + } |
|
682 | 752 | $data = $Common->getData($url); |
683 | 753 | if ($data != '') { |
684 | 754 | $table = $Common->table2array($data); |
@@ -732,11 +802,15 @@ discard block |
||
732 | 802 | $check_date = new Datetime($date); |
733 | 803 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
734 | 804 | $url= "http://services.aircanada.com/portal/rest/getFlightsByFlightNumber?forceTimetable=true&flightNumber=".$numvol."&carrierCode=AC&date=".$check_date->format('m-d-Y')."&app_key=AE919FDCC80311DF9BABC975DFD72085&cache=74249"; |
735 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
805 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
806 | + return array(); |
|
807 | + } |
|
736 | 808 | $data = $Common->getData($url); |
737 | 809 | $dom = new DomDocument(); |
738 | 810 | $dom->loadXML($data); |
739 | - if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) return array(); |
|
811 | + if ($dom->getElementsByTagName('DepartureStationInfo')->length == 0) { |
|
812 | + return array(); |
|
813 | + } |
|
740 | 814 | $departure = $dom->getElementsByTagName('DepartureStationInfo')->item(0); |
741 | 815 | if (isset($departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue)) { |
742 | 816 | $DepartureAirportIata = $departure->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
@@ -745,7 +819,9 @@ discard block |
||
745 | 819 | $ArrivalAirportIata = $arrival->getElementsByTagName('Airport')->item(0)->firstChild->nodeValue; |
746 | 820 | $arrivalTime = date('H:i',strtotime($arrival->getElementsByTagName('ScheduledTime')->item(0)->firstChild->nodeValue)); |
747 | 821 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_aircanada'); |
748 | - } else return array(); |
|
822 | + } else { |
|
823 | + return array(); |
|
824 | + } |
|
749 | 825 | } |
750 | 826 | |
751 | 827 | /** |
@@ -759,7 +835,9 @@ discard block |
||
759 | 835 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
760 | 836 | $check_date = new Datetime($date); |
761 | 837 | $url= "https://cat.sabresonicweb.com/SSWVN/meridia?posid=VNVN&page=flifoFlightInfoDetailsMessage_learn&action=flightInfoDetails&airline=VN&language=fr&depDay=".$check_date->format('j')."&depMonth=".strtoupper($check_date->format('M'))."&=&flight=".$numvol."&"; |
762 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
838 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
839 | + return array(); |
|
840 | + } |
|
763 | 841 | $data = $Common->getData($url); |
764 | 842 | if ($data != '') { |
765 | 843 | $table = $Common->table2array($data); |
@@ -788,7 +866,9 @@ discard block |
||
788 | 866 | $numvol = preg_replace('/^[A-Z]*/','',$callsign); |
789 | 867 | $check_date = new Datetime($date); |
790 | 868 | $url= "http://www.airberlin.com/en-US/site/aims.php"; |
791 | - if (!filter_var($numvol,FILTER_VALIDATE_INT)) return array(); |
|
869 | + if (!filter_var($numvol,FILTER_VALIDATE_INT)) { |
|
870 | + return array(); |
|
871 | + } |
|
792 | 872 | $post = array('type' => 'departure','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
793 | 873 | $data = $Common->getData($url,'post',$post); |
794 | 874 | //echo $data; |
@@ -798,10 +878,16 @@ discard block |
||
798 | 878 | if ($data != '') { |
799 | 879 | $table = $Common->table2array($data); |
800 | 880 | $flight = $table; |
801 | - if (isset($flight[5][4])) $departureTime = $flight[5][4]; |
|
802 | - else $departureTime = ''; |
|
803 | - if (isset($flight[5][2])) $departureAirport = $flight[5][2]; |
|
804 | - else $departureAirport = ''; |
|
881 | + if (isset($flight[5][4])) { |
|
882 | + $departureTime = $flight[5][4]; |
|
883 | + } else { |
|
884 | + $departureTime = ''; |
|
885 | + } |
|
886 | + if (isset($flight[5][2])) { |
|
887 | + $departureAirport = $flight[5][2]; |
|
888 | + } else { |
|
889 | + $departureAirport = ''; |
|
890 | + } |
|
805 | 891 | } |
806 | 892 | $post = array('type' => 'arrival','searchFlightNo' => '1','requestsent' => 'true', 'flightno' => $numvol,'date' => $check_date->format('Y-m-d'),'carrier' => 'AB'); |
807 | 893 | $data = $Common->getData($url,'post',$post); |
@@ -818,7 +904,9 @@ discard block |
||
818 | 904 | } |
819 | 905 | $url = 'http://www.airberlin.com/en-US/site/json/suggestAirport.php?searchfor=departures&searchflightid=0&departures%5B%5D=&suggestsource%5B0%5D=activeairports&withcountries=0&withoutroutings=0&promotion%5Bid%5D=&promotion%5Btype%5D=&routesource%5B0%5D=airberlin&routesource%5B1%5D=partner'; |
820 | 906 | $json = $Common->getData($url); |
821 | - if ($json == '') return array(); |
|
907 | + if ($json == '') { |
|
908 | + return array(); |
|
909 | + } |
|
822 | 910 | $parsed_json = json_decode($json); |
823 | 911 | $airports = $parsed_json->{'suggestList'}; |
824 | 912 | if (count($airports) > 0) { |
@@ -833,7 +921,9 @@ discard block |
||
833 | 921 | } |
834 | 922 | if (isset($DepartureAirportIata)) { |
835 | 923 | return array('DepartureAirportIATA' => $DepartureAirportIata,'DepartureTime' => $departureTime,'ArrivalAirportIATA' => $ArrivalAirportIata,'ArrivalTime' => $arrivalTime,'Source' => 'website_airberlin'); |
836 | - } else return array(); |
|
924 | + } else { |
|
925 | + return array(); |
|
926 | + } |
|
837 | 927 | } |
838 | 928 | |
839 | 929 | |
@@ -841,7 +931,9 @@ discard block |
||
841 | 931 | public function fetchSchedule($ident,$date = 'NOW') { |
842 | 932 | global $globalSchedulesSources, $globalSchedulesFetch; |
843 | 933 | $Common = new Common(); |
844 | - if (!$globalSchedulesFetch) return array(); |
|
934 | + if (!$globalSchedulesFetch) { |
|
935 | + return array(); |
|
936 | + } |
|
845 | 937 | $airline_icao = ''; |
846 | 938 | if (!is_numeric(substr($ident, 0, 3))) |
847 | 939 | { |
@@ -1083,14 +1175,21 @@ discard block |
||
1083 | 1175 | default: |
1084 | 1176 | // Randomly use a generic function to get hours |
1085 | 1177 | if (strlen($airline_icao) == 2) { |
1086 | - if (!isset($globalSchedulesSources)) $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1178 | + if (!isset($globalSchedulesSources)) { |
|
1179 | + $globalSchedulesSources = array('flightmapper','costtotravel','flightradar24','flightaware'); |
|
1180 | + } |
|
1087 | 1181 | if (count($globalSchedulesSources) > 0) { |
1088 | 1182 | $rand = mt_rand(0,count($globalSchedulesSources)-1); |
1089 | 1183 | $source = $globalSchedulesSources[$rand]; |
1090 | - if ($source == 'flightmapper') return $this->getFlightMapper($ident,$date); |
|
1091 | - elseif ($source == 'costtotravel') return $this->getCostToTravel($ident,$date); |
|
1184 | + if ($source == 'flightmapper') { |
|
1185 | + return $this->getFlightMapper($ident,$date); |
|
1186 | + } elseif ($source == 'costtotravel') { |
|
1187 | + return $this->getCostToTravel($ident,$date); |
|
1188 | + } |
|
1092 | 1189 | //elseif ($source == 'flightradar24') return $this->getFlightRadar24($ident,$date); |
1093 | - elseif ($source == 'flightaware') return $this->getFlightAware($ident,$date); |
|
1190 | + elseif ($source == 'flightaware') { |
|
1191 | + return $this->getFlightAware($ident,$date); |
|
1192 | + } |
|
1094 | 1193 | } |
1095 | 1194 | } |
1096 | 1195 | } |