@@ -26,14 +26,19 @@ discard block |
||
| 26 | 26 | */ |
| 27 | 27 | public function ident2icao($ident) { |
| 28 | 28 | if (substr($ident,0,2) == 'AF') { |
| 29 | - if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $ident; |
|
| 30 | - else $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 29 | + if (filter_var(substr($ident,2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 30 | + $icao = $ident; |
|
| 31 | + } else { |
|
| 32 | + $icao = 'AFR'.ltrim(substr($ident,2),'0'); |
|
| 33 | + } |
|
| 31 | 34 | } else { |
| 32 | 35 | $Spotter = new Spotter($this->db); |
| 33 | 36 | $identicao = $Spotter->getAllAirlineInfo(substr($ident,0,2)); |
| 34 | 37 | if (isset($identicao[0])) { |
| 35 | 38 | $icao = $identicao[0]['icao'].ltrim(substr($ident,2),'0'); |
| 36 | - } else $icao = $ident; |
|
| 39 | + } else { |
|
| 40 | + $icao = $ident; |
|
| 41 | + } |
|
| 37 | 42 | } |
| 38 | 43 | return $icao; |
| 39 | 44 | } |
@@ -106,14 +111,24 @@ discard block |
||
| 106 | 111 | $message = ''; |
| 107 | 112 | $result = array(); |
| 108 | 113 | $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); |
| 109 | - 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); |
|
| 110 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 111 | - if ($n == 0) $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 114 | + if ($n == 0) { |
|
| 115 | + $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); |
|
| 116 | + } |
|
| 117 | + if ($n == 0) { |
|
| 118 | + $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%6[0-9A-Z-],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 119 | + } |
|
| 120 | + if ($n == 0) { |
|
| 121 | + $n = sscanf($data,'%*04d-%*02d-%*02d,%*02d:%*02d:%*02d,%*7s,%*c,%5[0-9A-Z],%*c,%2[0-9a-zA-Z_],%d,%4[0-9A-Z],%6[0-9A-Z],%[^\r\n]',$registration,$label,$block_id,$msg_no,$ident,$message); |
|
| 122 | + } |
|
| 112 | 123 | if ($n != 0) { |
| 113 | 124 | $registration = str_replace('.','',$registration); |
| 114 | 125 | $result = array('registration' => $registration, 'ident' => $ident,'label' => $label, 'block_id' => $block_id,'msg_no' => $msg_no,'message' => $message); |
| 115 | - if ($globalDebug) echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
| 116 | - } else $message = $data; |
|
| 126 | + if ($globalDebug) { |
|
| 127 | + echo "Reg. : ".$registration." - Ident : ".$ident." - Label : ".$label." - Message : ".$message."\n"; |
|
| 128 | + } |
|
| 129 | + } else { |
|
| 130 | + $message = $data; |
|
| 131 | + } |
|
| 117 | 132 | $decode = array(); |
| 118 | 133 | $found = false; |
| 119 | 134 | // if ($registration != '' && $ident != '' && $registration != '!') { |
@@ -133,12 +148,21 @@ discard block |
||
| 133 | 148 | if ($n > 5 && ($lac == 'N' || $lac == 'S') && ($lnc == 'E' || $lnc == 'W')) { |
| 134 | 149 | $latitude = $la / 10000.0; |
| 135 | 150 | $longitude = $ln / 10000.0; |
| 136 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 137 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 151 | + if ($lac == 'S') { |
|
| 152 | + $latitude = '-'.$latitude; |
|
| 153 | + } |
|
| 154 | + if ($lnc == 'W') { |
|
| 155 | + $longitude = '-'.$longitude; |
|
| 156 | + } |
|
| 138 | 157 | // Temp not always available |
| 139 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
| 140 | - if ($temp == '') $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
| 141 | - else $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
| 158 | + if ($globalDebug) { |
|
| 159 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude.' - airport depart : '.$dair.' - airport arrival : '.$darr.' - température : '.$temp."°C\n"; |
|
| 160 | + } |
|
| 161 | + if ($temp == '') { |
|
| 162 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr,'Altitude' => $alt); |
|
| 163 | + } else { |
|
| 164 | + $decode = array('Latitude' => $latitude, 'Longitude' => $longitude, 'Departure airport' => $dair, 'Arrival airport' => $darr, 'Altitude' => 'FL'.$alt,'Temperature' => $temp.'°C'); |
|
| 165 | + } |
|
| 142 | 166 | |
| 143 | 167 | //$icao = $Translation->checkTranslation($ident); |
| 144 | 168 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -152,25 +176,35 @@ discard block |
||
| 152 | 176 | $ahour = ''; |
| 153 | 177 | $n = sscanf($message, "ARR01 %4[A-Z]%4d %4[A-Z]%4d", $dair, $dhour, $darr,$ahour); |
| 154 | 178 | if ($n == 4 && strlen($darr) == 4) { |
| 155 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 156 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 157 | - if ($globalDebug) echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
| 179 | + if ($dhour != '') { |
|
| 180 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 181 | + } |
|
| 182 | + if ($ahour != '') { |
|
| 183 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 184 | + } |
|
| 185 | + if ($globalDebug) { |
|
| 186 | + echo 'departure airport : '.$dair.' - arrival airport : '. $darr.' - departure hour : '. $dhour.' - arrival hour : '.$ahour."\n"; |
|
| 187 | + } |
|
| 158 | 188 | //$icao = ACARS->ident2icao($ident); |
| 159 | 189 | //$icao = $Translation->checkTranslation($ident); |
| 160 | 190 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
| 161 | 191 | $decode = array('Departure airport' => $dair, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour); |
| 162 | 192 | $found = true; |
| 163 | - } |
|
| 164 | - elseif ($n == 2 || $n == 4) { |
|
| 165 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 166 | - if ($globalDebug) echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
| 193 | + } elseif ($n == 2 || $n == 4) { |
|
| 194 | + if ($dhour != '') { |
|
| 195 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 196 | + } |
|
| 197 | + if ($globalDebug) { |
|
| 198 | + echo 'airport arrival : '.$dair.' - arrival hour : '.$dhour."\n"; |
|
| 199 | + } |
|
| 167 | 200 | //$icao = ACARS->ident2icao($ident); |
| 168 | 201 | //$icao = $Translation->checkTranslation($ident); |
| 169 | 202 | $decode = array('Arrival airport' => $dair, 'Arrival hour' => $dhour); |
| 170 | 203 | $found = true; |
| 171 | - } |
|
| 172 | - elseif ($n == 1) { |
|
| 173 | - if ($globalDebug) echo 'airport arrival : '.$darr."\n"; |
|
| 204 | + } elseif ($n == 1) { |
|
| 205 | + if ($globalDebug) { |
|
| 206 | + echo 'airport arrival : '.$darr."\n"; |
|
| 207 | + } |
|
| 174 | 208 | //$icao = ACARS->ident2icao($ident); |
| 175 | 209 | //$icao = $Translation->checkTranslation($ident); |
| 176 | 210 | $decode = array('Arrival airport' => $darr); |
@@ -188,7 +222,9 @@ discard block |
||
| 188 | 222 | $darr = ''; |
| 189 | 223 | $n = sscanf($message, "%4c,%4c,%*7s,%*d", $dair, $darr); |
| 190 | 224 | if ($n == 4) { |
| 191 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 225 | + if ($globalDebug) { |
|
| 226 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 227 | + } |
|
| 192 | 228 | //$icao = ACARS->ident2icao($ident); |
| 193 | 229 | //$icao = $Translation->checkTranslation($ident); |
| 194 | 230 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -222,14 +258,23 @@ discard block |
||
| 222 | 258 | $apiste = ''; |
| 223 | 259 | $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); |
| 224 | 260 | if ($n > 8) { |
| 225 | - 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"; |
|
| 226 | - if ($dhour != '') $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 227 | - if ($ahour != '') $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 261 | + if ($globalDebug) { |
|
| 262 | + 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"; |
|
| 263 | + } |
|
| 264 | + if ($dhour != '') { |
|
| 265 | + $dhour = substr(sprintf('%04d',$dhour),0,2).':'.substr(sprintf('%04d',$dhour),2); |
|
| 266 | + } |
|
| 267 | + if ($ahour != '') { |
|
| 268 | + $ahour = substr(sprintf('%04d',$ahour),0,2).':'.substr(sprintf('%04d',$ahour),2); |
|
| 269 | + } |
|
| 228 | 270 | $icao = trim($aident); |
| 229 | 271 | |
| 230 | 272 | //$decode = 'Departure airport : '.$dair.' ('.$ddate.' at '.$dhour.') - Arrival Airport : '.$aair.' (at '.$ahour.') way '.$apiste; |
| 231 | - if ($ahour == '') $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
| 232 | - else $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
| 273 | + if ($ahour == '') { |
|
| 274 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr); |
|
| 275 | + } else { |
|
| 276 | + $decode = array('Departure airport' => $dair, 'Departure date' => $ddate, 'Departure hour' => $dhour, 'Arrival airport' => $darr, 'Arrival hour' => $ahour, 'Arrival way' => $apiste); |
|
| 277 | + } |
|
| 233 | 278 | //$Schedule->addSchedule($icao,$dair,$dhour,$darr,$ahour,'ACARS'); |
| 234 | 279 | $decode['icao'] = $icao; |
| 235 | 280 | $found = true; |
@@ -251,9 +296,15 @@ discard block |
||
| 251 | 296 | $lns = $lns.'.'.$lns; |
| 252 | 297 | $latitude = $las / 1000.0; |
| 253 | 298 | $longitude = $lns / 1000.0; |
| 254 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 255 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 256 | - if ($globalDebug) echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
| 299 | + if ($lac == 'S') { |
|
| 300 | + $latitude = '-'.$latitude; |
|
| 301 | + } |
|
| 302 | + if ($lnc == 'W') { |
|
| 303 | + $longitude = '-'.$longitude; |
|
| 304 | + } |
|
| 305 | + if ($globalDebug) { |
|
| 306 | + echo 'latitude : '.$latitude.' - longitude : '.$longitude."\n"; |
|
| 307 | + } |
|
| 257 | 308 | $decode = array('Latitude' => $latitude, 'Longitude' => $longitude); |
| 258 | 309 | $found = true; |
| 259 | 310 | } |
@@ -271,7 +322,9 @@ discard block |
||
| 271 | 322 | $darr = ''; |
| 272 | 323 | $n = sscanf($message, "%*[0-9A-Z ]/%*s %4c/%4c .", $dair, $darr); |
| 273 | 324 | if ($n == 4) { |
| 274 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 325 | + if ($globalDebug) { |
|
| 326 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 327 | + } |
|
| 275 | 328 | //$icao = $Translation->checkTranslation($ident); |
| 276 | 329 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 277 | 330 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -284,7 +337,9 @@ discard block |
||
| 284 | 337 | $darr = ''; |
| 285 | 338 | $n = sscanf($message, "%*[0-9],%4c,%4c,", $dair, $darr); |
| 286 | 339 | if ($n == 4) { |
| 287 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 340 | + if ($globalDebug) { |
|
| 341 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 342 | + } |
|
| 288 | 343 | //$icao = $Translation->checkTranslation($ident); |
| 289 | 344 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 290 | 345 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -297,7 +352,9 @@ discard block |
||
| 297 | 352 | $darr = ''; |
| 298 | 353 | $n = sscanf($message, "002AF %4c %4c ", $dair, $darr); |
| 299 | 354 | if ($n == 2) { |
| 300 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 355 | + if ($globalDebug) { |
|
| 356 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 357 | + } |
|
| 301 | 358 | //$icao = $Translation->checkTranslation($ident); |
| 302 | 359 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
| 303 | 360 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
@@ -311,7 +368,9 @@ discard block |
||
| 311 | 368 | $darr = ''; |
| 312 | 369 | $n = sscanf($message, "#DFBA%*02d/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
| 313 | 370 | if ($n == 6) { |
| 314 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 371 | + if ($globalDebug) { |
|
| 372 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 373 | + } |
|
| 315 | 374 | //$icao = $Translation->checkTranslation($ident); |
| 316 | 375 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 317 | 376 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -324,7 +383,9 @@ discard block |
||
| 324 | 383 | $darr = ''; |
| 325 | 384 | $n = sscanf($message, "#DFBA%*02d/%*[0-9A-Z,]/%*[A-Z-],%*[0-9A-Z],%*d,%4c,%4c", $dair, $darr); |
| 326 | 385 | if ($n == 7) { |
| 327 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 386 | + if ($globalDebug) { |
|
| 387 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 388 | + } |
|
| 328 | 389 | //$icao = $Translation->checkTranslation($ident); |
| 329 | 390 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 330 | 391 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -352,8 +413,12 @@ discard block |
||
| 352 | 413 | $decode['icao'] = $icao; |
| 353 | 414 | $latitude = $las / 100.0; |
| 354 | 415 | $longitude = $lns / 100.0; |
| 355 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 356 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 416 | + if ($lac == 'S') { |
|
| 417 | + $latitude = '-'.$latitude; |
|
| 418 | + } |
|
| 419 | + if ($lnc == 'W') { |
|
| 420 | + $longitude = '-'.$longitude; |
|
| 421 | + } |
|
| 357 | 422 | |
| 358 | 423 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude,'Altitude' => 'FL'.$alt,'Fuel' => $fuel,'speed' => $speed); |
| 359 | 424 | $found = true; |
@@ -371,8 +436,12 @@ discard block |
||
| 371 | 436 | if ($n == 4) { |
| 372 | 437 | $latitude = $las; |
| 373 | 438 | $longitude = $lns; |
| 374 | - if ($lac == 'S') $latitude = '-'.$latitude; |
|
| 375 | - if ($lnc == 'W') $longitude = '-'.$longitude; |
|
| 439 | + if ($lac == 'S') { |
|
| 440 | + $latitude = '-'.$latitude; |
|
| 441 | + } |
|
| 442 | + if ($lnc == 'W') { |
|
| 443 | + $longitude = '-'.$longitude; |
|
| 444 | + } |
|
| 376 | 445 | |
| 377 | 446 | $decode = array('Latitude' => $latitude,'Longitude' => $longitude); |
| 378 | 447 | $found = true; |
@@ -388,7 +457,9 @@ discard block |
||
| 388 | 457 | $darr = ''; |
| 389 | 458 | $n = sscanf($message, "%*[0-9A-Z] NLINFO %*d/%*d %4c/%4c .", $dair, $darr); |
| 390 | 459 | if ($n == 5) { |
| 391 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 460 | + if ($globalDebug) { |
|
| 461 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 462 | + } |
|
| 392 | 463 | //$icao = $Translation->checkTranslation($ident); |
| 393 | 464 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 394 | 465 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -409,7 +480,9 @@ discard block |
||
| 409 | 480 | $aident = ''; |
| 410 | 481 | $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); |
| 411 | 482 | if ($n == 8) { |
| 412 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 483 | + if ($globalDebug) { |
|
| 484 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 485 | + } |
|
| 413 | 486 | $icao = trim($aident); |
| 414 | 487 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 415 | 488 | $decode['icao'] = $icao; |
@@ -426,7 +499,9 @@ discard block |
||
| 426 | 499 | $darr = ''; |
| 427 | 500 | $n = sscanf($message, "%*d/%*d %4s/%4s .%*6s", $dair, $darr); |
| 428 | 501 | if ($n == 5) { |
| 429 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 502 | + if ($globalDebug) { |
|
| 503 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 504 | + } |
|
| 430 | 505 | //$icao = $Translation->checkTranslation($ident); |
| 431 | 506 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 432 | 507 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -441,7 +516,9 @@ discard block |
||
| 441 | 516 | $darr = ''; |
| 442 | 517 | $n = sscanf($message,'%4[A-Z]%4[A-Z]%*4d',$dair,$darr); |
| 443 | 518 | if ($n == 3) { |
| 444 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 519 | + if ($globalDebug) { |
|
| 520 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 521 | + } |
|
| 445 | 522 | //$icao = $Translation->checkTranslation($ident); |
| 446 | 523 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 447 | 524 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -456,7 +533,9 @@ discard block |
||
| 456 | 533 | $darr = ''; |
| 457 | 534 | $n = sscanf($message,'3J01 DSPTCH %*d/%*d %4s/%4s .%*6s',$dair,$darr); |
| 458 | 535 | if ($n == 3) { |
| 459 | - if ($globalDebug) echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 536 | + if ($globalDebug) { |
|
| 537 | + echo 'airport depart : '.$dair.' - airport arrival : '.$darr."\n"; |
|
| 538 | + } |
|
| 460 | 539 | //$icao = $Translation->checkTranslation($ident); |
| 461 | 540 | //$Schedule->addSchedule($icao,$dair,'',$darr,'','ACARS'); |
| 462 | 541 | $decode = array('Departure airport' => $dair, 'Arrival airport' => $darr); |
@@ -466,7 +545,9 @@ discard block |
||
| 466 | 545 | if (!$found) { |
| 467 | 546 | $n = sscanf($message,'MET01%4c',$airport); |
| 468 | 547 | if ($n == 1) { |
| 469 | - if ($globalDebug) echo 'airport name : '.$airport; |
|
| 548 | + if ($globalDebug) { |
|
| 549 | + echo 'airport name : '.$airport; |
|
| 550 | + } |
|
| 470 | 551 | $decode = array('Airport/Waypoint name' => $airport); |
| 471 | 552 | $found = true; |
| 472 | 553 | } |
@@ -474,184 +555,126 @@ discard block |
||
| 474 | 555 | if ($label == 'H1') { |
| 475 | 556 | if (preg_match('/^#CFBFLR/',$message) || preg_match('/^#CFBWRN/',$message)) { |
| 476 | 557 | $decode = array_merge(array('Message nature' => 'Equipment failure'),$decode); |
| 477 | - } |
|
| 478 | - elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
| 558 | + } elseif (preg_match('/^#DFB\*TKO/',$message) || preg_match('/^#DFBTKO/',$message)) { |
|
| 479 | 559 | $decode = array_merge(array('Message nature' => 'Take off performance data'),$decode); |
| 480 | - } |
|
| 481 | - elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
| 560 | + } elseif (preg_match('/^#DFB\*CRZ/',$message) || preg_match('/^#DFBCRZ/',$message)) { |
|
| 482 | 561 | $decode = array_merge(array('Message nature' => 'Cruise performance data'),$decode); |
| 483 | - } |
|
| 484 | - elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
| 562 | + } elseif (preg_match('/^#DFB\*WOB/',$message) || preg_match('/^#DFBWOB/',$message)) { |
|
| 485 | 563 | $decode = array_merge(array('Message nature' => 'Weather observation'),$decode); |
| 486 | - } |
|
| 487 | - elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
| 564 | + } elseif (preg_match(':^#DFB/PIREP:',$message)) { |
|
| 488 | 565 | $decode = array_merge(array('Message nature' => 'Pilot Report'),$decode); |
| 489 | - } |
|
| 490 | - elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
| 566 | + } elseif (preg_match('/^#DFBEDA/',$message) || preg_match('/^#DFBENG/',$message)) { |
|
| 491 | 567 | $decode = array_merge(array('Message nature' => 'Engine Data'),$decode); |
| 492 | - } |
|
| 493 | - elseif (preg_match(':^#M1AAEP:',$message)) { |
|
| 568 | + } elseif (preg_match(':^#M1AAEP:',$message)) { |
|
| 494 | 569 | $decode = array_merge(array('Message nature' => 'Position/Weather Report'),$decode); |
| 495 | - } |
|
| 496 | - elseif (preg_match(':^#M2APWD:',$message)) { |
|
| 570 | + } elseif (preg_match(':^#M2APWD:',$message)) { |
|
| 497 | 571 | $decode = array_merge(array('Message nature' => 'Flight plan predicted wind data'),$decode); |
| 498 | - } |
|
| 499 | - elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
| 572 | + } elseif (preg_match(':^#M1BREQPWI:',$message)) { |
|
| 500 | 573 | $decode = array_merge(array('Message nature' => 'Predicted wind info request'),$decode); |
| 501 | - } |
|
| 502 | - elseif (preg_match(':^#CF:',$message)) { |
|
| 574 | + } elseif (preg_match(':^#CF:',$message)) { |
|
| 503 | 575 | $decode = array_merge(array('Message nature' => 'Central Fault Display'),$decode); |
| 504 | - } |
|
| 505 | - elseif (preg_match(':^#DF:',$message)) { |
|
| 576 | + } elseif (preg_match(':^#DF:',$message)) { |
|
| 506 | 577 | $decode = array_merge(array('Message nature' => 'Digital Flight Data Acquisition Unit'),$decode); |
| 507 | - } |
|
| 508 | - elseif (preg_match(':^#EC:',$message)) { |
|
| 578 | + } elseif (preg_match(':^#EC:',$message)) { |
|
| 509 | 579 | $decode = array_merge(array('Message nature' => 'Engine Display System'),$decode); |
| 510 | - } |
|
| 511 | - elseif (preg_match(':^#EI:',$message)) { |
|
| 580 | + } elseif (preg_match(':^#EI:',$message)) { |
|
| 512 | 581 | $decode = array_merge(array('Message nature' => 'Engine Report'),$decode); |
| 513 | - } |
|
| 514 | - elseif (preg_match(':^#H1:',$message)) { |
|
| 582 | + } elseif (preg_match(':^#H1:',$message)) { |
|
| 515 | 583 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Left'),$decode); |
| 516 | - } |
|
| 517 | - elseif (preg_match(':^#H2:',$message)) { |
|
| 584 | + } elseif (preg_match(':^#H2:',$message)) { |
|
| 518 | 585 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Right'),$decode); |
| 519 | - } |
|
| 520 | - elseif (preg_match(':^#HD:',$message)) { |
|
| 586 | + } elseif (preg_match(':^#HD:',$message)) { |
|
| 521 | 587 | $decode = array_merge(array('Message nature' => 'HF Data Radio - Selected'),$decode); |
| 522 | - } |
|
| 523 | - elseif (preg_match(':^#M1:',$message)) { |
|
| 588 | + } elseif (preg_match(':^#M1:',$message)) { |
|
| 524 | 589 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Left'),$decode); |
| 525 | - } |
|
| 526 | - elseif (preg_match(':^#M2:',$message)) { |
|
| 590 | + } elseif (preg_match(':^#M2:',$message)) { |
|
| 527 | 591 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Right'),$decode); |
| 528 | - } |
|
| 529 | - elseif (preg_match(':^#M3:',$message)) { |
|
| 592 | + } elseif (preg_match(':^#M3:',$message)) { |
|
| 530 | 593 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Center'),$decode); |
| 531 | - } |
|
| 532 | - elseif (preg_match(':^#MD:',$message)) { |
|
| 594 | + } elseif (preg_match(':^#MD:',$message)) { |
|
| 533 | 595 | $decode = array_merge(array('Message nature' => 'Flight Management Computer - Selected'),$decode); |
| 534 | - } |
|
| 535 | - elseif (preg_match(':^#PS:',$message)) { |
|
| 596 | + } elseif (preg_match(':^#PS:',$message)) { |
|
| 536 | 597 | $decode = array_merge(array('Message nature' => 'Keyboard/Display Unit'),$decode); |
| 537 | - } |
|
| 538 | - elseif (preg_match(':^#S1:',$message)) { |
|
| 598 | + } elseif (preg_match(':^#S1:',$message)) { |
|
| 539 | 599 | $decode = array_merge(array('Message nature' => 'SDU - Left'),$decode); |
| 540 | - } |
|
| 541 | - elseif (preg_match(':^#S2:',$message)) { |
|
| 600 | + } elseif (preg_match(':^#S2:',$message)) { |
|
| 542 | 601 | $decode = array_merge(array('Message nature' => 'SDU - Right'),$decode); |
| 543 | - } |
|
| 544 | - elseif (preg_match(':^#SD:',$message)) { |
|
| 602 | + } elseif (preg_match(':^#SD:',$message)) { |
|
| 545 | 603 | $decode = array_merge(array('Message nature' => 'SDU - Selected'),$decode); |
| 546 | - } |
|
| 547 | - elseif (preg_match(':^#T[0-8]:',$message)) { |
|
| 604 | + } elseif (preg_match(':^#T[0-8]:',$message)) { |
|
| 548 | 605 | $decode = array_merge(array('Message nature' => 'Cabin Terminal Messages'),$decode); |
| 549 | - } |
|
| 550 | - elseif (preg_match(':^#WO:',$message)) { |
|
| 606 | + } elseif (preg_match(':^#WO:',$message)) { |
|
| 551 | 607 | $decode = array_merge(array('Message nature' => 'Weather Observation Report'),$decode); |
| 552 | - } |
|
| 553 | - elseif (preg_match(':^#A1:',$message)) { |
|
| 608 | + } elseif (preg_match(':^#A1:',$message)) { |
|
| 554 | 609 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance'),$decode); |
| 555 | - } |
|
| 556 | - elseif (preg_match(':^#A3:',$message)) { |
|
| 610 | + } elseif (preg_match(':^#A3:',$message)) { |
|
| 557 | 611 | $decode = array_merge(array('Message nature' => 'Departure Clearance Response'),$decode); |
| 558 | - } |
|
| 559 | - elseif (preg_match(':^#A4:',$message)) { |
|
| 612 | + } elseif (preg_match(':^#A4:',$message)) { |
|
| 560 | 613 | $decode = array_merge(array('Message nature' => 'Flight Systems Message'),$decode); |
| 561 | - } |
|
| 562 | - elseif (preg_match(':^#A6:',$message)) { |
|
| 614 | + } elseif (preg_match(':^#A6:',$message)) { |
|
| 563 | 615 | $decode = array_merge(array('Message nature' => 'Request ADS Reports'),$decode); |
| 564 | - } |
|
| 565 | - elseif (preg_match(':^#A8:',$message)) { |
|
| 616 | + } elseif (preg_match(':^#A8:',$message)) { |
|
| 566 | 617 | $decode = array_merge(array('Message nature' => 'Deliver Departure Slot'),$decode); |
| 567 | - } |
|
| 568 | - elseif (preg_match(':^#A9:',$message)) { |
|
| 618 | + } elseif (preg_match(':^#A9:',$message)) { |
|
| 569 | 619 | $decode = array_merge(array('Message nature' => 'ATIS report'),$decode); |
| 570 | - } |
|
| 571 | - elseif (preg_match(':^#A0:',$message)) { |
|
| 620 | + } elseif (preg_match(':^#A0:',$message)) { |
|
| 572 | 621 | $decode = array_merge(array('Message nature' => 'ATIS Facility Notification (AFN)'),$decode); |
| 573 | - } |
|
| 574 | - elseif (preg_match(':^#AA:',$message)) { |
|
| 622 | + } elseif (preg_match(':^#AA:',$message)) { |
|
| 575 | 623 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
| 576 | - } |
|
| 577 | - elseif (preg_match(':^#AB:',$message)) { |
|
| 624 | + } elseif (preg_match(':^#AB:',$message)) { |
|
| 578 | 625 | $decode = array_merge(array('Message nature' => 'TWIP Report'),$decode); |
| 579 | - } |
|
| 580 | - elseif (preg_match(':^#AC:',$message)) { |
|
| 626 | + } elseif (preg_match(':^#AC:',$message)) { |
|
| 581 | 627 | $decode = array_merge(array('Message nature' => 'Pushback Clearance'),$decode); |
| 582 | - } |
|
| 583 | - elseif (preg_match(':^#AD:',$message)) { |
|
| 628 | + } elseif (preg_match(':^#AD:',$message)) { |
|
| 584 | 629 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance'),$decode); |
| 585 | - } |
|
| 586 | - elseif (preg_match(':^#AF:',$message)) { |
|
| 630 | + } elseif (preg_match(':^#AF:',$message)) { |
|
| 587 | 631 | $decode = array_merge(array('Message nature' => 'CPC Command/Response'),$decode); |
| 588 | - } |
|
| 589 | - elseif (preg_match(':^#B1:',$message)) { |
|
| 632 | + } elseif (preg_match(':^#B1:',$message)) { |
|
| 590 | 633 | $decode = array_merge(array('Message nature' => 'Request Oceanic Clearance'),$decode); |
| 591 | - } |
|
| 592 | - elseif (preg_match(':^#B2:',$message)) { |
|
| 634 | + } elseif (preg_match(':^#B2:',$message)) { |
|
| 593 | 635 | $decode = array_merge(array('Message nature' => 'Oceanic Clearance Readback'),$decode); |
| 594 | - } |
|
| 595 | - elseif (preg_match(':^#B3:',$message)) { |
|
| 636 | + } elseif (preg_match(':^#B3:',$message)) { |
|
| 596 | 637 | $decode = array_merge(array('Message nature' => 'Request Departure Clearance'),$decode); |
| 597 | - } |
|
| 598 | - elseif (preg_match(':^#B4:',$message)) { |
|
| 638 | + } elseif (preg_match(':^#B4:',$message)) { |
|
| 599 | 639 | $decode = array_merge(array('Message nature' => 'Departure Clearance Readback'),$decode); |
| 600 | - } |
|
| 601 | - elseif (preg_match(':^#B6:',$message)) { |
|
| 640 | + } elseif (preg_match(':^#B6:',$message)) { |
|
| 602 | 641 | $decode = array_merge(array('Message nature' => 'Provide ADS Report'),$decode); |
| 603 | - } |
|
| 604 | - elseif (preg_match(':^#B8:',$message)) { |
|
| 642 | + } elseif (preg_match(':^#B8:',$message)) { |
|
| 605 | 643 | $decode = array_merge(array('Message nature' => 'Request Departure Slot'),$decode); |
| 606 | - } |
|
| 607 | - elseif (preg_match(':^#B9:',$message)) { |
|
| 644 | + } elseif (preg_match(':^#B9:',$message)) { |
|
| 608 | 645 | $decode = array_merge(array('Message nature' => 'Request ATIS Report'),$decode); |
| 609 | - } |
|
| 610 | - elseif (preg_match(':^#B0:',$message)) { |
|
| 646 | + } elseif (preg_match(':^#B0:',$message)) { |
|
| 611 | 647 | $decode = array_merge(array('Message nature' => 'ATS Facility Notification'),$decode); |
| 612 | - } |
|
| 613 | - elseif (preg_match(':^#BA:',$message)) { |
|
| 648 | + } elseif (preg_match(':^#BA:',$message)) { |
|
| 614 | 649 | $decode = array_merge(array('Message nature' => 'ATCComm'),$decode); |
| 615 | - } |
|
| 616 | - elseif (preg_match(':^#BB:',$message)) { |
|
| 650 | + } elseif (preg_match(':^#BB:',$message)) { |
|
| 617 | 651 | $decode = array_merge(array('Message nature' => 'Request TWIP Report'),$decode); |
| 618 | - } |
|
| 619 | - elseif (preg_match(':^#BC:',$message)) { |
|
| 652 | + } elseif (preg_match(':^#BC:',$message)) { |
|
| 620 | 653 | $decode = array_merge(array('Message nature' => 'Pushback Clearance Request'),$decode); |
| 621 | - } |
|
| 622 | - elseif (preg_match(':^#BD:',$message)) { |
|
| 654 | + } elseif (preg_match(':^#BD:',$message)) { |
|
| 623 | 655 | $decode = array_merge(array('Message nature' => 'Expected Taxi Clearance Request'),$decode); |
| 624 | - } |
|
| 625 | - elseif (preg_match(':^#BE:',$message)) { |
|
| 656 | + } elseif (preg_match(':^#BE:',$message)) { |
|
| 626 | 657 | $decode = array_merge(array('Message nature' => 'CPC Aircraft Log-On/Off Request'),$decode); |
| 627 | - } |
|
| 628 | - elseif (preg_match(':^#BF:',$message)) { |
|
| 658 | + } elseif (preg_match(':^#BF:',$message)) { |
|
| 629 | 659 | $decode = array_merge(array('Message nature' => 'CPC WILCO/UNABLE Response'),$decode); |
| 630 | - } |
|
| 631 | - elseif (preg_match(':^#H3:',$message)) { |
|
| 660 | + } elseif (preg_match(':^#H3:',$message)) { |
|
| 632 | 661 | $decode = array_merge(array('Message nature' => 'Icing Report'),$decode); |
| 633 | 662 | } |
| 634 | 663 | } |
| 635 | 664 | if ($label == '10') { |
| 636 | 665 | if (preg_match(':^DTO01:',$message)) { |
| 637 | 666 | $decode = array_merge(array('Message nature' => 'Delayed Takeoff Report'),$decode); |
| 638 | - } |
|
| 639 | - elseif (preg_match(':^AIS01:',$message)) { |
|
| 667 | + } elseif (preg_match(':^AIS01:',$message)) { |
|
| 640 | 668 | $decode = array_merge(array('Message nature' => 'AIS Request'),$decode); |
| 641 | - } |
|
| 642 | - elseif (preg_match(':^FTX01:',$message)) { |
|
| 669 | + } elseif (preg_match(':^FTX01:',$message)) { |
|
| 643 | 670 | $decode = array_merge(array('Message nature' => 'Free Text Downlink'),$decode); |
| 644 | - } |
|
| 645 | - elseif (preg_match(':^FPL01:',$message)) { |
|
| 671 | + } elseif (preg_match(':^FPL01:',$message)) { |
|
| 646 | 672 | $decode = array_merge(array('Message nature' => 'Flight Plan Request'),$decode); |
| 647 | - } |
|
| 648 | - elseif (preg_match(':^WAB01:',$message)) { |
|
| 673 | + } elseif (preg_match(':^WAB01:',$message)) { |
|
| 649 | 674 | $decode = array_merge(array('Message nature' => 'Weight & Balance Request'),$decode); |
| 650 | - } |
|
| 651 | - elseif (preg_match(':^MET01:',$message)) { |
|
| 675 | + } elseif (preg_match(':^MET01:',$message)) { |
|
| 652 | 676 | $decode = array_merge(array('Message nature' => 'Weather Data Request'),$decode); |
| 653 | - } |
|
| 654 | - elseif (preg_match(':^WAB02:',$message)) { |
|
| 677 | + } elseif (preg_match(':^WAB02:',$message)) { |
|
| 655 | 678 | $decode = array_merge(array('Message nature' => 'Weight and Balance Acknowledgement'),$decode); |
| 656 | 679 | } |
| 657 | 680 | } |
@@ -666,38 +689,28 @@ discard block |
||
| 666 | 689 | $vsta = array('Version' => $version); |
| 667 | 690 | if ($state == 'E') { |
| 668 | 691 | $vsta = array_merge($vsta,array('Link state' => 'Established')); |
| 669 | - } |
|
| 670 | - elseif ($state == 'L') { |
|
| 692 | + } elseif ($state == 'L') { |
|
| 671 | 693 | $vsta = array_merge($vsta,array('Link state' => 'Lost')); |
| 672 | - } |
|
| 673 | - else { |
|
| 694 | + } else { |
|
| 674 | 695 | $vsta = array_merge($vsta,array('Link state' => 'Unknown')); |
| 675 | 696 | } |
| 676 | 697 | if ($type == 'V') { |
| 677 | 698 | $vsta = array_merge($vsta,array('Link type' => 'VHF ACARS')); |
| 678 | - } |
|
| 679 | - elseif ($type == 'S') { |
|
| 699 | + } elseif ($type == 'S') { |
|
| 680 | 700 | $vsta = array_merge($vsta,array('Link type' => 'Generic SATCOM')); |
| 681 | - } |
|
| 682 | - elseif ($type == 'H') { |
|
| 701 | + } elseif ($type == 'H') { |
|
| 683 | 702 | $vsta = array_merge($vsta,array('Link type' => 'HF')); |
| 684 | - } |
|
| 685 | - elseif ($type == 'G') { |
|
| 703 | + } elseif ($type == 'G') { |
|
| 686 | 704 | $vsta = array_merge($vsta,array('Link type' => 'GlobalStar SATCOM')); |
| 687 | - } |
|
| 688 | - elseif ($type == 'C') { |
|
| 705 | + } elseif ($type == 'C') { |
|
| 689 | 706 | $vsta = array_merge($vsta,array('Link type' => 'ICO SATCOM')); |
| 690 | - } |
|
| 691 | - elseif ($type == '2') { |
|
| 707 | + } elseif ($type == '2') { |
|
| 692 | 708 | $vsta = array_merge($vsta,array('Link type' => 'VDL Mode 2')); |
| 693 | - } |
|
| 694 | - elseif ($type == 'X') { |
|
| 709 | + } elseif ($type == 'X') { |
|
| 695 | 710 | $vsta = array_merge($vsta,array('Link type' => 'Inmarsat Aero')); |
| 696 | - } |
|
| 697 | - elseif ($type == 'I') { |
|
| 711 | + } elseif ($type == 'I') { |
|
| 698 | 712 | $vsta = array_merge($vsta,array('Link type' => 'Irridium SATCOM')); |
| 699 | - } |
|
| 700 | - else { |
|
| 713 | + } else { |
|
| 701 | 714 | $vsta = array_merge($vsta,array('Link type' => 'Unknown')); |
| 702 | 715 | } |
| 703 | 716 | $vsta = array_merge($vsta,array('Event occured at' => implode(':',str_split($at,2)))); |
@@ -706,7 +719,9 @@ discard block |
||
| 706 | 719 | } |
| 707 | 720 | |
| 708 | 721 | $title = $this->getTitlefromLabel($label); |
| 709 | - if ($title != '') $decode = array_merge(array('Message title' => $title),$decode); |
|
| 722 | + if ($title != '') { |
|
| 723 | + $decode = array_merge(array('Message title' => $title),$decode); |
|
| 724 | + } |
|
| 710 | 725 | /* |
| 711 | 726 | // Business jets always use GS0001 |
| 712 | 727 | if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
@@ -741,31 +756,54 @@ discard block |
||
| 741 | 756 | $msg = $message['message']; |
| 742 | 757 | $decode = $message['decode']; |
| 743 | 758 | $registration = (string)$message['registration']; |
| 744 | - if (isset($decode['latitude'])) $latitude = $decode['latitude']; |
|
| 745 | - else $latitude = ''; |
|
| 746 | - if (isset($decode['longitude'])) $longitude = $decode['longitude']; |
|
| 747 | - else $longitude = ''; |
|
| 748 | - if (isset($decode['airicao'])) $airicao = $decode['airicao']; |
|
| 749 | - else $airicao = ''; |
|
| 750 | - if (isset($decode['icao'])) $icao = $decode['icao']; |
|
| 751 | - else $icao = $Translation->checkTranslation($ident); |
|
| 759 | + if (isset($decode['latitude'])) { |
|
| 760 | + $latitude = $decode['latitude']; |
|
| 761 | + } else { |
|
| 762 | + $latitude = ''; |
|
| 763 | + } |
|
| 764 | + if (isset($decode['longitude'])) { |
|
| 765 | + $longitude = $decode['longitude']; |
|
| 766 | + } else { |
|
| 767 | + $longitude = ''; |
|
| 768 | + } |
|
| 769 | + if (isset($decode['airicao'])) { |
|
| 770 | + $airicao = $decode['airicao']; |
|
| 771 | + } else { |
|
| 772 | + $airicao = ''; |
|
| 773 | + } |
|
| 774 | + if (isset($decode['icao'])) { |
|
| 775 | + $icao = $decode['icao']; |
|
| 776 | + } else { |
|
| 777 | + $icao = $Translation->checkTranslation($ident); |
|
| 778 | + } |
|
| 752 | 779 | $image_array = $Image->getSpotterImage($registration); |
| 753 | 780 | if (!isset($image_array[0]['registration'])) { |
| 754 | 781 | $Image->addSpotterImage($registration); |
| 755 | 782 | } |
| 756 | 783 | // Business jets always use GS0001 |
| 757 | - if ($ident != 'GS0001') $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 758 | - if ($globalDebug && isset($info) && $info != '') echo $info; |
|
| 759 | - if (count($decode) > 0) $decode_json = json_encode($decode); |
|
| 760 | - else $decode_json = ''; |
|
| 784 | + if ($ident != 'GS0001') { |
|
| 785 | + $info = $this->addModeSData($ident,$registration,$icao,$airicao,$latitude,$longitude); |
|
| 786 | + } |
|
| 787 | + if ($globalDebug && isset($info) && $info != '') { |
|
| 788 | + echo $info; |
|
| 789 | + } |
|
| 790 | + if (count($decode) > 0) { |
|
| 791 | + $decode_json = json_encode($decode); |
|
| 792 | + } else { |
|
| 793 | + $decode_json = ''; |
|
| 794 | + } |
|
| 761 | 795 | if (isset($decode['Departure airport']) && isset($decode['Departure hour']) && isset($decode['Arrival airport']) && isset($decode['Arrival hour'])) { |
| 762 | 796 | $Schedule->addSchedule($icao,$decode['Departure airport'],$decode['Departure hour'],$decode['Arrival airport'],$decode['Arrival hour'],'ACARS'); |
| 763 | 797 | } elseif (isset($decode['Departure airport']) && isset($decode['Arrival airport'])) { |
| 764 | 798 | $Schedule->addSchedule($icao,$decode['Departure airport'],'',$decode['Arrival airport'],'','ACARS'); |
| 765 | 799 | } |
| 766 | 800 | $result = $this->addLiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
| 767 | - if (!isset($globalACARSArchive)) $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 768 | - if ($result && in_array($label,$globalACARSArchive)) $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 801 | + if (!isset($globalACARSArchive)) { |
|
| 802 | + $globalACARSArchive = array('10','80','81','82','3F'); |
|
| 803 | + } |
|
| 804 | + if ($result && in_array($label,$globalACARSArchive)) { |
|
| 805 | + $this->addArchiveAcarsData($ident,$registration,$label,$block_id,$msg_no,$msg,$decode_json); |
|
| 806 | + } |
|
| 769 | 807 | if ($globalDebug && count($decode) > 0) { |
| 770 | 808 | echo "Human readable data : ".implode(' - ',$decode)."\n"; |
| 771 | 809 | } |
@@ -788,7 +826,9 @@ discard block |
||
| 788 | 826 | if ($label != 'SQ' && $label != 'Q0' && $label != '_d' && $message != '') { |
| 789 | 827 | $Connection = new Connection($this->db); |
| 790 | 828 | $this->db = $Connection->db; |
| 791 | - if ($globalDebug) echo "Test if not already in Live ACARS table..."; |
|
| 829 | + if ($globalDebug) { |
|
| 830 | + echo "Test if not already in Live ACARS table..."; |
|
| 831 | + } |
|
| 792 | 832 | $query_test = "SELECT COUNT(*) as nb FROM acars_live WHERE ident = :ident AND registration = :registration AND message = :message"; |
| 793 | 833 | $query_test_values = array(':ident' => $ident,':registration' => $registration, ':message' => $message); |
| 794 | 834 | try { |
@@ -798,7 +838,9 @@ discard block |
||
| 798 | 838 | return "error : ".$e->getMessage(); |
| 799 | 839 | } |
| 800 | 840 | if ($stht->fetchColumn() == 0) { |
| 801 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
| 841 | + if ($globalDebug) { |
|
| 842 | + echo "Add Live ACARS data..."; |
|
| 843 | + } |
|
| 802 | 844 | $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)"; |
| 803 | 845 | $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")); |
| 804 | 846 | try { |
@@ -808,10 +850,14 @@ discard block |
||
| 808 | 850 | return "error : ".$e->getMessage(); |
| 809 | 851 | } |
| 810 | 852 | } else { |
| 811 | - if ($globalDebug) echo "Data already in DB...\n"; |
|
| 853 | + if ($globalDebug) { |
|
| 854 | + echo "Data already in DB...\n"; |
|
| 855 | + } |
|
| 812 | 856 | return false; |
| 813 | 857 | } |
| 814 | - if ($globalDebug) echo "Done\n"; |
|
| 858 | + if ($globalDebug) { |
|
| 859 | + echo "Done\n"; |
|
| 860 | + } |
|
| 815 | 861 | return true; |
| 816 | 862 | } |
| 817 | 863 | } |
@@ -842,7 +888,9 @@ discard block |
||
| 842 | 888 | } |
| 843 | 889 | if ($stht->fetchColumn() == 0) { |
| 844 | 890 | */ |
| 845 | - if ($globalDebug) echo "Add Live ACARS data..."; |
|
| 891 | + if ($globalDebug) { |
|
| 892 | + echo "Add Live ACARS data..."; |
|
| 893 | + } |
|
| 846 | 894 | $query = "INSERT INTO acars_archive (ident,registration,label,block_id,msg_no,message,decode) VALUES (:ident,:registration,:label,:block_id,:msg_no,:message,:decode)"; |
| 847 | 895 | $query_values = array(':ident' => $ident,':registration' => $registration, ':label' => $label,':block_id' => $block_id, ':msg_no' => $msg_no, ':message' => $message, ':decode' => $decode); |
| 848 | 896 | try { |
@@ -851,7 +899,9 @@ discard block |
||
| 851 | 899 | } catch(PDOException $e) { |
| 852 | 900 | return "error : ".$e->getMessage(); |
| 853 | 901 | } |
| 854 | - if ($globalDebug) echo "Done\n"; |
|
| 902 | + if ($globalDebug) { |
|
| 903 | + echo "Done\n"; |
|
| 904 | + } |
|
| 855 | 905 | } |
| 856 | 906 | } |
| 857 | 907 | |
@@ -874,8 +924,11 @@ discard block |
||
| 874 | 924 | return ''; |
| 875 | 925 | } |
| 876 | 926 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 877 | - if (count($row) > 0) return $row[0]['title']; |
|
| 878 | - else return ''; |
|
| 927 | + if (count($row) > 0) { |
|
| 928 | + return $row[0]['title']; |
|
| 929 | + } else { |
|
| 930 | + return ''; |
|
| 931 | + } |
|
| 879 | 932 | } |
| 880 | 933 | |
| 881 | 934 | /** |
@@ -894,8 +947,11 @@ discard block |
||
| 894 | 947 | return array(); |
| 895 | 948 | } |
| 896 | 949 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 897 | - if (count($row) > 0) return $row; |
|
| 898 | - else return array(); |
|
| 950 | + if (count($row) > 0) { |
|
| 951 | + return $row; |
|
| 952 | + } else { |
|
| 953 | + return array(); |
|
| 954 | + } |
|
| 899 | 955 | } |
| 900 | 956 | |
| 901 | 957 | /** |
@@ -915,8 +971,11 @@ discard block |
||
| 915 | 971 | return array(); |
| 916 | 972 | } |
| 917 | 973 | $row = $sth->fetchAll(PDO::FETCH_ASSOC); |
| 918 | - if (count($row) > 0) return $row[0]; |
|
| 919 | - else return array(); |
|
| 974 | + if (count($row) > 0) { |
|
| 975 | + return $row[0]; |
|
| 976 | + } else { |
|
| 977 | + return array(); |
|
| 978 | + } |
|
| 920 | 979 | } |
| 921 | 980 | |
| 922 | 981 | /** |
@@ -961,19 +1020,35 @@ discard block |
||
| 961 | 1020 | if ($row['registration'] != '') { |
| 962 | 1021 | $row['registration'] = str_replace('.','',$row['registration']); |
| 963 | 1022 | $image_array = $Image->getSpotterImage($row['registration']); |
| 964 | - 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'])); |
|
| 965 | - else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 966 | - } else $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 967 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 968 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 1023 | + if (count($image_array) > 0) { |
|
| 1024 | + $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'])); |
|
| 1025 | + } else { |
|
| 1026 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1027 | + } |
|
| 1028 | + } else { |
|
| 1029 | + $data = array_merge($data,array('image' => '','image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1030 | + } |
|
| 1031 | + if ($row['registration'] == '') { |
|
| 1032 | + $row['registration'] = 'NA'; |
|
| 1033 | + } |
|
| 1034 | + if ($row['ident'] == '') { |
|
| 1035 | + $row['ident'] = 'NA'; |
|
| 1036 | + } |
|
| 969 | 1037 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
| 970 | 1038 | if (isset($identicao[0])) { |
| 971 | 1039 | if (substr($row['ident'],0,2) == 'AF') { |
| 972 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 973 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 974 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1040 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 1041 | + $icao = $row['ident']; |
|
| 1042 | + } else { |
|
| 1043 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1044 | + } |
|
| 1045 | + } else { |
|
| 1046 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1047 | + } |
|
| 975 | 1048 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 976 | - } else $icao = $row['ident']; |
|
| 1049 | + } else { |
|
| 1050 | + $icao = $row['ident']; |
|
| 1051 | + } |
|
| 977 | 1052 | $icao = $Translation->checkTranslation($icao,false); |
| 978 | 1053 | $decode = json_decode($row['decode'],true); |
| 979 | 1054 | $found = false; |
@@ -998,7 +1073,9 @@ discard block |
||
| 998 | 1073 | $found = true; |
| 999 | 1074 | } |
| 1000 | 1075 | } |
| 1001 | - if ($found) $row['decode'] = json_encode($decode); |
|
| 1076 | + if ($found) { |
|
| 1077 | + $row['decode'] = json_encode($decode); |
|
| 1078 | + } |
|
| 1002 | 1079 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
| 1003 | 1080 | $result[] = $data; |
| 1004 | 1081 | $i++; |
@@ -1006,8 +1083,9 @@ discard block |
||
| 1006 | 1083 | if (isset($result)) { |
| 1007 | 1084 | $result[0]['query_number_rows'] = $i; |
| 1008 | 1085 | return $result; |
| 1086 | + } else { |
|
| 1087 | + return array(); |
|
| 1009 | 1088 | } |
| 1010 | - else return array(); |
|
| 1011 | 1089 | } |
| 1012 | 1090 | |
| 1013 | 1091 | /** |
@@ -1056,31 +1134,51 @@ discard block |
||
| 1056 | 1134 | if ($row['registration'] != '') { |
| 1057 | 1135 | $row['registration'] = str_replace('.','',$row['registration']); |
| 1058 | 1136 | $image_array = $Image->getSpotterImage($row['registration']); |
| 1059 | - 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'])); |
|
| 1060 | - else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1061 | - } else $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1137 | + if (count($image_array) > 0) { |
|
| 1138 | + $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'])); |
|
| 1139 | + } else { |
|
| 1140 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1141 | + } |
|
| 1142 | + } else { |
|
| 1143 | + $data = array_merge($data,array('image_thumbnail' => '','image_copyright' => '','image_source' => '','image_source_website' => '')); |
|
| 1144 | + } |
|
| 1062 | 1145 | $icao = ''; |
| 1063 | - if ($row['registration'] == '') $row['registration'] = 'NA'; |
|
| 1064 | - if ($row['ident'] == '') $row['ident'] = 'NA'; |
|
| 1146 | + if ($row['registration'] == '') { |
|
| 1147 | + $row['registration'] = 'NA'; |
|
| 1148 | + } |
|
| 1149 | + if ($row['ident'] == '') { |
|
| 1150 | + $row['ident'] = 'NA'; |
|
| 1151 | + } |
|
| 1065 | 1152 | $identicao = $Spotter->getAllAirlineInfo(substr($row['ident'],0,2)); |
| 1066 | 1153 | if (isset($identicao[0])) { |
| 1067 | 1154 | if (substr($row['ident'],0,2) == 'AF') { |
| 1068 | - if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) $icao = $row['ident']; |
|
| 1069 | - else $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1070 | - } else $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1155 | + if (filter_var(substr($row['ident'],2),FILTER_VALIDATE_INT,array("flags"=>FILTER_FLAG_ALLOW_OCTAL))) { |
|
| 1156 | + $icao = $row['ident']; |
|
| 1157 | + } else { |
|
| 1158 | + $icao = 'AFR'.ltrim(substr($row['ident'],2),'0'); |
|
| 1159 | + } |
|
| 1160 | + } else { |
|
| 1161 | + $icao = $identicao[0]['icao'].ltrim(substr($row['ident'],2),'0'); |
|
| 1162 | + } |
|
| 1071 | 1163 | $data = array_merge($data,array('airline_icao' => $identicao[0]['icao'],'airline_name' => $identicao[0]['name'])); |
| 1072 | - } else $icao = $row['ident']; |
|
| 1164 | + } else { |
|
| 1165 | + $icao = $row['ident']; |
|
| 1166 | + } |
|
| 1073 | 1167 | $icao = $Translation->checkTranslation($icao); |
| 1074 | 1168 | $decode = json_decode($row['decode'],true); |
| 1075 | 1169 | $found = false; |
| 1076 | 1170 | if ($decode != '' && array_key_exists('Departure airport',$decode)) { |
| 1077 | 1171 | $airport_info = $Spotter->getAllAirportInfo($decode['Departure airport']); |
| 1078 | - 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>'; |
|
| 1172 | + if (isset($airport_info[0]['icao'])) { |
|
| 1173 | + $decode['Departure airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1174 | + } |
|
| 1079 | 1175 | $found = true; |
| 1080 | 1176 | } |
| 1081 | 1177 | if ($decode != '' && array_key_exists('Arrival airport',$decode)) { |
| 1082 | 1178 | $airport_info = $Spotter->getAllAirportInfo($decode['Arrival airport']); |
| 1083 | - 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>'; |
|
| 1179 | + if (isset($airport_info[0]['icao'])) { |
|
| 1180 | + $decode['Arrival airport'] = '<a href="'.$globalURL.'/airport/'.$airport_info[0]['icao'].'">'.$airport_info[0]['city'].','.$airport_info[0]['country'].' ('.$airport_info[0]['icao'].')</a>'; |
|
| 1181 | + } |
|
| 1084 | 1182 | $found = true; |
| 1085 | 1183 | } |
| 1086 | 1184 | if ($decode != '' && array_key_exists('Airport/Waypoint name',$decode)) { |
@@ -1090,7 +1188,9 @@ discard block |
||
| 1090 | 1188 | $found = true; |
| 1091 | 1189 | } |
| 1092 | 1190 | } |
| 1093 | - if ($found) $row['decode'] = json_encode($decode); |
|
| 1191 | + if ($found) { |
|
| 1192 | + $row['decode'] = json_encode($decode); |
|
| 1193 | + } |
|
| 1094 | 1194 | $data = array_merge($data,array('registration' => $row['registration'],'message' => $row['message'], 'date' => $row['date'], 'ident' => $icao, 'decode' => $row['decode'])); |
| 1095 | 1195 | $result[] = $data; |
| 1096 | 1196 | $i++; |
@@ -1098,7 +1198,9 @@ discard block |
||
| 1098 | 1198 | if (isset($result)) { |
| 1099 | 1199 | $result[0]['query_number_rows'] = $i; |
| 1100 | 1200 | return $result; |
| 1101 | - } else return array(); |
|
| 1201 | + } else { |
|
| 1202 | + return array(); |
|
| 1203 | + } |
|
| 1102 | 1204 | } |
| 1103 | 1205 | |
| 1104 | 1206 | /** |
@@ -1114,25 +1216,37 @@ discard block |
||
| 1114 | 1216 | $ident = trim($ident); |
| 1115 | 1217 | $Translation = new Translation($this->db); |
| 1116 | 1218 | $Spotter = new Spotter($this->db); |
| 1117 | - if ($globalDebug) echo "Test if we add ModeS data..."; |
|
| 1219 | + if ($globalDebug) { |
|
| 1220 | + echo "Test if we add ModeS data..."; |
|
| 1221 | + } |
|
| 1118 | 1222 | //if ($icao == '') $icao = ACARS->ident2icao($ident); |
| 1119 | - if ($icao == '') $icao = $Translation->checkTranslation($ident); |
|
| 1120 | - if ($globalDebug) echo '- Ident : '.$icao.' - '; |
|
| 1223 | + if ($icao == '') { |
|
| 1224 | + $icao = $Translation->checkTranslation($ident); |
|
| 1225 | + } |
|
| 1226 | + if ($globalDebug) { |
|
| 1227 | + echo '- Ident : '.$icao.' - '; |
|
| 1228 | + } |
|
| 1121 | 1229 | if ($ident == '' || $registration == '') { |
| 1122 | - if ($globalDebug) echo "Ident or registration null, exit\n"; |
|
| 1230 | + if ($globalDebug) { |
|
| 1231 | + echo "Ident or registration null, exit\n"; |
|
| 1232 | + } |
|
| 1123 | 1233 | return ''; |
| 1124 | 1234 | } |
| 1125 | 1235 | $registration = str_replace('.','',$registration); |
| 1126 | 1236 | $ident = $Translation->ident2icao($ident); |
| 1127 | 1237 | // Check if a flight with same registration is flying now, if ok check if callsign = name in ACARS, else add it to translation |
| 1128 | - if ($globalDebug) echo "Check if needed to add translation ".$ident.'... '; |
|
| 1238 | + if ($globalDebug) { |
|
| 1239 | + echo "Check if needed to add translation ".$ident.'... '; |
|
| 1240 | + } |
|
| 1129 | 1241 | $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"; |
| 1130 | 1242 | $querysi_values = array(':registration' => $registration); |
| 1131 | 1243 | try { |
| 1132 | 1244 | $sthsi = $this->db->prepare($querysi); |
| 1133 | 1245 | $sthsi->execute($querysi_values); |
| 1134 | 1246 | } catch(PDOException $e) { |
| 1135 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1247 | + if ($globalDebug) { |
|
| 1248 | + echo $e->getMessage(); |
|
| 1249 | + } |
|
| 1136 | 1250 | return "error : ".$e->getMessage(); |
| 1137 | 1251 | } |
| 1138 | 1252 | $resultsi = $sthsi->fetch(PDO::FETCH_ASSOC); |
@@ -1140,9 +1254,14 @@ discard block |
||
| 1140 | 1254 | if (count($resultsi) > 0 && $resultsi['ident'] != $ident && $resultsi['ident'] != '') { |
| 1141 | 1255 | $Translation = new Translation($this->db); |
| 1142 | 1256 | $trans_ident = $Translation->getOperator($resultsi['ident']); |
| 1143 | - if ($globalDebug) echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
| 1144 | - if ($ident != $trans_ident) $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1145 | - elseif ($trans_ident == $ident) $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1257 | + if ($globalDebug) { |
|
| 1258 | + echo 'Add translation to table : '.$ident.' -> '.$resultsi['ident'].' '; |
|
| 1259 | + } |
|
| 1260 | + if ($ident != $trans_ident) { |
|
| 1261 | + $Translation->addOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1262 | + } elseif ($trans_ident == $ident) { |
|
| 1263 | + $Translation->updateOperator($resultsi['ident'],$ident,'ACARS'); |
|
| 1264 | + } |
|
| 1146 | 1265 | } else { |
| 1147 | 1266 | if ($registration != '' && $latitude != '' && $longitude != '') { |
| 1148 | 1267 | $query = "SELECT ModeS FROM aircraft_modes WHERE Registration = :registration LIMIT 1"; |
@@ -1151,32 +1270,46 @@ discard block |
||
| 1151 | 1270 | $sth = $this->db->prepare($query); |
| 1152 | 1271 | $sth->execute($query_values); |
| 1153 | 1272 | } catch(PDOException $e) { |
| 1154 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1273 | + if ($globalDebug) { |
|
| 1274 | + echo $e->getMessage(); |
|
| 1275 | + } |
|
| 1155 | 1276 | return "error : ".$e->getMessage(); |
| 1156 | 1277 | } |
| 1157 | 1278 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 1158 | 1279 | $sth->closeCursor(); |
| 1159 | - if (isset($result['modes'])) $hex = $result['modes']; |
|
| 1160 | - else $hex = ''; |
|
| 1280 | + if (isset($result['modes'])) { |
|
| 1281 | + $hex = $result['modes']; |
|
| 1282 | + } else { |
|
| 1283 | + $hex = ''; |
|
| 1284 | + } |
|
| 1161 | 1285 | $SI_data = array('hex' => $hex,'ident' => $ident,'aircraft_icao' => $ICAOTypeCode,'registration' => $registration,'latitude' => $latitude,'$longitude' => $longitude,'format_source' => 'ACARS'); |
| 1162 | - if ($this->fromACARSscript) $this->SI->add($SI_data); |
|
| 1286 | + if ($this->fromACARSscript) { |
|
| 1287 | + $this->SI->add($SI_data); |
|
| 1288 | + } |
|
| 1163 | 1289 | } |
| 1164 | 1290 | } |
| 1165 | - if ($globalDebug) echo 'Done'."\n"; |
|
| 1291 | + if ($globalDebug) { |
|
| 1292 | + echo 'Done'."\n"; |
|
| 1293 | + } |
|
| 1166 | 1294 | $query = "SELECT flightaware_id, ModeS FROM spotter_output WHERE ident = :ident AND format_source <> 'ACARS' ORDER BY spotter_id DESC LIMIT 1"; |
| 1167 | 1295 | $query_values = array(':ident' => $icao); |
| 1168 | 1296 | try { |
| 1169 | 1297 | $sth = $this->db->prepare($query); |
| 1170 | 1298 | $sth->execute($query_values); |
| 1171 | 1299 | } catch(PDOException $e) { |
| 1172 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1300 | + if ($globalDebug) { |
|
| 1301 | + echo $e->getMessage(); |
|
| 1302 | + } |
|
| 1173 | 1303 | return "error : ".$e->getMessage(); |
| 1174 | 1304 | } |
| 1175 | 1305 | $result = $sth->fetch(PDO::FETCH_ASSOC); |
| 1176 | 1306 | $sth->closeCursor(); |
| 1177 | 1307 | if (isset($result['flightaware_id'])) { |
| 1178 | - if (isset($result['ModeS'])) $ModeS = $result['ModeS']; |
|
| 1179 | - else $ModeS = ''; |
|
| 1308 | + if (isset($result['ModeS'])) { |
|
| 1309 | + $ModeS = $result['ModeS']; |
|
| 1310 | + } else { |
|
| 1311 | + $ModeS = ''; |
|
| 1312 | + } |
|
| 1180 | 1313 | if ($ModeS == '') { |
| 1181 | 1314 | $id = explode('-',$result['flightaware_id']); |
| 1182 | 1315 | $ModeS = $id[0]; |
@@ -1189,24 +1322,32 @@ discard block |
||
| 1189 | 1322 | $sthc = $this->db->prepare($queryc); |
| 1190 | 1323 | $sthc->execute($queryc_values); |
| 1191 | 1324 | } catch(PDOException $e) { |
| 1192 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1325 | + if ($globalDebug) { |
|
| 1326 | + echo $e->getMessage(); |
|
| 1327 | + } |
|
| 1193 | 1328 | return "error : ".$e->getMessage(); |
| 1194 | 1329 | } |
| 1195 | 1330 | $row = $sthc->fetch(PDO::FETCH_ASSOC); |
| 1196 | 1331 | $sthc->closeCursor(); |
| 1197 | 1332 | if (count($row) == 0) { |
| 1198 | - if ($globalDebug) echo " Add to ModeS table - "; |
|
| 1333 | + if ($globalDebug) { |
|
| 1334 | + echo " Add to ModeS table - "; |
|
| 1335 | + } |
|
| 1199 | 1336 | $queryi = "INSERT INTO aircraft_modes (ModeS,ModeSCountry,Registration,ICAOTypeCode,Source) VALUES (:ModeS,:ModeSCountry,:Registration, :ICAOTypeCode,'ACARS')"; |
| 1200 | 1337 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
| 1201 | 1338 | try { |
| 1202 | 1339 | $sthi = $this->db->prepare($queryi); |
| 1203 | 1340 | $sthi->execute($queryi_values); |
| 1204 | 1341 | } catch(PDOException $e) { |
| 1205 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1342 | + if ($globalDebug) { |
|
| 1343 | + echo $e->getMessage(); |
|
| 1344 | + } |
|
| 1206 | 1345 | return "error : ".$e->getMessage(); |
| 1207 | 1346 | } |
| 1208 | 1347 | } else { |
| 1209 | - if ($globalDebug) echo " Update ModeS table - "; |
|
| 1348 | + if ($globalDebug) { |
|
| 1349 | + echo " Update ModeS table - "; |
|
| 1350 | + } |
|
| 1210 | 1351 | if ($ICAOTypeCode != '') { |
| 1211 | 1352 | $queryi = "UPDATE aircraft_modes SET ModeSCountry = :ModeSCountry,Registration = :Registration,ICAOTypeCode = :ICAOTypeCode,Source = 'ACARS',LastModified = NOW() WHERE ModeS = :ModeS"; |
| 1212 | 1353 | $queryi_values = array(':ModeS' => $ModeS,':ModeSCountry' => $country,':Registration' => $registration, ':ICAOTypeCode' => $ICAOTypeCode); |
@@ -1218,7 +1359,9 @@ discard block |
||
| 1218 | 1359 | $sthi = $this->db->prepare($queryi); |
| 1219 | 1360 | $sthi->execute($queryi_values); |
| 1220 | 1361 | } catch(PDOException $e) { |
| 1221 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1362 | + if ($globalDebug) { |
|
| 1363 | + echo $e->getMessage(); |
|
| 1364 | + } |
|
| 1222 | 1365 | return "error : ".$e->getMessage(); |
| 1223 | 1366 | } |
| 1224 | 1367 | } |
@@ -1239,7 +1382,9 @@ discard block |
||
| 1239 | 1382 | return "error : ".$e->getMessage(); |
| 1240 | 1383 | } |
| 1241 | 1384 | */ |
| 1242 | - if ($globalDebug) echo " Update Spotter_output table - "; |
|
| 1385 | + if ($globalDebug) { |
|
| 1386 | + echo " Update Spotter_output table - "; |
|
| 1387 | + } |
|
| 1243 | 1388 | if ($ICAOTypeCode != '') { |
| 1244 | 1389 | if ($globalDBdriver == 'mysql') { |
| 1245 | 1390 | $queryi = "UPDATE spotter_output SET registration = :Registration,aircraft_icao = :ICAOTypeCode WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
@@ -1250,8 +1395,7 @@ discard block |
||
| 1250 | 1395 | } else { |
| 1251 | 1396 | if ($globalDBdriver == 'mysql') { |
| 1252 | 1397 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= date_sub(UTC_TIMESTAMP(), INTERVAL 1 HOUR)"; |
| 1253 | - } |
|
| 1254 | - elseif ($globalDBdriver == 'pgsql') { |
|
| 1398 | + } elseif ($globalDBdriver == 'pgsql') { |
|
| 1255 | 1399 | $queryi = "UPDATE spotter_output SET registration = :Registration WHERE ident = :ident AND date >= NOW() AT TIME ZONE 'UTC' - INTERVAL '1 HOUR'"; |
| 1256 | 1400 | } |
| 1257 | 1401 | $queryi_values = array(':Registration' => $registration,':ident' => $icao); |
@@ -1260,14 +1404,20 @@ discard block |
||
| 1260 | 1404 | $sthi = $this->db->prepare($queryi); |
| 1261 | 1405 | $sthi->execute($queryi_values); |
| 1262 | 1406 | } catch(PDOException $e) { |
| 1263 | - if ($globalDebug) echo $e->getMessage(); |
|
| 1407 | + if ($globalDebug) { |
|
| 1408 | + echo $e->getMessage(); |
|
| 1409 | + } |
|
| 1264 | 1410 | return "error : ".$e->getMessage(); |
| 1265 | 1411 | } |
| 1266 | 1412 | } |
| 1267 | 1413 | } else { |
| 1268 | - if ($globalDebug) echo " Can't find ModeS in spotter_output - "; |
|
| 1414 | + if ($globalDebug) { |
|
| 1415 | + echo " Can't find ModeS in spotter_output - "; |
|
| 1416 | + } |
|
| 1417 | + } |
|
| 1418 | + if ($globalDebug) { |
|
| 1419 | + echo "Done\n"; |
|
| 1269 | 1420 | } |
| 1270 | - if ($globalDebug) echo "Done\n"; |
|
| 1271 | 1421 | } |
| 1272 | 1422 | } |
| 1273 | 1423 | ?> |