@@ -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,10 +88,16 @@ 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 | - if ($html === false) return array(); |
|
| 98 | + if ($html === false) { |
|
| 99 | + return array(); |
|
| 100 | + } |
|
| 91 | 101 | $tabledata=array(); |
| 92 | 102 | foreach($html->find('tr') as $element) |
| 93 | 103 | { |
@@ -122,7 +132,9 @@ discard block |
||
| 122 | 132 | */ |
| 123 | 133 | public function text2array($data) { |
| 124 | 134 | $html = str_get_html($data); |
| 125 | - if ($html === false) return array(); |
|
| 135 | + if ($html === false) { |
|
| 136 | + return array(); |
|
| 137 | + } |
|
| 126 | 138 | $tabledata=array(); |
| 127 | 139 | foreach($html->find('p') as $element) |
| 128 | 140 | { |
@@ -143,7 +155,9 @@ discard block |
||
| 143 | 155 | * @return Float Distance in $unit |
| 144 | 156 | */ |
| 145 | 157 | public function distance($lat, $lon, $latc, $lonc, $unit = 'km') { |
| 146 | - if ($lat == $latc && $lon == $lonc) return 0; |
|
| 158 | + if ($lat == $latc && $lon == $lonc) { |
|
| 159 | + return 0; |
|
| 160 | + } |
|
| 147 | 161 | $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; |
| 148 | 162 | if ($unit == "km") { |
| 149 | 163 | return round($dist * 1.609344); |
@@ -167,10 +181,16 @@ discard block |
||
| 167 | 181 | public function withinThreshold ($timeDifference, $distance) { |
| 168 | 182 | $x = abs($timeDifference); |
| 169 | 183 | $d = abs($distance); |
| 170 | - if ($x == 0 || $d == 0) return true; |
|
| 184 | + if ($x == 0 || $d == 0) { |
|
| 185 | + return true; |
|
| 186 | + } |
|
| 171 | 187 | // may be due to Internet jitter; distance is realistic |
| 172 | - if ($x < 0.7 && $d < 2000) return true; |
|
| 173 | - else return $d/$x < 1500*0.27778; // 1500 km/h max |
|
| 188 | + if ($x < 0.7 && $d < 2000) { |
|
| 189 | + return true; |
|
| 190 | + } else { |
|
| 191 | + return $d/$x < 1500*0.27778; |
|
| 192 | + } |
|
| 193 | + // 1500 km/h max |
|
| 174 | 194 | } |
| 175 | 195 | |
| 176 | 196 | |
@@ -230,7 +250,9 @@ discard block |
||
| 230 | 250 | public function hex2str($hex) { |
| 231 | 251 | $str = ''; |
| 232 | 252 | $hexln = strlen($hex); |
| 233 | - for($i=0;$i<$hexln;$i+=2) $str .= chr(hexdec(substr($hex,$i,2))); |
|
| 253 | + for($i=0;$i<$hexln;$i+=2) { |
|
| 254 | + $str .= chr(hexdec(substr($hex,$i,2))); |
|
| 255 | + } |
|
| 234 | 256 | return $str; |
| 235 | 257 | } |
| 236 | 258 | |
@@ -258,8 +280,11 @@ discard block |
||
| 258 | 280 | $b = $lat2 - $lat1; |
| 259 | 281 | $c = -($a*$lat1+$b*$lon1); |
| 260 | 282 | $d = $a*$lat3+$b*$lon3+$c; |
| 261 | - if ($d > -$approx && $d < $approx) return true; |
|
| 262 | - else return false; |
|
| 283 | + if ($d > -$approx && $d < $approx) { |
|
| 284 | + return true; |
|
| 285 | + } else { |
|
| 286 | + return false; |
|
| 287 | + } |
|
| 263 | 288 | } |
| 264 | 289 | |
| 265 | 290 | public function array_merge_noappend() { |
@@ -285,7 +310,9 @@ discard block |
||
| 285 | 310 | return $result; |
| 286 | 311 | } |
| 287 | 312 | $handle = @opendir('./locale'); |
| 288 | - if ($handle === false) return $result; |
|
| 313 | + if ($handle === false) { |
|
| 314 | + return $result; |
|
| 315 | + } |
|
| 289 | 316 | while (false !== ($file = readdir($handle))) { |
| 290 | 317 | $path = './locale'.'/'.$file.'/LC_MESSAGES/fam.mo'; |
| 291 | 318 | if ($file != "." && $file != ".." && @file_exists($path)) { |
@@ -18,21 +18,40 @@ discard block |
||
| 18 | 18 | } |
| 19 | 19 | header('Content-Type: text/javascript'); |
| 20 | 20 | |
| 21 | -if (!isset($globalJsonCompress)) $compress = true; |
|
| 22 | -else $compress = $globalJsonCompress; |
|
| 21 | +if (!isset($globalJsonCompress)) { |
|
| 22 | + $compress = true; |
|
| 23 | +} else { |
|
| 24 | + $compress = $globalJsonCompress; |
|
| 25 | +} |
|
| 23 | 26 | |
| 24 | 27 | $from_archive = false; |
| 25 | 28 | $min = false; |
| 26 | 29 | $allhistory = false; |
| 27 | 30 | $filter['source'] = array(); |
| 28 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 29 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 30 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 31 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs')); |
|
| 32 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 33 | -if (isset($_COOKIE['Airlines']) && $_COOKIE['Airlines'] != '') $filter['airlines'] = explode(',',$_COOKIE['Airlines']); |
|
| 34 | -if (isset($_COOKIE['Sources']) && $_COOKIE['Sources'] != '') $filter['source_aprs'] = explode(',',$_COOKIE['Sources']); |
|
| 35 | -if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] != 'all') $filter['airlinestype'] = $_COOKIE['airlinestype']; |
|
| 31 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') { |
|
| 32 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 33 | +} |
|
| 34 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') { |
|
| 35 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 36 | +} |
|
| 37 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') { |
|
| 38 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 39 | +} |
|
| 40 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') { |
|
| 41 | + $filter['source'] = array_merge($filter['source'],array('sbs')); |
|
| 42 | +} |
|
| 43 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') { |
|
| 44 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 45 | +} |
|
| 46 | +if (isset($_COOKIE['Airlines']) && $_COOKIE['Airlines'] != '') { |
|
| 47 | + $filter['airlines'] = explode(',',$_COOKIE['Airlines']); |
|
| 48 | +} |
|
| 49 | +if (isset($_COOKIE['Sources']) && $_COOKIE['Sources'] != '') { |
|
| 50 | + $filter['source_aprs'] = explode(',',$_COOKIE['Sources']); |
|
| 51 | +} |
|
| 52 | +if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] != 'all') { |
|
| 53 | + $filter['airlinestype'] = $_COOKIE['airlinestype']; |
|
| 54 | +} |
|
| 36 | 55 | |
| 37 | 56 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
| 38 | 57 | $min = true; |
@@ -83,8 +102,12 @@ discard block |
||
| 83 | 102 | } else { |
| 84 | 103 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
| 85 | 104 | } |
| 86 | - if ($flightcnt == '') $flightcnt = 0; |
|
| 87 | -} else $flightcnt = 0; |
|
| 105 | + if ($flightcnt == '') { |
|
| 106 | + $flightcnt = 0; |
|
| 107 | + } |
|
| 108 | + } else { |
|
| 109 | + $flightcnt = 0; |
|
| 110 | +} |
|
| 88 | 111 | |
| 89 | 112 | $sqltime = round(microtime(true)-$begintime,2); |
| 90 | 113 | |
@@ -93,8 +116,11 @@ discard block |
||
| 93 | 116 | |
| 94 | 117 | $output = '{'; |
| 95 | 118 | $output .= '"type": "FeatureCollection",'; |
| 96 | - if ($min) $output .= '"minimal": "true",'; |
|
| 97 | - else $output .= '"minimal": "false",'; |
|
| 119 | + if ($min) { |
|
| 120 | + $output .= '"minimal": "true",'; |
|
| 121 | + } else { |
|
| 122 | + $output .= '"minimal": "false",'; |
|
| 123 | + } |
|
| 98 | 124 | $output .= '"fc": "'.$flightcnt.'",'; |
| 99 | 125 | $output .= '"sqt": "'.$sqltime.'",'; |
| 100 | 126 | |
@@ -131,11 +157,16 @@ discard block |
||
| 131 | 157 | //$output .= '"sqt": "'.$sqltime.'",'; |
| 132 | 158 | $output .= '"id": "'.$spotter_item['flightaware_id'].'",'; |
| 133 | 159 | $output .= '"properties": {'; |
| 134 | - if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
| 135 | - else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
| 160 | + if ($compress) { |
|
| 161 | + $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
| 162 | + } else { |
|
| 163 | + $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
| 164 | + } |
|
| 136 | 165 | $output .= '"fc": "'.$flightcnt.'",'; |
| 137 | 166 | $output .= '"sqt": "'.$sqltime.'",'; |
| 138 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
| 167 | + if (isset($begindate)) { |
|
| 168 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
| 169 | + } |
|
| 139 | 170 | |
| 140 | 171 | /* |
| 141 | 172 | if ($min) $output .= '"minimal": "true",'; |
@@ -143,13 +174,21 @@ discard block |
||
| 143 | 174 | */ |
| 144 | 175 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
| 145 | 176 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
| 146 | - if ($compress) $output .= '"c": "'.$spotter_item['ident'].'",'; |
|
| 147 | - else $output .= '"callsign": "'.$spotter_item['ident'].'",'; |
|
| 177 | + if ($compress) { |
|
| 178 | + $output .= '"c": "'.$spotter_item['ident'].'",'; |
|
| 179 | + } else { |
|
| 180 | + $output .= '"callsign": "'.$spotter_item['ident'].'",'; |
|
| 181 | + } |
|
| 148 | 182 | } else { |
| 149 | - if ($compress) $output .= '"c": "NA",'; |
|
| 150 | - else $output .= '"callsign": "NA",'; |
|
| 183 | + if ($compress) { |
|
| 184 | + $output .= '"c": "NA",'; |
|
| 185 | + } else { |
|
| 186 | + $output .= '"callsign": "NA",'; |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + if (isset($spotter_item['registration'])) { |
|
| 190 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 151 | 191 | } |
| 152 | - if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 153 | 192 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
| 154 | 193 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
| 155 | 194 | $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
@@ -162,20 +201,31 @@ discard block |
||
| 162 | 201 | $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
| 163 | 202 | } |
| 164 | 203 | if (!isset($spotter_item['aircraft_shadow'])) { |
| 165 | - if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = ''; |
|
| 166 | - else { |
|
| 204 | + if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') { |
|
| 205 | + $spotter_item['aircraft_shadow'] = ''; |
|
| 206 | + } else { |
|
| 167 | 207 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']); |
| 168 | - if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
| 169 | - elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
| 170 | - else $spotter_item['aircraft_shadow'] = ''; |
|
| 208 | + if (count($aircraft_info) > 0) { |
|
| 209 | + $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
| 210 | + } elseif (isset($spotter_item['format_source']) && $spotter_item['format_source'] == 'aprs') { |
|
| 211 | + $spotter_item['aircraft_shadow'] = 'PA18.png'; |
|
| 212 | + } else { |
|
| 213 | + $spotter_item['aircraft_shadow'] = ''; |
|
| 214 | + } |
|
| 171 | 215 | } |
| 172 | 216 | } |
| 173 | 217 | if ($spotter_item['aircraft_shadow'] == '') { |
| 174 | - if ($compress) $output .= '"as": "default.png",'; |
|
| 175 | - else $output .= '"aircraft_shadow": "default.png",'; |
|
| 218 | + if ($compress) { |
|
| 219 | + $output .= '"as": "default.png",'; |
|
| 220 | + } else { |
|
| 221 | + $output .= '"aircraft_shadow": "default.png",'; |
|
| 222 | + } |
|
| 176 | 223 | } else { |
| 177 | - if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 178 | - else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 224 | + if ($compress) { |
|
| 225 | + $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 226 | + } else { |
|
| 227 | + $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 228 | + } |
|
| 179 | 229 | } |
| 180 | 230 | if (isset($spotter_item['airline_name'])) { |
| 181 | 231 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
@@ -183,8 +233,11 @@ discard block |
||
| 183 | 233 | $output .= '"airline_name": "NA",'; |
| 184 | 234 | } |
| 185 | 235 | if (isset($spotter_item['departure_airport'])) { |
| 186 | - if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
| 187 | - else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
| 236 | + if ($compress) { |
|
| 237 | + $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
| 238 | + } else { |
|
| 239 | + $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
| 240 | + } |
|
| 188 | 241 | } |
| 189 | 242 | if (isset($spotter_item['departure_airport_city'])) { |
| 190 | 243 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",'; |
@@ -196,8 +249,11 @@ discard block |
||
| 196 | 249 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",'; |
| 197 | 250 | } |
| 198 | 251 | if (isset($spotter_item['arrival_airport'])) { |
| 199 | - if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
| 200 | - else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
| 252 | + if ($compress) { |
|
| 253 | + $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
| 254 | + } else { |
|
| 255 | + $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
| 256 | + } |
|
| 201 | 257 | } |
| 202 | 258 | if (isset($spotter_item['arrival_airport_city'])) { |
| 203 | 259 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",'; |
@@ -215,18 +271,29 @@ discard block |
||
| 215 | 271 | $output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",'; |
| 216 | 272 | } |
| 217 | 273 | |
| 218 | - if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
| 219 | - else $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 220 | - if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",'; |
|
| 221 | - else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 274 | + if ($compress) { |
|
| 275 | + $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
| 276 | + } else { |
|
| 277 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 278 | + } |
|
| 279 | + if ($compress) { |
|
| 280 | + $output .= '"h": "'.$spotter_item['heading'].'",'; |
|
| 281 | + } else { |
|
| 282 | + $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 283 | + } |
|
| 222 | 284 | |
| 223 | - if (isset($archivespeed)) $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
|
| 224 | - else $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']); |
|
| 285 | + if (isset($archivespeed)) { |
|
| 286 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
|
| 287 | + } else { |
|
| 288 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']); |
|
| 289 | + } |
|
| 225 | 290 | //$output .= '"nextlatitude": "'.$nextcoord['latitude'].'",'; |
| 226 | 291 | //$output .= '"nextlongitude": "'.$nextcoord['longitude'].'",'; |
| 227 | 292 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 228 | 293 | |
| 229 | - if (!$min) $output .= '"image": "'.$image.'",'; |
|
| 294 | + if (!$min) { |
|
| 295 | + $output .= '"image": "'.$image.'",'; |
|
| 296 | + } |
|
| 230 | 297 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
| 231 | 298 | $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
| 232 | 299 | } |
@@ -234,8 +301,11 @@ discard block |
||
| 234 | 301 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
| 235 | 302 | } |
| 236 | 303 | if (isset($spotter_item['squawk'])) { |
| 237 | - if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
| 238 | - else $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
| 304 | + if ($compress) { |
|
| 305 | + $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
| 306 | + } else { |
|
| 307 | + $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
| 308 | + } |
|
| 239 | 309 | } |
| 240 | 310 | if (isset($spotter_item['squawk_usage'])) { |
| 241 | 311 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",'; |
@@ -253,8 +323,11 @@ discard block |
||
| 253 | 323 | $output .= '"acars": "'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"), '<br />',$spotter_item['acars']['message'])).'",'; |
| 254 | 324 | } |
| 255 | 325 | // type when not aircraft ? |
| 256 | - if ($compress) $output .= '"t": "aircraft"'; |
|
| 257 | - else $output .= '"type": "aircraft"'; |
|
| 326 | + if ($compress) { |
|
| 327 | + $output .= '"t": "aircraft"'; |
|
| 328 | + } else { |
|
| 329 | + $output .= '"type": "aircraft"'; |
|
| 330 | + } |
|
| 258 | 331 | $output .= '},'; |
| 259 | 332 | $output .= '"geometry": {'; |
| 260 | 333 | $output .= '"type": "Point",'; |
@@ -321,7 +394,9 @@ discard block |
||
| 321 | 394 | //if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || (!isset($_COOKIE['flightpath']) && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) || (isset($_GET['history']) && $_GET['history'] != '' && $_GET['history'] != 'NA' && ($_GET['history'] == $spotter_item['ident'] || $_GET['history'] == $spotter_item['flightaware_id'])))) { |
| 322 | 395 | //if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || (!isset($_COOKIE['flightpath']) && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) || (isset($_GET['history']) && $_GET['history'] != '' && $_GET['history'] != 'NA' && ($_GET['history'] == $spotter_item['ident'] || $_GET['history'] == $spotter_item['flightaware_id']))) || (isset($_GET['history']) && $_GET['history'] == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) { |
| 323 | 396 | $history = filter_input(INPUT_GET,'history',FILTER_SANITIZE_STRING); |
| 324 | - if ($history == '' && isset($_COOKIE['history'])) $history = $_COOKIE['history']; |
|
| 397 | + if ($history == '' && isset($_COOKIE['history'])) { |
|
| 398 | + $history = $_COOKIE['history']; |
|
| 399 | + } |
|
| 325 | 400 | if ((isset($_COOKIE['flightpath']) && $_COOKIE['flightpath'] == 'true') || (!isset($_COOKIE['flightpath']) && (!isset($globalMapHistory) || $globalMapHistory || $allhistory) |
| 326 | 401 | || (isset($history) && $history != '' && $history != 'NA' && ($history == $spotter_item['ident'] || $history == $spotter_item['flightaware_id']))) |
| 327 | 402 | || (isset($history) && $history == '' && isset($_GET['flightaware_id']) && $_GET['flightaware_id'] == $spotter_item['flightaware_id'])) { |
@@ -346,8 +421,11 @@ discard block |
||
| 346 | 421 | $output_history .= ']}},'; |
| 347 | 422 | $output .= $output_history; |
| 348 | 423 | } |
| 349 | - if ($compress) $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 350 | - else $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 424 | + if ($compress) { |
|
| 425 | + $output_history = '{"type": "Feature","properties": {"c": "'.$spotter_item['ident'].'","t": "history","a": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 426 | + } else { |
|
| 427 | + $output_history = '{"type": "Feature","properties": {"callsign": "'.$spotter_item['ident'].'","type": "history","altitude": "'.$alt.'"},"geometry": {"type": "LineString","coordinates": ['; |
|
| 428 | + } |
|
| 351 | 429 | } |
| 352 | 430 | $output_history .= '['; |
| 353 | 431 | $output_history .= $spotter_history['longitude'].', '; |
@@ -397,7 +475,9 @@ discard block |
||
| 397 | 475 | $output .= ']'; |
| 398 | 476 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
| 399 | 477 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
| 400 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
| 478 | + if (isset($begindate)) { |
|
| 479 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
| 480 | + } |
|
| 401 | 481 | $output .= '"fc": "'.$j.'"'; |
| 402 | 482 | } else { |
| 403 | 483 | $output .= '"features": '; |
@@ -16,21 +16,40 @@ discard block |
||
| 16 | 16 | } |
| 17 | 17 | header('Content-Type: text/javascript'); |
| 18 | 18 | |
| 19 | -if (!isset($globalJsonCompress)) $compress = true; |
|
| 20 | -else $compress = $globalJsonCompress; |
|
| 19 | +if (!isset($globalJsonCompress)) { |
|
| 20 | + $compress = true; |
|
| 21 | +} else { |
|
| 22 | + $compress = $globalJsonCompress; |
|
| 23 | +} |
|
| 21 | 24 | |
| 22 | 25 | $from_archive = false; |
| 23 | 26 | $min = false; |
| 24 | 27 | $allhistory = false; |
| 25 | 28 | $filter['source'] = array(); |
| 26 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 27 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 28 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 29 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs')); |
|
| 30 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 31 | -if (isset($_COOKIE['Airlines']) && $_COOKIE['Airlines'] != '') $filter['airlines'] = explode(',',$_COOKIE['Airlines']); |
|
| 32 | -if (isset($_COOKIE['Sources']) && $_COOKIE['Sources'] != '') $filter['source_aprs'] = explode(',',$_COOKIE['Sources']); |
|
| 33 | -if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] != 'all') $filter['airlinestype'] = $_COOKIE['airlinestype']; |
|
| 29 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') { |
|
| 30 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 31 | +} |
|
| 32 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') { |
|
| 33 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 34 | +} |
|
| 35 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') { |
|
| 36 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 37 | +} |
|
| 38 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') { |
|
| 39 | + $filter['source'] = array_merge($filter['source'],array('sbs')); |
|
| 40 | +} |
|
| 41 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') { |
|
| 42 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 43 | +} |
|
| 44 | +if (isset($_COOKIE['Airlines']) && $_COOKIE['Airlines'] != '') { |
|
| 45 | + $filter['airlines'] = explode(',',$_COOKIE['Airlines']); |
|
| 46 | +} |
|
| 47 | +if (isset($_COOKIE['Sources']) && $_COOKIE['Sources'] != '') { |
|
| 48 | + $filter['source_aprs'] = explode(',',$_COOKIE['Sources']); |
|
| 49 | +} |
|
| 50 | +if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] != 'all') { |
|
| 51 | + $filter['airlinestype'] = $_COOKIE['airlinestype']; |
|
| 52 | +} |
|
| 34 | 53 | |
| 35 | 54 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
| 36 | 55 | $min = true; |
@@ -60,8 +79,12 @@ discard block |
||
| 60 | 79 | |
| 61 | 80 | if (!empty($spotter_array)) { |
| 62 | 81 | $flightcnt = $SpotterArchive->getLiveSpotterCount($begindate,$enddate,$filter); |
| 63 | - if ($flightcnt == '') $flightcnt = 0; |
|
| 64 | -} else $flightcnt = 0; |
|
| 82 | + if ($flightcnt == '') { |
|
| 83 | + $flightcnt = 0; |
|
| 84 | + } |
|
| 85 | + } else { |
|
| 86 | + $flightcnt = 0; |
|
| 87 | +} |
|
| 65 | 88 | |
| 66 | 89 | $sqltime = round(microtime(true)-$begintime,2); |
| 67 | 90 | |
@@ -70,8 +93,11 @@ discard block |
||
| 70 | 93 | |
| 71 | 94 | $output = '{'; |
| 72 | 95 | $output .= '"type": "FeatureCollection",'; |
| 73 | - if ($min) $output .= '"minimal": "true",'; |
|
| 74 | - else $output .= '"minimal": "false",'; |
|
| 96 | + if ($min) { |
|
| 97 | + $output .= '"minimal": "true",'; |
|
| 98 | + } else { |
|
| 99 | + $output .= '"minimal": "false",'; |
|
| 100 | + } |
|
| 75 | 101 | $output .= '"fc": "'.$flightcnt.'",'; |
| 76 | 102 | $output .= '"sqt": "'.$sqltime.'",'; |
| 77 | 103 | |
@@ -140,11 +166,16 @@ discard block |
||
| 140 | 166 | //$output .= '"fc": "'.$flightcnt.'",'; |
| 141 | 167 | //$output .= '"sqt": "'.$sqltime.'",'; |
| 142 | 168 | $output .= '"properties": {'; |
| 143 | - if ($compress) $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
| 144 | - else $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
| 169 | + if ($compress) { |
|
| 170 | + $output .= '"fi": "'.$spotter_item['flightaware_id'].'",'; |
|
| 171 | + } else { |
|
| 172 | + $output .= '"flightaware_id": "'.$spotter_item['flightaware_id'].'",'; |
|
| 173 | + } |
|
| 145 | 174 | $output .= '"fc": "'.$flightcnt.'",'; |
| 146 | 175 | $output .= '"sqt": "'.$sqltime.'",'; |
| 147 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
| 176 | + if (isset($begindate)) { |
|
| 177 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
| 178 | + } |
|
| 148 | 179 | |
| 149 | 180 | /* |
| 150 | 181 | if ($min) $output .= '"minimal": "true",'; |
@@ -152,13 +183,21 @@ discard block |
||
| 152 | 183 | */ |
| 153 | 184 | //$output .= '"fc": "'.$spotter_item['nb'].'",'; |
| 154 | 185 | if (isset($spotter_item['ident']) && $spotter_item['ident'] != '') { |
| 155 | - if ($compress) $output .= '"c": "'.$spotter_item['ident'].'",'; |
|
| 156 | - else $output .= '"callsign": "'.$spotter_item['ident'].'",'; |
|
| 186 | + if ($compress) { |
|
| 187 | + $output .= '"c": "'.$spotter_item['ident'].'",'; |
|
| 188 | + } else { |
|
| 189 | + $output .= '"callsign": "'.$spotter_item['ident'].'",'; |
|
| 190 | + } |
|
| 157 | 191 | } else { |
| 158 | - if ($compress) $output .= '"c": "NA",'; |
|
| 159 | - else $output .= '"callsign": "NA",'; |
|
| 192 | + if ($compress) { |
|
| 193 | + $output .= '"c": "NA",'; |
|
| 194 | + } else { |
|
| 195 | + $output .= '"callsign": "NA",'; |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + if (isset($spotter_item['registration'])) { |
|
| 199 | + $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 160 | 200 | } |
| 161 | - if (isset($spotter_item['registration'])) $output .= '"registration": "'.$spotter_item['registration'].'",'; |
|
| 162 | 201 | if (isset($spotter_item['aircraft_name']) && isset($spotter_item['aircraft_type'])) { |
| 163 | 202 | $output .= '"aircraft_name": "'.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')",'; |
| 164 | 203 | $output .= '"aircraft_wiki": "http://'.strtolower($globalLanguage).'.wikipedia.org/wiki/'.urlencode(str_replace(' ','_',$spotter_item['aircraft_name'])).'",'; |
@@ -171,19 +210,29 @@ discard block |
||
| 171 | 210 | $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
| 172 | 211 | } |
| 173 | 212 | if (!isset($spotter_item['aircraft_shadow'])) { |
| 174 | - if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') $spotter_item['aircraft_shadow'] = ''; |
|
| 175 | - else { |
|
| 213 | + if (!isset($spotter_item['aircraft_icao']) || $spotter_item['aircraft_icao'] == '') { |
|
| 214 | + $spotter_item['aircraft_shadow'] = ''; |
|
| 215 | + } else { |
|
| 176 | 216 | $aircraft_info = $Spotter->getAllAircraftInfo($spotter_item['aircraft_icao']); |
| 177 | - if (count($aircraft_info) > 0) $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
| 178 | - else $spotter_item['aircraft_shadow'] = ''; |
|
| 217 | + if (count($aircraft_info) > 0) { |
|
| 218 | + $spotter_item['aircraft_shadow'] = $aircraft_info[0]['aircraft_shadow']; |
|
| 219 | + } else { |
|
| 220 | + $spotter_item['aircraft_shadow'] = ''; |
|
| 221 | + } |
|
| 179 | 222 | } |
| 180 | 223 | } |
| 181 | 224 | if ($spotter_item['aircraft_shadow'] == '') { |
| 182 | - if ($compress) $output .= '"as": "default.png",'; |
|
| 183 | - else $output .= '"aircraft_shadow": "default.png",'; |
|
| 225 | + if ($compress) { |
|
| 226 | + $output .= '"as": "default.png",'; |
|
| 227 | + } else { |
|
| 228 | + $output .= '"aircraft_shadow": "default.png",'; |
|
| 229 | + } |
|
| 184 | 230 | } else { |
| 185 | - if ($compress) $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 186 | - else $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 231 | + if ($compress) { |
|
| 232 | + $output .= '"as": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 233 | + } else { |
|
| 234 | + $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 235 | + } |
|
| 187 | 236 | } |
| 188 | 237 | if (isset($spotter_item['airline_name'])) { |
| 189 | 238 | $output .= '"airline_name": "'.$spotter_item['airline_name'].'",'; |
@@ -191,8 +240,11 @@ discard block |
||
| 191 | 240 | $output .= '"airline_name": "NA",'; |
| 192 | 241 | } |
| 193 | 242 | if (isset($spotter_item['departure_airport'])) { |
| 194 | - if ($compress) $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
| 195 | - else $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
| 243 | + if ($compress) { |
|
| 244 | + $output .= '"dac": "'.$spotter_item['departure_airport'].'",'; |
|
| 245 | + } else { |
|
| 246 | + $output .= '"departure_airport_code": "'.$spotter_item['departure_airport'].'",'; |
|
| 247 | + } |
|
| 196 | 248 | } |
| 197 | 249 | if (isset($spotter_item['departure_airport_city'])) { |
| 198 | 250 | $output .= '"departure_airport": "'.$spotter_item['departure_airport_city'].', '.$spotter_item['departure_airport_country'].'",'; |
@@ -204,8 +256,11 @@ discard block |
||
| 204 | 256 | $output .= '"arrival_airport_time": "'.$spotter_item['arrival_airport_time'].'",'; |
| 205 | 257 | } |
| 206 | 258 | if (isset($spotter_item['arrival_airport'])) { |
| 207 | - if ($compress) $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
| 208 | - else $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
| 259 | + if ($compress) { |
|
| 260 | + $output .= '"aac": "'.$spotter_item['arrival_airport'].'",'; |
|
| 261 | + } else { |
|
| 262 | + $output .= '"arrival_airport_code": "'.$spotter_item['arrival_airport'].'",'; |
|
| 263 | + } |
|
| 209 | 264 | } |
| 210 | 265 | if (isset($spotter_item['arrival_airport_city'])) { |
| 211 | 266 | $output .= '"arrival_airport": "'.$spotter_item['arrival_airport_city'].', '.$spotter_item['arrival_airport_country'].'",'; |
@@ -223,18 +278,29 @@ discard block |
||
| 223 | 278 | $output .= '"ground_speed": "'.$spotter_item['ground_speed'].'",'; |
| 224 | 279 | } |
| 225 | 280 | |
| 226 | - if ($compress) $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
| 227 | - else $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 228 | - if ($compress)$output .= '"h": "'.$spotter_item['heading'].'",'; |
|
| 229 | - else $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 281 | + if ($compress) { |
|
| 282 | + $output .= '"a": "'.$spotter_item['altitude'].'",'; |
|
| 283 | + } else { |
|
| 284 | + $output .= '"altitude": "'.$spotter_item['altitude'].'",'; |
|
| 285 | + } |
|
| 286 | + if ($compress) { |
|
| 287 | + $output .= '"h": "'.$spotter_item['heading'].'",'; |
|
| 288 | + } else { |
|
| 289 | + $output .= '"heading": "'.$spotter_item['heading'].'",'; |
|
| 290 | + } |
|
| 230 | 291 | |
| 231 | - if (isset($archivespeed)) $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
|
| 232 | - else $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']); |
|
| 292 | + if (isset($archivespeed)) { |
|
| 293 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading'],$archivespeed); |
|
| 294 | + } else { |
|
| 295 | + $nextcoord = $Common->nextcoord($spotter_item['latitude'],$spotter_item['longitude'],$spotter_item['ground_speed'],$spotter_item['heading']); |
|
| 296 | + } |
|
| 233 | 297 | //$output .= '"nextlatitude": "'.$nextcoord['latitude'].'",'; |
| 234 | 298 | //$output .= '"nextlongitude": "'.$nextcoord['longitude'].'",'; |
| 235 | 299 | $output .= '"nextlatlon": ['.$nextcoord['latitude'].','.$nextcoord['longitude'].'],'; |
| 236 | 300 | |
| 237 | - if (!$min) $output .= '"image": "'.$image.'",'; |
|
| 301 | + if (!$min) { |
|
| 302 | + $output .= '"image": "'.$image.'",'; |
|
| 303 | + } |
|
| 238 | 304 | if (isset($spotter_item['image_copyright']) && $spotter_item['image_copyright'] != '') { |
| 239 | 305 | $output .= '"image_copyright": "'.str_replace('"',"'",trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'',$spotter_item['image_copyright']))).'",'; |
| 240 | 306 | } |
@@ -242,8 +308,11 @@ discard block |
||
| 242 | 308 | $output .= '"image_source_website": "'.urlencode($spotter_item['image_source_website']).'",'; |
| 243 | 309 | } |
| 244 | 310 | if (isset($spotter_item['squawk'])) { |
| 245 | - if ($compress) $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
| 246 | - else $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
| 311 | + if ($compress) { |
|
| 312 | + $output .= '"sq": "'.$spotter_item['squawk'].'",'; |
|
| 313 | + } else { |
|
| 314 | + $output .= '"squawk": "'.$spotter_item['squawk'].'",'; |
|
| 315 | + } |
|
| 247 | 316 | } |
| 248 | 317 | if (isset($spotter_item['squawk_usage'])) { |
| 249 | 318 | $output .= '"squawk_usage": "'.$spotter_item['squawk_usage'].'",'; |
@@ -277,8 +346,11 @@ discard block |
||
| 277 | 346 | |
| 278 | 347 | |
| 279 | 348 | // FIXME : type when not aircraft ? |
| 280 | - if ($compress) $output .= '"t": "aircraft"'; |
|
| 281 | - else $output .= '"type": "aircraft"'; |
|
| 349 | + if ($compress) { |
|
| 350 | + $output .= '"t": "aircraft"'; |
|
| 351 | + } else { |
|
| 352 | + $output .= '"type": "aircraft"'; |
|
| 353 | + } |
|
| 282 | 354 | $output .= '},'; |
| 283 | 355 | $output .= '"geometry": {'; |
| 284 | 356 | $output .= '"type": "MultiPoint",'; |
@@ -298,7 +370,9 @@ discard block |
||
| 298 | 370 | $output .= ']'; |
| 299 | 371 | $output .= ',"initial_sqltime": "'.$sqltime.'",'; |
| 300 | 372 | $output .= '"totaltime": "'.round(microtime(true)-$begintime,2).'",'; |
| 301 | - if (isset($begindate)) $output .= '"archive_date": "'.$begindate.'",'; |
|
| 373 | + if (isset($begindate)) { |
|
| 374 | + $output .= '"archive_date": "'.$begindate.'",'; |
|
| 375 | + } |
|
| 302 | 376 | $output .= '"fc": "'.$flightcnt.'"'; |
| 303 | 377 | } else { |
| 304 | 378 | $output .= '"features": '; |
@@ -46,7 +46,9 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | if ($spotter_item['image_source'] == 'flickr' || $spotter_item['image_source'] == 'wikimedia' || $spotter_item['image_source'] == 'devianart') { |
| 48 | 48 | $image = preg_replace("/^http:/i","https:",$spotter_item['image_thumbnail']); |
| 49 | - } else $image = $spotter_item['image_thumbnail']; |
|
| 49 | + } else { |
|
| 50 | + $image = $spotter_item['image_thumbnail']; |
|
| 51 | + } |
|
| 50 | 52 | |
| 51 | 53 | } |
| 52 | 54 | /* else { |
@@ -58,7 +60,9 @@ discard block |
||
| 58 | 60 | print '<div class="left"><img src="'.$image.'" alt="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].'" title="'.$spotter_item['registration'].' '.$spotter_item['aircraft_name'].' Image © '.$spotter_item['image_copyright'].'"/><br />Image © '.$spotter_item['image_copyright'].'</div>'; |
| 59 | 61 | } |
| 60 | 62 | print '<div class="right"><div class="callsign-details"><div class="callsign"><a href="'.$globalURL.'/redirect/'.$spotter_item['flightaware_id'].'" target="_blank">'.$spotter_item['ident'].'</a></div>'; |
| 61 | -if (isset($spotter_item['airline_name'])) print '<div class="airline">'.$spotter_item['airline_name'].'</div>'; |
|
| 63 | +if (isset($spotter_item['airline_name'])) { |
|
| 64 | + print '<div class="airline">'.$spotter_item['airline_name'].'</div>'; |
|
| 65 | +} |
|
| 62 | 66 | print '</div>'; |
| 63 | 67 | print '<div class="nomobile airports"><div class="airport"><span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['departure_airport'].'" target="_blank">'.$spotter_item['departure_airport'].'</a></span>'.$spotter_item['departure_airport_city'].' '.$spotter_item['departure_airport_country']; |
| 64 | 68 | if (isset($spotter_item['departure_airport_time'])) { |
@@ -86,9 +90,14 @@ discard block |
||
| 86 | 90 | print '<span class="code"><a href="'.$globalURL.'/airport/'.$spotter_item['arrival_airport'].'" target="_blank">'.$spotter_item['arrival_airport'].'</a></span>'.$spotter_item['arrival_airport_city'].' '.$spotter_item['arrival_airport_country']; |
| 87 | 91 | print '</div></div><div>'; |
| 88 | 92 | print '<span>'._("Aircraft").'</span>'; |
| 89 | -if (isset($spotter_item['aircraft_wiki'])) print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>'; |
|
| 90 | -if (isset($spotter_item['aircraft_type'])) print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>'; |
|
| 91 | -else print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name']; |
|
| 93 | +if (isset($spotter_item['aircraft_wiki'])) { |
|
| 94 | + print '<a href="'.$spotter_item['aircraft_wiki'].'">'.$spotter_item['aircraft_name'].'</a>'; |
|
| 95 | +} |
|
| 96 | +if (isset($spotter_item['aircraft_type'])) { |
|
| 97 | + print '<a href="'.$globalURL.'/aircraft/'.$spotter_item['aircraft_type'].'">'.$spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name'].' ('.$spotter_item['aircraft_type'].')</a>'; |
|
| 98 | +} else { |
|
| 99 | + print $spotter_item['aircraft_manufacturer'].' '.$spotter_item['aircraft_name']; |
|
| 100 | +} |
|
| 92 | 101 | print '</div>'; |
| 93 | 102 | print '<div><span>'._("Altitude").'</span>'; |
| 94 | 103 | if ((!isset($_COOKIE['unitaltitude']) && isset($globalUnitAltitude) && $globalUnitAltitude == 'feet') || (isset($_COOKIE['unitaltitude']) && $_COOKIE['unitaltitude'] == 'feet')) { |
@@ -97,7 +106,9 @@ discard block |
||
| 97 | 106 | print round($spotter_item['altitude']*30.48).' m (FL'.$spotter_item['altitude'].')'; |
| 98 | 107 | } |
| 99 | 108 | print '</div>'; |
| 100 | -if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>'; |
|
| 109 | +if (isset($spotter_item['registration']) && $spotter_item['registration'] != '') { |
|
| 110 | + print '<div><span>'._("Registration").'</span><a href="'.$globalURL.'/registration/'.$spotter_item['registration'].'" target="_blank">'.$spotter_item['registration'].'</a></div>'; |
|
| 111 | +} |
|
| 101 | 112 | print '<div><span>'._("Speed").'</span>'; |
| 102 | 113 | if ((!isset($_COOKIE['unitspeed']) && isset($globalUnitSpeed) && $globalUnitSpeed == 'mph') || (isset($_COOKIE['unitspeed']) && $_COOKIE['unitspeed'] == 'mph')) { |
| 103 | 114 | print round($spotter_item['ground_speed']*1.15078).' mph'; |
@@ -111,8 +122,11 @@ discard block |
||
| 111 | 122 | print '<div><span>'._("Heading").'</span>'.$spotter_item['heading'].'°</div>'; |
| 112 | 123 | if (isset($spotter_item['pilot_name']) && $spotter_item['pilot_name'] != '') { |
| 113 | 124 | print '<div><span>'._("Pilot").'</span>'; |
| 114 | - if (isset($spotter_item['pilot_id'])) print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')'; |
|
| 115 | - else print $spotter_item['pilot_name']; |
|
| 125 | + if (isset($spotter_item['pilot_id'])) { |
|
| 126 | + print $spotter_item['pilot_name'].' ('.$spotter_item['pilot_id'].')'; |
|
| 127 | + } else { |
|
| 128 | + print $spotter_item['pilot_name']; |
|
| 129 | + } |
|
| 116 | 130 | print '</div>'; |
| 117 | 131 | } |
| 118 | 132 | |
@@ -133,10 +147,18 @@ discard block |
||
| 133 | 147 | } |
| 134 | 148 | print '</div>'; |
| 135 | 149 | |
| 136 | -if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
|
| 137 | -if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
|
| 138 | -if (isset($spotter_item['acars']['message'])) print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
| 139 | -if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
|
| 150 | +if (isset($globalphpVMS) && $globalphpVMS && isset($globalVATSIM) && $globalVATSIM && isset($globalIVAO) && $globalIVAO && isset($spotter_item['format_source']) && $spotter_item['format_source'] != '' && $spotter_item['format_source'] != 'pireps') { |
|
| 151 | + print '<div class="waypoints"><span>'._("Source").'</span>'.$spotter_item['format_source'].'</div>'; |
|
| 152 | +} |
|
| 153 | +if (isset($spotter_item['waypoints']) && $spotter_item['waypoints'] != '') { |
|
| 154 | + print '<div class="waypoints"><span>'._("Route").'</span>'.$spotter_item['waypoints'].'</div>'; |
|
| 155 | +} |
|
| 156 | +if (isset($spotter_item['acars']['message'])) { |
|
| 157 | + print '<div class="acars"><span>'._("Latest ACARS message").'</span>'.trim(str_replace(array("\r\n","\r","\n","\\r","\\n","\\r\\n"),'<br/>',$spotter_item['acars']['message'])).'</div>'; |
|
| 158 | +} |
|
| 159 | +if (isset($spotter_item['squawk']) && $spotter_item['squawk'] != '' && $spotter_item['squawk'] != 0) { |
|
| 160 | + print '<div class="bottom">'._("Squawk:").' '.$spotter_item['squawk'].' - '.$spotter_item['squawk_usage'].'</div>'; |
|
| 161 | +} |
|
| 140 | 162 | print '</div>'; |
| 141 | 163 | ?> |
| 142 | 164 | </div> |
@@ -40,21 +40,40 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | header('Content-Type: text/javascript'); |
| 42 | 42 | |
| 43 | -if (!isset($globalJsonCompress)) $compress = true; |
|
| 44 | -else $compress = $globalJsonCompress; |
|
| 43 | +if (!isset($globalJsonCompress)) { |
|
| 44 | + $compress = true; |
|
| 45 | +} else { |
|
| 46 | + $compress = $globalJsonCompress; |
|
| 47 | +} |
|
| 45 | 48 | |
| 46 | 49 | $from_archive = false; |
| 47 | 50 | $min = false; |
| 48 | 51 | $allhistory = false; |
| 49 | 52 | $filter['source'] = array(); |
| 50 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 51 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 52 | -if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 53 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') $filter['source'] = array_merge($filter['source'],array('sbs')); |
|
| 54 | -if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 55 | -if (isset($_COOKIE['Airlines']) && $_COOKIE['Airlines'] != '') $filter['airlines'] = explode(',',$_COOKIE['Airlines']); |
|
| 56 | -if (isset($_COOKIE['Sources']) && $_COOKIE['Sources'] != '') $filter['source_aprs'] = explode(',',$_COOKIE['Sources']); |
|
| 57 | -if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] != 'all') $filter['airlinestype'] = $_COOKIE['airlinestype']; |
|
| 53 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalVATSIM) && $globalVATSIM && isset($_COOKIE['ShowVATSIM']) && $_COOKIE['ShowVATSIM'] == 'true') { |
|
| 54 | + $filter['source'] = array_merge($filter['source'],array('vatsimtxt')); |
|
| 55 | +} |
|
| 56 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalIVAO) && $globalIVAO && isset($_COOKIE['ShowIVAO']) && $_COOKIE['ShowIVAO'] == 'true') { |
|
| 57 | + $filter['source'] = array_merge($filter['source'],array('whazzup')); |
|
| 58 | +} |
|
| 59 | +if ((!isset($globalMapVAchoose) || $globalMapVAchoose) && isset($globalphpVMS) && $globalphpVMS && isset($_COOKIE['ShowVMS']) && $_COOKIE['ShowVMS'] == 'true') { |
|
| 60 | + $filter['source'] = array_merge($filter['source'],array('phpvmacars')); |
|
| 61 | +} |
|
| 62 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalSBS1) && $globalSBS1 && isset($_COOKIE['ShowSBS1']) && $_COOKIE['ShowSBS1'] == 'true') { |
|
| 63 | + $filter['source'] = array_merge($filter['source'],array('sbs')); |
|
| 64 | +} |
|
| 65 | +if ((!isset($globalMapchoose) || $globalMapchoose) && isset($globalAPRS) && $globalAPRS && isset($_COOKIE['ShowAPRS']) && $_COOKIE['ShowAPRS'] == 'true') { |
|
| 66 | + $filter['source'] = array_merge($filter['source'],array('aprs')); |
|
| 67 | +} |
|
| 68 | +if (isset($_COOKIE['Airlines']) && $_COOKIE['Airlines'] != '') { |
|
| 69 | + $filter['airlines'] = explode(',',$_COOKIE['Airlines']); |
|
| 70 | +} |
|
| 71 | +if (isset($_COOKIE['Sources']) && $_COOKIE['Sources'] != '') { |
|
| 72 | + $filter['source_aprs'] = explode(',',$_COOKIE['Sources']); |
|
| 73 | +} |
|
| 74 | +if (isset($_COOKIE['airlinestype']) && $_COOKIE['airlinestype'] != 'all') { |
|
| 75 | + $filter['airlinestype'] = $_COOKIE['airlinestype']; |
|
| 76 | +} |
|
| 58 | 77 | /* |
| 59 | 78 | if (isset($globalMapPopup) && !$globalMapPopup && !(isset($_COOKIE['flightpopup']) && $_COOKIE['flightpopup'] == 'true')) { |
| 60 | 79 | $min = true; |
@@ -105,8 +124,12 @@ discard block |
||
| 105 | 124 | } else { |
| 106 | 125 | $flightcnt = $SpotterLive->getLiveSpotterCount($filter); |
| 107 | 126 | } |
| 108 | - if ($flightcnt == '') $flightcnt = 0; |
|
| 109 | -} else $flightcnt = 0; |
|
| 127 | + if ($flightcnt == '') { |
|
| 128 | + $flightcnt = 0; |
|
| 129 | + } |
|
| 130 | + } else { |
|
| 131 | + $flightcnt = 0; |
|
| 132 | +} |
|
| 110 | 133 | |
| 111 | 134 | $sqltime = round(microtime(true)-$begintime,2); |
| 112 | 135 | $minitime = time(); |
@@ -263,8 +286,12 @@ discard block |
||
| 263 | 286 | } |
| 264 | 287 | } else { |
| 265 | 288 | $output .= '"model": {"gltf" : "/models/Cesium_Air.glb","scale" : 1.0,"minimumPixelSize": 20 },'; |
| 266 | - if ($spotter_item['aircraft_shadow'] != '') $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 267 | - if ($spotter_item['aircraft_icao'] != '') $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 289 | + if ($spotter_item['aircraft_shadow'] != '') { |
|
| 290 | + $output .= '"aircraft_shadow": "'.$spotter_item['aircraft_shadow'].'",'; |
|
| 291 | + } |
|
| 292 | + if ($spotter_item['aircraft_icao'] != '') { |
|
| 293 | + $output .= '"aircraft_icao": "'.$spotter_item['aircraft_icao'].'",'; |
|
| 294 | + } |
|
| 268 | 295 | } |
| 269 | 296 | $output .= '"heightReference": "CLAMP_TO_GROUND",'; |
| 270 | 297 | $output .= '"position": {'; |
@@ -273,7 +300,9 @@ discard block |
||
| 273 | 300 | // $output .= '"interpolationDegree" : 5,'; |
| 274 | 301 | // $output .= '"epoch" : "'.date("c",strtotime($spotter_item['date'])).'", '; |
| 275 | 302 | $output .= '"cartographicDegrees": ['; |
| 276 | - if ($minitime > strtotime($spotter_item['date'])) $minitime = strtotime($spotter_item['date']); |
|
| 303 | + if ($minitime > strtotime($spotter_item['date'])) { |
|
| 304 | + $minitime = strtotime($spotter_item['date']); |
|
| 305 | + } |
|
| 277 | 306 | $output .= '"'.date("c",strtotime($spotter_item['date'])).'", '; |
| 278 | 307 | $output .= $spotter_item['longitude'].', '; |
| 279 | 308 | $output .= $spotter_item['latitude'].', '; |
@@ -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 | } |
@@ -103,12 +108,18 @@ discard block |
||
| 103 | 108 | $message = ''; |
| 104 | 109 | $result = array(); |
| 105 | 110 | $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); |
| 106 | - 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); |
|
| 111 | + if ($n == 0) { |
|
| 112 | + $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); |
|
| 113 | + } |
|
| 107 | 114 | if ($n != 0) { |
| 108 | 115 | $registration = str_replace('.','',$registration); |
| 109 | 116 | $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
| 110 | - if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
| 111 | - } else $message = $data; |
|
| 117 | + if ($globalDebug) { |
|
| 118 | + echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
| 119 | + } |
|
| 120 | + } else { |
|
| 121 | + $message = $data; |
|
| 122 | + } |
|
| 112 | 123 | $icao = ''; |
| 113 | 124 | $airicao = ''; |
| 114 | 125 | $decode = array(); |
@@ -122,12 +133,21 @@ discard block |
||
| 122 | 133 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
| 123 | 134 | $latitude = $la / 10000.0; |
| 124 | 135 | $longitude = $ln / 10000.0; |
| 125 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 126 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 136 | + if ($lac == 'S') { |
|
| 137 | + $latitude = '-'.$latitude; |
|
| 138 | + } |
|
| 139 | + if ($lnc == 'W') { |
|
| 140 | + $longitude = '-'.$longitude; |
|
| 141 | + } |
|
| 127 | 142 | // Temp not always available |
| 128 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
| 129 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
| 130 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
| 143 | + if ($globalDebug) { |
|
| 144 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
| 145 | + } |
|
| 146 | + if ($temp == '') { |
|
| 147 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
| 148 | + } else { |
|
| 149 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
| 150 | + } |
|
| 131 | 151 | |
| 132 | 152 | //$icao = $Translation->checkTranslation($ident); |
| 133 | 153 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -137,25 +157,35 @@ discard block |
||
| 137 | 157 | if (!$found && ($label == '10')) { |
| 138 | 158 | $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
| 139 | 159 | if ($n == 4 && strlen($darr) == 4) { |
| 140 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 141 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 142 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
| 160 | + if ($dhour != '') { |
|
| 161 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 162 | + } |
|
| 163 | + if ($ahour != '') { |
|
| 164 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 165 | + } |
|
| 166 | + if ($globalDebug) { |
|
| 167 | + echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
| 168 | + } |
|
| 143 | 169 | //$icao = ACARS->ident2icao($ident); |
| 144 | 170 | //$icao = $Translation->checkTranslation($ident); |
| 145 | 171 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
| 146 | 172 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
| 147 | 173 | $found = true; |
| 148 | - } |
|
| 149 | - elseif ($n == 2 || $n == 4) { |
|
| 150 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 151 | - if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
| 174 | + } elseif ($n == 2 || $n == 4) { |
|
| 175 | + if ($dhour != '') { |
|
| 176 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 177 | + } |
|
| 178 | + if ($globalDebug) { |
|
| 179 | + echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
| 180 | + } |
|
| 152 | 181 | //$icao = ACARS->ident2icao($ident); |
| 153 | 182 | //$icao = $Translation->checkTranslation($ident); |
| 154 | 183 | $decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour); |
| 155 | 184 | $found = true; |
| 156 | - } |
|
| 157 | - elseif ($n == 1) { |
|
| 158 | - if ($globalDebug) echo 'airport arrival : '.$darr."\n"; |
|
| 185 | + } elseif ($n == 1) { |
|
| 186 | + if ($globalDebug) { |
|
| 187 | + echo 'airport arrival : '.$darr."\n"; |
|
| 188 | + } |
|
| 159 | 189 | //$icao = ACARS->ident2icao($ident); |
| 160 | 190 | //$icao = $Translation->checkTranslation($ident); |
| 161 | 191 | $decode = array('Arrival airport' => $darr); |
@@ -172,7 +202,9 @@ discard block |
||
| 172 | 202 | |
| 173 | 203 | $n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr); |
| 174 | 204 | if ($n == 4) { |
| 175 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 205 | + if ($globalDebug) { |
|
| 206 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 207 | + } |
|
| 176 | 208 | //$icao = ACARS->ident2icao($ident); |
| 177 | 209 | //$icao = $Translation->checkTranslation($ident); |
| 178 | 210 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -197,14 +229,23 @@ discard block |
||
| 197 | 229 | //$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); |
| 198 | 230 | $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); |
| 199 | 231 | if ($n > 8) { |
| 200 | - 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"; |
|
| 201 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 202 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 232 | + if ($globalDebug) { |
|
| 233 | + 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"; |
|
| 234 | + } |
|
| 235 | + if ($dhour != '') { |
|
| 236 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 237 | + } |
|
| 238 | + if ($ahour != '') { |
|
| 239 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 240 | + } |
|
| 203 | 241 | $icao = trim($aident); |
| 204 | 242 | |
| 205 | 243 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
| 206 | - if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
| 207 | - else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
| 244 | + if ($ahour == '') { |
|
| 245 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
| 246 | + } else { |
|
| 247 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
| 248 | + } |
|
| 208 | 249 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
| 209 | 250 | $decode['icao'] = $icao; |
| 210 | 251 | $found = true; |
@@ -221,9 +262,15 @@ discard block |
||
| 221 | 262 | $lns = $lns.'.'.$lns; |
| 222 | 263 | $latitude = $las / 1000.0; |
| 223 | 264 | $longitude = $lns / 1000.0; |
| 224 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 225 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 226 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
| 265 | + if ($lac == 'S') { |
|
| 266 | + $latitude = '-'.$latitude; |
|
| 267 | + } |
|
| 268 | + if ($lnc == 'W') { |
|
| 269 | + $longitude = '-'.$longitude; |
|
| 270 | + } |
|
| 271 | + if ($globalDebug) { |
|
| 272 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
| 273 | + } |
|
| 227 | 274 | $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
| 228 | 275 | $found = true; |
| 229 | 276 | } |
@@ -239,7 +286,9 @@ discard block |
||
| 239 | 286 | */ |
| 240 | 287 | $n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr); |
| 241 | 288 | if ($n == 4) { |
| 242 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 289 | + if ($globalDebug) { |
|
| 290 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 291 | + } |
|
| 243 | 292 | //$icao = $Translation->checkTranslation($ident); |
| 244 | 293 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 245 | 294 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -250,7 +299,9 @@ discard block |
||
| 250 | 299 | // example message : "Reg. : TS-ION - Ident : TU0634 - Label : 1L - Message : 000442152001337,DTTJ,LFPO,1609" |
| 251 | 300 | $n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr); |
| 252 | 301 | if ($n == 4) { |
| 253 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 302 | + if ($globalDebug) { |
|
| 303 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 304 | + } |
|
| 254 | 305 | //$icao = $Translation->checkTranslation($ident); |
| 255 | 306 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 256 | 307 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -261,7 +312,9 @@ discard block |
||
| 261 | 312 | // example message : "Reg. : OO-TAH - Ident : 3V042J - Label : 5U - Message : 002AF EBLG EBBR N4621.5E 524.2195" |
| 262 | 313 | $n = sscanf($message, "002AF %4c %4c ", $dair, $darr); |
| 263 | 314 | if ($n == 2) { |
| 264 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 315 | + if ($globalDebug) { |
|
| 316 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 317 | + } |
|
| 265 | 318 | //$icao = $Translation->checkTranslation($ident); |
| 266 | 319 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
| 267 | 320 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -273,7 +326,9 @@ discard block |
||
| 273 | 326 | // 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,-----' |
| 274 | 327 | $n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
| 275 | 328 | if ($n == 6) { |
| 276 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 329 | + if ($globalDebug) { |
|
| 330 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 331 | + } |
|
| 277 | 332 | //$icao = $Translation->checkTranslation($ident); |
| 278 | 333 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 279 | 334 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -284,7 +339,9 @@ discard block |
||
| 284 | 339 | // 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' |
| 285 | 340 | $n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
| 286 | 341 | if ($n == 7) { |
| 287 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 342 | + if ($globalDebug) { |
|
| 343 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 344 | + } |
|
| 288 | 345 | //$icao = $Translation->checkTranslation($ident); |
| 289 | 346 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 290 | 347 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -304,8 +361,12 @@ discard block |
||
| 304 | 361 | $decode['icao'] = $icao; |
| 305 | 362 | $latitude = $las / 100.0; |
| 306 | 363 | $longitude = $lns / 100.0; |
| 307 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 308 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 364 | + if ($lac == 'S') { |
|
| 365 | + $latitude = '-'.$latitude; |
|
| 366 | + } |
|
| 367 | + if ($lnc == 'W') { |
|
| 368 | + $longitude = '-'.$longitude; |
|
| 369 | + } |
|
| 309 | 370 | |
| 310 | 371 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
| 311 | 372 | $found = true; |
@@ -319,8 +380,12 @@ discard block |
||
| 319 | 380 | if ($n == 4) { |
| 320 | 381 | $latitude = $las; |
| 321 | 382 | $longitude = $lns; |
| 322 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 323 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 383 | + if ($lac == 'S') { |
|
| 384 | + $latitude = '-'.$latitude; |
|
| 385 | + } |
|
| 386 | + if ($lnc == 'W') { |
|
| 387 | + $longitude = '-'.$longitude; |
|
| 388 | + } |
|
| 324 | 389 | |
| 325 | 390 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
| 326 | 391 | $found = true; |
@@ -334,7 +399,9 @@ discard block |
||
| 334 | 399 | */ |
| 335 | 400 | $n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr); |
| 336 | 401 | if ($n == 5) { |
| 337 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 402 | + if ($globalDebug) { |
|
| 403 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 404 | + } |
|
| 338 | 405 | //$icao = $Translation->checkTranslation($ident); |
| 339 | 406 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 340 | 407 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -352,7 +419,9 @@ discard block |
||
| 352 | 419 | // $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); |
| 353 | 420 | $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); |
| 354 | 421 | if ($n == 8) { |
| 355 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 422 | + if ($globalDebug) { |
|
| 423 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 424 | + } |
|
| 356 | 425 | $icao = trim($aident); |
| 357 | 426 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 358 | 427 | $decode['icao'] = $icao; |
@@ -367,7 +436,9 @@ discard block |
||
| 367 | 436 | */ |
| 368 | 437 | $n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr); |
| 369 | 438 | if ($n == 5) { |
| 370 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 439 | + if ($globalDebug) { |
|
| 440 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 441 | + } |
|
| 371 | 442 | //$icao = $Translation->checkTranslation($ident); |
| 372 | 443 | |
| 373 | 444 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -381,7 +452,9 @@ discard block |
||
| 381 | 452 | */ |
| 382 | 453 | $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
| 383 | 454 | if ($n == 3) { |
| 384 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 455 | + if ($globalDebug) { |
|
| 456 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 457 | + } |
|
| 385 | 458 | //$icao = $Translation->checkTranslation($ident); |
| 386 | 459 | |
| 387 | 460 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -395,7 +468,9 @@ discard block |
||
| 395 | 468 | */ |
| 396 | 469 | $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
| 397 | 470 | if ($n == 3) { |
| 398 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 471 | + if ($globalDebug) { |
|
| 472 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 473 | + } |
|
| 399 | 474 | //$icao = $Translation->checkTranslation($ident); |
| 400 | 475 | |
| 401 | 476 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -406,7 +481,9 @@ discard block |
||
| 406 | 481 | if (!$found) { |
| 407 | 482 | $n = sscanf($message,'MET01%4c',$airport); |
| 408 | 483 | if ($n == 1) { |
| 409 | - if ($globalDebug) echo 'airport name : '.$airport; |
|
| 484 | + if ($globalDebug) { |
|
| 485 | + echo 'airport name : '.$airport; |
|
| 486 | + } |
|
| 410 | 487 | $decode = array('Airport/Waypoint name' => $airport); |
| 411 | 488 | $found = true; |
| 412 | 489 | } |
@@ -415,184 +492,126 @@ discard block |
||
| 415 | 492 | if ($label == 'H1') { |
| 416 | 493 | if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
| 417 | 494 | $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
| 418 | - } |
|
| 419 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
| 495 | + } elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
| 420 | 496 | $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
| 421 | - } |
|
| 422 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
| 497 | + } elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
| 423 | 498 | $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
| 424 | - } |
|
| 425 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
| 499 | + } elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
| 426 | 500 | $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
| 427 | - } |
|
| 428 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
| 501 | + } elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
| 429 | 502 | $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
| 430 | - } |
|
| 431 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
| 503 | + } elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
| 432 | 504 | $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
| 433 | - } |
|
| 434 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
| 505 | + } elseif (preg_match(':^#M1AAEP:',$message)) { |
|
| 435 | 506 | $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
| 436 | - } |
|
| 437 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
| 507 | + } elseif (preg_match(':^#M2APWD:',$message)) { |
|
| 438 | 508 | $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
| 439 | - } |
|
| 440 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
| 509 | + } elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
| 441 | 510 | $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
| 442 | - } |
|
| 443 | - elseif (preg_match(':^#CF:',$message)) { |
|
| 511 | + } elseif (preg_match(':^#CF:',$message)) { |
|
| 444 | 512 | $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
| 445 | - } |
|
| 446 | - elseif (preg_match(':^#DF:',$message)) { |
|
| 513 | + } elseif (preg_match(':^#DF:',$message)) { |
|
| 447 | 514 | $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
| 448 | - } |
|
| 449 | - elseif (preg_match(':^#EC:',$message)) { |
|
| 515 | + } elseif (preg_match(':^#EC:',$message)) { |
|
| 450 | 516 | $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
| 451 | - } |
|
| 452 | - elseif (preg_match(':^#EI:',$message)) { |
|
| 517 | + } elseif (preg_match(':^#EI:',$message)) { |
|
| 453 | 518 | $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
| 454 | - } |
|
| 455 | - elseif (preg_match(':^#H1:',$message)) { |
|
| 519 | + } elseif (preg_match(':^#H1:',$message)) { |
|
| 456 | 520 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
| 457 | - } |
|
| 458 | - elseif (preg_match(':^#H2:',$message)) { |
|
| 521 | + } elseif (preg_match(':^#H2:',$message)) { |
|
| 459 | 522 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
| 460 | - } |
|
| 461 | - elseif (preg_match(':^#HD:',$message)) { |
|
| 523 | + } elseif (preg_match(':^#HD:',$message)) { |
|
| 462 | 524 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
| 463 | - } |
|
| 464 | - elseif (preg_match(':^#M1:',$message)) { |
|
| 525 | + } elseif (preg_match(':^#M1:',$message)) { |
|
| 465 | 526 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
| 466 | - } |
|
| 467 | - elseif (preg_match(':^#M2:',$message)) { |
|
| 527 | + } elseif (preg_match(':^#M2:',$message)) { |
|
| 468 | 528 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
| 469 | - } |
|
| 470 | - elseif (preg_match(':^#M3:',$message)) { |
|
| 529 | + } elseif (preg_match(':^#M3:',$message)) { |
|
| 471 | 530 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
| 472 | - } |
|
| 473 | - elseif (preg_match(':^#MD:',$message)) { |
|
| 531 | + } elseif (preg_match(':^#MD:',$message)) { |
|
| 474 | 532 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
| 475 | - } |
|
| 476 | - elseif (preg_match(':^#PS:',$message)) { |
|
| 533 | + } elseif (preg_match(':^#PS:',$message)) { |
|
| 477 | 534 | $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
| 478 | - } |
|
| 479 | - elseif (preg_match(':^#S1:',$message)) { |
|
| 535 | + } elseif (preg_match(':^#S1:',$message)) { |
|
| 480 | 536 | $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
| 481 | - } |
|
| 482 | - elseif (preg_match(':^#S2:',$message)) { |
|
| 537 | + } elseif (preg_match(':^#S2:',$message)) { |
|
| 483 | 538 | $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
| 484 | - } |
|
| 485 | - elseif (preg_match(':^#SD:',$message)) { |
|
| 539 | + } elseif (preg_match(':^#SD:',$message)) { |
|
| 486 | 540 | $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
| 487 | - } |
|
| 488 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
| 541 | + } elseif (preg_match(':^#T[0-8]:',$message)) { |
|
| 489 | 542 | $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
| 490 | - } |
|
| 491 | - elseif (preg_match(':^#WO:',$message)) { |
|
| 543 | + } elseif (preg_match(':^#WO:',$message)) { |
|
| 492 | 544 | $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
| 493 | - } |
|
| 494 | - elseif (preg_match(':^#A1:',$message)) { |
|
| 545 | + } elseif (preg_match(':^#A1:',$message)) { |
|
| 495 | 546 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
| 496 | - } |
|
| 497 | - elseif (preg_match(':^#A3:',$message)) { |
|
| 547 | + } elseif (preg_match(':^#A3:',$message)) { |
|
| 498 | 548 | $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
| 499 | - } |
|
| 500 | - elseif (preg_match(':^#A4:',$message)) { |
|
| 549 | + } elseif (preg_match(':^#A4:',$message)) { |
|
| 501 | 550 | $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
| 502 | - } |
|
| 503 | - elseif (preg_match(':^#A6:',$message)) { |
|
| 551 | + } elseif (preg_match(':^#A6:',$message)) { |
|
| 504 | 552 | $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
| 505 | - } |
|
| 506 | - elseif (preg_match(':^#A8:',$message)) { |
|
| 553 | + } elseif (preg_match(':^#A8:',$message)) { |
|
| 507 | 554 | $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
| 508 | - } |
|
| 509 | - elseif (preg_match(':^#A9:',$message)) { |
|
| 555 | + } elseif (preg_match(':^#A9:',$message)) { |
|
| 510 | 556 | $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
| 511 | - } |
|
| 512 | - elseif (preg_match(':^#A0:',$message)) { |
|
| 557 | + } elseif (preg_match(':^#A0:',$message)) { |
|
| 513 | 558 | $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
| 514 | - } |
|
| 515 | - elseif (preg_match(':^#AA:',$message)) { |
|
| 559 | + } elseif (preg_match(':^#AA:',$message)) { |
|
| 516 | 560 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
| 517 | - } |
|
| 518 | - elseif (preg_match(':^#AB:',$message)) { |
|
| 561 | + } elseif (preg_match(':^#AB:',$message)) { |
|
| 519 | 562 | $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
| 520 | - } |
|
| 521 | - elseif (preg_match(':^#AC:',$message)) { |
|
| 563 | + } elseif (preg_match(':^#AC:',$message)) { |
|
| 522 | 564 | $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
| 523 | - } |
|
| 524 | - elseif (preg_match(':^#AD:',$message)) { |
|
| 565 | + } elseif (preg_match(':^#AD:',$message)) { |
|
| 525 | 566 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
| 526 | - } |
|
| 527 | - elseif (preg_match(':^#AF:',$message)) { |
|
| 567 | + } elseif (preg_match(':^#AF:',$message)) { |
|
| 528 | 568 | $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
| 529 | - } |
|
| 530 | - elseif (preg_match(':^#B1:',$message)) { |
|
| 569 | + } elseif (preg_match(':^#B1:',$message)) { |
|
| 531 | 570 | $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
| 532 | - } |
|
| 533 | - elseif (preg_match(':^#B2:',$message)) { |
|
| 571 | + } elseif (preg_match(':^#B2:',$message)) { |
|
| 534 | 572 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
| 535 | - } |
|
| 536 | - elseif (preg_match(':^#B3:',$message)) { |
|
| 573 | + } elseif (preg_match(':^#B3:',$message)) { |
|
| 537 | 574 | $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
| 538 | - } |
|
| 539 | - elseif (preg_match(':^#B4:',$message)) { |
|
| 575 | + } elseif (preg_match(':^#B4:',$message)) { |
|
| 540 | 576 | $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
| 541 | - } |
|
| 542 | - elseif (preg_match(':^#B6:',$message)) { |
|
| 577 | + } elseif (preg_match(':^#B6:',$message)) { |
|
| 543 | 578 | $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
| 544 | - } |
|
| 545 | - elseif (preg_match(':^#B8:',$message)) { |
|
| 579 | + } elseif (preg_match(':^#B8:',$message)) { |
|
| 546 | 580 | $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
| 547 | - } |
|
| 548 | - elseif (preg_match(':^#B9:',$message)) { |
|
| 581 | + } elseif (preg_match(':^#B9:',$message)) { |
|
| 549 | 582 | $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
| 550 | - } |
|
| 551 | - elseif (preg_match(':^#B0:',$message)) { |
|
| 583 | + } elseif (preg_match(':^#B0:',$message)) { |
|
| 552 | 584 | $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
| 553 | - } |
|
| 554 | - elseif (preg_match(':^#BA:',$message)) { |
|
| 585 | + } elseif (preg_match(':^#BA:',$message)) { |
|
| 555 | 586 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
| 556 | - } |
|
| 557 | - elseif (preg_match(':^#BB:',$message)) { |
|
| 587 | + } elseif (preg_match(':^#BB:',$message)) { |
|
| 558 | 588 | $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
| 559 | - } |
|
| 560 | - elseif (preg_match(':^#BC:',$message)) { |
|
| 589 | + } elseif (preg_match(':^#BC:',$message)) { |
|
| 561 | 590 | $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
| 562 | - } |
|
| 563 | - elseif (preg_match(':^#BD:',$message)) { |
|
| 591 | + } elseif (preg_match(':^#BD:',$message)) { |
|
| 564 | 592 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
| 565 | - } |
|
| 566 | - elseif (preg_match(':^#BE:',$message)) { |
|
| 593 | + } elseif (preg_match(':^#BE:',$message)) { |
|
| 567 | 594 | $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
| 568 | - } |
|
| 569 | - elseif (preg_match(':^#BF:',$message)) { |
|
| 595 | + } elseif (preg_match(':^#BF:',$message)) { |
|
| 570 | 596 | $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
| 571 | - } |
|
| 572 | - elseif (preg_match(':^#H3:',$message)) { |
|
| 597 | + } elseif (preg_match(':^#H3:',$message)) { |
|
| 573 | 598 | $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
| 574 | 599 | } |
| 575 | 600 | } |
| 576 | 601 | if ($label == '10') { |
| 577 | 602 | if (preg_match(':^DTO01:',$message)) { |
| 578 | 603 | $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
| 579 | - } |
|
| 580 | - elseif (preg_match(':^AIS01:',$message)) { |
|
| 604 | + } elseif (preg_match(':^AIS01:',$message)) { |
|
| 581 | 605 | $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
| 582 | - } |
|
| 583 | - elseif (preg_match(':^FTX01:',$message)) { |
|
| 606 | + } elseif (preg_match(':^FTX01:',$message)) { |
|
| 584 | 607 | $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
| 585 | - } |
|
| 586 | - elseif (preg_match(':^FPL01:',$message)) { |
|
| 608 | + } elseif (preg_match(':^FPL01:',$message)) { |
|
| 587 | 609 | $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
| 588 | - } |
|
| 589 | - elseif (preg_match(':^WAB01:',$message)) { |
|
| 610 | + } elseif (preg_match(':^WAB01:',$message)) { |
|
| 590 | 611 | $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
| 591 | - } |
|
| 592 | - elseif (preg_match(':^MET01:',$message)) { |
|
| 612 | + } elseif (preg_match(':^MET01:',$message)) { |
|
| 593 | 613 | $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
| 594 | - } |
|
| 595 | - elseif (preg_match(':^WAB02:',$message)) { |
|
| 614 | + } elseif (preg_match(':^WAB02:',$message)) { |
|
| 596 | 615 | $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
| 597 | 616 | } |
| 598 | 617 | } |
@@ -607,38 +626,28 @@ discard block |
||
| 607 | 626 | $vsta = array('Version' => $version); |
| 608 | 627 | if ($state == 'E') { |
| 609 | 628 | $vsta = array_merge($vsta,array('Link state' => 'Established')); |
| 610 | - } |
|
| 611 | - elseif ($state == 'L') { |
|
| 629 | + } elseif ($state == 'L') { |
|
| 612 | 630 | $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
| 613 | - } |
|
| 614 | - else { |
|
| 631 | + } else { |
|
| 615 | 632 | $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
| 616 | 633 | } |
| 617 | 634 | if ($type == 'V') { |
| 618 | 635 | $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
| 619 | - } |
|
| 620 | - elseif ($type == 'S') { |
|
| 636 | + } elseif ($type == 'S') { |
|
| 621 | 637 | $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
| 622 | - } |
|
| 623 | - elseif ($type == 'H') { |
|
| 638 | + } elseif ($type == 'H') { |
|
| 624 | 639 | $vsta = array_merge($vsta,array('Link type' => 'HF')); |
| 625 | - } |
|
| 626 | - elseif ($type == 'G') { |
|
| 640 | + } elseif ($type == 'G') { |
|
| 627 | 641 | $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
| 628 | - } |
|
| 629 | - elseif ($type == 'C') { |
|
| 642 | + } elseif ($type == 'C') { |
|
| 630 | 643 | $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
| 631 | - } |
|
| 632 | - elseif ($type == '2') { |
|
| 644 | + } elseif ($type == '2') { |
|
| 633 | 645 | $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
| 634 | - } |
|
| 635 | - elseif ($type == 'X') { |
|
| 646 | + } elseif ($type == 'X') { |
|
| 636 | 647 | $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
| 637 | - } |
|
| 638 | - elseif ($type == 'I') { |
|
| 648 | + } elseif ($type == 'I') { |
|
| 639 | 649 | $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
| 640 | - } |
|
| 641 | - else { |
|
| 650 | + } else { |
|
| 642 | 651 | $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
| 643 | 652 | } |
| 644 | 653 | $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
@@ -647,7 +656,9 @@ discard block |
||
| 647 | 656 | } |
| 648 | 657 | |
| 649 | 658 | $title = $this->getTitlefromLabel($label); |
| 650 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
| 659 | + if ($title != '') { |
|
| 660 | + $decode = array_merge(array('Message title' => $title),$decode); |
|
| 661 | + } |
|
| 651 | 662 | |
| 652 | 663 | /* |
| 653 | 664 | // Business jets always use GS0001 |
@@ -688,14 +699,26 @@ discard block |
||
| 688 | 699 | $decode = $message['decode']; |
| 689 | 700 | $registration = $message['registration']; |
| 690 | 701 | |
| 691 | - if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
|
| 692 | - else $latitude = ''; |
|
| 693 | - if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
|
| 694 | - else $longitude = ''; |
|
| 695 | - if (isset($decode['airicao'])) $airicao = $decode['airicao']; |
|
| 696 | - else $airicao = ''; |
|
| 697 | - if (isset($decode['icao'])) $icao = $decode['icao']; |
|
| 698 | - else $icao = $Translation->checkTranslation($ident); |
|
| 702 | + if (isset($decode['latitude'])) { |
|
| 703 | + $latitude = $decode['latitude']; |
|
| 704 | + } else { |
|
| 705 | + $latitude = ''; |
|
| 706 | + } |
|
| 707 | + if (isset($decode['longitude'])) { |
|
| 708 | + $longitude = $decode['longitude']; |
|
| 709 | + } else { |
|
| 710 | + $longitude = ''; |
|
| 711 | + } |
|
| 712 | + if (isset($decode['airicao'])) { |
|
| 713 | + $airicao = $decode['airicao']; |
|
| 714 | + } else { |
|
| 715 | + $airicao = ''; |
|
| 716 | + } |
|
| 717 | + if (isset($decode['icao'])) { |
|
| 718 | + $icao = $decode['icao']; |
|
| 719 | + } else { |
|
| 720 | + $icao = $Translation->checkTranslation($ident); |
|
| 721 | + } |
|
| 699 | 722 | |
| 700 | 723 | $image_array = $Image->getSpotterImage($registration); |
| 701 | 724 | if (!isset($image_array[0]['registration'])) { |
@@ -703,11 +726,18 @@ discard block |
||
| 703 | 726 | } |
| 704 | 727 | |
| 705 | 728 | // Business jets always use GS0001 |
| 706 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 707 | - if ($globalDebug && isset($info) && $info != '') echo $info; |
|
| 729 | + if ($ident != 'GS0001') { |
|
| 730 | + $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 731 | + } |
|
| 732 | + if ($globalDebug && isset($info) && $info != '') { |
|
| 733 | + echo $info; |
|
| 734 | + } |
|
| 708 | 735 | |
| 709 | - if (count($decode) > 0) $decode_json = json_encode($decode); |
|
| 710 | - else $decode_json = ''; |
|
| 736 | + if (count($decode) > 0) { |
|
| 737 | + $decode_json = json_encode($decode); |
|
| 738 | + } else { |
|
| 739 | + $decode_json = ''; |
|
| 740 | + } |
|
| 711 | 741 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
| 712 | 742 | $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
| 713 | 743 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
@@ -715,8 +745,12 @@ discard block |
||
| 715 | 745 | } |
| 716 | 746 | |
| 717 | 747 | $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
| 718 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 719 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 748 | + if (!isset($globalACARSArchive)) { |
|
| 749 | + $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 750 | + } |
|
| 751 | + if ($result && in_array($label,$globalACARSArchive)) { |
|
| 752 | + $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 753 | + } |
|
| 720 | 754 | |
| 721 | 755 | if ($globalDebug && count($decode) > 0) { |
| 722 | 756 | echo "Human readable data : ".implode(' - ',$decode)."\n"; |
@@ -741,7 +775,9 @@ discard block |
||
| 741 | 775 | $Connection = new Connection($this->db); |
| 742 | 776 | $this->db = $Connection->db; |
| 743 | 777 | |
| 744 | - if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
|
| 778 | + if ($globalDebug) { |
|
| 779 | + echo "Test if not already in Live ACARS table..."; |
|
| 780 | + } |
|
| 745 | 781 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
| 746 | 782 | $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
| 747 | 783 | try { |
@@ -751,7 +787,9 @@ discard block |
||
| 751 | 787 | return "error : ".$e->getMessage(); |
| 752 | 788 | } |
| 753 | 789 | if ($stht->fetchColumn() == 0) { |
| 754 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
| 790 | + if ($globalDebug) { |
|
| 791 | + echo "Add Live ACARS data..."; |
|
| 792 | + } |
|
| 755 | 793 | $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)"; |
| 756 | 794 | $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")); |
| 757 | 795 | try { |
@@ -762,10 +800,14 @@ discard block |
||
| 762 | 800 | return "error : ".$e->getMessage(); |
| 763 | 801 | } |
| 764 | 802 | } else { |
| 765 | - if ($globalDebug) echo "Data already in DB...\n"; |
|
| 803 | + if ($globalDebug) { |
|
| 804 | + echo "Data already in DB...\n"; |
|
| 805 | + } |
|
| 766 | 806 | return false; |
| 767 | 807 | } |
| 768 | - if ($globalDebug) echo "Done\n"; |
|
| 808 | + if ($globalDebug) { |
|
| 809 | + echo "Done\n"; |
|
| 810 | + } |
|
| 769 | 811 | return true; |
| 770 | 812 | } |
| 771 | 813 | } |
@@ -797,7 +839,9 @@ discard block |
||
| 797 | 839 | } |
| 798 | 840 | if ($stht->fetchColumn() == 0) { |
| 799 | 841 | */ |
| 800 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
| 842 | + if ($globalDebug) { |
|
| 843 | + echo "Add Live ACARS data..."; |
|
| 844 | + } |
|
| 801 | 845 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
| 802 | 846 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
| 803 | 847 | try { |
@@ -808,7 +852,9 @@ discard block |
||
| 808 | 852 | return "error : ".$e->getMessage(); |
| 809 | 853 | } |
| 810 | 854 | // } |
| 811 | - if ($globalDebug) echo "Done\n"; |
|
| 855 | + if ($globalDebug) { |
|
| 856 | + echo "Done\n"; |
|
| 857 | + } |
|
| 812 | 858 | } |
| 813 | 859 | } |
| 814 | 860 | |
@@ -832,8 +878,11 @@ discard block |
||
| 832 | 878 | die; |
| 833 | 879 | } |
| 834 | 880 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 835 | - if (count($row) > 0) return $row[0]['title']; |
|
| 836 | - else return ''; |
|
| 881 | + if (count($row) > 0) { |
|
| 882 | + return $row[0]['title']; |
|
| 883 | + } else { |
|
| 884 | + return ''; |
|
| 885 | + } |
|
| 837 | 886 | } |
| 838 | 887 | |
| 839 | 888 | /** |
@@ -853,8 +902,11 @@ discard block |
||
| 853 | 902 | die; |
| 854 | 903 | } |
| 855 | 904 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 856 | - if (count($row) > 0) return $row; |
|
| 857 | - else return array(); |
|
| 905 | + if (count($row) > 0) { |
|
| 906 | + return $row; |
|
| 907 | + } else { |
|
| 908 | + return array(); |
|
| 909 | + } |
|
| 858 | 910 | } |
| 859 | 911 | |
| 860 | 912 | /** |
@@ -875,8 +927,11 @@ discard block |
||
| 875 | 927 | die; |
| 876 | 928 | } |
| 877 | 929 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 878 | - if (count($row) > 0) return $row[0]; |
|
| 879 | - else return array(); |
|
| 930 | + if (count($row) > 0) { |
|
| 931 | + return $row[0]; |
|
| 932 | + } else { |
|
| 933 | + return array(); |
|
| 934 | + } |
|
| 880 | 935 | } |
| 881 | 936 | |
| 882 | 937 | /** |
@@ -928,20 +983,36 @@ discard block |
||
| 928 | 983 | if ($row['registration'] != '') { |
| 929 | 984 | $row['registration'] = str_replace('.','',$row['registration']); |
| 930 | 985 | $image_array = $Image->getSpotterImage($row['registration']); |
| 931 | - 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'])); |
|
| 932 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 933 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 934 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 935 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 986 | + if (count($image_array) > 0) { |
|
| 987 | + $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'])); |
|
| 988 | + } else { |
|
| 989 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 990 | + } |
|
| 991 | + } else { |
|
| 992 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 993 | + } |
|
| 994 | + if ($row['registration'] == '') { |
|
| 995 | + $row['registration'] = 'NA'; |
|
| 996 | + } |
|
| 997 | + if ($row['ident'] == '') { |
|
| 998 | + $row['ident'] = 'NA'; |
|
| 999 | + } |
|
| 936 | 1000 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
| 937 | 1001 | if (isset($identicao[0])) { |
| 938 | 1002 | if (substr($row['ident'],0,2) == 'AF') { |
| 939 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 940 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 941 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1003 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 1004 | + $icao = $row['ident']; |
|
| 1005 | + } else { |
|
| 1006 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1007 | + } |
|
| 1008 | + } else { |
|
| 1009 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1010 | + } |
|
| 942 | 1011 | |
| 943 | 1012 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 944 | - } else $icao = $row['ident']; |
|
| 1013 | + } else { |
|
| 1014 | + $icao = $row['ident']; |
|
| 1015 | + } |
|
| 945 | 1016 | $icao = $Translation->checkTranslation($icao,false); |
| 946 | 1017 | |
| 947 | 1018 | $decode = json_decode($row['decode'],true); |
@@ -967,7 +1038,9 @@ discard block |
||
| 967 | 1038 | $found = true; |
| 968 | 1039 | } |
| 969 | 1040 | } |
| 970 | - if ($found) $row['decode'] = json_encode($decode); |
|
| 1041 | + if ($found) { |
|
| 1042 | + $row['decode'] = json_encode($decode); |
|
| 1043 | + } |
|
| 971 | 1044 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
| 972 | 1045 | $result[] = $data; |
| 973 | 1046 | $i++; |
@@ -975,8 +1048,9 @@ discard block |
||
| 975 | 1048 | if (isset($result)) { |
| 976 | 1049 | $result[0]['query_number_rows'] = $i; |
| 977 | 1050 | return $result; |
| 1051 | + } else { |
|
| 1052 | + return array(); |
|
| 978 | 1053 | } |
| 979 | - else return array(); |
|
| 980 | 1054 | } |
| 981 | 1055 | |
| 982 | 1056 | /** |
@@ -1036,20 +1110,36 @@ discard block |
||
| 1036 | 1110 | if ($row['registration'] != '') { |
| 1037 | 1111 | $row['registration'] = str_replace('.','',$row['registration']); |
| 1038 | 1112 | $image_array = $Image->getSpotterImage($row['registration']); |
| 1039 | - 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'])); |
|
| 1040 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1041 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1113 | + if (count($image_array) > 0) { |
|
| 1114 | + $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'])); |
|
| 1115 | + } else { |
|
| 1116 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1117 | + } |
|
| 1118 | + } else { |
|
| 1119 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1120 | + } |
|
| 1042 | 1121 | $icao = ''; |
| 1043 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 1044 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 1122 | + if ($row['registration'] == '') { |
|
| 1123 | + $row['registration'] = 'NA'; |
|
| 1124 | + } |
|
| 1125 | + if ($row['ident'] == '') { |
|
| 1126 | + $row['ident'] = 'NA'; |
|
| 1127 | + } |
|
| 1045 | 1128 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
| 1046 | 1129 | if (isset($identicao[0])) { |
| 1047 | 1130 | if (substr($row['ident'],0,2) == 'AF') { |
| 1048 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 1049 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1050 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1131 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 1132 | + $icao = $row['ident']; |
|
| 1133 | + } else { |
|
| 1134 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1135 | + } |
|
| 1136 | + } else { |
|
| 1137 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1138 | + } |
|
| 1051 | 1139 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 1052 | - } else $icao = $row['ident']; |
|
| 1140 | + } else { |
|
| 1141 | + $icao = $row['ident']; |
|
| 1142 | + } |
|
| 1053 | 1143 | $icao = $Translation->checkTranslation($icao); |
| 1054 | 1144 | |
| 1055 | 1145 | |
@@ -1057,12 +1147,16 @@ discard block |
||
| 1057 | 1147 | $found = false; |
| 1058 | 1148 | if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
| 1059 | 1149 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
| 1060 | - 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>'; |
|
| 1150 | + if (isset($airport_info[0]['icao'])) { |
|
| 1151 | + $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1152 | + } |
|
| 1061 | 1153 | $found = true; |
| 1062 | 1154 | } |
| 1063 | 1155 | if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
| 1064 | 1156 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
| 1065 | - 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>'; |
|
| 1157 | + if (isset($airport_info[0]['icao'])) { |
|
| 1158 | + $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1159 | + } |
|
| 1066 | 1160 | $found = true; |
| 1067 | 1161 | } |
| 1068 | 1162 | if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
@@ -1072,7 +1166,9 @@ discard block |
||
| 1072 | 1166 | $found = true; |
| 1073 | 1167 | } |
| 1074 | 1168 | } |
| 1075 | - if ($found) $row['decode'] = json_encode($decode); |
|
| 1169 | + if ($found) { |
|
| 1170 | + $row['decode'] = json_encode($decode); |
|
| 1171 | + } |
|
| 1076 | 1172 | |
| 1077 | 1173 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
| 1078 | 1174 | $result[] = $data; |
@@ -1081,7 +1177,9 @@ discard block |
||
| 1081 | 1177 | if (isset($result)) { |
| 1082 | 1178 | $result[0]['query_number_rows'] = $i; |
| 1083 | 1179 | return $result; |
| 1084 | - } else return array(); |
|
| 1180 | + } else { |
|
| 1181 | + return array(); |
|
| 1182 | + } |
|
| 1085 | 1183 | } |
| 1086 | 1184 | |
| 1087 | 1185 | /** |
@@ -1097,19 +1195,29 @@ discard block |
||
| 1097 | 1195 | $ident = trim($ident); |
| 1098 | 1196 | $Translation = new Translation($this->db); |
| 1099 | 1197 | $Spotter = new Spotter($this->db); |
| 1100 | - if ($globalDebug) echo "Test if we add ModeS data..."; |
|
| 1198 | + if ($globalDebug) { |
|
| 1199 | + echo "Test if we add ModeS data..."; |
|
| 1200 | + } |
|
| 1101 | 1201 | //if ($icao == '') $icao = ACARS->ident2icao($ident); |
| 1102 | - if ($icao == '') $icao = $Translation->checkTranslation($ident); |
|
| 1103 | - if ($globalDebug) echo '- Ident : '.$icao.' - '; |
|
| 1202 | + if ($icao == '') { |
|
| 1203 | + $icao = $Translation->checkTranslation($ident); |
|
| 1204 | + } |
|
| 1205 | + if ($globalDebug) { |
|
| 1206 | + echo '- Ident : '.$icao.' - '; |
|
| 1207 | + } |
|
| 1104 | 1208 | if ($ident == '' || $registration == '') { |
| 1105 | - if ($globalDebug) echo "Ident or registration null, exit\n"; |
|
| 1209 | + if ($globalDebug) { |
|
| 1210 | + echo "Ident or registration null, exit\n"; |
|
| 1211 | + } |
|
| 1106 | 1212 | return ''; |
| 1107 | 1213 | } |
| 1108 | 1214 | |
| 1109 | 1215 | $registration = str_replace('.','',$registration); |
| 1110 | 1216 | $ident = $Translation->ident2icao($ident); |
| 1111 | 1217 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
| 1112 | - if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
|
| 1218 | + if ($globalDebug) { |
|
| 1219 | + echo "Check if needed to add translation ".$ident.'... '; |
|
| 1220 | + } |
|
| 1113 | 1221 | $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"; |
| 1114 | 1222 | $querysi_values = array(':registration' => $registration); |
| 1115 | 1223 | try { |
@@ -1117,7 +1225,9 @@ discard block |
||
| 1117 | 1225 | $sthsi = $this->db->prepare($querysi); |
| 1118 | 1226 | $sthsi->execute($querysi_values); |
| 1119 | 1227 | } catch(PDOException $e) { |
| 1120 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1228 | + if ($globalDebug) { |
|
| 1229 | + echo $e->getMessage(); |
|
| 1230 | + } |
|
| 1121 | 1231 | return "error : ".$e->getMessage(); |
| 1122 | 1232 | } |
| 1123 | 1233 | $resultsi = $sthsi->fetch(PDO::FETCH_ASSOC); |
@@ -1125,9 +1235,14 @@ discard block |
||
| 1125 | 1235 | if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') { |
| 1126 | 1236 | $Translation = new Translation($this->db); |
| 1127 | 1237 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
| 1128 | - if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
| 1129 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1130 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1238 | + if ($globalDebug) { |
|
| 1239 | + echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
| 1240 | + } |
|
| 1241 | + if ($ident != $trans_ident) { |
|
| 1242 | + $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1243 | + } elseif ($trans_ident == $ident) { |
|
| 1244 | + $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1245 | + } |
|
| 1131 | 1246 | } else { |
| 1132 | 1247 | if ($registration != '' && $latitude != '' && $longitude != '') { |
| 1133 | 1248 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1136,17 +1251,24 @@ discard block |
||
| 1136 | 1251 | $sth = $this->db->prepare($query); |
| 1137 | 1252 | $sth->execute($query_values); |
| 1138 | 1253 | } catch(PDOException $e) { |
| 1139 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1254 | + if ($globalDebug) { |
|
| 1255 | + echo $e->getMessage(); |
|
| 1256 | + } |
|
| 1140 | 1257 | return "error : ".$e->getMessage(); |
| 1141 | 1258 | } |
| 1142 | 1259 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 1143 | - if (isset($result['modes'])) $hex = $result['modes']; |
|
| 1144 | - else $hex = ''; |
|
| 1260 | + if (isset($result['modes'])) { |
|
| 1261 | + $hex = $result['modes']; |
|
| 1262 | + } else { |
|
| 1263 | + $hex = ''; |
|
| 1264 | + } |
|
| 1145 | 1265 | $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
| 1146 | 1266 | $this->SI->add($SI_data); |
| 1147 | 1267 | } |
| 1148 | 1268 | } |
| 1149 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 1269 | + if ($globalDebug) { |
|
| 1270 | + echo 'Done'."\n"; |
|
| 1271 | + } |
|
| 1150 | 1272 | |
| 1151 | 1273 | $query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1"; |
| 1152 | 1274 | $query_values = array(':ident' => $icao); |
@@ -1155,14 +1277,19 @@ discard block |
||
| 1155 | 1277 | $sth = $this->db->prepare($query); |
| 1156 | 1278 | $sth->execute($query_values); |
| 1157 | 1279 | } catch(PDOException $e) { |
| 1158 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1280 | + if ($globalDebug) { |
|
| 1281 | + echo $e->getMessage(); |
|
| 1282 | + } |
|
| 1159 | 1283 | return "error : ".$e->getMessage(); |
| 1160 | 1284 | } |
| 1161 | 1285 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 1162 | 1286 | //print_r($result); |
| 1163 | 1287 | if (isset($result['flightaware_id'])) { |
| 1164 | - if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
|
| 1165 | - else $ModeS = ''; |
|
| 1288 | + if (isset($result['ModeS'])) { |
|
| 1289 | + $ModeS = $result['ModeS']; |
|
| 1290 | + } else { |
|
| 1291 | + $ModeS = ''; |
|
| 1292 | + } |
|
| 1166 | 1293 | if ($ModeS == '') { |
| 1167 | 1294 | $id = explode('-',$result['flightaware_id']); |
| 1168 | 1295 | $ModeS = $id[0]; |
@@ -1176,13 +1303,17 @@ discard block |
||
| 1176 | 1303 | $sthc = $this->db->prepare($queryc); |
| 1177 | 1304 | $sthc->execute($queryc_values); |
| 1178 | 1305 | } catch(PDOException $e) { |
| 1179 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1306 | + if ($globalDebug) { |
|
| 1307 | + echo $e->getMessage(); |
|
| 1308 | + } |
|
| 1180 | 1309 | return "error : ".$e->getMessage(); |
| 1181 | 1310 | } |
| 1182 | 1311 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
| 1183 | 1312 | |
| 1184 | 1313 | if (count($row) == 0) { |
| 1185 | - if ($globalDebug) echo " Add to ModeS table - "; |
|
| 1314 | + if ($globalDebug) { |
|
| 1315 | + echo " Add to ModeS table - "; |
|
| 1316 | + } |
|
| 1186 | 1317 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
| 1187 | 1318 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
| 1188 | 1319 | try { |
@@ -1190,11 +1321,15 @@ discard block |
||
| 1190 | 1321 | $sthi = $this->db->prepare($queryi); |
| 1191 | 1322 | $sthi->execute($queryi_values); |
| 1192 | 1323 | } catch(PDOException $e) { |
| 1193 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1324 | + if ($globalDebug) { |
|
| 1325 | + echo $e->getMessage(); |
|
| 1326 | + } |
|
| 1194 | 1327 | return "error : ".$e->getMessage(); |
| 1195 | 1328 | } |
| 1196 | 1329 | } else { |
| 1197 | - if ($globalDebug) echo " Update ModeS table - "; |
|
| 1330 | + if ($globalDebug) { |
|
| 1331 | + echo " Update ModeS table - "; |
|
| 1332 | + } |
|
| 1198 | 1333 | if ($ICAOTypeCode != '') { |
| 1199 | 1334 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
| 1200 | 1335 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
@@ -1207,7 +1342,9 @@ discard block |
||
| 1207 | 1342 | $sthi = $this->db->prepare($queryi); |
| 1208 | 1343 | $sthi->execute($queryi_values); |
| 1209 | 1344 | } catch(PDOException $e) { |
| 1210 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1345 | + if ($globalDebug) { |
|
| 1346 | + echo $e->getMessage(); |
|
| 1347 | + } |
|
| 1211 | 1348 | return "error : ".$e->getMessage(); |
| 1212 | 1349 | } |
| 1213 | 1350 | } |
@@ -1229,7 +1366,9 @@ discard block |
||
| 1229 | 1366 | return "error : ".$e->getMessage(); |
| 1230 | 1367 | } |
| 1231 | 1368 | */ |
| 1232 | - if ($globalDebug) echo " Update Spotter_output table - "; |
|
| 1369 | + if ($globalDebug) { |
|
| 1370 | + echo " Update Spotter_output table - "; |
|
| 1371 | + } |
|
| 1233 | 1372 | if ($ICAOTypeCode != '') { |
| 1234 | 1373 | if ($globalDBdriver == 'mysql') { |
| 1235 | 1374 | $queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
@@ -1240,8 +1379,7 @@ discard block |
||
| 1240 | 1379 | } else { |
| 1241 | 1380 | if ($globalDBdriver == 'mysql') { |
| 1242 | 1381 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
| 1243 | - } |
|
| 1244 | - elseif ($globalDBdriver == 'pgsql') { |
|
| 1382 | + } elseif ($globalDBdriver == 'pgsql') { |
|
| 1245 | 1383 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
| 1246 | 1384 | } |
| 1247 | 1385 | $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
@@ -1251,15 +1389,21 @@ discard block |
||
| 1251 | 1389 | $sthi = $this->db->prepare($queryi); |
| 1252 | 1390 | $sthi->execute($queryi_values); |
| 1253 | 1391 | } catch(PDOException $e) { |
| 1254 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1392 | + if ($globalDebug) { |
|
| 1393 | + echo $e->getMessage(); |
|
| 1394 | + } |
|
| 1255 | 1395 | return "error : ".$e->getMessage(); |
| 1256 | 1396 | } |
| 1257 | 1397 | |
| 1258 | 1398 | } |
| 1259 | 1399 | } else { |
| 1260 | - if ($globalDebug) echo " Can't find ModeS in spotter_output - "; |
|
| 1400 | + if ($globalDebug) { |
|
| 1401 | + echo " Can't find ModeS in spotter_output - "; |
|
| 1402 | + } |
|
| 1403 | + } |
|
| 1404 | + if ($globalDebug) { |
|
| 1405 | + echo "Done\n"; |
|
| 1261 | 1406 | } |
| 1262 | - if ($globalDebug) echo "Done\n"; |
|
| 1263 | 1407 | } |
| 1264 | 1408 | } |
| 1265 | 1409 | ?> |
@@ -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 = array(); |
| 90 | 98 | $result['location'] = $pieces[$pos]; |
| 91 | 99 | $pos++; |
@@ -94,16 +102,26 @@ discard block |
||
| 94 | 102 | $c = count($pieces); |
| 95 | 103 | for($pos++; $pos < $c; $pos++) { |
| 96 | 104 | $piece = $pieces[$pos]; |
| 97 | - if ($piece == 'RMK') break; |
|
| 98 | - if ($piece == 'AUTO') $result['auto'] = true; |
|
| 99 | - if ($piece == 'COR') $result['correction'] = true; |
|
| 105 | + if ($piece == 'RMK') { |
|
| 106 | + break; |
|
| 107 | + } |
|
| 108 | + if ($piece == 'AUTO') { |
|
| 109 | + $result['auto'] = true; |
|
| 110 | + } |
|
| 111 | + if ($piece == 'COR') { |
|
| 112 | + $result['correction'] = true; |
|
| 113 | + } |
|
| 100 | 114 | // Wind Speed |
| 101 | 115 | if (preg_match('#(VRB|\d\d\d)(\d\d)(?:G(\d\d))?(KT|MPS|KPH)(?: (\d{1,3})V(\d{1,3}))?$#', $piece, $matches)) { |
| 102 | 116 | $result['wind']['direction'] = (float)$matches[1]; |
| 103 | 117 | $result['wind']['unit'] = $matches[4]; |
| 104 | - if ($result['wind']['unit'] == 'KT') $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 105 | - elseif ($result['wind']['unit'] == 'KPH') $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 106 | - elseif ($result['wind']['unit'] == 'MPS') $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 118 | + if ($result['wind']['unit'] == 'KT') { |
|
| 119 | + $result['wind']['speed'] = round(((float)$matches[2])*0.51444444444,2); |
|
| 120 | + } elseif ($result['wind']['unit'] == 'KPH') { |
|
| 121 | + $result['wind']['speed'] = round(((float)$matches[2])*1000,2); |
|
| 122 | + } elseif ($result['wind']['unit'] == 'MPS') { |
|
| 123 | + $result['wind']['speed'] = round(((float)$matches[2]),2); |
|
| 124 | + } |
|
| 107 | 125 | $result['wind']['gust'] = (float)$matches[3]; |
| 108 | 126 | $result['wind']['unit'] = $matches[4]; |
| 109 | 127 | $result['wind']['min_variation'] = array_key_exists(5,$matches) ? $matches[5] : 0; |
@@ -185,14 +203,23 @@ discard block |
||
| 185 | 203 | //$this->addCloudCover($matches[1], ((float)$matches[2]) * 100, isset($matches[3]) ? $matches[3] : ''); |
| 186 | 204 | $type = $matches[1]; |
| 187 | 205 | $cloud = array(); |
| 188 | - if ($type == 'SKC') $cloud['type'] = 'No cloud/Sky clear'; |
|
| 189 | - elseif ($type == 'CLR') $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
| 190 | - elseif ($type == 'NSC') $cloud['type'] = 'No significant cloud'; |
|
| 191 | - elseif ($type == 'FEW') $cloud['type'] = 'Few'; |
|
| 192 | - elseif ($type == 'SCT') $cloud['type'] = 'Scattered'; |
|
| 193 | - elseif ($type == 'BKN') $cloud['type'] = 'Broken'; |
|
| 194 | - elseif ($type == 'OVC') $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
| 195 | - elseif ($type == 'VV') $cloud['type'] = 'Vertical visibility'; |
|
| 206 | + if ($type == 'SKC') { |
|
| 207 | + $cloud['type'] = 'No cloud/Sky clear'; |
|
| 208 | + } elseif ($type == 'CLR') { |
|
| 209 | + $cloud['type'] = 'No cloud below 12,000ft (3700m)'; |
|
| 210 | + } elseif ($type == 'NSC') { |
|
| 211 | + $cloud['type'] = 'No significant cloud'; |
|
| 212 | + } elseif ($type == 'FEW') { |
|
| 213 | + $cloud['type'] = 'Few'; |
|
| 214 | + } elseif ($type == 'SCT') { |
|
| 215 | + $cloud['type'] = 'Scattered'; |
|
| 216 | + } elseif ($type == 'BKN') { |
|
| 217 | + $cloud['type'] = 'Broken'; |
|
| 218 | + } elseif ($type == 'OVC') { |
|
| 219 | + $cloud['type'] = 'Overcast/Full cloud coverage'; |
|
| 220 | + } elseif ($type == 'VV') { |
|
| 221 | + $cloud['type'] = 'Vertical visibility'; |
|
| 222 | + } |
|
| 196 | 223 | $cloud['type_code'] = $type; |
| 197 | 224 | $cloud['level'] = round(((float)$matches[2]) * 100 * 0.3048); |
| 198 | 225 | $cloud['significant'] = isset($matches[3]) ? $matches[3] : ''; |
@@ -222,8 +249,11 @@ discard block |
||
| 222 | 249 | if (preg_match('#^(R[A-Z0-9]{2,3})/([0-9]{4})(V([0-9]{4}))?(FT)?$#', $piece, $matches)) { |
| 223 | 250 | //echo $piece; |
| 224 | 251 | //print_r($matches); |
| 225 | - if (isset($matches[5])) $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 226 | - else $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 252 | + if (isset($matches[5])) { |
|
| 253 | + $range = array('exact' => (float)$matches[2], 'unit' => $matches[5] ? 'FT' : 'M'); |
|
| 254 | + } else { |
|
| 255 | + $range = array('exact' => (float)$matches[2], 'unit' => 'M'); |
|
| 256 | + } |
|
| 227 | 257 | if (isset($matches[3])) { |
| 228 | 258 | $range = Array( |
| 229 | 259 | 'from' => (float)$matches[2], |
@@ -256,8 +286,11 @@ discard block |
||
| 256 | 286 | if (isset($matches[3])) { |
| 257 | 287 | $text[] = $this->texts[$matches[3]]; |
| 258 | 288 | } |
| 259 | - if (!isset($result['weather'])) $result['weather'] = implode(' ', $text); |
|
| 260 | - else $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
| 289 | + if (!isset($result['weather'])) { |
|
| 290 | + $result['weather'] = implode(' ', $text); |
|
| 291 | + } else { |
|
| 292 | + $result['weather'] = $result['weather'].' / '.implode(' ', $text); |
|
| 293 | + } |
|
| 261 | 294 | } |
| 262 | 295 | } |
| 263 | 296 | return $result; |
@@ -269,8 +302,11 @@ discard block |
||
| 269 | 302 | if (isset($globalMETARcycle) && $globalMETARcycle) { |
| 270 | 303 | $query = "SELECT * FROM metar WHERE metar_location = :icao"; |
| 271 | 304 | } else { |
| 272 | - if ($globalDBdriver == 'mysql') $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
| 273 | - else $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
| 305 | + if ($globalDBdriver == 'mysql') { |
|
| 306 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= DATE_SUB(UTC_TIMESTAMP(), INTERVAL 10 HOUR) LIMIT 1"; |
|
| 307 | + } else { |
|
| 308 | + $query = "SELECT * FROM metar WHERE metar_location = :icao AND metar_date >= now() AT TIMEZONE 'UTC' - '10 HOUR'->INTERVAL LIMIT 0,1"; |
|
| 309 | + } |
|
| 274 | 310 | } |
| 275 | 311 | $query_values = array(':icao' => $icao); |
| 276 | 312 | try { |
@@ -325,7 +361,9 @@ discard block |
||
| 325 | 361 | |
| 326 | 362 | public function addMETARCycle() { |
| 327 | 363 | global $globalDebug, $globalIVAO; |
| 328 | - if (isset($globalDebug) && $globalDebug) echo "Downloading METAR cycle..."; |
|
| 364 | + if (isset($globalDebug) && $globalDebug) { |
|
| 365 | + echo "Downloading METAR cycle..."; |
|
| 366 | + } |
|
| 329 | 367 | date_default_timezone_set("UTC"); |
| 330 | 368 | $Common = new Common(); |
| 331 | 369 | if (isset($globalIVAO) && $globalIVAO) { |
@@ -333,7 +371,9 @@ discard block |
||
| 333 | 371 | } else { |
| 334 | 372 | $cycle = $Common->getData('http://tgftp.nws.noaa.gov/data/observations/metar/cycles/'.date('H').'Z.TXT'); |
| 335 | 373 | } |
| 336 | - if (isset($globalDebug) && $globalDebug) echo "Done - Updating DB..."; |
|
| 374 | + if (isset($globalDebug) && $globalDebug) { |
|
| 375 | + echo "Done - Updating DB..."; |
|
| 376 | + } |
|
| 337 | 377 | $date = ''; |
| 338 | 378 | foreach(explode("\n",$cycle) as $line) { |
| 339 | 379 | if (preg_match('#^([0-9]{4})/([0-9]{2})/([0-9]{2}) ([0-9]{2}):([0-9]{2})$#',$line)) { |
@@ -342,22 +382,32 @@ discard block |
||
| 342 | 382 | } elseif ($line != '') { |
| 343 | 383 | //$this->parse($line); |
| 344 | 384 | //echo $line; |
| 345 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
| 385 | + if ($date == '') { |
|
| 386 | + $date = date('Y/m/d H:m'); |
|
| 387 | + } |
|
| 346 | 388 | $pos = 0; |
| 347 | 389 | $pieces = preg_split('/\s/',$line); |
| 348 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 349 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 390 | + if ($pieces[0] == 'METAR') { |
|
| 391 | + $pos++; |
|
| 392 | + } |
|
| 393 | + if (strlen($pieces[$pos]) != 4) { |
|
| 394 | + $pos++; |
|
| 395 | + } |
|
| 350 | 396 | $location = $pieces[$pos]; |
| 351 | 397 | echo $this->addMETAR($location,$line,$date); |
| 352 | 398 | } |
| 353 | 399 | //echo $line."\n"; |
| 354 | 400 | } |
| 355 | - if (isset($globalDebug) && $globalDebug) echo "Done\n"; |
|
| 401 | + if (isset($globalDebug) && $globalDebug) { |
|
| 402 | + echo "Done\n"; |
|
| 403 | + } |
|
| 356 | 404 | |
| 357 | 405 | } |
| 358 | 406 | public function downloadMETAR($icao) { |
| 359 | 407 | global $globalMETARurl; |
| 360 | - if ($globalMETARurl == '') return array(); |
|
| 408 | + if ($globalMETARurl == '') { |
|
| 409 | + return array(); |
|
| 410 | + } |
|
| 361 | 411 | date_default_timezone_set("UTC"); |
| 362 | 412 | $Common = new Common(); |
| 363 | 413 | $url = str_replace('{icao}',$icao,$globalMETARurl); |
@@ -370,16 +420,24 @@ discard block |
||
| 370 | 420 | } elseif ($line != '') { |
| 371 | 421 | //$this->parse($line); |
| 372 | 422 | //echo $line; |
| 373 | - if ($date == '') $date = date('Y/m/d H:m'); |
|
| 423 | + if ($date == '') { |
|
| 424 | + $date = date('Y/m/d H:m'); |
|
| 425 | + } |
|
| 374 | 426 | $pos = 0; |
| 375 | 427 | $pieces = preg_split('/\s/',$line); |
| 376 | - if ($pieces[0] == 'METAR') $pos++; |
|
| 377 | - if (strlen($pieces[$pos]) != 4) $pos++; |
|
| 428 | + if ($pieces[0] == 'METAR') { |
|
| 429 | + $pos++; |
|
| 430 | + } |
|
| 431 | + if (strlen($pieces[$pos]) != 4) { |
|
| 432 | + $pos++; |
|
| 433 | + } |
|
| 378 | 434 | $location = $pieces[$pos]; |
| 379 | 435 | if (strlen($location == 4)) { |
| 380 | 436 | $this->addMETAR($location,$line,$date); |
| 381 | 437 | return array('0' => array('metar_date' => $date, 'metar_location' => $location, 'metar' => $line)); |
| 382 | - } else return array(); |
|
| 438 | + } else { |
|
| 439 | + return array(); |
|
| 440 | + } |
|
| 383 | 441 | } |
| 384 | 442 | //echo $line."\n"; |
| 385 | 443 | } |
@@ -22,7 +22,9 @@ discard block |
||
| 22 | 22 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
| 23 | 23 | $aircraft_icao = filter_var($aircraft_icao,FILTER_SANITIZE_STRING); |
| 24 | 24 | $airline_icao = filter_var($airline_icao,FILTER_SANITIZE_STRING); |
| 25 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
| 25 | + if ($registration == '' && $aircraft_icao != '') { |
|
| 26 | + $registration = $aircraft_icao.$airline_icao; |
|
| 27 | + } |
|
| 26 | 28 | $registration = trim($registration); |
| 27 | 29 | $query = "SELECT spotter_image.image, spotter_image.image_thumbnail, spotter_image.image_source, spotter_image.image_source_website,spotter_image.image_copyright |
| 28 | 30 | FROM spotter_image |
@@ -60,8 +62,11 @@ discard block |
||
| 60 | 62 | public function getExifCopyright($url) { |
| 61 | 63 | $exif = exif_read_data($url); |
| 62 | 64 | $copyright = ''; |
| 63 | - if (isset($exif['COMPUTED']['copyright'])) $copyright = $exif['COMPUTED']['copyright']; |
|
| 64 | - elseif (isset($exif['copyright'])) $copyright = $exif['copyright']; |
|
| 65 | + if (isset($exif['COMPUTED']['copyright'])) { |
|
| 66 | + $copyright = $exif['COMPUTED']['copyright']; |
|
| 67 | + } elseif (isset($exif['copyright'])) { |
|
| 68 | + $copyright = $exif['copyright']; |
|
| 69 | + } |
|
| 65 | 70 | if ($copyright != '') { |
| 66 | 71 | $copyright = str_replace('Copyright ','',$copyright); |
| 67 | 72 | $copyright = str_replace('© ','',$copyright); |
@@ -79,18 +84,29 @@ discard block |
||
| 79 | 84 | public function addSpotterImage($registration,$aircraft_icao = '', $airline_icao = '') |
| 80 | 85 | { |
| 81 | 86 | global $globalDebug,$globalAircraftImageFetch; |
| 82 | - if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) return ''; |
|
| 87 | + if (isset($globalAircraftImageFetch) && !$globalAircraftImageFetch) { |
|
| 88 | + return ''; |
|
| 89 | + } |
|
| 83 | 90 | $registration = filter_var($registration,FILTER_SANITIZE_STRING); |
| 84 | 91 | $registration = trim($registration); |
| 85 | 92 | //getting the aircraft image |
| 86 | - if ($globalDebug && $registration != '') echo 'Try to find an aircraft image for '.$registration.'...'; |
|
| 87 | - elseif ($globalDebug && $aircraft_icao != '') echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
| 88 | - elseif ($globalDebug && $airline_icao != '') echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
| 89 | - else return "success"; |
|
| 93 | + if ($globalDebug && $registration != '') { |
|
| 94 | + echo 'Try to find an aircraft image for '.$registration.'...'; |
|
| 95 | + } elseif ($globalDebug && $aircraft_icao != '') { |
|
| 96 | + echo 'Try to find an aircraft image for '.$aircraft_icao.'...'; |
|
| 97 | + } elseif ($globalDebug && $airline_icao != '') { |
|
| 98 | + echo 'Try to find an aircraft image for '.$airline_icao.'...'; |
|
| 99 | + } else { |
|
| 100 | + return "success"; |
|
| 101 | + } |
|
| 90 | 102 | $image_url = $this->findAircraftImage($registration,$aircraft_icao,$airline_icao); |
| 91 | - if ($registration == '' && $aircraft_icao != '') $registration = $aircraft_icao.$airline_icao; |
|
| 103 | + if ($registration == '' && $aircraft_icao != '') { |
|
| 104 | + $registration = $aircraft_icao.$airline_icao; |
|
| 105 | + } |
|
| 92 | 106 | if ($image_url['original'] != '') { |
| 93 | - if ($globalDebug) echo 'Found !'."\n"; |
|
| 107 | + if ($globalDebug) { |
|
| 108 | + echo 'Found !'."\n"; |
|
| 109 | + } |
|
| 94 | 110 | $query = "INSERT INTO spotter_image (registration, image, image_thumbnail, image_copyright, image_source,image_source_website) VALUES (:registration,:image,:image_thumbnail,:copyright,:source,:source_website)"; |
| 95 | 111 | try { |
| 96 | 112 | $sth = $this->db->prepare($query); |
@@ -99,7 +115,9 @@ discard block |
||
| 99 | 115 | echo $e->getMessage()."\n"; |
| 100 | 116 | return "error"; |
| 101 | 117 | } |
| 102 | - } elseif ($globalDebug) echo "Not found :'(\n"; |
|
| 118 | + } elseif ($globalDebug) { |
|
| 119 | + echo "Not found :'(\n"; |
|
| 120 | + } |
|
| 103 | 121 | return "success"; |
| 104 | 122 | } |
| 105 | 123 | |
@@ -114,36 +132,75 @@ discard block |
||
| 114 | 132 | { |
| 115 | 133 | global $globalAircraftImageSources, $globalIVAO; |
| 116 | 134 | $Spotter = new Spotter($this->db); |
| 117 | - if (!isset($globalIVAO)) $globalIVAO = FALSE; |
|
| 135 | + if (!isset($globalIVAO)) { |
|
| 136 | + $globalIVAO = FALSE; |
|
| 137 | + } |
|
| 118 | 138 | $aircraft_registration = filter_var($aircraft_registration,FILTER_SANITIZE_STRING); |
| 119 | 139 | if ($aircraft_registration != '') { |
| 120 | - if (strpos($aircraft_registration,'/') !== false) return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 140 | + if (strpos($aircraft_registration,'/') !== false) { |
|
| 141 | + return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
|
| 142 | + } |
|
| 121 | 143 | $aircraft_registration = urlencode(trim($aircraft_registration)); |
| 122 | 144 | $aircraft_info = $Spotter->getAircraftInfoByRegistration($aircraft_registration); |
| 123 | - if (isset($aircraft_info[0]['aircraft_name'])) $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
| 124 | - else $aircraft_name = ''; |
|
| 125 | - if (isset($aircraft_info[0]['aircraft_icao'])) $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
| 126 | - else $aircraft_icao = ''; |
|
| 127 | - if (isset($aircraft_info[0]['airline_icao'])) $airline_icao = $aircraft_info[0]['airline_icao']; |
|
| 128 | - else $airline_icao = ''; |
|
| 145 | + if (isset($aircraft_info[0]['aircraft_name'])) { |
|
| 146 | + $aircraft_name = $aircraft_info[0]['aircraft_name']; |
|
| 147 | + } else { |
|
| 148 | + $aircraft_name = ''; |
|
| 149 | + } |
|
| 150 | + if (isset($aircraft_info[0]['aircraft_icao'])) { |
|
| 151 | + $aircraft_name = $aircraft_info[0]['aircraft_icao']; |
|
| 152 | + } else { |
|
| 153 | + $aircraft_icao = ''; |
|
| 154 | + } |
|
| 155 | + if (isset($aircraft_info[0]['airline_icao'])) { |
|
| 156 | + $airline_icao = $aircraft_info[0]['airline_icao']; |
|
| 157 | + } else { |
|
| 158 | + $airline_icao = ''; |
|
| 159 | + } |
|
| 129 | 160 | } elseif ($aircraft_icao != '') { |
| 130 | 161 | $aircraft_registration = $aircraft_icao; |
| 131 | 162 | $aircraft_name = ''; |
| 132 | - } else return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 133 | - if (!isset($globalAircraftImageSources)) $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 163 | + } else { |
|
| 164 | + return array('thumbnail' => '','original' => '', 'copyright' => '', 'source' => '','source_website' => ''); |
|
| 165 | + } |
|
| 166 | + if (!isset($globalAircraftImageSources)) { |
|
| 167 | + $globalAircraftImageSources = array('ivaomtl','wikimedia','airportdata','deviantart','flickr','bing','jetphotos','planepictures','planespotters'); |
|
| 168 | + } |
|
| 134 | 169 | foreach ($globalAircraftImageSources as $source) { |
| 135 | 170 | $source = strtolower($source); |
| 136 | - if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao); |
|
| 137 | - if ($source == 'planespotters' && !$globalIVAO) $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name); |
|
| 138 | - if ($source == 'flickr') $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name); |
|
| 139 | - if ($source == 'bing') $images_array = $this->fromBing($aircraft_registration,$aircraft_name); |
|
| 140 | - if ($source == 'deviantart') $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name); |
|
| 141 | - if ($source == 'wikimedia') $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name); |
|
| 142 | - if ($source == 'jetphotos' && !$globalIVAO) $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name); |
|
| 143 | - if ($source == 'planepictures' && !$globalIVAO) $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name); |
|
| 144 | - if ($source == 'airportdata' && !$globalIVAO) $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name); |
|
| 145 | - if ($source == 'customsources') $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name); |
|
| 146 | - if (isset($images_array) && $images_array['original'] != '') return $images_array; |
|
| 171 | + if ($source == 'ivaomtl' && $globalIVAO && $aircraft_icao != '' && $airline_icao != '') { |
|
| 172 | + $images_array = $this->fromIvaoMtl($aircraft_icao,$airline_icao); |
|
| 173 | + } |
|
| 174 | + if ($source == 'planespotters' && !$globalIVAO) { |
|
| 175 | + $images_array = $this->fromPlanespotters($aircraft_registration,$aircraft_name); |
|
| 176 | + } |
|
| 177 | + if ($source == 'flickr') { |
|
| 178 | + $images_array = $this->fromFlickr($aircraft_registration,$aircraft_name); |
|
| 179 | + } |
|
| 180 | + if ($source == 'bing') { |
|
| 181 | + $images_array = $this->fromBing($aircraft_registration,$aircraft_name); |
|
| 182 | + } |
|
| 183 | + if ($source == 'deviantart') { |
|
| 184 | + $images_array = $this->fromDeviantart($aircraft_registration,$aircraft_name); |
|
| 185 | + } |
|
| 186 | + if ($source == 'wikimedia') { |
|
| 187 | + $images_array = $this->fromWikimedia($aircraft_registration,$aircraft_name); |
|
| 188 | + } |
|
| 189 | + if ($source == 'jetphotos' && !$globalIVAO) { |
|
| 190 | + $images_array = $this->fromJetPhotos($aircraft_registration,$aircraft_name); |
|
| 191 | + } |
|
| 192 | + if ($source == 'planepictures' && !$globalIVAO) { |
|
| 193 | + $images_array = $this->fromPlanePictures($aircraft_registration,$aircraft_name); |
|
| 194 | + } |
|
| 195 | + if ($source == 'airportdata' && !$globalIVAO) { |
|
| 196 | + $images_array = $this->fromAirportData($aircraft_registration,$aircraft_name); |
|
| 197 | + } |
|
| 198 | + if ($source == 'customsources') { |
|
| 199 | + $images_array = $this->fromCustomSource($aircraft_registration,$aircraft_name); |
|
| 200 | + } |
|
| 201 | + if (isset($images_array) && $images_array['original'] != '') { |
|
| 202 | + return $images_array; |
|
| 203 | + } |
|
| 147 | 204 | } |
| 148 | 205 | return array('thumbnail' => '','original' => '', 'copyright' => '','source' => '','source_website' => ''); |
| 149 | 206 | } |
@@ -301,8 +358,11 @@ discard block |
||
| 301 | 358 | */ |
| 302 | 359 | public function fromFlickr($aircraft_registration,$aircraft_name='') { |
| 303 | 360 | $Common = new Common(); |
| 304 | - if ($aircraft_name != '') $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name); |
|
| 305 | - else $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft'; |
|
| 361 | + if ($aircraft_name != '') { |
|
| 362 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.','.urlencode($aircraft_name); |
|
| 363 | + } else { |
|
| 364 | + $url = 'https://api.flickr.com/services/feeds/photos_public.gne?format=rss2&license=1,2,3,4,5,6,7&per_page=1&tags='.$aircraft_registration.',aircraft'; |
|
| 365 | + } |
|
| 306 | 366 | $data = $Common->getData($url); |
| 307 | 367 | if ($xml = simplexml_load_string($data)) { |
| 308 | 368 | if (isset($xml->channel->item)) { |
@@ -346,9 +406,14 @@ discard block |
||
| 346 | 406 | public function fromBing($aircraft_registration,$aircraft_name='') { |
| 347 | 407 | global $globalImageBingKey; |
| 348 | 408 | $Common = new Common(); |
| 349 | - if (!isset($globalImageBingKey) || $globalImageBingKey == '') return false; |
|
| 350 | - if ($aircraft_name != '') $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 351 | - else $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 409 | + if (!isset($globalImageBingKey) || $globalImageBingKey == '') { |
|
| 410 | + return false; |
|
| 411 | + } |
|
| 412 | + if ($aircraft_name != '') { |
|
| 413 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27'.$aircraft_registration.'%20'.urlencode($aircraft_name).'%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 414 | + } else { |
|
| 415 | + $url = 'https://api.datamarket.azure.com/Bing/Search/v1/Image?$format=json&$top=1&Query=%27%2B'.$aircraft_registration.'%20%2Baircraft%20-site:planespotters.com%20-site:flickr.com%27'; |
|
| 416 | + } |
|
| 352 | 417 | $headers = array("Authorization: Basic " . base64_encode("ignored:".$globalImageBingKey)); |
| 353 | 418 | $data = $Common->getData($url,'get','',$headers); |
| 354 | 419 | $result = json_decode($data); |
@@ -402,13 +467,18 @@ discard block |
||
| 402 | 467 | */ |
| 403 | 468 | public function fromWikimedia($aircraft_registration,$aircraft_name='') { |
| 404 | 469 | $Common = new Common(); |
| 405 | - if ($aircraft_name != '') $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name); |
|
| 406 | - else $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft'; |
|
| 470 | + if ($aircraft_name != '') { |
|
| 471 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20'.urlencode($aircraft_name); |
|
| 472 | + } else { |
|
| 473 | + $url = 'https://commons.wikimedia.org/w/api.php?action=query&list=search&format=json&srlimit=1&srnamespace=6&continue&srsearch="'.$aircraft_registration.'"%20aircraft'; |
|
| 474 | + } |
|
| 407 | 475 | $data = $Common->getData($url); |
| 408 | 476 | $result = json_decode($data); |
| 409 | 477 | if (isset($result->query->search[0]->title)) { |
| 410 | 478 | $fileo = $result->query->search[0]->title; |
| 411 | - if (substr($fileo,-3) == 'pdf') return false; |
|
| 479 | + if (substr($fileo,-3) == 'pdf') { |
|
| 480 | + return false; |
|
| 481 | + } |
|
| 412 | 482 | $file = urlencode($fileo); |
| 413 | 483 | $url2 = 'https://commons.wikimedia.org/w/api.php?action=query&format=json&continue&iilimit=500&prop=imageinfo&iiprop=user|url|size|mime|sha1|timestamp&iiurlwidth=200%27&titles='.$file; |
| 414 | 484 | $data2 = $Common->getData($url2); |
@@ -460,7 +530,9 @@ discard block |
||
| 460 | 530 | global $globalAircraftCustomSources; |
| 461 | 531 | //$globalAircraftImageCustomSource[] = array('thumbnail' => '','original' => '', 'copyright' => '', 'source_website' => '', 'source' => '','exif' => true); |
| 462 | 532 | if (!empty($globalAircraftImageCustomSources)) { |
| 463 | - if (!isset($globalAircraftImageCustomSources[0])) $globalAircraftImageCustomSources[] = $globalAircraftImageCustomSources; |
|
| 533 | + if (!isset($globalAircraftImageCustomSources[0])) { |
|
| 534 | + $globalAircraftImageCustomSources[] = $globalAircraftImageCustomSources; |
|
| 535 | + } |
|
| 464 | 536 | foreach ($globalAircraftImageCustomSources as $source) { |
| 465 | 537 | $Common = new Common(); |
| 466 | 538 | $url = str_replace('{registration}',$aircraft_registration,$source['original']); |
@@ -469,17 +541,25 @@ discard block |
||
| 469 | 541 | $image_url = array(); |
| 470 | 542 | $image_url['thumbnail'] = $url_thumbnail; |
| 471 | 543 | $image_url['original'] = $url; |
| 472 | - if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) $exifCopyright = $this->getExifCopyright($url); |
|
| 473 | - else $exifCopyright = ''; |
|
| 474 | - if ($exifCopyright != '') $image_url['copyright'] = $exifCopyright; |
|
| 475 | - else $image_url['copyright'] = $source['copyright']; |
|
| 544 | + if ($source['exif'] && exif_imagetype($url) == IMAGETYPE_JPEG) { |
|
| 545 | + $exifCopyright = $this->getExifCopyright($url); |
|
| 546 | + } else { |
|
| 547 | + $exifCopyright = ''; |
|
| 548 | + } |
|
| 549 | + if ($exifCopyright != '') { |
|
| 550 | + $image_url['copyright'] = $exifCopyright; |
|
| 551 | + } else { |
|
| 552 | + $image_url['copyright'] = $source['copyright']; |
|
| 553 | + } |
|
| 476 | 554 | $image_url['source_website'] = $source['source_website']; |
| 477 | 555 | $image_url['source'] = $source['source']; |
| 478 | 556 | return $image_url; |
| 479 | 557 | } |
| 480 | 558 | } |
| 481 | 559 | return false; |
| 482 | - } else return false; |
|
| 560 | + } else { |
|
| 561 | + return false; |
|
| 562 | + } |
|
| 483 | 563 | } |
| 484 | 564 | } |
| 485 | 565 | |
@@ -14,10 +14,17 @@ discard block |
||
| 14 | 14 | if ($over_country == '') { |
| 15 | 15 | $Spotter = new Spotter($this->db); |
| 16 | 16 | $data_country = $Spotter->getCountryFromLatitudeLongitude($latitude,$longitude); |
| 17 | - if (!empty($data_country)) $country = $data_country['iso2']; |
|
| 18 | - else $country = ''; |
|
| 19 | - } else $country = $over_country; |
|
| 20 | - if ($airline_type === NULL) $airline_type =''; |
|
| 17 | + if (!empty($data_country)) { |
|
| 18 | + $country = $data_country['iso2']; |
|
| 19 | + } else { |
|
| 20 | + $country = ''; |
|
| 21 | + } |
|
| 22 | + } else { |
|
| 23 | + $country = $over_country; |
|
| 24 | + } |
|
| 25 | + if ($airline_type === NULL) { |
|
| 26 | + $airline_type =''; |
|
| 27 | + } |
|
| 21 | 28 | |
| 22 | 29 | //if ($country == '') echo "\n".'************ UNKNOW COUNTRY ****************'."\n"; |
| 23 | 30 | //else echo "\n".'*/*/*/*/*/*/*/ Country : '.$country.' */*/*/*/*/*/*/*/*/'."\n"; |
@@ -502,7 +509,9 @@ discard block |
||
| 502 | 509 | $additional_query .= "(spotter_archive_output.pilot_name like '%".$q_item."%') OR "; |
| 503 | 510 | $additional_query .= "(spotter_archive_output.ident like '%".$q_item."%') OR "; |
| 504 | 511 | $translate = $Translation->ident2icao($q_item); |
| 505 | - if ($translate != $q_item) $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 512 | + if ($translate != $q_item) { |
|
| 513 | + $additional_query .= "(spotter_archive_output.ident like '%".$translate."%') OR "; |
|
| 514 | + } |
|
| 506 | 515 | $additional_query .= "(spotter_archive_output.highlight like '%".$q_item."%')"; |
| 507 | 516 | $additional_query .= ")"; |
| 508 | 517 | } |
@@ -720,7 +729,9 @@ discard block |
||
| 720 | 729 | date_default_timezone_set($globalTimezone); |
| 721 | 730 | $datetime = new DateTime(); |
| 722 | 731 | $offset = $datetime->format('P'); |
| 723 | - } else $offset = '+00:00'; |
|
| 732 | + } else { |
|
| 733 | + $offset = '+00:00'; |
|
| 734 | + } |
|
| 724 | 735 | |
| 725 | 736 | |
| 726 | 737 | if ($date_array[1] != "") |
@@ -883,9 +894,13 @@ discard block |
||
| 883 | 894 | $query .= "AND date < CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - INTERVAL '".$olderthanmonths." MONTHS'"; |
| 884 | 895 | } |
| 885 | 896 | } |
| 886 | - if ($sincedate != '') $query .= "AND date > '".$sincedate."' "; |
|
| 897 | + if ($sincedate != '') { |
|
| 898 | + $query .= "AND date > '".$sincedate."' "; |
|
| 899 | + } |
|
| 887 | 900 | $query .= "GROUP BY c.name, c.iso3, c.iso2 ORDER BY nb DESC"; |
| 888 | - if ($limit) $query .= " LIMIT 0,10"; |
|
| 901 | + if ($limit) { |
|
| 902 | + $query .= " LIMIT 0,10"; |
|
| 903 | + } |
|
| 889 | 904 | |
| 890 | 905 | |
| 891 | 906 | $sth = $this->db->prepare($query); |